diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index afb95f1ed65..0bb4100de9b 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -1157,7 +1157,7 @@ If the code is invalid, a warning will be issued. Note that no error is thrown s #### preserveEntrySignatures -Type: `"strict" | "allow-extension" | "exports-only" | false`
CLI: `--preserveEntrySignatures `/`--no-preserveEntrySignatures`
Default: `"strict"` +Type: `"strict" | "allow-extension" | "exports-only" | false`
CLI: `--preserveEntrySignatures `/`--no-preserveEntrySignatures`
Default: `"exports-only"` Controls if Rollup tries to ensure that entry chunks have the same exports as the underlying entry module. diff --git a/package-lock.json b/package-lock.json index 3c269b29141..ab456df2db1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "3.0.0-1", + "version": "3.0.0-2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rollup", - "version": "3.0.0-1", + "version": "3.0.0-2", "license": "MIT", "bin": { "rollup": "dist/bin/rollup" diff --git a/package.json b/package.json index c661ccc57a6..22876ae4445 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "3.0.0-1", + "version": "3.0.0-2", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", diff --git a/src/Chunk.ts b/src/Chunk.ts index 1de928d917b..eda5b4dca19 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -52,7 +52,7 @@ import { namespaceInteropHelpersByInteropType } from './utils/interopHelpers'; import { basename, extname, isAbsolute } from './utils/path'; -import relativeId, { getAliasName, getImportPath } from './utils/relativeId'; +import { getAliasName, getImportPath } from './utils/relativeId'; import type { RenderOptions } from './utils/renderHelpers'; import { makeUnique, renderNamePattern } from './utils/renderNamePattern'; import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; @@ -297,21 +297,6 @@ export default class Chunk { const moduleExportNamesByVariable = module.getExportNamesByVariable(); for (const exposedVariable of this.exports) { if (!moduleExportNamesByVariable.has(exposedVariable)) { - if ( - moduleExportNamesByVariable.size === 0 && - module.isUserDefinedEntryPoint && - module.preserveSignature === 'strict' && - this.unsetOptions.has('preserveEntrySignatures') - ) { - this.inputOptions.onwarn({ - code: 'EMPTY_FACADE', - id: module.id, - message: `To preserve the export signature of the entry module "${relativeId( - module.id - )}", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`, - url: 'https://rollupjs.org/guide/en/#preserveentrysignatures' - }); - } return false; } } diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 4665ddcbff3..e357f6e89ae 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -4,7 +4,6 @@ import type { InputOptions, ModuleSideEffectsOption, NormalizedInputOptions, - PreserveEntrySignaturesOption, RollupBuild, WarningHandler } from '../../rollup/types'; @@ -55,7 +54,7 @@ export function normalizeInputOptions(config: InputOptions): { onwarn, perf: config.perf || false, plugins: ensureArray(config.plugins), - preserveEntrySignatures: getPreserveEntrySignatures(config, unsetOptions), + preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only', preserveModules: getPreserveModules(config, onwarn, strictDeprecations), preserveSymlinks: config.preserveSymlinks || false, shimMissingExports: config.shimMissingExports || false, @@ -219,19 +218,6 @@ const getModuleContext = ( return () => context; }; -const getPreserveEntrySignatures = ( - config: InputOptions, - unsetOptions: Set -): NormalizedInputOptions['preserveEntrySignatures'] => { - const configPreserveEntrySignatures = config.preserveEntrySignatures as - | PreserveEntrySignaturesOption - | undefined; - if (configPreserveEntrySignatures == null) { - unsetOptions.add('preserveEntrySignatures'); - } - return configPreserveEntrySignatures ?? 'strict'; -}; - const getPreserveModules = ( config: InputOptions, warn: WarningHandler, diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js deleted file mode 100644 index 4044ae8b0a7..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: - 'Does not warn if preserveEntrySignatures is not set and an empty facade is created for a plugin chunk', - options: { - input: [], - plugins: { - buildStart() { - this.emitFile({ type: 'chunk', id: 'main', name: 'entry' }); - } - } - } -}; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js deleted file mode 100644 index c9e76e3e891..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-main'], (function (entry) { 'use strict'; - - globalThis.sharedDynamic = entry.shared; - -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js deleted file mode 100644 index 11c4936bfa6..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-main'], (function (entry) { 'use strict'; - - - -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js deleted file mode 100644 index 6dc4ddd5172..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['require', 'exports'], (function (require, exports) { 'use strict'; - - const shared = 'shared'; - - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); - globalThis.sharedStatic = shared; - - exports.shared = shared; - -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js deleted file mode 100644 index 5585f0a0567..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var entry = require('./generated-main.js'); - -globalThis.sharedDynamic = entry.shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js deleted file mode 100644 index 464b4ce8e34..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('./generated-main.js'); - diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js deleted file mode 100644 index e9d30866266..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -const shared = 'shared'; - -Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); -globalThis.sharedStatic = shared; - -exports.shared = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js deleted file mode 100644 index 3bae49ca2fb..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js +++ /dev/null @@ -1,3 +0,0 @@ -import { s as shared } from './generated-main.js'; - -globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js deleted file mode 100644 index bc3090f4a30..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js +++ /dev/null @@ -1 +0,0 @@ -import './generated-main.js'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js deleted file mode 100644 index 90b5ce20955..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js +++ /dev/null @@ -1,6 +0,0 @@ -const shared = 'shared'; - -import('./generated-dynamic.js'); -globalThis.sharedStatic = shared; - -export { shared as s }; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js deleted file mode 100644 index 76d2f1834e0..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-main.js'], (function () { - 'use strict'; - var shared; - return { - setters: [function (module) { - shared = module.s; - }], - execute: (function () { - - globalThis.sharedDynamic = shared; - - }) - }; -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js deleted file mode 100644 index 5c63e91437f..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-main.js'], (function () { - 'use strict'; - return { - setters: [function () {}], - execute: (function () { - - - - }) - }; -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js deleted file mode 100644 index 4fed28b3a33..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], (function (exports, module) { - 'use strict'; - return { - execute: (function () { - - const shared = exports('s', 'shared'); - - module.import('./generated-dynamic.js'); - globalThis.sharedStatic = shared; - - }) - }; -})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js deleted file mode 100644 index d7a191e6ace..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; - -globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js deleted file mode 100644 index cd35843de7a..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const shared = 'shared'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js deleted file mode 100644 index 20bd28fbede..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; -import('./dynamic.js'); -globalThis.sharedStatic = shared; diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js index 04b6611f8fc..acf1441a057 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -28,7 +28,7 @@ module.exports = { name: 'test-plugin' } ], - preserveEntrySignatures: 'strict', + preserveEntrySignatures: 'exports-only', preserveSymlinks: false, shimMissingExports: false, strictDeprecations: true, diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/_config.js b/test/function/samples/preserve-entry-signatures-empty-facade/_config.js deleted file mode 100644 index 2630a32285d..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'warns when creating an empty facade and "preserveEntrySignatures" is not specified', - options: { - input: ['main.js'] - }, - warnings: [ - { - code: 'EMPTY_FACADE', - id: path.join(__dirname, 'main.js'), - message: `To preserve the export signature of the entry module "main.js", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`, - url: 'https://rollupjs.org/guide/en/#preserveentrysignatures' - } - ] -}; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js b/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js deleted file mode 100644 index 71d2c545469..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js +++ /dev/null @@ -1,2 +0,0 @@ -import { shared } from './lib.js'; -global.shared = shared; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/lib.js b/test/function/samples/preserve-entry-signatures-empty-facade/lib.js deleted file mode 100644 index cd35843de7a..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const shared = 'shared'; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/main.js b/test/function/samples/preserve-entry-signatures-empty-facade/main.js deleted file mode 100644 index 27c56080b9b..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; -global.shared = shared; -import('./dynamic.js');