Skip to content

Commit c5bca6c

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 0b98ab3 commit c5bca6c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/index.ts

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

68+
/** to be called at the end of Rollup's build phase, before output generation */
69+
const buildDone = (): void =>
70+
{
71+
if (!watchMode && !noErrors)
72+
context.info(yellow("there were errors or warnings."));
73+
74+
cache().done();
75+
}
76+
6877
const pluginOptions: IOptions = Object.assign({},
6978
{
7079
check: true,
@@ -204,9 +213,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
204213
{
205214
// always checking on fatal errors, even if options.check is set to false
206215
typecheckFile(id, snapshot, contextWrapper);
207-
208216
// since no output was generated, aborting compilation
209-
cache().done();
210217
this.error(red(`failed to transpile '${id}'`));
211218
}
212219

@@ -259,6 +266,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
259266
{
260267
if (err)
261268
{
269+
buildDone();
262270
// workaround: err.stack contains err.message and Rollup prints both, causing duplication, so split out the stack itself if it exists (c.f. https://github.com/ezolenko/rollup-plugin-typescript2/issues/103#issuecomment-1172820658)
263271
const stackOnly = err.stack?.split(err.message)[1];
264272
if (stackOnly)
@@ -268,7 +276,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
268276
}
269277

270278
if (!pluginOptions.check)
271-
return
279+
return buildDone();
272280

273281
// walkTree once on each cycle when in watch mode
274282
if (watchMode)
@@ -298,10 +306,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
298306
typecheckFile(key, snapshot, context);
299307
});
300308

301-
if (!watchMode && !noErrors)
302-
context.info(yellow("there were errors or warnings."));
303-
304-
cache().done();
309+
buildDone();
305310
},
306311

307312
generateBundle(this, _output)

0 commit comments

Comments
 (0)