Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3.0] Change default for preserveEntrySignatures to exports-only #4576

Merged
merged 1 commit into from Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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.