From ebbf16b866869513bcd2c2a10572be6430ebfb32 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Thu, 13 Jul 2023 22:06:16 -0400 Subject: [PATCH] deps: bump Rollup peerDep to 3.7.5+, remove tech debt - 3.7.5 includes https://github.com/rollup/rollup/commit/ffab4cd09f82c878d42dc9f18572674b5ccd44f9 - which fixes the duplicate error logging upstream and allows us to remove the `buildEnd` workaround - 2.60.0 includes `this.load`, so can remove the `satisfies` check - 2.14.0 includes `this.meta.watchMode`, so can remove the env check - remove deprecated `rollupCommonJSResolveHack` - it hasn't done anything since 6fb0e75f5328666dca8ff7b11bc956096351a3eb in late 2020 (~2.5 years ago) - and has been formally deprecated since 74f6761ff63863cdb3e92ca1f33640fe6f4fc7db over a year ago - remove `objectHashIgnoreUnknownHack` warning - hasn't been needed for async functions since 9afc8df0a1dd2a4967fb9a609656bcb678f2a5db in early 2020 (~3.5 years ago) - so I think that's a long enough window to now remove the warning - also add a link in the docs to `object-hash` - noticed there wasn't one, despite all the links I added to the docs! --- README.md | 14 +++----------- __tests__/fixtures/options.ts | 1 - package-lock.json | 2 +- package.json | 2 +- src/index.ts | 28 +++------------------------- src/ioptions.ts | 1 - 6 files changed, 8 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 4b727375..f1b27d50 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,6 @@ This also allows for passing in different `tsconfig` files depending on your bui Must be before `rollup-plugin-typescript2` in the plugin list, especially when the `browser: true` option is used (see [#66](https://github.com/ezolenko/rollup-plugin-typescript2/issues/66)). -#### @rollup/plugin-commonjs - -See the explanation for `rollupCommonJSResolveHack` option below. - #### @rollup/plugin-babel This plugin transpiles code, but doesn't change file extensions. `@rollup/plugin-babel` only looks at code with these extensions [by default](https://github.com/rollup/plugins/tree/master/packages/babel#extensions): `.js,.jsx,.es6,.es,.mjs`. To workaround this, add `.ts` and `.tsx` to its list of extensions. @@ -165,14 +161,10 @@ See [#108](https://github.com/ezolenko/rollup-plugin-typescript2/issues/108) Bail out on first syntactic or semantic error. In some cases, setting this to false will result in an exception in Rollup itself (for example, unresolvable imports). -* `rollupCommonJSResolveHack`: false - - _Deprecated_. OS native paths are now _always_ used since [`0.30.0`](https://github.com/ezolenko/rollup-plugin-typescript2/releases/0.30.0) (see [#251](https://github.com/ezolenko/rollup-plugin-typescript2/pull/251)), so this no longer has any effect -- as if it is always `true`. - * `objectHashIgnoreUnknownHack`: false The plugin uses your Rollup config as part of its cache key. - `object-hash` is used to generate a hash, but it can have trouble with some uncommon types of elements. + [`object-hash`](https://github.com/puleos/object-hash) is used to generate a hash, but it can have trouble with some uncommon types of elements. Setting this option to true will make `object-hash` ignore unknowns, at the cost of not invalidating the cache if ignored elements are changed. Only enable this option if you need it (e.g. if you get `Error: Unknown object type "xxx"`) and make sure to run with `clean: true` once in a while and definitely before a release. @@ -238,8 +230,8 @@ Otherwise the plugin should work in watch mode. Make sure to run a normal build ### Requirements * TypeScript `2.4+` -* Rollup `1.26.3+` -* Node `6.4.0+` (basic ES6 support) +* Rollup `3.7.5+` +* Node `14.18.0+` (Rollup [requirement](https://github.com/rollup/rollup/blob/096ae92972a920dc53c3bbe9b1001ea82a15e86a/package.json#L133)) ### Reporting bugs and Contributing diff --git a/__tests__/fixtures/options.ts b/__tests__/fixtures/options.ts index 921ec6e0..2a53d9a8 100644 --- a/__tests__/fixtures/options.ts +++ b/__tests__/fixtures/options.ts @@ -15,7 +15,6 @@ export function makeOptions(cacheDir: string, cwd: string): IOptions { cacheRoot: cacheDir, cwd, abortOnError: false, - rollupCommonJSResolveHack: false, typescript: ts, objectHashIgnoreUnknownHack: false, tsconfigOverride: null, diff --git a/package-lock.json b/package-lock.json index 34f8aa6f..a0b19ad9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "typescript": "^4.6.3" }, "peerDependencies": { - "rollup": ">=1.26.3", + "rollup": ">=3.7.5", "typescript": ">=2.4.0" } }, diff --git a/package.json b/package.json index bf5cbfca..ab0e831e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "tslib": "^2.4.0" }, "peerDependencies": { - "rollup": ">=1.26.3", + "rollup": ">=3.7.5", "typescript": ">=2.4.0" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index cb1f7d15..66404c03 100644 --- a/src/index.ts +++ b/src/index.ts @@ -98,7 +98,6 @@ const typescript: PluginImpl = (options) => include: ["*.ts+(|x)", "**/*.ts+(|x)", "**/*.cts", "**/*.mts"], exclude: ["*.d.ts", "**/*.d.ts", "**/*.d.cts", "**/*.d.mts"], abortOnError: true, - rollupCommonJSResolveHack: false, tsconfig: undefined, useTsconfigDeclarationDir: false, tsconfigOverride: {}, @@ -128,7 +127,7 @@ const typescript: PluginImpl = (options) => { context = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: "); - 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) + watchMode = !!this.meta.watchMode; ({ parsedTsConfig: parsedConfig, fileName: tsConfigPath } = parseTsConfig(context, pluginOptions)); // print out all versions and configurations @@ -142,21 +141,11 @@ const typescript: PluginImpl = (options) => if (!satisfies(this.meta.rollupVersion, ROLLUP_VERSION_RANGE, { includePrerelease: true })) context.error(`Installed Rollup version '${this.meta.rollupVersion}' is outside of supported range '${ROLLUP_VERSION_RANGE}'`); - supportsThisLoad = satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease : true }); // this.load is 2.60.0+ only (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2600) - if (!supportsThisLoad) - context.warn(() => `${yellow("You are using a Rollup version '<2.60.0'")}. This may result in type-only files being ignored.`); - context.info(`rollup-plugin-typescript2 version: ${RPT2_VERSION}`); context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`); context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`); context.debug(() => `tsconfig path: ${tsConfigPath}`); - if (pluginOptions.objectHashIgnoreUnknownHack) - context.warn(() => `${yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`); - - if (pluginOptions.rollupCommonJSResolveHack) - context.warn(() => `${yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`); - if (watchMode) context.info(`running in watch mode`); @@ -312,19 +301,8 @@ const typescript: PluginImpl = (options) => { generateRound = 0; // in watch mode, buildEnd resets generate count just before generateBundle for each output - if (err) - { - buildDone(); - // 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) - const stackOnly = err.stack?.split(err.message)[1]; - if (stackOnly) - this.error({ ...err, message: err.message, stack: stackOnly }); - else - this.error(err); - } - - if (!pluginOptions.check) - return buildDone(); + if (err || !pluginOptions.check) + return buildDone(); // walkTree once on each cycle when in watch mode if (watchMode) diff --git a/src/ioptions.ts b/src/ioptions.ts index 1f7ad458..5bd1e9d1 100644 --- a/src/ioptions.ts +++ b/src/ioptions.ts @@ -21,7 +21,6 @@ export interface IOptions clean: boolean; cacheRoot: string; abortOnError: boolean; - rollupCommonJSResolveHack: boolean; tsconfig?: string; useTsconfigDeclarationDir: boolean; typescript: typeof tsModule;