Skip to content

Commit

Permalink
[v4.0] Remove deprecated features (#5143)
Browse files Browse the repository at this point in the history
* Remove hasModuleSideEffects from module info

* Remove this.moduleIds from plugin context

* Remove output.preferConst

* Remove output.dynamicImportFunction

* Remove output.experimentalDeepDynamicChunkOptimization

* Remove output.namespaceToStringTag

* Remove inlineDynamicImports input option

* Remove manualChunks and preserveModules input options as well as maxParallelFileReads
  • Loading branch information
lukastaegert committed Sep 21, 2023
1 parent 85fe93d commit bf88044
Show file tree
Hide file tree
Showing 844 changed files with 80 additions and 7,869 deletions.
79 changes: 0 additions & 79 deletions docs/configuration-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2556,50 +2556,6 @@ Whether to skip the `bundle.write()` step when a rebuild is triggered.
☢️ These options have been deprecated and may be removed in a future Rollup version.
### inlineDynamicImports
_Use the [`output.inlineDynamicImports`](#output-inlinedynamicimports) output option instead, which has the same signature._
### manualChunks
_Use the [`output.manualChunks`](#output-manualchunks) output option instead, which has the same signature._
### maxParallelFileReads
_Use the [`maxParallelFileOps`](#maxparallelfileops) option instead._
| | |
| -------: | :-------------------------------- |
| Type: | `number` |
| CLI: | `--maxParallelFileReads <number>` |
| Default: | 20 |
Limits the number of files rollup will open in parallel when reading modules. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This depends on how many open file handles the os allows.
### output.dynamicImportFunction
_Use the [`renderDynamicImport`](../plugin-development/index.md#renderdynamicimport) plugin hook instead._
| | |
| -------: | :------------------------------- |
| Type: | `string` |
| CLI: | `--dynamicImportFunction <name>` |
| Default: | `import` |
This will rename the dynamic import function to the chosen name when outputting ES bundles. This is useful for generating code that uses a dynamic import polyfill such as [this one](https://github.com/uupaa/dynamic-import-polyfill).
### output.experimentalDeepDynamicChunkOptimization
_This option is no longer needed._
| | |
| --: | :-- |
| Type: | `boolean` |
| CLI: | `--experimentalDeepDynamicChunkOptimization`/`--no-experimentalDeepDynamicChunkOptimization` |
| Default: | `false` |
This option was used to prevent performance issues with the full chunk optimization algorithm. As the algorithm is much faster now, this option is now ignored by Rollup and should no longer be used.
### output.externalImportAssertions
_Use the [`output.externalImportAttributes`](#output-externalimportattributes) option instead._
Expand All @@ -2611,38 +2567,3 @@ _Use the [`output.externalImportAttributes`](#output-externalimportattributes) o
| Default: | `true` |
Whether to add import assertions to external imports in the output if the output format is `es`. By default, assertions are taken from the input files, but plugins can add or remove assertions later. E.g. `import "foo" assert {type: "json"}` will cause the same import to appear in the output unless the option is set to `false`. Note that all imports of a module need to have consistent assertions, otherwise a warning is emitted.
### output.preferConst
_Use the [`output.generatedCode.constBindings`](#output-generatedcode-constbindings) option instead._
| | |
| -------: | :--------------------------------- |
| Type: | `boolean` |
| CLI: | `--preferConst`/`--no-preferConst` |
| Default: | `false` |
Generate `const` declarations for exports rather than `var` declarations.
### output.namespaceToStringTag
_Use [`output.generatedCode.symbols`](#output-generatedcode-symbols) instead._
| | |
| -------: | :--------------------------------------------------- |
| Type: | `boolean` |
| CLI: | `--namespaceToStringTag`/`--no-namespaceToStringTag` |
| Default: | `false` |
Whether to add spec compliant `.toString()` tags to namespace objects. If this option is set,
```javascript
import * as namespace from './file.js';
console.log(String(namespace));
```
will always log `[object Module]`;
### preserveModules
_Use the [`output.preserveModules`](#output-preservemodules) output option instead, which has the same signature._
2 changes: 1 addition & 1 deletion docs/guide/en/slugs-and-pages-by-legacy-slugs.json

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions docs/plugin-development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1747,20 +1747,6 @@ When used in the `transform` hook, the `id` of the current module will also be a
If the [`logLevel`](../configuration-options/index.md#loglevel) option is set to `"silent"`, this method will do nothing.
## Deprecated Context Functions
☢️ These context utility functions have been deprecated and may be removed in a future Rollup version.
- `this.moduleIds: IterableIterator<string>` - _**Use [`this.getModuleIds`](#this-getmoduleids)**_ - An `Iterator` that gives access to all module ids in the current graph. It can be iterated via
```js
for (const moduleId of this.moduleIds) {
/* ... */
}
```
or converted into an Array via `Array.from(this.moduleIds)`.
## File URLs
To reference a file URL reference from within JS code, use the `import.meta.ROLLUP_FILE_URL_referenceId` replacement. This will generate code that depends on the output format and generates a URL that points to the emitted file in the target environment. Note that all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available.
Expand Down
21 changes: 15 additions & 6 deletions src/Chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,12 @@ export default class Chunk {
renderedModules,
snippets
} = this;
const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag } = outputOptions;
const {
compact,
format,
freeze,
generatedCode: { symbols }
} = outputOptions;
const { _, cnst, n } = snippets;
this.setDynamicImportResolutions(fileName);
this.setImportMetaResolutions(fileName);
Expand All @@ -1204,14 +1209,13 @@ export default class Chunk {

const renderOptions: RenderOptions = {
accessedDocumentCurrentScript: false,
dynamicImportFunction,
exportNamesByVariable,
format,
freeze,
indent,
namespaceToStringTag,
pluginDriver,
snippets,
symbols,
useOriginalName: null
};

Expand Down Expand Up @@ -1319,8 +1323,13 @@ export default class Chunk {
}

private setIdentifierRenderResolutions() {
const { format, interop, namespaceToStringTag, preserveModules, externalLiveBindings } =
this.outputOptions;
const {
format,
generatedCode: { symbols },
interop,
preserveModules,
externalLiveBindings
} = this.outputOptions;
const syntheticExports = new Set<SyntheticNamedExportVariable>();
for (const exportName of this.getExportNames()) {
const exportVariable = this.exportsByName.get(exportName)!;
Expand All @@ -1347,7 +1356,7 @@ export default class Chunk {
if (this.needsExportsShim) {
usedNames.add(MISSING_EXPORT_SHIM_VARIABLE);
}
if (namespaceToStringTag) {
if (symbols) {
usedNames.add('Symbol');
}
switch (format) {
Expand Down
20 changes: 3 additions & 17 deletions src/ExternalModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { CustomPluginOptions, ModuleInfo, NormalizedInputOptions } from './
import { EMPTY_ARRAY } from './utils/blank';
import { makeLegal } from './utils/identifierHelpers';
import { LOGLEVEL_WARN } from './utils/logging';
import { logUnusedExternalImports, warnDeprecation } from './utils/logs';
import { URL_THIS_GETMODULEINFO } from './utils/urls';
import { logUnusedExternalImports } from './utils/logs';

export default class ExternalModule {
readonly dynamicImporters: string[] = [];
Expand All @@ -31,7 +30,7 @@ export default class ExternalModule {
this.suggestedVariableName = makeLegal(id.split(/[/\\]/).pop()!);

const { importers, dynamicImporters } = this;
const info: ModuleInfo = (this.info = {
this.info = {
ast: null,
attributes,
code: null,
Expand All @@ -43,15 +42,6 @@ export default class ExternalModule {
exportedBindings: null,
exports: null,
hasDefaultExport: null,
get hasModuleSideEffects() {
warnDeprecation(
'Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
URL_THIS_GETMODULEINFO,
true,
options
);
return info.moduleSideEffects;
},
id,
implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
implicitlyLoadedBefore: EMPTY_ARRAY,
Expand All @@ -66,11 +56,7 @@ export default class ExternalModule {
meta,
moduleSideEffects,
syntheticNamedExports: false
});
// Hide the deprecated key so that it only warns when accessed explicitly
Object.defineProperty(this.info, 'hasModuleSideEffects', {
enumerable: false
});
};
}

getVariableForExportName(name: string): [variable: ExternalVariable] {
Expand Down
18 changes: 1 addition & 17 deletions src/Module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ import {
logNamespaceConflict,
logParseError,
logShimmedExport,
logSyntheticNamedExportsNeedNamespaceExport,
warnDeprecation
logSyntheticNamedExportsNeedNamespaceExport
} from './utils/logs';
import {
doAttributesDiffer,
Expand All @@ -78,7 +77,6 @@ import type { PureFunctions } from './utils/pureFunctions';
import type { RenderOptions } from './utils/renderHelpers';
import { timeEnd, timeStart } from './utils/timers';
import { markModuleAndImpureDependenciesAsExecuted } from './utils/traverseStaticDependencies';
import { URL_THIS_GETMODULEINFO } from './utils/urls';
import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames';

interface ImportDescription {
Expand Down Expand Up @@ -331,15 +329,6 @@ export default class Module {
}
return module.exports.has('default') || reexportDescriptions.has('default');
},
get hasModuleSideEffects() {
warnDeprecation(
'Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.',
URL_THIS_GETMODULEINFO,
true,
options
);
return this.moduleSideEffects;
},
id,
get implicitlyLoadedAfterOneOf() {
// eslint-disable-next-line unicorn/prefer-spread
Expand Down Expand Up @@ -380,11 +369,6 @@ export default class Module {
moduleSideEffects,
syntheticNamedExports
};
// Hide the deprecated key so that it only warns when accessed explicitly
// eslint-disable-next-line unicorn/consistent-destructuring
Object.defineProperty(this.info, 'hasModuleSideEffects', {
enumerable: false
});
}

basename(): string {
Expand Down
12 changes: 0 additions & 12 deletions src/ast/nodes/ImportExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ export default class ImportExpression extends NodeBase {
exportMode: 'none' | 'named' | 'default' | 'external',
{
compact,
dynamicImportFunction,
dynamicImportInCjs,
format,
generatedCode: { arrowFunctions },
Expand Down Expand Up @@ -362,17 +361,6 @@ export default class ImportExpression extends NodeBase {
}
};
}
case 'es': {
if (dynamicImportFunction) {
return {
helper: null,
mechanism: {
left: `${dynamicImportFunction}(`,
right: ')'
}
};
}
}
}
return { helper: null, mechanism: null };
}
Expand Down
4 changes: 2 additions & 2 deletions src/ast/variables/NamespaceVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class NamespaceVariable extends Variable {
format,
freeze,
indent: t,
namespaceToStringTag,
symbols,
snippets: { _, cnst, getObject, getPropertyAccess, n, s }
} = options;
const memberVariables = this.getMemberVariables();
Expand Down Expand Up @@ -157,7 +157,7 @@ export default class NamespaceVariable extends Variable {
)}])`;
} else {
// The helper to merge namespaces will also take care of freezing and toStringTag
if (namespaceToStringTag) {
if (symbols) {
output = `/*#__PURE__*/Object.defineProperty(${output},${_}Symbol.toStringTag,${_}${getToStringTagValue(
getObject
)})`;
Expand Down
6 changes: 3 additions & 3 deletions src/finalisers/amd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default function amd(
esModule,
externalLiveBindings,
freeze,
generatedCode: { symbols },
interop,
namespaceToStringTag,
strict
}: NormalizedOutputOptions
): void {
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function amd(
interop,
externalLiveBindings,
freeze,
namespaceToStringTag,
symbols,
accessedGlobals,
t,
snippets
Expand All @@ -88,7 +88,7 @@ export default function amd(
let namespaceMarkers = getNamespaceMarkers(
namedExportsMode && hasExports,
isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)),
isModuleFacade && namespaceToStringTag,
isModuleFacade && symbols,
snippets
);
if (namespaceMarkers) {
Expand Down
6 changes: 3 additions & 3 deletions src/finalisers/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function cjs(
externalLiveBindings,
freeze,
interop,
namespaceToStringTag,
generatedCode: { symbols },
strict
}: NormalizedOutputOptions
): void {
Expand All @@ -38,7 +38,7 @@ export default function cjs(
let namespaceMarkers = getNamespaceMarkers(
namedExportsMode && hasExports,
isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)),
isModuleFacade && namespaceToStringTag,
isModuleFacade && symbols,
snippets
);
if (namespaceMarkers) {
Expand All @@ -50,7 +50,7 @@ export default function cjs(
interop,
externalLiveBindings,
freeze,
namespaceToStringTag,
symbols,
accessedGlobals,
t,
snippets
Expand Down
4 changes: 2 additions & 2 deletions src/finalisers/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { FinaliserOptions } from './index';
export default function es(
magicString: MagicStringBundle,
{ accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }: FinaliserOptions,
{ externalLiveBindings, freeze, namespaceToStringTag }: NormalizedOutputOptions
{ externalLiveBindings, freeze, generatedCode: { symbols } }: NormalizedOutputOptions
): void {
const { n } = snippets;

Expand All @@ -21,7 +21,7 @@ export default function es(
snippets,
externalLiveBindings,
freeze,
namespaceToStringTag
symbols
);
if (intro) magicString.prepend(intro);

Expand Down

0 comments on commit bf88044

Please sign in to comment.