Skip to content

Commit

Permalink
[v3.0] Change default for preserveEntrySignatures to exports-only (#4576
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lukastaegert committed Jul 29, 2022
1 parent ab391de commit d196046
Show file tree
Hide file tree
Showing 26 changed files with 7 additions and 162 deletions.
2 changes: 1 addition & 1 deletion docs/999-big-list-of-options.md
Expand Up @@ -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`<br> CLI: `--preserveEntrySignatures <strict|allow-extension>`/`--no-preserveEntrySignatures`<br> Default: `"strict"`
Type: `"strict" | "allow-extension" | "exports-only" | false`<br> CLI: `--preserveEntrySignatures <strict|allow-extension>`/`--no-preserveEntrySignatures`<br> Default: `"exports-only"`

Controls if Rollup tries to ensure that entry chunks have the same exports as the underlying entry module.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 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",
Expand Down
17 changes: 1 addition & 16 deletions src/Chunk.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
}
Expand Down
16 changes: 1 addition & 15 deletions src/utils/options/normalizeInputOptions.ts
Expand Up @@ -4,7 +4,6 @@ import type {
InputOptions,
ModuleSideEffectsOption,
NormalizedInputOptions,
PreserveEntrySignaturesOption,
RollupBuild,
WarningHandler
} from '../../rollup/types';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -219,19 +218,6 @@ const getModuleContext = (
return () => context;
};

const getPreserveEntrySignatures = (
config: InputOptions,
unsetOptions: Set<string>
): NormalizedInputOptions['preserveEntrySignatures'] => {
const configPreserveEntrySignatures = config.preserveEntrySignatures as
| PreserveEntrySignaturesOption
| undefined;
if (configPreserveEntrySignatures == null) {
unsetOptions.add('preserveEntrySignatures');
}
return configPreserveEntrySignatures ?? 'strict';
};

const getPreserveModules = (
config: InputOptions,
warn: WarningHandler,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion test/function/samples/options-hook/_config.js
Expand Up @@ -28,7 +28,7 @@ module.exports = {
name: 'test-plugin'
}
],
preserveEntrySignatures: 'strict',
preserveEntrySignatures: 'exports-only',
preserveSymlinks: false,
shimMissingExports: false,
strictDeprecations: true,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit d196046

Please sign in to comment.