Skip to content

Commit 697e839

Browse files
authored
clean: remove redundant generateRound === 0 check (#400)
- when `options` is called, `generateRound` should have already been reset to `0`, so this is redundant / unnecessary - `options` is only called once per watch cycle - `options` is also an `input` hook, not an `output` hook, i.e. it's only called once for _all_ outputs, _not_ per each output - `generateRound` only tracks the output round - this might be leftover historical remnants prior to Rollup officially separating `output` hooks, but even before then, it should only have been called once for _all_ outputs - since, per the Rollup API, it's only called during `rollup.rollup` and not during `bundle.generate` etc - c.f. old docs https://github.com/rollup/rollup/blob/v1.18.0/docs/05-plugin-development.md#options - it's possible this is _even older_, but I couldn't find plugin docs for Rollup pre-1.0 to try to confirm against
1 parent 4e5ab74 commit 697e839

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/index.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,24 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
125125
watchMode = process.env.ROLLUP_WATCH === "true" || !!this.meta.watchMode; // meta.watchMode was added in 2.14.0 to capture watch via Rollup API (i.e. no env var) (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2140)
126126
({ parsedTsConfig: parsedConfig, fileName: tsConfigPath } = parseTsConfig(context, pluginOptions));
127127

128-
if (generateRound === 0)
129-
{
130-
context.info(`typescript version: ${tsModule.version}`);
131-
context.info(`tslib version: ${tslibVersion}`);
132-
context.info(`rollup version: ${this.meta.rollupVersion}`);
128+
// print out all versions and configurations
129+
context.info(`typescript version: ${tsModule.version}`);
130+
context.info(`tslib version: ${tslibVersion}`);
131+
context.info(`rollup version: ${this.meta.rollupVersion}`);
133132

134-
context.info(`rollup-plugin-typescript2 version: $RPT2_VERSION`);
135-
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`);
136-
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
137-
context.debug(() => `tsconfig path: ${tsConfigPath}`);
133+
context.info(`rollup-plugin-typescript2 version: $RPT2_VERSION`);
134+
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`);
135+
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
136+
context.debug(() => `tsconfig path: ${tsConfigPath}`);
138137

139-
if (pluginOptions.objectHashIgnoreUnknownHack)
140-
context.warn(() => `${yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`);
138+
if (pluginOptions.objectHashIgnoreUnknownHack)
139+
context.warn(() => `${yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`);
141140

142-
if (pluginOptions.rollupCommonJSResolveHack)
143-
context.warn(() => `${yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
141+
if (pluginOptions.rollupCommonJSResolveHack)
142+
context.warn(() => `${yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
144143

145-
if (watchMode)
146-
context.info(`running in watch mode`);
147-
}
144+
if (watchMode)
145+
context.info(`running in watch mode`);
148146

149147
filter = createFilter(context, pluginOptions, parsedConfig);
150148

0 commit comments

Comments
 (0)