Skip to content

Commit 49b26f4

Browse files
committed
call cache().done() and !noErrors in check and non-check conditions
- instead of making a big `if` statement, decided to split out a `buildDone` function - to always call at the end of the input phase - we can also move the `cache().done()` in `emitSkipped` into `buildEnd`, as `buildEnd` gets called when an error occurs as well - and this way we properly print for errors as well - `buildDone` will have more usage in other PRs as well, so I figure it makes sense to split it out now as well
1 parent 167b7c9 commit 49b26f4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
6666
noErrors = false;
6767
}
6868

69+
/** to be called at the end of Rollup's build phase, before output generation */
70+
const buildDone = (): void =>
71+
{
72+
if (!watchMode && !noErrors)
73+
context.info(yellow("there were errors or warnings."));
74+
75+
cache().done();
76+
}
77+
6978
const pluginOptions: IOptions = Object.assign({},
7079
{
7180
check: true,
@@ -208,7 +217,6 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
208217
typecheckFile(id, snapshot, contextWrapper);
209218

210219
// since no output was generated, aborting compilation
211-
cache().done();
212220
if (_.isFunction(this.error))
213221
this.error(red(`failed to transpile '${id}'`));
214222
}
@@ -260,7 +268,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
260268
buildEnd(err)
261269
{
262270
if (!pluginOptions.check || err)
263-
return
271+
return buildDone();
264272

265273
// walkTree once on each cycle when in watch mode
266274
if (watchMode)
@@ -290,10 +298,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
290298
typecheckFile(key, snapshot, context);
291299
});
292300

293-
if (!watchMode && !noErrors)
294-
context.info(yellow("there were errors or warnings."));
295-
296-
cache().done();
301+
buildDone();
297302
},
298303

299304
generateBundle(this, _output)

0 commit comments

Comments
 (0)