diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md
index 0abc711e461..c5ba87e775e 100644
--- a/docs/05-plugin-development.md
+++ b/docs/05-plugin-development.md
@@ -201,7 +201,7 @@ In case a dynamic import is not passed a string as argument, this hook gets acce
Note that the return value of this hook will not be passed to `resolveId` afterwards; if you need access to the static resolution algorithm, you can use [`this.resolve(source, importer)`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null) on the plugin context.
#### `resolveFileUrl`
-Type: `({assetReferenceId: string | null, chunkId: string, chunkReferenceId: string | null, fileName: string, format: string, moduleId: string, relativePath: string}) => string | null`
+Type: `({chunkId: string, fileName: string, format: string, moduleId: string, referenceId: string, relativePath: string}) => string | null`
Kind: `sync, first`
Allows to customize how Rollup resolves URLs of files that were emitted by plugins via `this.emitAsset` or `this.emitChunk`. By default, Rollup will generate code for `import.meta.ROLLUP_ASSET_URL_assetReferenceId` and `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId` that should correctly generate absolute URLs of emitted files independent of the output format and the host system where the code is deployed.
@@ -327,38 +327,50 @@ Adds additional files to be monitored in watch mode so that changes to these fil
In general, it is recommended to use `this.addWatchfile` from within the hook that depends on the watched file.
-#### `this.emitAsset(assetName: string, source: string) => string`
+#### `this.emitFile(emittedFile: EmittedChunk | EmittedAsset) => string`
-Emits a custom file that is included in the build output, returning an `assetReferenceId` that can be used to reference the emitted file. You can defer setting the source if you provide it later via [`this.setAssetSource(assetReferenceId, source)`](guide/en/#thissetassetsourceassetreferenceid-string-source-string--buffer--void). A string or Buffer source must be set for each asset through either method or an error will be thrown on generate completion.
+Emits a new file that is included in the build output and returns a `referenceId` that can be used in various places to reference the emitted file. `emittedFile` can have one of two forms:
-Emitted assets will follow the [`output.assetFileNames`](guide/en/#outputassetfilenames) naming scheme. You can reference the URL of the file in any code returned by a [`load`](guide/en/#load) or [`transform`](guide/en/#transform) plugin hook via `import.meta.ROLLUP_ASSET_URL_assetReferenceId`. See [Asset URLs](guide/en/#asset-urls) for more details and an example.
-
-The generated code that replaces `import.meta.ROLLUP_ASSET_URL_assetReferenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. Once the asset has been finalized during `generate`, you can also use [`this.getAssetFileName(assetReferenceId)`](guide/en/#thisgetassetfilenameassetreferenceid-string--string) to determine the file name.
+```
+// EmittedChunk
+{
+ type: 'chunk',
+ id: string,
+ name?: string,
+ fileName?: string
+}
-#### `this.emitChunk(moduleId: string, options?: {name?: string}) => string`
+// EmittedAsset
+{
+ type: 'asset',
+ source?: string | Buffer,
+ name?: string,
+ fileName?: string
+}
+```
-Emits a new chunk with the given module as entry point. This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split. It returns a `chunkReferenceId` that can be used to later access the generated file name of the chunk.
+In both cases, either a `name` or a `fileName` can be supplied. If a `fileName` is provided, it will be used unmodified as the name of the generated file, throwing an error if this causes a conflict. Otherwise if a `name` is supplied, this will be used as substitution for `[name]` in the corresponding [`output.chunkFileNames`](guide/en/#outputchunkfilenames) or [`output.assetFileNames`](guide/en/#outputassetfilenames) pattern, possibly adding a unique number to the end of the file name to avoid conflicts. If neither a `name` nor `fileName` is supplied, a default name will be used.
+
+You can reference the URL of an emitted file in any code returned by a [`load`](guide/en/#load) or [`transform`](guide/en/#transform) plugin hook via `import.meta.ROLLUP_FILE_URL_referenceId`. See [File URLs](guide/en/#file-urls) for more details and an example.
+
+The generated code that replaces `import.meta.ROLLUP_FILE_URL_referenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. You can also use [`this.getFileName(referenceId)`](guide/en/#thisgetfilenamereferenceid-string--string) to determine the file name as soon as it is available
-Emitted chunks will follow the [`output.chunkFileNames`](guide/en/#outputchunkfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames) naming scheme. If a `name` is provided, this will be used for the `[name]` file name placeholder, otherwise the name will be derived from the file name. If a `name` is provided, this name must not conflict with any other entry point names unless the entry points reference the same entry module. You can reference the URL of the emitted chunk in any code returned by a [`load`](guide/en/#load) or [`transform`](guide/en/#transform) plugin hook via `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId`.
+If the `type` is *`chunk`*, then this emits a new chunk with the given module id as entry point. This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split or a facade chunk with reexports will be created. Chunks with a specified `fileName` will always generate separate chunks while other emitted chunks may be deduplicated with existing chunks even if the `name` does not match. If such a chunk is not deduplicated, the [`output.chunkFileNames`](guide/en/#outputchunkfilenames) name pattern will be used.
-The generated code that replaces `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. Once the chunk has been rendered during `generate`, you can also use [`this.getChunkFileName(chunkReferenceId)`](guide/en/#thisgetchunkfilenamechunkreferenceid-string--string) to determine the file name.
+If the `type` is *`asset`*, then this emits an arbitrary new file with the given `source` as content. It is possible to defer setting the `source` via [`this.setAssetSource(assetReferenceId, source)`](guide/en/#thissetassetsourceassetreferenceid-string-source-string--buffer--void) to a later time to be able to reference a file during the build phase while setting the source separately for each output during the generate phase. Assets with a specified `fileName` will always generate separate files while other emitted assets may be deduplicated with existing assets if they have the same source even if the `name` does not match. If such an asset is not deduplicated, the [`output.assetFileNames`](guide/en/#outputassetfilenames) name pattern will be used.
#### `this.error(error: string | Error, position?: number | { column: number; line: number }) => never`
Structurally equivalent to `this.warn`, except that it will also abort the bundling process.
-#### `this.getAssetFileName(assetReferenceId: string) => string`
-
-Get the file name of an asset, according to the `assetFileNames` output option pattern. The file name will be relative to `outputOptions.dir`.
-
-#### `this.getChunkFileName(chunkReferenceId: string) => string`
-
-Get the file name of an emitted chunk. The file name will be relative to `outputOptions.dir`.
-
#### `this.getCombinedSourcemap() => SourceMap`
Get the combined source maps of all previous plugins. This context function can only be used in [`transform`](guide/en/#transform) plugin hook.
+#### `this.getFileName(referenceId: string) => string`
+
+Get the file name of a chunk or asset that has been emitted via [`this.emitFile`](guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string) . The file name will be relative to `outputOptions.dir`.
+
#### `this.getModuleInfo(moduleId: string) => ModuleInfo`
Returns additional information about the module in question in the form
@@ -422,13 +434,29 @@ The `position` argument is a character index where the warning was raised. If pr
☢️ These context utility functions have been deprecated and may be removed in a future Rollup version.
-- `this.isExternal(id: string, importer: string, isResolved: boolean): boolean` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Determine if a given module ID is external when imported by `importer`. When `isResolved` is false, Rollup will try to resolve the id before testing if it is external.
+- `this.emitAsset(assetName: string, source: string) => string` - _**Use [`this.emitFile`](guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string)**_ - Emits a custom file that is included in the build output, returning an `assetReferenceId` that can be used to reference the emitted file. You can defer setting the source if you provide it later via [`this.setAssetSource(assetReferenceId, source)`](guide/en/#thissetassetsourceassetreferenceid-string-source-string--buffer--void). A string or Buffer source must be set for each asset through either method or an error will be thrown on generate completion.
+
+ Emitted assets will follow the [`output.assetFileNames`](guide/en/#outputassetfilenames) naming scheme. You can reference the URL of the file in any code returned by a [`load`](guide/en/#load) or [`transform`](guide/en/#transform) plugin hook via `import.meta.ROLLUP_ASSET_URL_assetReferenceId`.
+
+ The generated code that replaces `import.meta.ROLLUP_ASSET_URL_assetReferenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. Once the asset has been finalized during `generate`, you can also use [`this.getFileName(assetReferenceId)`](guide/en/#thisgetfilenamereferenceid-string--string) to determine the file name.
+
+- `this.emitChunk(moduleId: string, options?: {name?: string}) => string` - _**Use [`this.emitFile`](guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string)**_ - Emits a new chunk with the given module as entry point. This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split. It returns a `chunkReferenceId` that can be used to later access the generated file name of the chunk.
+
+ Emitted chunks will follow the [`output.chunkFileNames`](guide/en/#outputchunkfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames) naming scheme. If a `name` is provided, this will be used for the `[name]` file name placeholder, otherwise the name will be derived from the file name. If a `name` is provided, this name must not conflict with any other entry point names unless the entry points reference the same entry module. You can reference the URL of the emitted chunk in any code returned by a [`load`](guide/en/#load) or [`transform`](guide/en/#transform) plugin hook via `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId`.
+
+ The generated code that replaces `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. Once the chunk has been rendered during `generate`, you can also use [`this.getFileName(chunkReferenceId)`](guide/en/#thisgetfilenamereferenceid-string--string) to determine the file name.
+
+- `this.getAssetFileName(assetReferenceId: string) => string` - _**Use [`this.getFileName`](guide/en/#thisgetfilenamereferenceid-string--string)**_ - Get the file name of an asset, according to the `assetFileNames` output option pattern. The file name will be relative to `outputOptions.dir`.
+
+- `this.getChunkFileName(chunkReferenceId: string) => string` - _**Use [`this.getFileName`](guide/en/#thisgetfilenamereferenceid-string--string)**_ - Get the file name of an emitted chunk. The file name will be relative to `outputOptions.dir`.
+
+- `this.isExternal(id: string, importer: string, isResolved: boolean) => boolean` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Determine if a given module ID is external when imported by `importer`. When `isResolved` is false, Rollup will try to resolve the id before testing if it is external.
- `this.resolveId(source: string, importer: string) => Promise` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Resolve imports to module ids (i.e. file names) using the same plugins that Rollup uses. Returns `null` if an id cannot be resolved.
-### Asset URLs
+### File URLs
-To reference an asset URL reference from within JS code, use the `import.meta.ROLLUP_ASSET_URL_assetReferenceId` 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.
+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.
The following example will detect imports of `.svg` files, emit the imported files as assets, and return their URLs to be used e.g. as the `src` attribute of an `img` tag:
@@ -443,26 +471,28 @@ export default function svgResolverPlugin () {
},
load(id) {
if (id.endsWith('.svg')) {
- const assetReferenceId = this.emitAsset(
- path.basename(id),
- fs.readFileSync(id)
- );
- return `export default import.meta.ROLLUP_ASSET_URL_${assetReferenceId};`;
+ const referenceId = this.emitFile({
+ type: 'asset',
+ name: path.basename(id),
+ source: fs.readFileSync(id)
+ });
+ return `export default import.meta.ROLLUP_FILE_URL_${referenceId};`;
}
}
});
}
+```
+
+Usage:
-// usage
+```js
import logo from '../images/logo.svg';
const image = document.createElement('img');
image.src = logo;
document.body.appendChild(image);
```
-### Chunk URLs
-
-Similar to assets, emitted chunks can be referenced from within JS code via the `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId` replacement.
+Similar to assets, emitted chunks can be referenced from within JS code via `import.meta.ROLLUP_FILE_URL_referenceId` as well.
The following example will detect imports prefixed with `register-paint-worklet:` and generate the necessary code and separate chunk to generate a CSS paint worklet. Note that this will only work in modern browsers and will only work if the output format is set to `esm`.
@@ -473,20 +503,21 @@ export default function paintWorkletPlugin () {
return ({
load(id) {
if (id.startsWith(REGISTER_WORKLET)) {
- return `CSS.paintWorklet.addModule(import.meta.ROLLUP_CHUNK_URL_${this.emitChunk(
- id.slice(REGISTER_WORKLET.length)
- )});`;
+ return `CSS.paintWorklet.addModule(import.meta.ROLLUP_FILE_URL_${this.emitFile({
+ type: 'chunk',
+ id: id.slice(REGISTER_WORKLET.length)
+ })});`;
}
},
resolveId(source, importer) {
// We remove the prefix, resolve everything to absolute ids and add the prefix again
// This makes sure that you can use relative imports to define worklets
- if (source.startsWith(REGISTER_WORKLET)) {
- return this.resolveId(source.slice(REGISTER_WORKLET.length), importer).then(
- id => REGISTER_WORKLET + id
- );
- }
- return null;
+ if (source.startsWith(REGISTER_WORKLET)) {
+ return this.resolve(source.slice(REGISTER_WORKLET.length), importer).then(
+ resolvedId => REGISTER_WORKLET + resolvedId.id
+ );
+ }
+ return null;
}
});
}
@@ -503,17 +534,17 @@ document.body.innerHTML += `
();
+ private fileName: string | null = null;
private imports = new Set();
+ private name: string | null = null;
private needsExportsShim = false;
private renderedDeclarations: {
dependencies: ChunkDependencies;
@@ -179,25 +192,20 @@ export default class Chunk {
}
}
- const entryModule = this.entryModules[0];
- if (entryModule) {
+ const moduleForNaming =
+ this.entryModules[0] || this.orderedModules[this.orderedModules.length - 1];
+ if (moduleForNaming) {
this.variableName = makeLegal(
basename(
- entryModule.chunkAlias || entryModule.manualChunkAlias || getAliasName(entryModule.id)
+ moduleForNaming.chunkName ||
+ moduleForNaming.manualChunkAlias ||
+ getAliasName(moduleForNaming.id)
)
);
- } else {
- this.variableName = '__chunk_' + ++graph.curChunkIndex;
}
}
- canModuleBeFacade(
- moduleExportNamesByVariable: Map,
- moduleChunkAlias: string | null
- ): boolean {
- if (this.manualChunkAlias && moduleChunkAlias && this.manualChunkAlias !== moduleChunkAlias) {
- return false;
- }
+ canModuleBeFacade(moduleExportNamesByVariable: Map): boolean {
for (const exposedVariable of this.exports) {
if (!moduleExportNamesByVariable.has(exposedVariable)) {
return false;
@@ -209,22 +217,33 @@ export default class Chunk {
generateFacades(): Chunk[] {
const facades: Chunk[] = [];
for (const module of this.entryModules) {
+ const requiredFacades: FacadeName[] = Array.from(module.userChunkNames).map(name => ({
+ name
+ }));
+ if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) {
+ requiredFacades.push({});
+ }
+ requiredFacades.push(...Array.from(module.chunkFileNames).map(fileName => ({ fileName })));
+ if (requiredFacades.length === 0) {
+ requiredFacades.push({});
+ }
if (!this.facadeModule) {
const exportNamesByVariable = module.getExportNamesByVariable();
- if (
- this.graph.preserveModules ||
- this.canModuleBeFacade(exportNamesByVariable, module.chunkAlias)
- ) {
+ if (this.graph.preserveModules || this.canModuleBeFacade(exportNamesByVariable)) {
this.facadeModule = module;
+ module.facadeChunk = this;
for (const [variable, exportNames] of exportNamesByVariable) {
for (const exportName of exportNames) {
this.exportNames[exportName] = variable;
}
}
- continue;
+ this.assignFacadeName(requiredFacades.shift() as FacadeName, module);
}
}
- facades.push(Chunk.generateFacade(this.graph, module));
+
+ for (const facadeName of requiredFacades) {
+ facades.push(Chunk.generateFacade(this.graph, module, facadeName));
+ }
}
return facades;
}
@@ -234,19 +253,16 @@ export default class Chunk {
patternName: string,
addons: Addons,
options: OutputOptions,
- existingNames: Record
- ) {
- this.id = makeUnique(
- renderNamePattern(pattern, patternName, type => {
- switch (type) {
- case 'format':
- return options.format === 'es' ? 'esm' : options.format;
- case 'hash':
- return this.computeContentHashWithDependencies(addons, options);
- case 'name':
- return this.getChunkName();
- }
- return undefined as any;
+ existingNames: Record
+ ): string {
+ if (this.fileName !== null) {
+ return this.fileName;
+ }
+ return makeUnique(
+ renderNamePattern(pattern, patternName, {
+ format: () => (options.format === 'es' ? 'esm' : (options.format as string)),
+ hash: () => this.computeContentHashWithDependencies(addons, options),
+ name: () => this.getChunkName()
}),
existingNames
);
@@ -254,10 +270,10 @@ export default class Chunk {
generateIdPreserveModules(
preserveModulesRelativeDir: string,
- existingNames: Record
- ) {
+ existingNames: Record
+ ): string {
const sanitizedId = sanitizeFileName(this.orderedModules[0].id);
- this.id = makeUnique(
+ return makeUnique(
normalize(
isAbsolute(this.orderedModules[0].id)
? relative(preserveModulesRelativeDir, sanitizedId)
@@ -304,11 +320,11 @@ export default class Chunk {
}
getChunkName(): string {
- return this.chunkName || (this.chunkName = this.computeChunkName());
+ return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
}
getDynamicImportIds(): string[] {
- return this.dynamicDependencies.map(chunk => chunk.id).filter(Boolean);
+ return this.dynamicDependencies.map(chunk => chunk.id).filter(Boolean) as string[];
}
getExportNames(): string[] {
@@ -318,7 +334,7 @@ export default class Chunk {
}
getImportIds(): string[] {
- return this.dependencies.map(chunk => chunk.id);
+ return this.dependencies.map(chunk => chunk.id).filter(Boolean) as string[];
}
getRenderedHash(): string {
@@ -616,13 +632,9 @@ export default class Chunk {
if (dep instanceof ExternalModule && !dep.renormalizeRenderPath) continue;
const renderedDependency = this.renderedDeclarations.dependencies[i];
-
- const depId = dep instanceof ExternalModule ? renderedDependency.id : dep.id;
- let relPath = this.id ? normalize(relative(dirname(this.id), depId)) : depId;
- if (!relPath.startsWith('../')) relPath = './' + relPath;
-
+ const depId = dep instanceof ExternalModule ? renderedDependency.id : (dep.id as string);
if (dep instanceof Chunk) renderedDependency.namedExportsMode = dep.exportMode !== 'default';
- renderedDependency.id = relPath;
+ renderedDependency.id = this.getRelativePath(depId);
}
this.finaliseDynamicImports(format);
@@ -697,23 +709,18 @@ export default class Chunk {
let file: string;
if (options.file) file = resolve(options.sourcemapFile || options.file);
- else if (options.dir) file = resolve(options.dir, this.id);
- else file = resolve(this.id);
-
- if (this.graph.pluginDriver.hasLoadersOrTransforms) {
- const decodedMap = magicString.generateDecodedMap({});
- map = collapseSourcemaps(
- this,
- file,
- decodedMap,
- this.usedModules,
- chunkSourcemapChain,
- options.sourcemapExcludeSources as boolean
- );
- } else {
- map = magicString.generateMap({ file, includeContent: !options.sourcemapExcludeSources });
- }
-
+ else if (options.dir) file = resolve(options.dir, this.id as string);
+ else file = resolve(this.id as string);
+
+ const decodedMap = magicString.generateDecodedMap({});
+ map = collapseSourcemaps(
+ this,
+ file,
+ decodedMap,
+ this.usedModules,
+ chunkSourcemapChain,
+ options.sourcemapExcludeSources as boolean
+ );
map.sources = map.sources.map(sourcePath =>
normalize(
options.sourcemapPathTransform ? options.sourcemapPathTransform(sourcePath) : sourcePath
@@ -782,17 +789,14 @@ export default class Chunk {
}
}
- private computeChunkName(): string {
- if (this.manualChunkAlias) {
- return sanitizeFileName(this.manualChunkAlias);
- }
- if (this.facadeModule !== null) {
- return sanitizeFileName(this.facadeModule.chunkAlias || getAliasName(this.facadeModule.id));
- }
- for (const module of this.orderedModules) {
- if (module.chunkAlias) return sanitizeFileName(module.chunkAlias);
+ private assignFacadeName({ fileName, name }: FacadeName, facadedModule: Module) {
+ if (fileName) {
+ this.fileName = fileName;
+ } else {
+ this.name = sanitizeFileName(
+ name || facadedModule.chunkName || getAliasName(facadedModule.id)
+ );
}
- return 'chunk';
}
private computeContentHashWithDependencies(addons: Addons, options: OutputOptions): string {
@@ -817,19 +821,24 @@ export default class Chunk {
if (resolution instanceof Module) {
if (resolution.chunk !== this && isChunkRendered(resolution.chunk as Chunk)) {
const resolutionChunk = resolution.facadeChunk || (resolution.chunk as Chunk);
- let relPath = normalize(relative(dirname(this.id), resolutionChunk.id));
- if (!relPath.startsWith('../')) relPath = './' + relPath;
- node.renderFinalResolution(code, `'${relPath}'`, format);
+ node.renderFinalResolution(
+ code,
+ `'${this.getRelativePath(resolutionChunk.id as string)}'`,
+ format
+ );
}
- } else if (resolution instanceof ExternalModule) {
- let resolutionId = resolution.id;
- if (resolution.renormalizeRenderPath) {
- resolutionId = normalize(relative(dirname(this.id), resolution.renderPath));
- if (!resolutionId.startsWith('../')) resolutionId = './' + resolutionId;
- }
- node.renderFinalResolution(code, `'${resolutionId}'`, format);
} else {
- node.renderFinalResolution(code, resolution, format);
+ node.renderFinalResolution(
+ code,
+ resolution instanceof ExternalModule
+ ? `'${
+ resolution.renormalizeRenderPath
+ ? this.getRelativePath(resolution.renderPath)
+ : resolution.id
+ }'`
+ : resolution,
+ format
+ );
}
}
}
@@ -838,7 +847,7 @@ export default class Chunk {
private finaliseImportMetas(format: string): void {
for (const [module, code] of this.renderedModuleSources) {
for (const importMeta of module.importMetas) {
- importMeta.renderFinalMechanism(code, this.id, format, this.graph.pluginDriver);
+ importMeta.renderFinalMechanism(code, this.id as string, format, this.graph.pluginDriver);
}
}
}
@@ -983,6 +992,24 @@ export default class Chunk {
return exports;
}
+ private getFallbackChunkName(): string {
+ if (this.manualChunkAlias) {
+ return this.manualChunkAlias;
+ }
+ if (this.fileName) {
+ return getAliasName(this.fileName);
+ }
+ for (const module of this.orderedModules) {
+ if (module.chunkName) return module.chunkName;
+ }
+ return 'chunk';
+ }
+
+ private getRelativePath(targetPath: string): string {
+ const relativePath = normalize(relative(dirname(this.id as string), targetPath));
+ return relativePath.startsWith('../') ? relativePath : './' + relativePath;
+ }
+
private inlineChunkDependencies(chunk: Chunk, deep: boolean) {
for (const dep of chunk.dependencies) {
if (dep instanceof ExternalModule) {
diff --git a/src/Graph.ts b/src/Graph.ts
index 6326e50669d..871994d972c 100644
--- a/src/Graph.ts
+++ b/src/Graph.ts
@@ -8,16 +8,14 @@ import { EntityPathTracker } from './ast/utils/EntityPathTracker';
import Chunk, { isChunkRendered } from './Chunk';
import ExternalModule from './ExternalModule';
import Module, { defaultAcornOptions } from './Module';
-import { ModuleLoader, UnresolvedModuleWithAlias } from './ModuleLoader';
+import { ModuleLoader, UnresolvedModule } from './ModuleLoader';
import {
- Asset,
ExternalOption,
GetManualChunk,
InputOptions,
ManualChunksOption,
ModuleJSON,
ModuleSideEffectsOption,
- OutputBundle,
PureModulesOption,
RollupCache,
RollupWarning,
@@ -26,7 +24,6 @@ import {
TreeshakingOptions,
WarningHandler
} from './rollup/types';
-import { finaliseAsset } from './utils/assetHooks';
import { BuildPhase } from './utils/buildPhase';
import { assignChunkColouringHashes } from './utils/chunkColouring';
import { Uint8ArrayToHexString } from './utils/entryHashing';
@@ -50,26 +47,25 @@ function makeOnwarn() {
function normalizeEntryModules(
entryModules: string | string[] | Record
-): UnresolvedModuleWithAlias[] {
+): UnresolvedModule[] {
if (typeof entryModules === 'string') {
- return [{ alias: null, unresolvedId: entryModules }];
+ return [{ fileName: null, name: null, id: entryModules }];
}
if (Array.isArray(entryModules)) {
- return entryModules.map(unresolvedId => ({ alias: null, unresolvedId }));
+ return entryModules.map(id => ({ fileName: null, name: null, id }));
}
- return Object.keys(entryModules).map(alias => ({
- alias,
- unresolvedId: entryModules[alias]
+ return Object.keys(entryModules).map(name => ({
+ fileName: null,
+ id: entryModules[name],
+ name
}));
}
export default class Graph {
acornOptions: acorn.Options;
acornParser: typeof acorn.Parser;
- assetsById = new Map();
cachedModules: Map;
contextParse: (code: string, acornOptions?: acorn.Options) => ESTree.Program;
- curChunkIndex = 0;
deoptimizationTracker: EntityPathTracker;
getModuleContext: (id: string) => string;
moduleById = new Map();
@@ -93,7 +89,6 @@ export default class Graph {
constructor(options: InputOptions, watcher?: RollupWatcher) {
this.onwarn = (options.onwarn as WarningHandler) || makeOnwarn();
- this.curChunkIndex = 0;
this.deoptimizationTracker = new EntityPathTracker();
this.cachedModules = new Map();
if (options.cache) {
@@ -315,9 +310,7 @@ export default class Graph {
chunks = chunks.filter(isChunkRendered);
const facades: Chunk[] = [];
for (const chunk of chunks) {
- for (const facade of chunk.generateFacades()) {
- facades.push(facade);
- }
+ facades.push(...chunk.generateFacades());
}
timeEnd('generate chunks', 2);
@@ -327,14 +320,6 @@ export default class Graph {
});
}
- finaliseAssets(assetFileNames: string) {
- const outputBundle: OutputBundle = Object.create(null);
- this.assetsById.forEach(asset => {
- if (asset.source !== undefined) finaliseAsset(asset, outputBundle, assetFileNames);
- });
- return outputBundle;
- }
-
getCache(): RollupCache {
// handle plugin cache eviction
for (const name in this.pluginCache) {
diff --git a/src/Module.ts b/src/Module.ts
index bf30ec88ff2..11bc333cf39 100644
--- a/src/Module.ts
+++ b/src/Module.ts
@@ -31,9 +31,8 @@ import Chunk from './Chunk';
import ExternalModule from './ExternalModule';
import Graph from './Graph';
import {
- Asset,
DecodedSourceMapOrMissing,
- EmittedChunk,
+ EmittedFile,
ExistingDecodedSourceMap,
ModuleJSON,
ResolvedIdMap,
@@ -92,9 +91,8 @@ export interface AstContext {
deoptimizationTracker: EntityPathTracker;
error: (props: RollupError, pos: number) => void;
fileName: string;
- getAssetFileName: (assetReferenceId: string) => string;
- getChunkFileName: (chunkReferenceId: string) => string;
getExports: () => string[];
+ getFileName: (fileReferenceId: string) => string;
getModuleExecIndex: () => number;
getModuleName: () => string;
getReexports: () => string[];
@@ -114,6 +112,7 @@ export interface AstContext {
tryCatchDeoptimization: boolean;
usesTopLevelAwait: boolean;
warn: (warning: RollupWarning, pos: number) => void;
+ warnDeprecation: (deprecation: string | RollupWarning, activeDeprecation: boolean) => void;
}
export const defaultAcornOptions: acorn.Options = {
@@ -170,7 +169,8 @@ const MISSING_EXPORT_SHIM_DESCRIPTION: ExportDescription = {
export default class Module {
chunk?: Chunk;
- chunkAlias: string = null as any;
+ chunkFileNames = new Set();
+ chunkName: string | null = null;
code!: string;
comments: CommentDescription[] = [];
customTransformCache!: boolean;
@@ -206,8 +206,8 @@ export default class Module {
scope!: ModuleScope;
sourcemapChain!: DecodedSourceMapOrMissing[];
sources: string[] = [];
- transformAssets?: Asset[];
- transformChunks?: EmittedChunk[];
+ transformFiles?: EmittedFile[];
+ userChunkNames = new Set();
usesTopLevelAwait = false;
private allExportNames?: Set;
@@ -531,22 +531,17 @@ export default class Module {
originalSourcemap,
resolvedIds,
sourcemapChain,
- transformAssets,
- transformChunks,
- transformDependencies
+ transformDependencies,
+ transformFiles
}: TransformModuleJSON & {
- transformAssets?: Asset[] | undefined;
- transformChunks?: EmittedChunk[] | undefined;
+ transformFiles?: EmittedFile[] | undefined;
}) {
this.code = code;
this.originalCode = originalCode;
this.originalSourcemap = originalSourcemap;
this.sourcemapChain = sourcemapChain;
- if (transformAssets) {
- this.transformAssets = transformAssets;
- }
- if (transformChunks) {
- this.transformChunks = transformChunks;
+ if (transformFiles) {
+ this.transformFiles = transformFiles;
}
this.transformDependencies = transformDependencies;
this.customTransformCache = customTransformCache;
@@ -586,9 +581,8 @@ export default class Module {
deoptimizationTracker: this.graph.deoptimizationTracker,
error: this.error.bind(this),
fileName, // Needed for warnings
- getAssetFileName: this.graph.pluginDriver.getAssetFileName,
- getChunkFileName: this.graph.moduleLoader.getChunkFileName.bind(this.graph.moduleLoader),
getExports: this.getExports.bind(this),
+ getFileName: this.graph.pluginDriver.getFileName,
getModuleExecIndex: () => this.execIndex,
getModuleName: this.basename.bind(this),
getReexports: this.getReexports.bind(this),
@@ -610,7 +604,8 @@ export default class Module {
tryCatchDeoptimization: (!this.graph.treeshakingOptions ||
this.graph.treeshakingOptions.tryCatchDeoptimization) as boolean,
usesTopLevelAwait: false,
- warn: this.warn.bind(this)
+ warn: this.warn.bind(this),
+ warnDeprecation: this.graph.warnDeprecation.bind(this.graph)
};
this.scope = new ModuleScope(this.graph.scope, this.astContext);
@@ -635,9 +630,8 @@ export default class Module {
originalSourcemap: this.originalSourcemap,
resolvedIds: this.resolvedIds,
sourcemapChain: this.sourcemapChain,
- transformAssets: this.transformAssets,
- transformChunks: this.transformChunks,
- transformDependencies: this.transformDependencies
+ transformDependencies: this.transformDependencies,
+ transformFiles: this.transformFiles
};
}
diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts
index 51c03d29bcc..9290a509035 100644
--- a/src/ModuleLoader.ts
+++ b/src/ModuleLoader.ts
@@ -1,5 +1,4 @@
import * as ESTree from 'estree';
-import Chunk from './Chunk';
import ExternalModule from './ExternalModule';
import Graph from './Graph';
import Module from './Module';
@@ -17,8 +16,6 @@ import {
import {
errBadLoader,
errCannotAssignModuleToChunk,
- errChunkNotGeneratedForFileName,
- errChunkReferenceIdNotFoundForFilename,
errEntryCannotBeExternal,
errInternalIdCannotBeExternal,
errInvalidOption,
@@ -30,18 +27,14 @@ import {
} from './utils/error';
import { isRelative, resolve } from './utils/path';
import { PluginDriver } from './utils/pluginDriver';
-import { addWithNewReferenceId } from './utils/referenceIds';
import relativeId from './utils/relativeId';
import { timeEnd, timeStart } from './utils/timers';
import transform from './utils/transform';
-export interface UnresolvedModuleWithAlias {
- alias: string | null;
- unresolvedId: string;
-}
-
-interface UnresolvedEntryModuleWithAlias extends UnresolvedModuleWithAlias {
- manualChunkAlias?: string;
+export interface UnresolvedModule {
+ fileName: string | null;
+ id: string;
+ name: string | null;
}
function normalizeRelativeExternalId(importer: string, source: string) {
@@ -97,10 +90,6 @@ function getHasModuleSideEffects(
export class ModuleLoader {
readonly isExternal: IsExternal;
- private readonly entriesByReferenceId = new Map<
- string,
- { module: Module | null; name: string }
- >();
private readonly entryModules: Module[] = [];
private readonly getManualChunk: GetManualChunk;
private readonly graph: Graph;
@@ -131,29 +120,8 @@ export class ModuleLoader {
this.getManualChunk = typeof getManualChunk === 'function' ? getManualChunk : () => null;
}
- addEntryModuleAndGetReferenceId(unresolvedEntryModule: UnresolvedModuleWithAlias): string {
- const entryRecord: { module: Module | null; name: string } = {
- module: null,
- name: unresolvedEntryModule.unresolvedId
- };
- const referenceId = addWithNewReferenceId(
- entryRecord,
- this.entriesByReferenceId,
- unresolvedEntryModule.unresolvedId
- );
- this.addEntryModules([unresolvedEntryModule], false)
- .then(({ newEntryModules: [module] }) => {
- entryRecord.module = module;
- })
- .catch(() => {
- // Avoid unhandled Promise rejection as the error will be thrown later
- // once module loading has finished
- });
- return referenceId;
- }
-
addEntryModules(
- unresolvedEntryModules: UnresolvedModuleWithAlias[],
+ unresolvedEntryModules: UnresolvedModule[],
isUserDefined: boolean
): Promise<{
entryModules: Module[];
@@ -161,8 +129,20 @@ export class ModuleLoader {
newEntryModules: Module[];
}> {
const loadNewEntryModulesPromise = Promise.all(
- unresolvedEntryModules.map(unresolvedEntryModule =>
- this.loadEntryModule(unresolvedEntryModule, true)
+ unresolvedEntryModules.map(({ fileName, id, name }) =>
+ this.loadEntryModule(id, true).then(module => {
+ if (fileName !== null) {
+ module.chunkFileNames.add(fileName);
+ } else if (name !== null) {
+ if (module.chunkName === null) {
+ module.chunkName = name;
+ }
+ if (isUserDefined) {
+ module.userChunkNames.add(name);
+ }
+ }
+ return module;
+ })
)
).then(entryModules => {
for (const entryModule of entryModules) {
@@ -182,41 +162,24 @@ export class ModuleLoader {
}
addManualChunks(manualChunks: Record): Promise {
- const unresolvedManualChunks: UnresolvedEntryModuleWithAlias[] = [];
+ const unresolvedManualChunks: { alias: string; id: string }[] = [];
for (const alias of Object.keys(manualChunks)) {
const manualChunkIds = manualChunks[alias];
- for (const unresolvedId of manualChunkIds) {
- unresolvedManualChunks.push({ alias: null, unresolvedId, manualChunkAlias: alias });
+ for (const id of manualChunkIds) {
+ unresolvedManualChunks.push({ id, alias });
}
}
const loadNewManualChunkModulesPromise = Promise.all(
- unresolvedManualChunks.map(unresolvedManualChunk =>
- this.loadEntryModule(unresolvedManualChunk, false)
- )
+ unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false))
).then(manualChunkModules => {
for (let index = 0; index < manualChunkModules.length; index++) {
- this.addToManualChunk(
- unresolvedManualChunks[index].manualChunkAlias as string,
- manualChunkModules[index]
- );
+ this.addModuleToManualChunk(unresolvedManualChunks[index].alias, manualChunkModules[index]);
}
});
return this.awaitLoadModulesPromise(loadNewManualChunkModulesPromise);
}
- getChunkFileName(referenceId: string): string {
- const entryRecord = this.entriesByReferenceId.get(referenceId);
- if (!entryRecord) return error(errChunkReferenceIdNotFoundForFilename(referenceId));
- const fileName =
- entryRecord.module &&
- (entryRecord.module.facadeChunk
- ? entryRecord.module.facadeChunk.id
- : (entryRecord.module.chunk as Chunk).id);
- if (!fileName) return error(errChunkNotGeneratedForFileName(entryRecord));
- return fileName;
- }
-
async resolveId(
source: string,
importer: string,
@@ -231,7 +194,7 @@ export class ModuleLoader {
);
}
- private addToManualChunk(alias: string, module: Module) {
+ private addModuleToManualChunk(alias: string, module: Module) {
if (module.manualChunkAlias !== null && module.manualChunkAlias !== alias) {
error(errCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias));
}
@@ -307,7 +270,7 @@ export class ModuleLoader {
this.modulesById.set(id, module);
const manualChunkAlias = this.getManualChunk(id);
if (typeof manualChunkAlias === 'string') {
- this.addToManualChunk(manualChunkAlias, module);
+ this.addModuleToManualChunk(manualChunkAlias, module);
}
timeStart('load modules', 3);
@@ -333,13 +296,9 @@ export class ModuleLoader {
!cachedModule.customTransformCache &&
cachedModule.originalCode === sourceDescription.code
) {
- if (cachedModule.transformAssets) {
- for (const { name, source } of cachedModule.transformAssets)
- this.pluginDriver.emitAsset(name, source);
- }
- if (cachedModule.transformChunks) {
- for (const { id, options } of cachedModule.transformChunks)
- this.pluginDriver.emitChunk(id, options);
+ if (cachedModule.transformFiles) {
+ for (const emittedFile of cachedModule.transformFiles)
+ this.pluginDriver.emitFile(emittedFile);
}
return cachedModule;
}
@@ -419,10 +378,7 @@ export class ModuleLoader {
return resolvedId;
}
- private loadEntryModule = (
- { alias, unresolvedId }: UnresolvedModuleWithAlias,
- isEntry: boolean
- ): Promise =>
+ private loadEntryModule = (unresolvedId: string, isEntry: boolean): Promise =>
this.pluginDriver.hookFirst('resolveId', [unresolvedId, undefined]).then(resolveIdResult => {
if (
resolveIdResult === false ||
@@ -436,15 +392,7 @@ export class ModuleLoader {
: resolveIdResult;
if (typeof id === 'string') {
- return this.fetchModule(id, undefined as any, true, isEntry).then(module => {
- if (alias !== null) {
- if (module.chunkAlias !== null && module.chunkAlias !== alias) {
- return error(errCannotAssignModuleToChunk(module.id, alias, module.chunkAlias));
- }
- module.chunkAlias = alias;
- }
- return module;
- });
+ return this.fetchModule(id, undefined as any, true, isEntry);
}
return error(errUnresolvedEntry(unresolvedId));
});
diff --git a/src/ast/nodes/MetaProperty.ts b/src/ast/nodes/MetaProperty.ts
index 10ccb958f1d..4c466ea7ffa 100644
--- a/src/ast/nodes/MetaProperty.ts
+++ b/src/ast/nodes/MetaProperty.ts
@@ -10,6 +10,7 @@ import { NodeBase } from './shared/Node';
const ASSET_PREFIX = 'ROLLUP_ASSET_URL_';
const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_';
+const FILE_PREFIX = 'ROLLUP_FILE_URL_';
export default class MetaProperty extends NodeBase {
meta!: Identifier;
@@ -33,7 +34,11 @@ export default class MetaProperty extends NodeBase {
if (metaProperty) {
if (metaProperty === 'url') {
this.scope.addAccessedGlobalsByFormat(accessedMetaUrlGlobals);
- } else if (metaProperty.startsWith(ASSET_PREFIX) || metaProperty.startsWith(CHUNK_PREFIX)) {
+ } else if (
+ metaProperty.startsWith(FILE_PREFIX) ||
+ metaProperty.startsWith(ASSET_PREFIX) ||
+ metaProperty.startsWith(CHUNK_PREFIX)
+ ) {
this.scope.addAccessedGlobalsByFormat(accessedFileUrlGlobals);
}
}
@@ -54,21 +59,35 @@ export default class MetaProperty extends NodeBase {
): void {
if (!this.included) return;
const parent = this.parent;
- const importMetaProperty = this.metaProperty as string | null;
+ const metaProperty = this.metaProperty as string | null;
if (
- importMetaProperty &&
- (importMetaProperty.startsWith(ASSET_PREFIX) || importMetaProperty.startsWith(CHUNK_PREFIX))
+ metaProperty &&
+ (metaProperty.startsWith(FILE_PREFIX) ||
+ metaProperty.startsWith(ASSET_PREFIX) ||
+ metaProperty.startsWith(CHUNK_PREFIX))
) {
+ let referenceId: string | null = null;
let assetReferenceId: string | null = null;
let chunkReferenceId: string | null = null;
let fileName: string;
- if (importMetaProperty.startsWith(ASSET_PREFIX)) {
- assetReferenceId = importMetaProperty.substr(ASSET_PREFIX.length);
- fileName = this.context.getAssetFileName(assetReferenceId);
+ if (metaProperty.startsWith(FILE_PREFIX)) {
+ referenceId = metaProperty.substr(FILE_PREFIX.length);
+ fileName = this.context.getFileName(referenceId);
+ } else if (metaProperty.startsWith(ASSET_PREFIX)) {
+ this.context.warnDeprecation(
+ `Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`,
+ false
+ );
+ assetReferenceId = metaProperty.substr(ASSET_PREFIX.length);
+ fileName = this.context.getFileName(assetReferenceId);
} else {
- chunkReferenceId = importMetaProperty.substr(CHUNK_PREFIX.length);
- fileName = this.context.getChunkFileName(chunkReferenceId);
+ this.context.warnDeprecation(
+ `Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`,
+ false
+ );
+ chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length);
+ fileName = this.context.getFileName(chunkReferenceId);
}
const relativePath = normalize(relative(dirname(chunkId), fileName));
let replacement;
@@ -92,6 +111,7 @@ export default class MetaProperty extends NodeBase {
fileName,
format,
moduleId: this.context.module.id,
+ referenceId: referenceId || assetReferenceId || (chunkReferenceId as string),
relativePath
}
]);
@@ -107,7 +127,7 @@ export default class MetaProperty extends NodeBase {
}
const replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
- importMetaProperty,
+ metaProperty,
{
chunkId,
format,
diff --git a/src/rollup/index.ts b/src/rollup/index.ts
index aaa93791824..bc11bab656b 100644
--- a/src/rollup/index.ts
+++ b/src/rollup/index.ts
@@ -3,10 +3,9 @@ import Chunk from '../Chunk';
import { optimizeChunks } from '../chunk-optimization';
import Graph from '../Graph';
import { createAddons } from '../utils/addons';
-import { createAssetPluginHooks, finaliseAsset } from '../utils/assetHooks';
import { assignChunkIds } from '../utils/assignChunkIds';
import commondir from '../utils/commondir';
-import { errDeprecation, error } from '../utils/error';
+import { errCannotEmitFromOptionsHook, errDeprecation, error } from '../utils/error';
import { writeFile } from '../utils/fs';
import getExportMode from '../utils/getExportMode';
import mergeOptions, { GenericConfigObject } from '../utils/mergeOptions';
@@ -18,10 +17,10 @@ import {
InputOptions,
OutputAsset,
OutputBundle,
+ OutputBundleWithPlaceholders,
OutputChunk,
OutputOptions,
Plugin,
- PluginContext,
RollupBuild,
RollupCache,
RollupOutput,
@@ -148,6 +147,33 @@ export function setWatcher(watcher: RollupWatcher) {
curWatcher = watcher;
}
+function assignChunksToBundle(
+ chunks: Chunk[],
+ outputBundle: OutputBundleWithPlaceholders
+): OutputBundle {
+ for (let i = 0; i < chunks.length; i++) {
+ const chunk = chunks[i];
+ const facadeModule = chunk.facadeModule;
+
+ outputBundle[chunk.id as string] = {
+ code: undefined as any,
+ dynamicImports: chunk.getDynamicImportIds(),
+ exports: chunk.getExportNames(),
+ facadeModuleId: facadeModule && facadeModule.id,
+ fileName: chunk.id,
+ imports: chunk.getImportIds(),
+ isDynamicEntry: facadeModule !== null && facadeModule.dynamicallyImportedBy.length > 0,
+ isEntry: facadeModule !== null && facadeModule.isEntryPoint,
+ map: undefined,
+ modules: chunk.renderedModules,
+ get name() {
+ return chunk.getChunkName();
+ }
+ } as OutputChunk;
+ }
+ return outputBundle as OutputBundle;
+}
+
export default function rollup(rawInputOptions: GenericConfigObject): Promise {
try {
const inputOptions = getInputOptions(rawInputOptions);
@@ -194,114 +220,75 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise {
timeStart('GENERATE', 1);
const assetFileNames = outputOptions.assetFileNames || 'assets/[name]-[hash][extname]';
- const outputBundle: OutputBundle = graph.finaliseAssets(assetFileNames);
+ const outputBundleWithPlaceholders: OutputBundleWithPlaceholders = Object.create(null);
+ let outputBundle;
const inputBase = commondir(getAbsoluteEntryModulePaths(chunks));
-
- return graph.pluginDriver
- .hookParallel('renderStart', [])
- .then(() => createAddons(graph, outputOptions))
- .then(addons => {
- // pre-render all chunks
- for (const chunk of chunks) {
- if (!inputOptions.preserveModules) chunk.generateInternalExports(outputOptions);
- if (chunk.facadeModule && chunk.facadeModule.isEntryPoint)
- chunk.exportMode = getExportMode(chunk, outputOptions);
- }
- for (const chunk of chunks) {
- chunk.preRender(outputOptions, inputBase);
- }
- if (!optimized && inputOptions.experimentalOptimizeChunks) {
- optimizeChunks(
- chunks,
- outputOptions,
- inputOptions.chunkGroupingSize as number,
- inputBase
- );
- optimized = true;
- }
-
- assignChunkIds(chunks, inputOptions, outputOptions, inputBase, addons);
-
- // assign to outputBundle
- for (let i = 0; i < chunks.length; i++) {
- const chunk = chunks[i];
- const facadeModule = chunk.facadeModule;
-
- outputBundle[chunk.id] = {
- code: undefined as any,
- dynamicImports: chunk.getDynamicImportIds(),
- exports: chunk.getExportNames(),
- facadeModuleId: facadeModule && facadeModule.id,
- fileName: chunk.id,
- imports: chunk.getImportIds(),
- isDynamicEntry:
- facadeModule !== null && facadeModule.dynamicallyImportedBy.length > 0,
- isEntry: facadeModule !== null && facadeModule.isEntryPoint,
- map: undefined,
- modules: chunk.renderedModules,
- get name() {
- return chunk.getChunkName();
- }
- } as OutputChunk;
- }
-
- return Promise.all(
- chunks.map(chunk => {
- const outputChunk = outputBundle[chunk.id] as OutputChunk;
- return chunk.render(outputOptions, addons, outputChunk).then(rendered => {
- outputChunk.code = rendered.code;
- outputChunk.map = rendered.map;
-
- return graph.pluginDriver.hookParallel('ongenerate', [
- { bundle: outputChunk, ...outputOptions },
- outputChunk
- ]);
- });
- })
- ).then(() => {});
- })
- .catch(error =>
- graph.pluginDriver.hookParallel('renderError', [error]).then(() => {
- throw error;
- })
- )
- .then(() => {
- // run generateBundle hook
-
- // assets emitted during generateBundle are unique to that specific generate call
- const assets = new Map(graph.assetsById);
- const generateAssetPluginHooks = createAssetPluginHooks(
- assets,
- outputBundle,
- assetFileNames
+ graph.pluginDriver.startOutput(outputBundleWithPlaceholders, assetFileNames);
+
+ try {
+ await graph.pluginDriver.hookParallel('renderStart', []);
+ const addons = await createAddons(graph, outputOptions);
+ for (const chunk of chunks) {
+ if (!inputOptions.preserveModules) chunk.generateInternalExports(outputOptions);
+ if (chunk.facadeModule && chunk.facadeModule.isEntryPoint)
+ chunk.exportMode = getExportMode(chunk, outputOptions);
+ }
+ for (const chunk of chunks) {
+ chunk.preRender(outputOptions, inputBase);
+ }
+ if (!optimized && inputOptions.experimentalOptimizeChunks) {
+ optimizeChunks(
+ chunks,
+ outputOptions,
+ inputOptions.chunkGroupingSize as number,
+ inputBase
);
-
- return graph.pluginDriver
- .hookSeq(
- 'generateBundle',
- [outputOptions, outputBundle, isWrite],
- context =>
- ({
- ...context,
- ...generateAssetPluginHooks
- } as PluginContext)
- )
- .then(() => {
- // throw errors for assets not finalised with a source
- assets.forEach(asset => {
- if (asset.fileName === undefined)
- finaliseAsset(asset, outputBundle, assetFileNames);
- });
+ optimized = true;
+ }
+ assignChunkIds(
+ chunks,
+ inputOptions,
+ outputOptions,
+ inputBase,
+ addons,
+ outputBundleWithPlaceholders
+ );
+ outputBundle = assignChunksToBundle(chunks, outputBundleWithPlaceholders);
+
+ await Promise.all(
+ chunks.map(chunk => {
+ const outputChunk = outputBundleWithPlaceholders[chunk.id as string] as OutputChunk;
+ return chunk.render(outputOptions, addons, outputChunk).then(rendered => {
+ outputChunk.code = rendered.code;
+ outputChunk.map = rendered.map;
+
+ return graph.pluginDriver.hookParallel('ongenerate', [
+ { bundle: outputChunk, ...outputOptions },
+ outputChunk
+ ]);
});
- })
- .then(() => {
- timeEnd('GENERATE', 1);
- return outputBundle;
- });
+ })
+ );
+ } catch (error) {
+ await graph.pluginDriver.hookParallel('renderError', [error]);
+ throw error;
+ }
+ await graph.pluginDriver.hookSeq('generateBundle', [
+ outputOptions,
+ outputBundle,
+ isWrite
+ ]);
+ graph.pluginDriver.finaliseAssets();
+
+ timeEnd('GENERATE', 1);
+ return outputBundle;
}
const cache = useCache ? graph.getCache() : undefined;
@@ -383,16 +370,18 @@ function getSortingFileType(file: OutputAsset | OutputChunk): SortingFileType {
return SortingFileType.SECONDARY_CHUNK;
}
-function createOutput(outputBundle: Record): RollupOutput {
+function createOutput(outputBundle: Record): RollupOutput {
return {
- output: Object.keys(outputBundle)
+ output: (Object.keys(outputBundle)
.map(fileName => outputBundle[fileName])
- .sort((outputFileA, outputFileB) => {
- const fileTypeA = getSortingFileType(outputFileA);
- const fileTypeB = getSortingFileType(outputFileB);
- if (fileTypeA === fileTypeB) return 0;
- return fileTypeA < fileTypeB ? -1 : 1;
- }) as [OutputChunk, ...(OutputChunk | OutputAsset)[]]
+ .filter(outputFile => Object.keys(outputFile).length > 0) as (
+ | OutputChunk
+ | OutputAsset)[]).sort((outputFileA, outputFileB) => {
+ const fileTypeA = getSortingFileType(outputFileA);
+ const fileTypeB = getSortingFileType(outputFileB);
+ if (fileTypeA === fileTypeB) return 0;
+ return fileTypeA < fileTypeB ? -1 : 1;
+ }) as [OutputChunk, ...(OutputChunk | OutputAsset)[]]
};
}
@@ -468,7 +457,15 @@ function normalizeOutputOptions(
const outputOptions = pluginDriver.hookReduceArg0Sync(
'outputOptions',
[mergedOutputOptions],
- outputOptionsReducer
+ outputOptionsReducer,
+ pluginContext => {
+ const emitError = () => pluginContext.error(errCannotEmitFromOptionsHook());
+ return {
+ ...pluginContext,
+ emitFile: emitError,
+ setAssetSource: emitError
+ };
+ }
);
checkOutputOptions(outputOptions);
diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts
index 36f5394eda6..41d9b5c82bc 100644
--- a/src/rollup/types.d.ts
+++ b/src/rollup/types.d.ts
@@ -111,19 +111,7 @@ export interface TransformModuleJSON {
export interface ModuleJSON extends TransformModuleJSON {
dependencies: string[];
id: string;
- transformAssets: Asset[] | undefined;
- transformChunks: EmittedChunk[] | undefined;
-}
-
-export interface EmittedChunk {
- id: string;
- options: { name?: string } | undefined;
-}
-
-export interface Asset {
- fileName: string;
- name: string;
- source: string | Buffer;
+ transformFiles: EmittedFile[] | undefined;
}
export interface PluginCache {
@@ -137,17 +125,42 @@ export interface MinimalPluginContext {
meta: PluginContextMeta;
}
+export interface EmittedAsset {
+ fileName?: string;
+ name?: string;
+ source?: string | Buffer;
+ type: 'asset';
+}
+
+export interface EmittedChunk {
+ fileName?: string;
+ id: string;
+ name?: string;
+ type: 'chunk';
+}
+
+export type EmittedFile = EmittedAsset | EmittedChunk;
+
export type EmitAsset = (name: string, source?: string | Buffer) => string;
-export type EmitChunk = (name: string, options?: { name?: string }) => string;
+
+export type EmitChunk = (id: string, options?: { name?: string }) => string;
+
+export type EmitFile = (emittedFile: EmittedFile) => string;
export interface PluginContext extends MinimalPluginContext {
addWatchFile: (id: string) => void;
cache: PluginCache;
+ /** @deprecated Use `this.emitFile` instead */
emitAsset: EmitAsset;
+ /** @deprecated Use `this.emitFile` instead */
emitChunk: EmitChunk;
+ emitFile: EmitFile;
error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
+ /** @deprecated Use `this.getFileName` instead */
getAssetFileName: (assetReferenceId: string) => string;
+ /** @deprecated Use `this.getFileName` instead */
getChunkFileName: (chunkReferenceId: string) => string;
+ getFileName: (fileReferenceId: string) => string;
getModuleInfo: (
moduleId: string
) => {
@@ -278,6 +291,7 @@ export type ResolveFileUrlHook = (
fileName: string;
format: string;
moduleId: string;
+ referenceId: string;
relativePath: string;
}
) => string | null | undefined;
@@ -300,6 +314,10 @@ export interface OutputBundle {
[fileName: string]: OutputAsset | OutputChunk;
}
+export interface OutputBundleWithPlaceholders {
+ [fileName: string]: OutputAsset | OutputChunk | {};
+}
+
interface OnGenerateOptions extends OutputOptions {
bundle: OutputChunk;
}
diff --git a/src/utils/FileEmitter.ts b/src/utils/FileEmitter.ts
new file mode 100644
index 00000000000..edd72dda3ba
--- /dev/null
+++ b/src/utils/FileEmitter.ts
@@ -0,0 +1,340 @@
+import sha256 from 'hash.js/lib/hash/sha/256';
+import Chunk from '../Chunk';
+import Graph from '../Graph';
+import Module from '../Module';
+import { OutputAsset, OutputBundleWithPlaceholders } from '../rollup/types';
+import { BuildPhase } from './buildPhase';
+import {
+ errAssetNotFinalisedForFileName,
+ errAssetReferenceIdNotFoundForSetSource,
+ errAssetSourceAlreadySet,
+ errChunkNotGeneratedForFileName,
+ errFailedValidation,
+ errFileNameConflict,
+ errFileReferenceIdNotFoundForFilename,
+ errInvalidRollupPhaseForChunkEmission,
+ errNoAssetSourceSet,
+ error
+} from './error';
+import { extname } from './path';
+import { isPlainPathFragment } from './relativeId';
+import { makeUnique, renderNamePattern } from './renderNamePattern';
+
+interface OutputSpecificFileData {
+ assetFileNames: string;
+ bundle: OutputBundleWithPlaceholders;
+}
+
+function generateAssetFileName(
+ name: string | undefined,
+ source: string | Buffer,
+ output: OutputSpecificFileData
+): string {
+ const emittedName = name || 'asset';
+ return makeUnique(
+ renderNamePattern(output.assetFileNames, 'output.assetFileNames', {
+ hash() {
+ const hash = sha256();
+ hash.update(emittedName);
+ hash.update(':');
+ hash.update(source);
+ return hash.digest('hex').substr(0, 8);
+ },
+ ext: () => extname(emittedName).substr(1),
+ extname: () => extname(emittedName),
+ name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length)
+ }),
+ output.bundle
+ );
+}
+
+function reserveFileNameInBundle(fileName: string, bundle: OutputBundleWithPlaceholders) {
+ if (fileName in bundle) {
+ return error(errFileNameConflict(fileName));
+ }
+ bundle[fileName] = FILE_PLACEHOLDER;
+}
+
+interface ConsumedChunk {
+ fileName: string | undefined;
+ module: null | Module;
+ name: string;
+ type: 'chunk';
+}
+
+interface ConsumedAsset {
+ fileName: string | undefined;
+ name: string | undefined;
+ source: string | Buffer | undefined;
+ type: 'asset';
+}
+
+interface EmittedFile {
+ fileName?: string;
+ name?: string;
+ type: 'chunk' | 'asset';
+ [key: string]: unknown;
+}
+
+type ConsumedFile = ConsumedChunk | ConsumedAsset;
+
+export const FILE_PLACEHOLDER = {
+ isPlaceholder: true
+};
+
+function hasValidType(
+ emittedFile: unknown
+): emittedFile is { type: 'asset' | 'chunk'; [key: string]: unknown } {
+ return (
+ emittedFile &&
+ ((emittedFile as { [key: string]: unknown }).type === 'asset' ||
+ (emittedFile as { [key: string]: unknown }).type === 'chunk')
+ );
+}
+
+function hasValidName(emittedFile: {
+ type: 'asset' | 'chunk';
+ [key: string]: unknown;
+}): emittedFile is EmittedFile {
+ const validatedName = emittedFile.fileName || emittedFile.name;
+ return (
+ !validatedName || (typeof validatedName === 'string' && isPlainPathFragment(validatedName))
+ );
+}
+
+function getValidSource(
+ source: unknown,
+ emittedFile: { fileName?: string; name?: string },
+ fileReferenceId: string | null
+): string | Buffer {
+ if (typeof source !== 'string' && !Buffer.isBuffer(source)) {
+ const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
+ return error(
+ errFailedValidation(
+ `Could not set source for ${
+ typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'
+ }, asset source needs to be a string of Buffer.`
+ )
+ );
+ }
+ return source;
+}
+
+function getAssetFileName(file: ConsumedAsset, referenceId: string): string {
+ if (typeof file.fileName !== 'string') {
+ return error(errAssetNotFinalisedForFileName(file.name || referenceId));
+ }
+ return file.fileName;
+}
+
+function getChunkFileName(file: ConsumedChunk): string {
+ const fileName = file.fileName || (file.module && (file.module.facadeChunk as Chunk).id);
+ if (!fileName) return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
+ return fileName;
+}
+
+export class FileEmitter {
+ private filesByReferenceId = new Map();
+ // tslint:disable member-ordering
+ private buildFilesByReferenceId = this.filesByReferenceId;
+ private graph: Graph;
+ private output: OutputSpecificFileData | null = null;
+
+ constructor(graph: Graph) {
+ this.graph = graph;
+ }
+
+ public emitFile = (emittedFile: unknown): string => {
+ if (!hasValidType(emittedFile)) {
+ return error(
+ errFailedValidation(
+ `Emitted files must be of type "asset" or "chunk", received "${emittedFile &&
+ (emittedFile as any).type}".`
+ )
+ );
+ }
+ if (!hasValidName(emittedFile)) {
+ return error(
+ errFailedValidation(
+ `The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "${emittedFile.fileName ||
+ emittedFile.name}".`
+ )
+ );
+ }
+ if (emittedFile.type === 'chunk') {
+ return this.emitChunk(emittedFile);
+ } else {
+ return this.emitAsset(emittedFile);
+ }
+ };
+
+ public getFileName = (fileReferenceId: string) => {
+ const emittedFile = this.filesByReferenceId.get(fileReferenceId);
+ if (!emittedFile) return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
+ if (emittedFile.type === 'chunk') {
+ return getChunkFileName(emittedFile);
+ } else {
+ return getAssetFileName(emittedFile, fileReferenceId);
+ }
+ };
+
+ public setAssetSource = (referenceId: string, requestedSource: unknown) => {
+ const consumedFile = this.filesByReferenceId.get(referenceId);
+ if (!consumedFile) return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
+ if (consumedFile.type !== 'asset') {
+ return error(
+ errFailedValidation(
+ `Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`
+ )
+ );
+ }
+ if (consumedFile.source !== undefined) {
+ return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
+ }
+ const source = getValidSource(requestedSource, consumedFile, referenceId);
+ if (this.output) {
+ this.finalizeAsset(consumedFile, source, referenceId, this.output);
+ } else {
+ consumedFile.source = source;
+ }
+ };
+
+ public startOutput(outputBundle: OutputBundleWithPlaceholders, assetFileNames: string) {
+ this.filesByReferenceId = new Map(this.buildFilesByReferenceId);
+ this.output = {
+ assetFileNames,
+ bundle: outputBundle
+ };
+ for (const emittedFile of this.filesByReferenceId.values()) {
+ if (emittedFile.fileName) {
+ reserveFileNameInBundle(emittedFile.fileName, this.output.bundle);
+ }
+ }
+ for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) {
+ if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
+ this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.output);
+ }
+ }
+ }
+
+ public assertAssetsFinalized() {
+ for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
+ if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
+ error(errNoAssetSourceSet(emittedFile.name || referenceId));
+ }
+ }
+
+ private emitAsset(emittedAsset: EmittedFile): string {
+ const source =
+ typeof emittedAsset.source !== 'undefined'
+ ? getValidSource(emittedAsset.source, emittedAsset, null)
+ : undefined;
+ const consumedAsset: ConsumedAsset = {
+ fileName: emittedAsset.fileName,
+ name: emittedAsset.name,
+ source,
+ type: 'asset'
+ };
+ const referenceId = this.assignReferenceId(
+ consumedAsset,
+ emittedAsset.fileName || emittedAsset.name || emittedAsset.type
+ );
+ if (this.output) {
+ if (emittedAsset.fileName) {
+ reserveFileNameInBundle(emittedAsset.fileName, this.output.bundle);
+ }
+ if (source !== undefined) {
+ this.finalizeAsset(consumedAsset, source, referenceId, this.output);
+ }
+ }
+ return referenceId;
+ }
+
+ private emitChunk(emittedChunk: EmittedFile): string {
+ if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
+ error(errInvalidRollupPhaseForChunkEmission());
+ }
+ if (typeof emittedChunk.id !== 'string') {
+ return error(
+ errFailedValidation(
+ `Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`
+ )
+ );
+ }
+ const consumedChunk: ConsumedChunk = {
+ fileName: emittedChunk.fileName,
+ module: null,
+ name: emittedChunk.name || emittedChunk.id,
+ type: 'chunk'
+ };
+ this.graph.moduleLoader
+ .addEntryModules(
+ [
+ {
+ fileName: emittedChunk.fileName || null,
+ id: emittedChunk.id,
+ name: emittedChunk.name || null
+ }
+ ],
+ false
+ )
+ .then(({ newEntryModules: [module] }) => {
+ consumedChunk.module = module;
+ })
+ .catch(() => {
+ // Avoid unhandled Promise rejection as the error will be thrown later
+ // once module loading has finished
+ });
+
+ return this.assignReferenceId(consumedChunk, emittedChunk.id);
+ }
+
+ private assignReferenceId(file: ConsumedFile, idBase: string): string {
+ let referenceId: string | undefined;
+ do {
+ const hash = sha256();
+ if (referenceId) {
+ hash.update(referenceId);
+ } else {
+ hash.update(idBase);
+ }
+ referenceId = hash.digest('hex').substr(0, 8);
+ } while (this.filesByReferenceId.has(referenceId));
+ this.filesByReferenceId.set(referenceId, file);
+ return referenceId;
+ }
+
+ private finalizeAsset(
+ consumedFile: ConsumedFile,
+ source: string | Buffer,
+ referenceId: string,
+ output: OutputSpecificFileData
+ ) {
+ const fileName =
+ consumedFile.fileName ||
+ this.findExistingAssetFileNameWithSource(output.bundle, source) ||
+ generateAssetFileName(consumedFile.name, source, output);
+
+ // We must not modify the original assets to avoid interaction between outputs
+ const assetWithFileName = { ...consumedFile, source, fileName };
+ this.filesByReferenceId.set(referenceId, assetWithFileName);
+ output.bundle[fileName] = { fileName, isAsset: true, source };
+ }
+
+ private findExistingAssetFileNameWithSource(
+ bundle: OutputBundleWithPlaceholders,
+ source: string | Buffer
+ ): string | null {
+ for (const fileName of Object.keys(bundle)) {
+ const outputFile = bundle[fileName] as OutputAsset;
+ if (
+ outputFile.isAsset &&
+ (Buffer.isBuffer(source) && Buffer.isBuffer(outputFile.source)
+ ? source.equals(outputFile.source)
+ : source === outputFile.source)
+ )
+ return fileName;
+ }
+ return null;
+ }
+}
diff --git a/src/utils/assetHooks.ts b/src/utils/assetHooks.ts
deleted file mode 100644
index 7caadf1f7aa..00000000000
--- a/src/utils/assetHooks.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import sha256 from 'hash.js/lib/hash/sha/256';
-import { Asset, EmitAsset, OutputBundle } from '../rollup/types';
-import {
- errAssetNotFinalisedForFileName,
- errAssetReferenceIdNotFoundForFilename,
- errAssetReferenceIdNotFoundForSetSource,
- errAssetSourceAlreadySet,
- errAssetSourceMissingForSetSource,
- errInvalidAssetName,
- errNoAssetSourceSet,
- error
-} from './error';
-import { extname } from './path';
-import { addWithNewReferenceId } from './referenceIds';
-import { isPlainName } from './relativeId';
-import { makeUnique, renderNamePattern } from './renderNamePattern';
-
-export function getAssetFileName(
- asset: Asset,
- existingNames: Record,
- assetFileNames: string
-) {
- if (asset.source === undefined) error(errNoAssetSourceSet(asset));
- if (asset.fileName) return asset.fileName;
-
- return makeUnique(
- renderNamePattern(assetFileNames, 'assetFileNames', name => {
- switch (name) {
- case 'hash':
- const hash = sha256();
- hash.update(name);
- hash.update(':');
- hash.update(asset.source);
- return hash.digest('hex').substr(0, 8);
- case 'name':
- return asset.name.substr(0, asset.name.length - extname(asset.name).length);
- case 'extname':
- return extname(asset.name);
- case 'ext':
- return extname(asset.name).substr(1);
- }
- return undefined as any;
- }),
- existingNames
- );
-}
-
-export function createAssetPluginHooks(
- assetsByReferenceId: Map,
- outputBundle?: OutputBundle,
- assetFileNames?: string
-) {
- return {
- emitAsset(name: string, source?: string | Buffer) {
- if (typeof name !== 'string' || !isPlainName(name)) error(errInvalidAssetName(name));
- const asset: Asset = { name, source: source as string | Buffer, fileName: undefined as any };
- if (outputBundle && source !== undefined)
- finaliseAsset(asset, outputBundle, assetFileNames as string);
- return addWithNewReferenceId(asset, assetsByReferenceId, name);
- },
-
- setAssetSource(assetReferenceId: string, source?: string | Buffer) {
- const asset = assetsByReferenceId.get(assetReferenceId);
- if (!asset) return error(errAssetReferenceIdNotFoundForSetSource(assetReferenceId));
- if (asset.source !== undefined) return error(errAssetSourceAlreadySet(asset));
- if (typeof source !== 'string' && !source)
- return error(errAssetSourceMissingForSetSource(asset));
- asset.source = source;
- if (outputBundle) finaliseAsset(asset, outputBundle, assetFileNames as string);
- },
-
- getAssetFileName(assetReferenceId: string) {
- const asset = assetsByReferenceId.get(assetReferenceId);
- if (!asset) return error(errAssetReferenceIdNotFoundForFilename(assetReferenceId));
- if ((asset).fileName === undefined)
- return error(errAssetNotFinalisedForFileName(asset));
- return (asset).fileName;
- }
- };
-}
-
-export function finaliseAsset(asset: Asset, outputBundle: OutputBundle, assetFileNames: string) {
- const fileName = getAssetFileName(asset, outputBundle, assetFileNames);
- asset.fileName = fileName;
- outputBundle[fileName] = {
- fileName,
- isAsset: true,
- source: asset.source
- };
-}
-
-export function createTransformEmitAsset(
- assetsByReferenceId: Map,
- emitAsset: EmitAsset
-) {
- const assets: Asset[] = [];
- return {
- assets,
- emitAsset: (name: string, source?: string | Buffer) => {
- const assetReferenceId = emitAsset(name, source);
- const asset = assetsByReferenceId.get(assetReferenceId) as Asset;
- assets.push({
- fileName: undefined as any,
- name: asset.name,
- source: asset.source
- });
- return assetReferenceId;
- }
- };
-}
diff --git a/src/utils/assignChunkIds.ts b/src/utils/assignChunkIds.ts
index fab6fcea035..452de880205 100644
--- a/src/utils/assignChunkIds.ts
+++ b/src/utils/assignChunkIds.ts
@@ -1,6 +1,7 @@
import Chunk from '../Chunk';
-import { InputOptions, OutputOptions } from '../rollup/types';
+import { InputOptions, OutputBundleWithPlaceholders, OutputOptions } from '../rollup/types';
import { Addons } from './addons';
+import { FILE_PLACEHOLDER } from './FileEmitter';
import { basename } from './path';
export function assignChunkIds(
@@ -8,40 +9,37 @@ export function assignChunkIds(
inputOptions: InputOptions,
outputOptions: OutputOptions,
inputBase: string,
- addons: Addons
+ addons: Addons,
+ bundle: OutputBundleWithPlaceholders
) {
- const usedIds: Record = {};
- const [entryChunks, otherChunks] = chunks.reduce<[Chunk[], Chunk[]]>(
- ([entryChunks, otherChunks], chunk) => {
- (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint
- ? entryChunks
- : otherChunks
- ).push(chunk);
- return [entryChunks, otherChunks];
- },
- [[], []]
- );
+ const entryChunks: Chunk[] = [];
+ const otherChunks: Chunk[] = [];
+ for (const chunk of chunks) {
+ (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint
+ ? entryChunks
+ : otherChunks
+ ).push(chunk);
+ }
// make sure entry chunk names take precedence with regard to deconflicting
const chunksForNaming: Chunk[] = entryChunks.concat(otherChunks);
- for (let i = 0; i < chunksForNaming.length; i++) {
- const chunk = chunksForNaming[i];
-
+ for (const chunk of chunksForNaming) {
+ const facadeModule = chunk.facadeModule;
if (outputOptions.file) {
chunk.id = basename(outputOptions.file);
} else if (inputOptions.preserveModules) {
- chunk.generateIdPreserveModules(inputBase, usedIds);
+ chunk.id = chunk.generateIdPreserveModules(inputBase, bundle);
} else {
let pattern, patternName;
- if (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint) {
+ if (facadeModule && facadeModule.isUserDefinedEntryPoint) {
pattern = outputOptions.entryFileNames || '[name].js';
patternName = 'output.entryFileNames';
} else {
pattern = outputOptions.chunkFileNames || '[name]-[hash].js';
patternName = 'output.chunkFileNames';
}
- chunk.generateId(pattern, patternName, addons, outputOptions, usedIds);
+ chunk.id = chunk.generateId(pattern, patternName, addons, outputOptions, bundle);
}
- usedIds[chunk.id] = true;
+ bundle[chunk.id] = FILE_PLACEHOLDER;
}
}
diff --git a/src/utils/defaultPlugin.ts b/src/utils/defaultPlugin.ts
index 4b27c4c1546..7c93d36c9de 100644
--- a/src/utils/defaultPlugin.ts
+++ b/src/utils/defaultPlugin.ts
@@ -112,7 +112,10 @@ const getRelativeUrlFromDocument = (relativePath: string) =>
);
const relativeUrlMechanisms: Record string> = {
- amd: relativePath => getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`),
+ amd: relativePath => {
+ if (relativePath[0] !== '.') relativePath = './' + relativePath;
+ return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
+ },
cjs: relativePath =>
`(typeof document === 'undefined' ? ${getResolveUrl(
`'file:' + __dirname + '/${relativePath}'`,
diff --git a/src/utils/error.ts b/src/utils/error.ts
index 120324499c8..7010eb883c2 100644
--- a/src/utils/error.ts
+++ b/src/utils/error.ts
@@ -1,11 +1,11 @@
import { locate } from 'locate-character';
import Module from '../Module';
-import { Asset, RollupError, RollupWarning } from '../rollup/types';
+import { RollupError, RollupWarning } from '../rollup/types';
import getCodeFrame from './getCodeFrame';
import relativeId from './relativeId';
export function error(base: Error | RollupError, props?: RollupError): never {
- if (base instanceof Error === false) base = Object.assign(new Error(base.message), base);
+ if (!(base instanceof Error)) base = Object.assign(new Error(base.message), base);
if (props) Object.assign(base, props);
throw base;
}
@@ -37,38 +37,41 @@ export enum Errors {
ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET',
ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING',
BAD_LOADER = 'BAD_LOADER',
- CHUNK_NOT_FOUND = 'CHUNK_NOT_FOUND',
+ CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK',
CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED',
DEPRECATED_FEATURE = 'DEPRECATED_FEATURE',
- INVALID_ASSET_NAME = 'INVALID_ASSET_NAME',
+ FILE_NOT_FOUND = 'FILE_NOT_FOUND',
+ FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT',
INVALID_CHUNK = 'INVALID_CHUNK',
INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID',
INVALID_OPTION = 'INVALID_OPTION',
INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK',
INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE',
NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT',
+ PLUGIN_ERROR = 'PLUGIN_ERROR',
UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY',
- UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT'
+ UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT',
+ VALIDATION_ERROR = 'VALIDATION_ERROR'
}
-export function errAssetNotFinalisedForFileName(asset: Asset) {
+export function errAssetNotFinalisedForFileName(name: string) {
return {
code: Errors.ASSET_NOT_FINALISED,
- message: `Plugin error - Unable to get file name for asset "${asset.name}". Ensure that the source is set and that generate is called first.`
+ message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.`
};
}
-export function errChunkNotGeneratedForFileName(entry: { name: string }) {
+export function errCannotEmitFromOptionsHook() {
return {
- code: Errors.CHUNK_NOT_GENERATED,
- message: `Plugin error - Unable to get file name for chunk "${entry.name}". Ensure that generate is called first.`
+ code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
+ message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
};
}
-export function errAssetReferenceIdNotFoundForFilename(assetReferenceId: string) {
+export function errChunkNotGeneratedForFileName(name: string) {
return {
- code: Errors.ASSET_NOT_FOUND,
- message: `Plugin error - Unable to get file name for unknown asset "${assetReferenceId}".`
+ code: Errors.CHUNK_NOT_GENERATED,
+ message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.`
};
}
@@ -79,24 +82,17 @@ export function errAssetReferenceIdNotFoundForSetSource(assetReferenceId: string
};
}
-export function errAssetSourceAlreadySet(asset: Asset) {
+export function errAssetSourceAlreadySet(name: string) {
return {
code: Errors.ASSET_SOURCE_ALREADY_SET,
- message: `Plugin error - Unable to set the source for asset "${asset.name}", source already set.`
+ message: `Unable to set the source for asset "${name}", source already set.`
};
}
-export function errAssetSourceMissingForSetSource(asset: Asset) {
+export function errNoAssetSourceSet(assetName: string) {
return {
code: Errors.ASSET_SOURCE_MISSING,
- message: `Plugin error creating asset "${asset.name}", setAssetSource call without a source.`
- };
-}
-
-export function errNoAssetSourceSet(asset: Asset) {
- return {
- code: Errors.ASSET_SOURCE_MISSING,
- message: `Plugin error creating asset "${asset.name}" - no asset source set.`
+ message: `Plugin error creating asset "${assetName}" - no asset source set.`
};
}
@@ -109,24 +105,24 @@ export function errBadLoader(id: string) {
};
}
-export function errChunkReferenceIdNotFoundForFilename(chunkReferenceId: string) {
+export function errDeprecation(deprecation: string | RollupWarning) {
return {
- code: Errors.CHUNK_NOT_FOUND,
- message: `Plugin error - Unable to get file name for unknown chunk "${chunkReferenceId}".`
+ code: Errors.DEPRECATED_FEATURE,
+ ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
};
}
-export function errDeprecation(deprecation: string | RollupWarning) {
+export function errFileReferenceIdNotFoundForFilename(assetReferenceId: string) {
return {
- code: Errors.DEPRECATED_FEATURE,
- ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
+ code: Errors.FILE_NOT_FOUND,
+ message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
};
}
-export function errInvalidAssetName(name: string) {
+export function errFileNameConflict(fileName: string) {
return {
- code: Errors.INVALID_ASSET_NAME,
- message: `Plugin error creating asset, name "${name}" is not a plain (non relative or absolute URL) string name.`
+ code: Errors.FILE_NAME_CONFLICT,
+ message: `Could not emit file "${fileName}" as it conflicts with an already emitted file.`
};
}
@@ -166,10 +162,10 @@ export function errInvalidRollupPhaseForAddWatchFile() {
};
}
-export function errInvalidRollupPhaseForEmitChunk() {
+export function errInvalidRollupPhaseForChunkEmission() {
return {
code: Errors.INVALID_ROLLUP_PHASE,
- message: `Cannot call emitChunk after module loading has finished.`
+ message: `Cannot emit chunks after module loading has finished.`
};
}
@@ -223,3 +219,10 @@ export function errUnresolvedImportTreatedAsExternal(source: string, importer: s
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
};
}
+
+export function errFailedValidation(message: string) {
+ return {
+ code: Errors.VALIDATION_ERROR,
+ message
+ };
+}
diff --git a/src/utils/pluginDriver.ts b/src/utils/pluginDriver.ts
index 436ff0e35a3..cf6411c53cc 100644
--- a/src/utils/pluginDriver.ts
+++ b/src/utils/pluginDriver.ts
@@ -4,34 +4,30 @@ import ExternalModule from '../ExternalModule';
import Graph from '../Graph';
import Module from '../Module';
import {
- EmitAsset,
- EmitChunk,
+ EmitFile,
InputOptions,
+ OutputBundleWithPlaceholders,
Plugin,
PluginCache,
PluginContext,
PluginHooks,
+ RollupError,
RollupWarning,
RollupWatcher,
SerializablePluginCache
} from '../rollup/types';
-import { createAssetPluginHooks } from './assetHooks';
import { BuildPhase } from './buildPhase';
import { getRollupDefaultPlugin } from './defaultPlugin';
-import {
- errInvalidRollupPhaseForAddWatchFile,
- errInvalidRollupPhaseForEmitChunk,
- error
-} from './error';
+import { errInvalidRollupPhaseForAddWatchFile, error, Errors } from './error';
+import { FileEmitter } from './FileEmitter';
type Args = T extends (...args: infer K) => any ? K : never;
type EnsurePromise = Promise ? K : T>;
export interface PluginDriver {
- emitAsset: EmitAsset;
- emitChunk: EmitChunk;
- hasLoadersOrTransforms: boolean;
- getAssetFileName(assetReferenceId: string): string;
+ emitFile: EmitFile;
+ finaliseAssets(): void;
+ getFileName(assetReferenceId: string): string;
hookFirst>(
hook: H,
args: Args,
@@ -77,10 +73,11 @@ export interface PluginDriver {
args: Args,
context?: HookContext
): void;
+ startOutput(outputBundle: OutputBundleWithPlaceholders, assetFileNames: string): void;
}
export type Reduce = (reduction: T, result: R, plugin: Plugin) => T;
-export type HookContext = (context: PluginContext, plugin?: Plugin) => PluginContext;
+export type HookContext = (context: PluginContext, plugin: Plugin) => PluginContext;
export const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
@@ -108,6 +105,26 @@ function warnDeprecatedHooks(plugins: Plugin[], graph: Graph) {
}
}
+export function throwPluginError(
+ err: string | RollupError,
+ plugin: string,
+ { hook, id }: { hook?: string; id?: string } = {}
+): never {
+ if (typeof err === 'string') err = { message: err };
+ if (err.code && err.code !== Errors.PLUGIN_ERROR) {
+ err.pluginCode = err.code;
+ }
+ err.code = Errors.PLUGIN_ERROR;
+ err.plugin = plugin;
+ if (hook) {
+ err.hook = hook;
+ }
+ if (id) {
+ err.id = id;
+ }
+ return error(err);
+}
+
export function createPluginDriver(
graph: Graph,
options: InputOptions,
@@ -115,13 +132,36 @@ export function createPluginDriver(
watcher?: RollupWatcher
): PluginDriver {
warnDeprecatedHooks(options.plugins as Plugin[], graph);
+
+ function getDeprecatedHookHandler(
+ handler: H,
+ handlerName: string,
+ newHandlerName: string,
+ pluginName: string,
+ acitveDeprecation: boolean
+ ): H {
+ let deprecationWarningShown = false;
+ return (((...args: any[]) => {
+ if (!deprecationWarningShown) {
+ deprecationWarningShown = true;
+ graph.warnDeprecation(
+ {
+ message: `The "this.${handlerName}" plugin context function used by plugin ${pluginName} is deprecated. The "this.${newHandlerName}" plugin context function should be used instead.`,
+ plugin: pluginName
+ },
+ acitveDeprecation
+ );
+ }
+ return handler(...args);
+ }) as unknown) as H;
+ }
+
const plugins = [
...(options.plugins as Plugin[]),
getRollupDefaultPlugin(options.preserveSymlinks as boolean)
];
- const { emitAsset, getAssetFileName, setAssetSource } = createAssetPluginHooks(graph.assetsById);
+ const fileEmitter = new FileEmitter(graph);
const existingPluginKeys = new Set();
- let hasLoadersOrTransforms = false;
const pluginContexts: PluginContext[] = plugins.map((plugin, pidx) => {
let cacheable = true;
@@ -133,12 +173,6 @@ export function createPluginDriver(
}
}
- if (
- !hasLoadersOrTransforms &&
- (plugin.load || plugin.transform || plugin.transformBundle || plugin.transformChunk)
- )
- hasLoadersOrTransforms = true;
-
let cacheInstance: PluginCache;
if (!pluginCache) {
cacheInstance = noCache;
@@ -157,23 +191,41 @@ export function createPluginDriver(
graph.watchFiles[id] = true;
},
cache: cacheInstance,
- emitAsset,
- emitChunk(id, options) {
- if (graph.phase > BuildPhase.LOAD_AND_PARSE)
- this.error(errInvalidRollupPhaseForEmitChunk());
- return pluginDriver.emitChunk(id, options);
- },
+ emitAsset: getDeprecatedHookHandler(
+ (name: string, source?: string | Buffer) =>
+ fileEmitter.emitFile({ type: 'asset', name, source }),
+ 'emitAsset',
+ 'emitFile',
+ plugin.name,
+ false
+ ),
+ emitChunk: getDeprecatedHookHandler(
+ (id: string, options?: { name?: string }) =>
+ fileEmitter.emitFile({ type: 'chunk', id, name: options && options.name }),
+ 'emitChunk',
+ 'emitFile',
+ plugin.name,
+ false
+ ),
+ emitFile: fileEmitter.emitFile,
error(err): never {
- if (typeof err === 'string') err = { message: err };
- if (err.code) err.pluginCode = err.code;
- err.code = 'PLUGIN_ERROR';
- err.plugin = plugin.name;
- return error(err);
- },
- getAssetFileName: getAssetFileName as (assetId: string) => string,
- getChunkFileName(chunkReferenceId) {
- return graph.moduleLoader.getChunkFileName(chunkReferenceId);
+ return throwPluginError(err, plugin.name);
},
+ getAssetFileName: getDeprecatedHookHandler(
+ fileEmitter.getFileName,
+ 'getAssetFileName',
+ 'getFileName',
+ plugin.name,
+ false
+ ),
+ getChunkFileName: getDeprecatedHookHandler(
+ fileEmitter.getFileName,
+ 'getChunkFileName',
+ 'getFileName',
+ plugin.name,
+ false
+ ),
+ getFileName: fileEmitter.getFileName,
getModuleInfo(moduleId) {
const foundModule = graph.moduleById.get(moduleId);
if (foundModule == null) {
@@ -191,22 +243,14 @@ export function createPluginDriver(
isExternal: foundModule instanceof ExternalModule
};
},
- isExternal: (() => {
- let deprecationWarningShown = false;
- return (id: string, parentId: string, isResolved = false) => {
- if (!deprecationWarningShown) {
- deprecationWarningShown = true;
- graph.warnDeprecation(
- {
- message: `The "this.isExternal" plugin context function used by plugin ${plugin.name} is deprecated. The "this.resolve" plugin context function should be used instead.`,
- plugin: plugin.name
- },
- false
- );
- }
- return graph.moduleLoader.isExternal(id, parentId, isResolved);
- };
- })(),
+ isExternal: getDeprecatedHookHandler(
+ (id: string, parentId: string, isResolved = false) =>
+ graph.moduleLoader.isExternal(id, parentId, isResolved),
+ 'isExternal',
+ 'resolve',
+ plugin.name,
+ false
+ ),
meta: {
rollupVersion
},
@@ -221,25 +265,17 @@ export function createPluginDriver(
options && options.skipSelf ? pidx : null
);
},
- resolveId: (() => {
- let deprecationWarningShown = false;
- return (source: string, importer: string) => {
- if (!deprecationWarningShown) {
- deprecationWarningShown = true;
- graph.warnDeprecation(
- {
- message: `The "this.resolveId" plugin context function used by plugin ${plugin.name} is deprecated. The "this.resolve" plugin context function should be used instead.`,
- plugin: plugin.name
- },
- false
- );
- }
- return graph.moduleLoader
+ resolveId: getDeprecatedHookHandler(
+ (source: string, importer: string) =>
+ graph.moduleLoader
.resolveId(source, importer)
- .then(resolveId => resolveId && resolveId.id);
- };
- })(),
- setAssetSource,
+ .then(resolveId => resolveId && resolveId.id),
+ 'resolveId',
+ 'resolve',
+ plugin.name,
+ false
+ ),
+ setAssetSource: fileEmitter.setAssetSource,
warn(warning) {
if (typeof warning === 'string') warning = { message: warning } as RollupWarning;
if (warning.code) warning.pluginCode = warning.code;
@@ -301,16 +337,8 @@ export function createPluginDriver(
}
return hook.apply(context, args);
} catch (err) {
- if (typeof err === 'string') err = { message: err };
- if (err.code !== 'PLUGIN_ERROR') {
- if (err.code) err.pluginCode = err.code;
- err.code = 'PLUGIN_ERROR';
- }
- err.plugin = plugin.name;
- err.hook = hookName;
- error(err);
+ return throwPluginError(err, plugin.name, { hook: hookName });
}
- return undefined as any;
}
function runHook(
@@ -342,28 +370,15 @@ export function createPluginDriver(
}
return hook.apply(context, args);
})
- .catch(err => {
- if (typeof err === 'string') err = { message: err };
- if (err.code !== 'PLUGIN_ERROR') {
- if (err.code) err.pluginCode = err.code;
- err.code = 'PLUGIN_ERROR';
- }
- err.plugin = plugin.name;
- err.hook = hookName;
- error(err);
- });
+ .catch(err => throwPluginError(err, plugin.name, { hook: hookName }));
}
const pluginDriver: PluginDriver = {
- emitAsset,
- emitChunk(id, options) {
- return graph.moduleLoader.addEntryModuleAndGetReferenceId({
- alias: (options && options.name) || null,
- unresolvedId: id
- });
+ emitFile: fileEmitter.emitFile,
+ finaliseAssets() {
+ fileEmitter.assertAssetsFinalized();
},
- getAssetFileName: getAssetFileName as (assetId: string) => string,
- hasLoadersOrTransforms,
+ getFileName: fileEmitter.getFileName,
// chains, ignores returns
hookSeq(name, args, hookContext) {
@@ -449,6 +464,10 @@ export function createPluginDriver(
});
}
return promise;
+ },
+
+ startOutput(outputBundle: OutputBundleWithPlaceholders, assetFileNames: string): void {
+ fileEmitter.startOutput(outputBundle, assetFileNames);
}
};
diff --git a/src/utils/referenceIds.ts b/src/utils/referenceIds.ts
deleted file mode 100644
index f4e4665f525..00000000000
--- a/src/utils/referenceIds.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import sha256 from 'hash.js/lib/hash/sha/256';
-
-export function addWithNewReferenceId(item: T, idMap: Map, hashBase: string): string {
- let referenceId: string | undefined;
- do {
- const hash = sha256();
- if (referenceId) {
- hash.update(referenceId);
- } else {
- hash.update(hashBase);
- }
- referenceId = hash.digest('hex').substr(0, 8);
- } while (idMap.has(referenceId));
- idMap.set(referenceId, item);
- return referenceId;
-}
diff --git a/src/utils/relativeId.ts b/src/utils/relativeId.ts
index 56c0160d860..d21dd62bbd3 100644
--- a/src/utils/relativeId.ts
+++ b/src/utils/relativeId.ts
@@ -1,4 +1,5 @@
import { basename, extname, isAbsolute, relative } from './path';
+import { sanitizeFileName } from './sanitizeFileName';
export function getAliasName(id: string) {
const base = basename(id);
@@ -10,10 +11,11 @@ export default function relativeId(id: string) {
return relative(process.cwd(), id);
}
-export function isPlainName(name: string) {
- // not starting with "./", "/". "../"
- return !(
- name[0] === '/' ||
- (name[1] === '.' && (name[2] === '/' || (name[2] === '.' && name[3] === '/')))
+export function isPlainPathFragment(name: string) {
+ // not starting with "/", "./", "../"
+ return (
+ name[0] !== '/' &&
+ !(name[0] === '.' && (name[1] === '/' || name[1] === '.')) &&
+ sanitizeFileName(name) === name
);
}
diff --git a/src/utils/renderNamePattern.ts b/src/utils/renderNamePattern.ts
index 12e14666b83..6734f202fc8 100644
--- a/src/utils/renderNamePattern.ts
+++ b/src/utils/renderNamePattern.ts
@@ -1,29 +1,31 @@
-import { error } from './error';
+import { errFailedValidation, error } from './error';
import { extname } from './path';
-import { isPlainName } from './relativeId';
+import { isPlainPathFragment } from './relativeId';
export function renderNamePattern(
pattern: string,
patternName: string,
- getReplacement: (name: string) => string
+ replacements: { [name: string]: () => string }
) {
- if (!isPlainName(pattern))
- error({
- code: 'INVALID_PATTERN',
- message: `Invalid output pattern "${pattern}" for ${patternName}, cannot be an absolute or relative URL or path.`
- });
+ if (!isPlainPathFragment(pattern))
+ return error(
+ errFailedValidation(
+ `Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths and must not contain invalid characters.`
+ )
+ );
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
- const replacement = getReplacement(type);
- if (replacement === undefined)
- error({
- code: 'INVALID_PATTERN_REPLACEMENT',
- message: `"${type}" is not a valid substitution name in output option ${patternName} pattern.`
- });
- if (!isPlainName(replacement))
- error({
- code: 'INVALID_PATTERN_REPLACEMENT',
- message: `Invalid replacement "${replacement}" for "${type}" in ${patternName} pattern, must be a plain path name.`
- });
+ if (!replacements.hasOwnProperty(type)) {
+ return error(
+ errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`)
+ );
+ }
+ const replacement = replacements[type]();
+ if (!isPlainPathFragment(replacement))
+ return error(
+ errFailedValidation(
+ `Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`
+ )
+ );
return replacement;
});
}
diff --git a/src/utils/transform.ts b/src/utils/transform.ts
index 03185b922a7..2e6d6f382bb 100644
--- a/src/utils/transform.ts
+++ b/src/utils/transform.ts
@@ -2,10 +2,8 @@ import MagicString, { SourceMap } from 'magic-string';
import Graph from '../Graph';
import Module from '../Module';
import {
- Asset,
DecodedSourceMapOrMissing,
- EmitAsset,
- EmittedChunk,
+ EmittedFile,
Plugin,
PluginCache,
PluginContext,
@@ -15,12 +13,11 @@ import {
TransformResult,
TransformSourceDescription
} from '../rollup/types';
-import { createTransformEmitAsset } from './assetHooks';
import { collapseSourcemap } from './collapseSourcemaps';
import { decodedSourcemap } from './decodedSourcemap';
-import { augmentCodeLocation, error } from './error';
+import { augmentCodeLocation } from './error';
import { dirname, resolve } from './path';
-import { trackPluginCache } from './pluginDriver';
+import { throwPluginError, trackPluginCache } from './pluginDriver';
export default function transform(
graph: Graph,
@@ -31,12 +28,10 @@ export default function transform(
const sourcemapChain: DecodedSourceMapOrMissing[] = [];
let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
- const baseEmitAsset = graph.pluginDriver.emitAsset;
const originalCode = source.code;
let ast = source.ast;
- let transformDependencies: string[];
- let emittedAssets: Asset[];
- const emittedChunks: EmittedChunk[] = [];
+ const transformDependencies: string[] = [];
+ const emittedFiles: EmittedFile[] = [];
let customTransformCache = false;
let moduleSideEffects: boolean | null = null;
let trackedPluginCache: { cache: PluginCache; used: boolean };
@@ -54,15 +49,12 @@ export default function transform(
if (customTransformCache) {
if (result && typeof result === 'object' && Array.isArray(result.dependencies)) {
for (const dep of result.dependencies) {
- const depId = resolve(dirname(id), dep);
- if (!graph.watchFiles[depId]) graph.watchFiles[depId] = true;
+ graph.watchFiles[resolve(dirname(id), dep)] = true;
}
}
} else {
- // assets/chunks emitted by a transform hook need to be emitted again if the hook is skipped
- if (emittedAssets.length) module.transformAssets = emittedAssets;
- if (emittedChunks.length) module.transformChunks = emittedChunks;
-
+ // files emitted by a transform hook need to be emitted again if the hook is skipped
+ if (emittedFiles.length) module.transformFiles = emittedFiles;
if (result && typeof result === 'object' && Array.isArray(result.dependencies)) {
// not great, but a useful way to track this without assuming WeakMap
if (!(curPlugin as any).warnedTransformDependencies)
@@ -71,7 +63,6 @@ export default function transform(
true
);
(curPlugin as any).warnedTransformDependencies = true;
- if (!transformDependencies) transformDependencies = [];
for (const dep of result.dependencies)
transformDependencies.push(resolve(dirname(id), dep));
}
@@ -113,15 +104,9 @@ export default function transform(
[curSource, id],
transformReducer,
(pluginContext, plugin) => {
- curPlugin = plugin as Plugin;
+ curPlugin = plugin;
if (curPlugin.cacheKey) customTransformCache = true;
else trackedPluginCache = trackPluginCache(pluginContext.cache);
-
- let emitAsset: EmitAsset;
- ({ assets: emittedAssets, emitAsset } = createTransformEmitAsset(
- graph.assetsById,
- baseEmitAsset
- ));
return {
...pluginContext,
cache: trackedPluginCache ? trackedPluginCache.cache : pluginContext.cache,
@@ -139,13 +124,21 @@ export default function transform(
err.hook = 'transform';
return pluginContext.error(err);
},
- emitAsset,
+ emitAsset(name: string, source?: string | Buffer) {
+ const emittedFile = { type: 'asset' as 'asset', name, source };
+ emittedFiles.push({ ...emittedFile });
+ return graph.pluginDriver.emitFile(emittedFile);
+ },
emitChunk(id, options) {
- emittedChunks.push({ id, options });
- return graph.pluginDriver.emitChunk(id, options);
+ const emittedFile = { type: 'chunk' as 'chunk', id, name: options && options.name };
+ emittedFiles.push({ ...emittedFile });
+ return graph.pluginDriver.emitFile(emittedFile);
+ },
+ emitFile(emittedFile: EmittedFile) {
+ emittedFiles.push(emittedFile);
+ return graph.pluginDriver.emitFile(emittedFile);
},
addWatchFile(id: string) {
- if (!transformDependencies) transformDependencies = [];
transformDependencies.push(id);
pluginContext.addWatchFile(id);
},
@@ -155,7 +148,7 @@ export default function transform(
try {
this.error({
code: 'INVALID_SETASSETSOURCE',
- message: `setAssetSource cannot be called in transform for caching reasons. Use emitAsset with a source, or call setAssetSource in another hook.`
+ message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
});
} catch (err) {
setAssetSourceErr = err;
@@ -187,15 +180,7 @@ export default function transform(
};
}
)
- .catch(err => {
- if (typeof err === 'string') err = { message: err };
- if (err.code !== 'PLUGIN_ERROR') {
- if (err.code) err.pluginCode = err.code;
- err.code = 'PLUGIN_ERROR';
- }
- err.id = id;
- error(err);
- })
+ .catch(err => throwPluginError(err, curPlugin.name, { hook: 'transform', id }))
.then(code => {
if (!customTransformCache && setAssetSourceErr) throw setAssetSourceErr;
diff --git a/test/chunking-form/samples/asset-emission/_expected/amd/main.js b/test/chunking-form/samples/asset-emission/_expected/amd/main.js
deleted file mode 100644
index ad49a69bf83..00000000000
--- a/test/chunking-form/samples/asset-emission/_expected/amd/main.js
+++ /dev/null
@@ -1,8 +0,0 @@
-define(['require', './nested/chunk'], function (require, __chunk_1) { 'use strict';
-
- var logo = new URL(require.toUrl('assets/logo1-25253976.svg'), document.baseURI).href;
-
- __chunk_1.showImage(logo);
- new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) });
-
-});
diff --git a/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk2.js
deleted file mode 100644
index ad229a9409e..00000000000
--- a/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk2.js
+++ /dev/null
@@ -1,7 +0,0 @@
-define(['require', './chunk'], function (require, __chunk_1) { 'use strict';
-
- var logo = new URL(require.toUrl('../assets/logo2-25253976.svg'), document.baseURI).href;
-
- __chunk_1.showImage(logo);
-
-});
diff --git a/test/chunking-form/samples/asset-emission/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/asset-emission/_expected/cjs/nested/chunk2.js
deleted file mode 100644
index 10f8b21bde6..00000000000
--- a/test/chunking-form/samples/asset-emission/_expected/cjs/nested/chunk2.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-var __chunk_1 = require('./chunk.js');
-
-var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/../assets/logo2-25253976.svg').href : new URL('../assets/logo2-25253976.svg', document.currentScript && document.currentScript.src || document.baseURI).href);
-
-__chunk_1.showImage(logo);
diff --git a/test/chunking-form/samples/asset-emission/_expected/system/assets/logo2-25253976.svg b/test/chunking-form/samples/asset-emission/_expected/system/assets/logo2-25253976.svg
deleted file mode 100644
index 20bb5dfe639..00000000000
--- a/test/chunking-form/samples/asset-emission/_expected/system/assets/logo2-25253976.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js b/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js
index ac14c9b6c66..108e509e2f3 100644
--- a/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js
+++ b/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep2) { 'use strict';
function fn () {
console.log('dep1 fn');
@@ -7,7 +7,7 @@ define(['./generated-chunk'], function (__chunk_1) { 'use strict';
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js b/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js
index 111b5a4ace0..362f7851a1c 100644
--- a/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js
+++ b/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep2) { 'use strict';
function fn () {
console.log('lib1 fn');
@@ -12,7 +12,7 @@ define(['./generated-chunk'], function (__chunk_1) { 'use strict';
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/basic-chunking/_expected/cjs/main1.js b/test/chunking-form/samples/basic-chunking/_expected/cjs/main1.js
index 3f1d6358cca..d5090945ce7 100644
--- a/test/chunking-form/samples/basic-chunking/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/basic-chunking/_expected/cjs/main1.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
function fn () {
console.log('dep1 fn');
@@ -9,7 +9,7 @@ function fn () {
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/basic-chunking/_expected/cjs/main2.js b/test/chunking-form/samples/basic-chunking/_expected/cjs/main2.js
index ca04f12a578..360eacc9f9b 100644
--- a/test/chunking-form/samples/basic-chunking/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/basic-chunking/_expected/cjs/main2.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
function fn () {
console.log('lib1 fn');
@@ -14,7 +14,7 @@ function fn$1 () {
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-chunk2.js
index 81990cfcc0b..ee7aed4131e 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-chunk2.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-chunk2.js
@@ -1,8 +1,8 @@
-define(['exports', './generated-chunk', './generated-chunk3'], function (exports, __chunk_1, __chunk_3) { 'use strict';
+define(['exports', './generated-chunk', './generated-chunk3'], function (exports, dep1, dep2) { 'use strict';
- var x = __chunk_1.x + 1;
+ var x = dep1.x + 1;
- var y = __chunk_3.x + 1;
+ var y = dep2.x + 1;
exports.x = x;
exports.y = y;
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js
index ebe790c766a..0e65131f4fd 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict';
+define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (dep1, shared2, dep2) { 'use strict';
- console.log(__chunk_2.x + __chunk_2.y);
+ console.log(shared2.x + shared2.y);
});
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js
index 6924458be25..4a881f3542f 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict';
+define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (dep1, shared2, dep2) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js
index 80869868e48..bd74061e2d8 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep1) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js
index 57661f926d5..1fc33edde0c 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk3'], function (__chunk_3) { 'use strict';
+define(['./generated-chunk3'], function (dep2) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-chunk2.js
index bfffacb8799..1869f3a0186 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-chunk2.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-chunk2.js
@@ -1,11 +1,11 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
-var __chunk_3 = require('./generated-chunk3.js');
+var dep1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk3.js');
-var x = __chunk_1.x + 1;
+var x = dep1.x + 1;
-var y = __chunk_3.x + 1;
+var y = dep2.x + 1;
exports.x = x;
exports.y = y;
diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js
index 814ecdd4098..395b4cbab96 100644
--- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js
@@ -1,7 +1,7 @@
'use strict';
require('./generated-chunk.js');
-var __chunk_2 = require('./generated-chunk2.js');
+var shared2 = require('./generated-chunk2.js');
require('./generated-chunk3.js');
-console.log(__chunk_2.x + __chunk_2.y);
+console.log(shared2.x + shared2.y);
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-chunk3.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-chunk3.js
index 63b1b2fef74..872a82acb49 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-chunk3.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-chunk3.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { 'use strict';
+define(['./generated-chunk', './generated-chunk2'], function (dep111, dep112) { 'use strict';
console.log('11');
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js
index 84e0fbc0088..6748631337f 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js
@@ -1,7 +1,7 @@
-define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict';
+define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (dep111, dep112, dep11) { 'use strict';
console.log('1');
- console.log(__chunk_2.x);
+ console.log(dep112.x);
});
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js
index 6924458be25..b8d58e21dee 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict';
+define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (dep111, dep112, dep11) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js
index 80869868e48..f4841ed82fe 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep111) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js
index 01a1c62db72..bc6715800f4 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk2'], function (__chunk_2) { 'use strict';
+define(['./generated-chunk2'], function (dep112) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js
index 2c7c4ca8683..b2a67e5bc37 100644
--- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js
@@ -1,9 +1,9 @@
'use strict';
require('./generated-chunk.js');
-var __chunk_2 = require('./generated-chunk2.js');
+var dep112 = require('./generated-chunk2.js');
require('./generated-chunk3.js');
console.log('1');
-console.log(__chunk_2.x);
+console.log(dep112.x);
diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js
index 166cf5b87f0..fff81b46661 100644
--- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js
@@ -1,8 +1,8 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep1) { 'use strict';
class Main1 {
constructor () {
- __chunk_1.fn();
+ dep1.fn();
}
}
diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js
index 2755a1f1093..7665de6f99c 100644
--- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js
@@ -1,8 +1,8 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep1) { 'use strict';
class Main2 {
constructor () {
- __chunk_1.fn$1();
+ dep1.fn$1();
}
}
diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main1.js
index db58d12e0f5..57540c44ee0 100644
--- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main1.js
@@ -1,10 +1,10 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep1 = require('./generated-chunk.js');
class Main1 {
constructor () {
- __chunk_1.fn();
+ dep1.fn();
}
}
diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main2.js
index 1e03271063e..f03cd93dc87 100644
--- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/cjs/main2.js
@@ -1,10 +1,10 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep1 = require('./generated-chunk.js');
class Main2 {
constructor () {
- __chunk_1.fn$1();
+ dep1.fn$1();
}
}
diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js
index b2e05fcc77c..4bc5739ac53 100644
--- a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js
@@ -1,8 +1,8 @@
-define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict';
+define(['exports', './generated-chunk'], function (exports, one) { 'use strict';
- exports.ItemOne = __chunk_1.One;
+ exports.ItemOne = one.One;
Object.defineProperty(exports, '__esModule', { value: true });
diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js
index 5817de20203..28aa6948e70 100644
--- a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js
@@ -1,8 +1,8 @@
-define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict';
+define(['exports', './generated-chunk'], function (exports, one) { 'use strict';
class Two {
test() {
- return __chunk_1.ONE_CONSTANT;
+ return one.ONE_CONSTANT;
}
}
diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js
index 6d99df53376..6a6c1b487cc 100644
--- a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js
@@ -2,8 +2,8 @@
Object.defineProperty(exports, '__esModule', { value: true });
-var __chunk_1 = require('./generated-chunk.js');
+var one = require('./generated-chunk.js');
-exports.ItemOne = __chunk_1.One;
+exports.ItemOne = one.One;
diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js
index 5af2561690a..e0adf1b39da 100644
--- a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js
@@ -2,11 +2,11 @@
Object.defineProperty(exports, '__esModule', { value: true });
-var __chunk_1 = require('./generated-chunk.js');
+var one = require('./generated-chunk.js');
class Two {
test() {
- return __chunk_1.ONE_CONSTANT;
+ return one.ONE_CONSTANT;
}
}
diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js
index aa788e1c4dc..fcc3e22f67b 100644
--- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js
@@ -1,7 +1,7 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (lib) { 'use strict';
function fn () {
- var emptyFunction = __chunk_1.emptyFunction;
+ var emptyFunction = lib.emptyFunction;
console.log(emptyFunction);
}
diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js
index 80869868e48..09d13545f2a 100644
--- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (lib) { 'use strict';
diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/cjs/main1.js
index e30ecabb6d1..245b14fc81c 100644
--- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/cjs/main1.js
@@ -1,9 +1,9 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var lib = require('./generated-chunk.js');
function fn () {
- var emptyFunction = __chunk_1.emptyFunction;
+ var emptyFunction = lib.emptyFunction;
console.log(emptyFunction);
}
diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js
index d618cb1c2d6..9de2c058385 100644
--- a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js
@@ -1,9 +1,9 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep1) { 'use strict';
class Main1 {
constructor () {
- __chunk_1.fn();
- console.log(__chunk_1.text);
+ dep1.fn();
+ console.log(dep1.text);
}
}
diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js
index c49699c2b2c..cd376312505 100644
--- a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js
@@ -1,9 +1,9 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep1) { 'use strict';
class Main2 {
constructor () {
- __chunk_1.fn$1();
- console.log(__chunk_1.text$1);
+ dep1.fn$1();
+ console.log(dep1.text$1);
}
}
diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main1.js
index 316cd5a722a..60027ffe8ee 100644
--- a/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main1.js
@@ -1,11 +1,11 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep1 = require('./generated-chunk.js');
class Main1 {
constructor () {
- __chunk_1.fn();
- console.log(__chunk_1.text);
+ dep1.fn();
+ console.log(dep1.text);
}
}
diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main2.js
index d6a9f21b5e8..d3a7b6358b0 100644
--- a/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunk-live-bindings/_expected/cjs/main2.js
@@ -1,11 +1,11 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep1 = require('./generated-chunk.js');
class Main2 {
constructor () {
- __chunk_1.fn$1();
- console.log(__chunk_1.text$1);
+ dep1.fn$1();
+ console.log(dep1.text$1);
}
}
diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js
index 2167f01dcf8..91c28dd2e42 100644
--- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js
@@ -1,9 +1,9 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (shared) { 'use strict';
- __chunk_1.commonjsGlobal.fn = d => d + 1;
- var cjs = __chunk_1.commonjsGlobal.fn;
+ shared.commonjsGlobal.fn = d => d + 1;
+ var cjs = shared.commonjsGlobal.fn;
- var main1 = __chunk_1.d.map(cjs);
+ var main1 = shared.d.map(cjs);
return main1;
diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js
index aaabc773106..b80ae0d3892 100644
--- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js
@@ -1,6 +1,6 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (shared) { 'use strict';
- var main2 = __chunk_1.d.map(d => d + 2);
+ var main2 = shared.d.map(d => d + 2);
return main2;
diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main1.js
index 180e8c27663..b75d97e0ced 100644
--- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main1.js
@@ -1,10 +1,10 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var shared = require('./generated-chunk.js');
-__chunk_1.commonjsGlobal.fn = d => d + 1;
-var cjs = __chunk_1.commonjsGlobal.fn;
+shared.commonjsGlobal.fn = d => d + 1;
+var cjs = shared.commonjsGlobal.fn;
-var main1 = __chunk_1.d.map(cjs);
+var main1 = shared.d.map(cjs);
module.exports = main1;
diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main2.js
index 65c7edb2329..ce051f9dca8 100644
--- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/cjs/main2.js
@@ -1,7 +1,7 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var shared = require('./generated-chunk.js');
-var main2 = __chunk_1.d.map(d => d + 2);
+var main2 = shared.d.map(d => d + 2);
module.exports = main2;
diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js b/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js
index 0996f9cb03b..dc61fbfae26 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js
@@ -1,5 +1,5 @@
-define(['../chunks/chunk', '../chunks/chunk3'], function (__chunk_1, __chunk_3) { 'use strict';
+define(['../chunks/chunk', '../chunks/chunk3'], function (dep1, dep3) { 'use strict';
- console.log(__chunk_1.num + __chunk_3.num);
+ console.log(dep1.num + dep3.num);
});
diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js b/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js
index 587db5114ca..263d4b3c0ed 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js
@@ -1,5 +1,5 @@
-define(['./chunks/chunk', './chunks/chunk2'], function (__chunk_1, __chunk_2) { 'use strict';
+define(['./chunks/chunk', './chunks/chunk2'], function (dep1, dep2) { 'use strict';
- console.log(__chunk_1.num + __chunk_2.num);
+ console.log(dep1.num + dep2.num);
});
diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js b/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js
index 66a2dc57923..2b47f5f6800 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js
@@ -1,5 +1,5 @@
-define(['./chunks/chunk2', './chunks/chunk3'], function (__chunk_2, __chunk_3) { 'use strict';
+define(['./chunks/chunk2', './chunks/chunk3'], function (dep2, dep3) { 'use strict';
- console.log(__chunk_2.num + __chunk_3.num);
+ console.log(dep2.num + dep3.num);
});
diff --git a/test/chunking-form/samples/chunk-naming/_expected/cjs/custom/entryC.js b/test/chunking-form/samples/chunk-naming/_expected/cjs/custom/entryC.js
index 369303485d2..ef92b645475 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/cjs/custom/entryC.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/cjs/custom/entryC.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('../chunks/chunk.js');
-var __chunk_3 = require('../chunks/chunk3.js');
+var dep1 = require('../chunks/chunk.js');
+var dep3 = require('../chunks/chunk3.js');
-console.log(__chunk_1.num + __chunk_3.num);
+console.log(dep1.num + dep3.num);
diff --git a/test/chunking-form/samples/chunk-naming/_expected/cjs/entryA.js b/test/chunking-form/samples/chunk-naming/_expected/cjs/entryA.js
index 2c43ef416cc..0cf31f7652b 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/cjs/entryA.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/cjs/entryA.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./chunks/chunk.js');
-var __chunk_2 = require('./chunks/chunk2.js');
+var dep1 = require('./chunks/chunk.js');
+var dep2 = require('./chunks/chunk2.js');
-console.log(__chunk_1.num + __chunk_2.num);
+console.log(dep1.num + dep2.num);
diff --git a/test/chunking-form/samples/chunk-naming/_expected/cjs/entryB.js b/test/chunking-form/samples/chunk-naming/_expected/cjs/entryB.js
index 3e63d354d8a..f8f15a60782 100644
--- a/test/chunking-form/samples/chunk-naming/_expected/cjs/entryB.js
+++ b/test/chunking-form/samples/chunk-naming/_expected/cjs/entryB.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_2 = require('./chunks/chunk2.js');
-var __chunk_3 = require('./chunks/chunk3.js');
+var dep2 = require('./chunks/chunk2.js');
+var dep3 = require('./chunks/chunk3.js');
-console.log(__chunk_2.num + __chunk_3.num);
+console.log(dep2.num + dep3.num);
diff --git a/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js b/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js
index 12d3a520ed4..1d2a2737c70 100644
--- a/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js
@@ -1,8 +1,8 @@
-define(['./generated-chunk'],function(__chunk_1){'use strict';function fn () {
+define(['./generated-chunk'],function(dep2){'use strict';function fn () {
console.log('dep1 fn');
}class Main1 {
constructor () {
fn();
- __chunk_1.f();
+ dep2.f();
}
}return Main1;});
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js b/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js
index fa6b2a09851..85ff93f21c8 100644
--- a/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk','external'],function(__chunk_1,external){'use strict';function fn () {
+define(['./generated-chunk','external'],function(dep2,external){'use strict';function fn () {
console.log('lib1 fn');
external.fn();
}function fn$1 () {
@@ -7,6 +7,6 @@ define(['./generated-chunk','external'],function(__chunk_1,external){'use strict
}class Main2 {
constructor () {
fn$1();
- __chunk_1.f();
+ dep2.f();
}
}return Main2;});
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-compact/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-compact/_expected/cjs/main1.js
index 631d097e6f6..6dc9d76ea1f 100644
--- a/test/chunking-form/samples/chunking-compact/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunking-compact/_expected/cjs/main1.js
@@ -1,8 +1,8 @@
-'use strict';var __chunk_1=require('./generated-chunk.js');function fn () {
+'use strict';var dep2=require('./generated-chunk.js');function fn () {
console.log('dep1 fn');
}class Main1 {
constructor () {
fn();
- __chunk_1.f();
+ dep2.f();
}
}module.exports=Main1;
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-compact/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-compact/_expected/cjs/main2.js
index 916428d57a9..854dd48c92e 100644
--- a/test/chunking-form/samples/chunking-compact/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunking-compact/_expected/cjs/main2.js
@@ -1,4 +1,4 @@
-'use strict';var __chunk_1=require('./generated-chunk.js'),external=require('external');function fn () {
+'use strict';var dep2=require('./generated-chunk.js'),external=require('external');function fn () {
console.log('lib1 fn');
external.fn();
}function fn$1 () {
@@ -7,6 +7,6 @@
}class Main2 {
constructor () {
fn$1();
- __chunk_1.f();
+ dep2.f();
}
}module.exports=Main2;
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js b/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js
index ac14c9b6c66..108e509e2f3 100644
--- a/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep2) { 'use strict';
function fn () {
console.log('dep1 fn');
@@ -7,7 +7,7 @@ define(['./generated-chunk'], function (__chunk_1) { 'use strict';
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js b/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js
index c6f58144aa8..7cfbb3515ea 100644
--- a/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk', 'external'], function (__chunk_1, external) { 'use strict';
+define(['./generated-chunk', 'external'], function (dep2, external) { 'use strict';
function fn () {
console.log('lib1 fn');
@@ -13,7 +13,7 @@ define(['./generated-chunk', 'external'], function (__chunk_1, external) { 'use
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-externals/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-externals/_expected/cjs/main1.js
index 3f1d6358cca..d5090945ce7 100644
--- a/test/chunking-form/samples/chunking-externals/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunking-externals/_expected/cjs/main1.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
function fn () {
console.log('dep1 fn');
@@ -9,7 +9,7 @@ function fn () {
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-externals/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-externals/_expected/cjs/main2.js
index 20c359298e1..357ed56270f 100644
--- a/test/chunking-form/samples/chunking-externals/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunking-externals/_expected/cjs/main2.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
var external = require('external');
function fn () {
@@ -16,7 +16,7 @@ function fn$1 () {
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js
index 46adba2f54f..08b071d4e0a 100644
--- a/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js
@@ -1,4 +1,4 @@
-define(['exports', 'external', './generated-chunk'], function (exports, external, __chunk_1) { 'use strict';
+define(['exports', 'external', './generated-chunk'], function (exports, external, dep) { 'use strict';
diff --git a/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js
index 46adba2f54f..08b071d4e0a 100644
--- a/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['exports', 'external', './generated-chunk'], function (exports, external, __chunk_1) { 'use strict';
+define(['exports', 'external', './generated-chunk'], function (exports, external, dep) { 'use strict';
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js
index e69175e6288..0afd0b1be07 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep2) { 'use strict';
function fn () {
console.log('dep1 fn');
@@ -7,7 +7,7 @@ define(['./generated-chunk'], function (__chunk_1) { 'use strict';
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map
index bb897b029b1..325a06a233e 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map
@@ -1 +1 @@
-{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;GAAC,DCCc,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAI,EAAE,EAAE,CAAC;EACT,IAAIA,YAAG,EAAE,CAAC;EACV,GAAG;EACH;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;GAAC,DCCc,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAI,EAAE,EAAE,CAAC;EACT,IAAIA,OAAG,EAAE,CAAC;EACV,GAAG;EACH;;;;;;;;"}
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js
index 2a762c5f878..ede2faa9fa4 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep2) { 'use strict';
function fn () {
console.log('lib1 fn');
@@ -12,7 +12,7 @@ define(['./generated-chunk'], function (__chunk_1) { 'use strict';
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map
index 607acbbeec9..ae9ec33bbb1 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map
@@ -1 +1 @@
-{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB,CAAC;;ECAM,SAASA,IAAE,IAAI;EACtB,EAAEC,EAAK,EAAE,CAAC;EACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB,CAAC;;ECEc,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAIC,IAAG,EAAE,CAAC;EACV,IAAIF,YAAE,EAAE,CAAC;EACT,GAAG;EACH;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB,CAAC;;ECAM,SAASA,IAAE,IAAI;EACtB,EAAEC,EAAK,EAAE,CAAC;EACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB,CAAC;;ECEc,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAIC,IAAG,EAAE,CAAC;EACV,IAAIF,OAAE,EAAE,CAAC;EACT,GAAG;EACH;;;;;;;;"}
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js
index b75b412a5b6..4f1ae2dd061 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
function fn () {
console.log('dep1 fn');
@@ -9,7 +9,7 @@ function fn () {
class Main1 {
constructor () {
fn();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map
index 47f38d8ff91..146662c5a98 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map
@@ -1 +1 @@
-{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;EACpB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;;;CACxB,DCCc,MAAM,KAAK,CAAC;EACzB,WAAW,CAAC,GAAG;IACb,EAAE,EAAE,CAAC;IACLA,YAAG,EAAE,CAAC;GACP;;;;;"}
\ No newline at end of file
+{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;EACpB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;;;CACxB,DCCc,MAAM,KAAK,CAAC;EACzB,WAAW,CAAC,GAAG;IACb,EAAE,EAAE,CAAC;IACLA,OAAG,EAAE,CAAC;GACP;;;;;"}
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js
index b91e05aabc3..575b4056b99 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js
@@ -1,6 +1,6 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep2 = require('./generated-chunk.js');
function fn () {
console.log('lib1 fn');
@@ -14,7 +14,7 @@ function fn$1 () {
class Main2 {
constructor () {
fn$1();
- __chunk_1.fn();
+ dep2.fn();
}
}
diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map
index e79021e3cd7..1709cfe53aa 100644
--- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map
+++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map
@@ -1 +1 @@
-{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;EACpB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CACxB;;ACAM,SAASA,IAAE,IAAI;EACpBC,EAAK,EAAE,CAAC;EACR,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CACxB;;ACEc,MAAM,KAAK,CAAC;EACzB,WAAW,CAAC,GAAG;IACbC,IAAG,EAAE,CAAC;IACNF,YAAE,EAAE,CAAC;GACN;;;;;"}
\ No newline at end of file
+{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;EACpB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CACxB;;ACAM,SAASA,IAAE,IAAI;EACpBC,EAAK,EAAE,CAAC;EACR,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CACxB;;ACEc,MAAM,KAAK,CAAC;EACzB,WAAW,CAAC,GAAG;IACbC,IAAG,EAAE,CAAC;IACNF,OAAE,EAAE,CAAC;GACN;;;;;"}
\ No newline at end of file
diff --git a/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js
index af1d847e2f9..18a8affa0de 100644
--- a/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js
+++ b/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js
@@ -1,4 +1,4 @@
-define(['exports', 'starexternal1', 'external1', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal1, external1, starexternal2, external2, __chunk_1) { 'use strict';
+define(['exports', 'starexternal1', 'external1', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal1, external1, starexternal2, external2, dep) { 'use strict';
var main = '1';
@@ -16,7 +16,7 @@ define(['exports', 'starexternal1', 'external1', 'starexternal2', 'external2', '
return external1.e;
}
});
- exports.dep = __chunk_1.dep;
+ exports.dep = dep.dep;
exports.main = main;
Object.defineProperty(exports, '__esModule', { value: true });
diff --git a/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js
index 680171b02dc..3f3fc18f276 100644
--- a/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js
+++ b/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js
@@ -1,4 +1,4 @@
-define(['exports', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal2, external2, __chunk_1) { 'use strict';
+define(['exports', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal2, external2, dep) { 'use strict';
var main = '2';
@@ -16,7 +16,7 @@ define(['exports', 'starexternal2', 'external2', './generated-chunk'], function
return external2.e;
}
});
- exports.dep = __chunk_1.dep;
+ exports.dep = dep.dep;
exports.main = main;
Object.defineProperty(exports, '__esModule', { value: true });
diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js
index 7082c9aa626..c4e5c7b17c1 100644
--- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js
@@ -6,7 +6,7 @@ var starexternal1 = require('starexternal1');
var external1 = require('external1');
require('starexternal2');
require('external2');
-var __chunk_1 = require('./generated-chunk.js');
+var dep = require('./generated-chunk.js');
var main = '1';
@@ -24,5 +24,5 @@ Object.defineProperty(exports, 'e', {
return external1.e;
}
});
-exports.dep = __chunk_1.dep;
+exports.dep = dep.dep;
exports.main = main;
diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js
index 51eaa277781..4f085285c75 100644
--- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
var starexternal2 = require('starexternal2');
var external2 = require('external2');
-var __chunk_1 = require('./generated-chunk.js');
+var dep = require('./generated-chunk.js');
var main = '2';
@@ -22,5 +22,5 @@ Object.defineProperty(exports, 'e', {
return external2.e;
}
});
-exports.dep = __chunk_1.dep;
+exports.dep = dep.dep;
exports.main = main;
diff --git a/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js b/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js
index 875ce56c7de..edaa6114189 100644
--- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js
+++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep) { 'use strict';
- console.log(__chunk_1.x);
+ console.log(dep.x);
});
diff --git a/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js b/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js
index 5d18b330e59..37f699e7206 100644
--- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js
+++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (dep) { 'use strict';
- console.log(x, __chunk_1.x);
+ console.log(x, dep.x);
});
diff --git a/test/chunking-form/samples/deconflict-globals/_expected/cjs/main1.js b/test/chunking-form/samples/deconflict-globals/_expected/cjs/main1.js
index ec89a94037f..537c99d18e8 100644
--- a/test/chunking-form/samples/deconflict-globals/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/deconflict-globals/_expected/cjs/main1.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep = require('./generated-chunk.js');
-console.log(__chunk_1.x);
+console.log(dep.x);
diff --git a/test/chunking-form/samples/deconflict-globals/_expected/cjs/main2.js b/test/chunking-form/samples/deconflict-globals/_expected/cjs/main2.js
index 3fac3def85e..5da40c6f426 100644
--- a/test/chunking-form/samples/deconflict-globals/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/deconflict-globals/_expected/cjs/main2.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var dep = require('./generated-chunk.js');
-console.log(x, __chunk_1.x);
+console.log(x, dep.x);
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js
index 4116f89dc57..feee89f7078 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (proxy2) { 'use strict';
- console.log(__chunk_1.bar, __chunk_1.bar);
+ console.log(proxy2.bar, proxy2.bar);
});
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js
index 4116f89dc57..feee89f7078 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (proxy2) { 'use strict';
- console.log(__chunk_1.bar, __chunk_1.bar);
+ console.log(proxy2.bar, proxy2.bar);
});
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main1.js
index b3cc08fc4d9..7b26323fcee 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main1.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var proxy2 = require('./generated-chunk.js');
-console.log(__chunk_1.bar, __chunk_1.bar);
+console.log(proxy2.bar, proxy2.bar);
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main2.js
index b3cc08fc4d9..7b26323fcee 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/cjs/main2.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var proxy2 = require('./generated-chunk.js');
-console.log(__chunk_1.bar, __chunk_1.bar);
+console.log(proxy2.bar, proxy2.bar);
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js
index 4116f89dc57..2d85f4f5f0d 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (proxy) { 'use strict';
- console.log(__chunk_1.bar, __chunk_1.bar);
+ console.log(proxy.bar, proxy.bar);
});
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js
index 4116f89dc57..2d85f4f5f0d 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (proxy) { 'use strict';
- console.log(__chunk_1.bar, __chunk_1.bar);
+ console.log(proxy.bar, proxy.bar);
});
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main1.js
index b3cc08fc4d9..55c9b13cb7e 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main1.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var proxy = require('./generated-chunk.js');
-console.log(__chunk_1.bar, __chunk_1.bar);
+console.log(proxy.bar, proxy.bar);
diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main2.js
index b3cc08fc4d9..55c9b13cb7e 100644
--- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/cjs/main2.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var proxy = require('./generated-chunk.js');
-console.log(__chunk_1.bar, __chunk_1.bar);
+console.log(proxy.bar, proxy.bar);
diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js
index 0ed08f8c0a5..be83c4e0d05 100644
--- a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js
+++ b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (module3) { 'use strict';
- console.log(__chunk_1.b, __chunk_1.b);
+ console.log(module3.b, module3.b);
});
diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js
index 0ed08f8c0a5..be83c4e0d05 100644
--- a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js
+++ b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js
@@ -1,5 +1,5 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (module3) { 'use strict';
- console.log(__chunk_1.b, __chunk_1.b);
+ console.log(module3.b, module3.b);
});
diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main1.js
index 52ebedf3a5d..4bead314162 100644
--- a/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main1.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var module3 = require('./generated-chunk.js');
-console.log(__chunk_1.b, __chunk_1.b);
+console.log(module3.b, module3.b);
diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main2.js b/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main2.js
index 52ebedf3a5d..4bead314162 100644
--- a/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/default-export-name-conflict/_expected/cjs/main2.js
@@ -1,5 +1,5 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var module3 = require('./generated-chunk.js');
-console.log(__chunk_1.b, __chunk_1.b);
+console.log(module3.b, module3.b);
diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js
index d67cb599463..9fe0088b29a 100644
--- a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js
+++ b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js
@@ -1,6 +1,6 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (shared) { 'use strict';
- var main1 = __chunk_1.d.map(d => d + 1);
+ var main1 = shared.d.map(d => d + 1);
return main1;
diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js
index aaabc773106..b80ae0d3892 100644
--- a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js
+++ b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js
@@ -1,6 +1,6 @@
-define(['./generated-chunk'], function (__chunk_1) { 'use strict';
+define(['./generated-chunk'], function (shared) { 'use strict';
- var main2 = __chunk_1.d.map(d => d + 2);
+ var main2 = shared.d.map(d => d + 2);
return main2;
diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main1.js b/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main1.js
index 1bf78d9019b..36e411ab23e 100644
--- a/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main1.js
+++ b/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main1.js
@@ -1,7 +1,7 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var shared = require('./generated-chunk.js');
-var main1 = __chunk_1.d.map(d => d + 1);
+var main1 = shared.d.map(d => d + 1);
module.exports = main1;
diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main2.js b/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main2.js
index 65c7edb2329..ce051f9dca8 100644
--- a/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main2.js
+++ b/test/chunking-form/samples/default-identifier-renaming/_expected/cjs/main2.js
@@ -1,7 +1,7 @@
'use strict';
-var __chunk_1 = require('./generated-chunk.js');
+var shared = require('./generated-chunk.js');
-var main2 = __chunk_1.d.map(d => d + 2);
+var main2 = shared.d.map(d => d + 2);
module.exports = main2;
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js
index b521ad4b012..44faf871ab5 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js
@@ -2,7 +2,7 @@ define(['require'], function (require) { 'use strict';
var asset2 = 'resolved';
- var asset3 = new URL(require.toUrl('assets/asset-unresolved-9548436d.txt'), document.baseURI).href;
+ var asset3 = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href;
new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }).then(result => console.log(result, asset2, asset3));
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js
index 2a8c640ebaf..c52ce8abedf 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js
@@ -1,6 +1,6 @@
define(['require', 'exports'], function (require, exports) { 'use strict';
- var solved = 'nested/chunk.js:solved:assets/asset-solved-9b321da2.txt:../assets/asset-solved-9b321da2.txt';
+ var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt';
exports.default = solved;
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js
index 8518bc0354c..3b5850e8d3c 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js
@@ -2,6 +2,6 @@
var asset2 = 'resolved';
-var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-9548436d.txt').href : new URL('assets/asset-unresolved-9548436d.txt', document.currentScript && document.currentScript.src || document.baseURI).href);
+var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href);
new Promise(function (resolve) { resolve(require('./nested/chunk.js')); }).then(result => console.log(result, asset2, asset3));
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js
index 42f557796ee..5ddc0c99e0d 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js
@@ -1,5 +1,5 @@
'use strict';
-var solved = 'nested/chunk.js:solved:assets/asset-solved-9b321da2.txt:../assets/asset-solved-9b321da2.txt';
+var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt';
exports.default = solved;
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js
index f061c14feed..c78af2b3768 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js
@@ -1,5 +1,5 @@
var asset2 = 'resolved';
-var asset3 = new URL('assets/asset-unresolved-9548436d.txt', import.meta.url).href;
+var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href;
import('./nested/chunk.js').then(result => console.log(result, asset2, asset3));
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js
index 70feca23425..1af7c01e941 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js
@@ -1,3 +1,3 @@
-var solved = 'nested/chunk.js:solved:assets/asset-solved-9b321da2.txt:../assets/asset-solved-9b321da2.txt';
+var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt';
export default solved;
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js
index ee045a93e6e..971fff86b4d 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js
@@ -5,7 +5,7 @@ System.register([], function (exports, module) {
var asset2 = 'resolved';
- var asset3 = new URL('assets/asset-unresolved-9548436d.txt', module.meta.url).href;
+ var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href;
module.import('./nested/chunk.js').then(result => console.log(result, asset2, asset3));
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js
index 59d15ec5e1b..3bdc2610687 100644
--- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js
+++ b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js
@@ -3,7 +3,7 @@ System.register([], function (exports, module) {
return {
execute: function () {
- var solved = exports('default', 'nested/chunk.js:solved:assets/asset-solved-9b321da2.txt:../assets/asset-solved-9b321da2.txt');
+ var solved = exports('default', 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt');
}
};
diff --git a/test/chunking-form/samples/configure-file-url/_config.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js
similarity index 97%
rename from test/chunking-form/samples/configure-file-url/_config.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js
index 9ee4fa22535..81c4557c73b 100644
--- a/test/chunking-form/samples/configure-file-url/_config.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js
@@ -1,6 +1,7 @@
module.exports = {
description: 'allows to configure file urls',
options: {
+ strictDeprecations: false,
output: {
chunkFileNames: 'nested/chunk.js'
},
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js
similarity index 59%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/main.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js
index 75ab2148e8f..d5222443f37 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/amd/main.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js
@@ -3,8 +3,8 @@ define(['require'], function (require) { 'use strict';
const asset = 'resolved';
const chunk = 'resolved';
- const asset$1 = new URL(require.toUrl('assets/asset-unresolved-9548436d.txt'), document.baseURI).href;
- const chunk$1 = new URL(require.toUrl('nested/chunk.js'), document.baseURI).href;
+ const asset$1 = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href;
+ const chunk$1 = new URL(require.toUrl('./nested/chunk.js'), document.baseURI).href;
new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) }).then(result => console.log(result, chunk, chunk$1, asset, asset$1));
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk.js
diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js
similarity index 74%
rename from test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js
index bdb11983b26..c40e57b7bf5 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js
@@ -1,6 +1,6 @@
define(['require', 'exports'], function (require, exports) { 'use strict';
- const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=amd:relativePath=../assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null';
+ const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=amd:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null';
const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=amd:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7';
exports.asset = asset;
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js
similarity index 91%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/main.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js
index f365d118a36..dc2ba8a1434 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/cjs/main.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js
@@ -3,7 +3,7 @@
const asset = 'resolved';
const chunk = 'resolved';
-const asset$1 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-9548436d.txt').href : new URL('assets/asset-unresolved-9548436d.txt', document.currentScript && document.currentScript.src || document.baseURI).href);
+const asset$1 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href);
const chunk$1 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/nested/chunk.js').href : new URL('nested/chunk.js', document.currentScript && document.currentScript.src || document.baseURI).href);
new Promise(function (resolve) { resolve(require('./nested/chunk2.js')); }).then(result => console.log(result, chunk, chunk$1, asset, asset$1));
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk.js
diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js
similarity index 70%
rename from test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js
index 1d4203c7455..2ea0d2caf6f 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js
@@ -1,6 +1,6 @@
'use strict';
-const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=cjs:relativePath=../assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null';
+const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=cjs:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null';
const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=cjs:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7';
exports.asset = asset;
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js
similarity index 79%
rename from test/chunking-form/samples/configure-file-url/_expected/es/main.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js
index 3234da07909..4053f550431 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/es/main.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js
@@ -1,7 +1,7 @@
const asset = 'resolved';
const chunk = 'resolved';
-const asset$1 = new URL('assets/asset-unresolved-9548436d.txt', import.meta.url).href;
+const asset$1 = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href;
const chunk$1 = new URL('nested/chunk.js', import.meta.url).href;
import('./nested/chunk2.js').then(result => console.log(result, chunk, chunk$1, asset, asset$1));
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk.js
diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js
similarity index 67%
rename from test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js
index 63b7c7ebdf0..736b09b62c1 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js
@@ -1,4 +1,4 @@
-const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=es:relativePath=../assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null';
+const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=es:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null';
const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=es:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7';
export { asset, chunk };
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-resolved-8bd22e6e.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-dfc93baf.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-resolved-8bd22e6e.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-solved-28a7ac89.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-9b321da2.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-solved-28a7ac89.txt
diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-unresolved-8dcd7fca.txt
similarity index 100%
rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-9548436d.txt
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-unresolved-8dcd7fca.txt
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js
similarity index 85%
rename from test/chunking-form/samples/configure-file-url/_expected/system/main.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js
index f45bae342b0..7b2eb79d1dd 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/system/main.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js
@@ -6,7 +6,7 @@ System.register([], function (exports, module) {
const asset = 'resolved';
const chunk = 'resolved';
- const asset$1 = new URL('assets/asset-unresolved-9548436d.txt', module.meta.url).href;
+ const asset$1 = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href;
const chunk$1 = new URL('nested/chunk.js', module.meta.url).href;
module.import('./nested/chunk2.js').then(result => console.log(result, chunk, chunk$1, asset, asset$1));
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk.js
diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js
similarity index 75%
rename from test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js
index bdec926656e..0ef79e2e19a 100644
--- a/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js
@@ -3,7 +3,7 @@ System.register([], function (exports, module) {
return {
execute: function () {
- const asset = exports('asset', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=system:relativePath=../assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null');
+ const asset = exports('asset', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=system:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null');
const chunk = exports('chunk', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=system:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7');
}
diff --git a/test/chunking-form/samples/configure-file-url/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/chunk.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/chunk.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/chunk.js
diff --git a/test/chunking-form/samples/configure-file-url/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/main.js
similarity index 100%
rename from test/chunking-form/samples/configure-file-url/main.js
rename to test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/main.js
diff --git a/test/chunking-form/samples/asset-emission/_config.js b/test/chunking-form/samples/deprecated/emit-asset/_config.js
similarity index 95%
rename from test/chunking-form/samples/asset-emission/_config.js
rename to test/chunking-form/samples/deprecated/emit-asset/_config.js
index 9784a297436..6a83f6f385e 100644
--- a/test/chunking-form/samples/asset-emission/_config.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_config.js
@@ -4,6 +4,7 @@ const path = require('path');
module.exports = {
description: 'supports emitting assets from plugin hooks',
options: {
+ strictDeprecations: false,
input: ['main.js'],
output: {
chunkFileNames: 'nested/chunk.js'
diff --git a/test/chunking-form/samples/asset-emission/_expected/cjs/assets/logo2-25253976.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo1-a5ec488b.svg
similarity index 99%
rename from test/chunking-form/samples/asset-emission/_expected/cjs/assets/logo2-25253976.svg
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo1-a5ec488b.svg
index 20bb5dfe639..cb7e52c5130 100644
--- a/test/chunking-form/samples/asset-emission/_expected/cjs/assets/logo2-25253976.svg
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo1-a5ec488b.svg
@@ -1,3 +1,3 @@
\ No newline at end of file
+
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo2-6d5979e4.svg
new file mode 100644
index 00000000000..b446284a4cd
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo2-6d5979e4.svg
@@ -0,0 +1,3 @@
+
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js
new file mode 100644
index 00000000000..337791a6921
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js
@@ -0,0 +1,8 @@
+define(['require', './nested/chunk'], function (require, showImage) { 'use strict';
+
+ var logo = new URL(require.toUrl('./assets/logo1-a5ec488b.svg'), document.baseURI).href;
+
+ showImage.showImage(logo);
+ new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) });
+
+});
diff --git a/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk.js
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk2.js
new file mode 100644
index 00000000000..92ac9ba4db0
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk2.js
@@ -0,0 +1,7 @@
+define(['require', './chunk'], function (require, showImage) { 'use strict';
+
+ var logo = new URL(require.toUrl('../assets/logo2-6d5979e4.svg'), document.baseURI).href;
+
+ showImage.showImage(logo);
+
+});
diff --git a/test/chunking-form/samples/asset-emission/_expected/es/assets/logo1-25253976.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo1-a5ec488b.svg
similarity index 99%
rename from test/chunking-form/samples/asset-emission/_expected/es/assets/logo1-25253976.svg
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo1-a5ec488b.svg
index 20bb5dfe639..cb7e52c5130 100644
--- a/test/chunking-form/samples/asset-emission/_expected/es/assets/logo1-25253976.svg
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo1-a5ec488b.svg
@@ -1,3 +1,3 @@
\ No newline at end of file
+
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo2-6d5979e4.svg
new file mode 100644
index 00000000000..b446284a4cd
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo2-6d5979e4.svg
@@ -0,0 +1,3 @@
+
diff --git a/test/chunking-form/samples/asset-emission/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js
similarity index 52%
rename from test/chunking-form/samples/asset-emission/_expected/cjs/main.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js
index 16adc59ce96..5078a894cce 100644
--- a/test/chunking-form/samples/asset-emission/_expected/cjs/main.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js
@@ -1,8 +1,8 @@
'use strict';
-var __chunk_1 = require('./nested/chunk.js');
+var showImage = require('./nested/chunk.js');
-var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo1-25253976.svg').href : new URL('assets/logo1-25253976.svg', document.currentScript && document.currentScript.src || document.baseURI).href);
+var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo1-a5ec488b.svg').href : new URL('assets/logo1-a5ec488b.svg', document.currentScript && document.currentScript.src || document.baseURI).href);
-__chunk_1.showImage(logo);
+showImage.showImage(logo);
new Promise(function (resolve) { resolve(require('./nested/chunk2.js')); });
diff --git a/test/chunking-form/samples/asset-emission/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/asset-emission/_expected/cjs/nested/chunk.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk.js
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk2.js
new file mode 100644
index 00000000000..510d2678d19
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk2.js
@@ -0,0 +1,7 @@
+'use strict';
+
+var showImage = require('./chunk.js');
+
+var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/../assets/logo2-6d5979e4.svg').href : new URL('../assets/logo2-6d5979e4.svg', document.currentScript && document.currentScript.src || document.baseURI).href);
+
+showImage.showImage(logo);
diff --git a/test/chunking-form/samples/asset-emission/_expected/es/assets/logo2-25253976.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo1-a5ec488b.svg
similarity index 99%
rename from test/chunking-form/samples/asset-emission/_expected/es/assets/logo2-25253976.svg
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo1-a5ec488b.svg
index 20bb5dfe639..cb7e52c5130 100644
--- a/test/chunking-form/samples/asset-emission/_expected/es/assets/logo2-25253976.svg
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo1-a5ec488b.svg
@@ -1,3 +1,3 @@
\ No newline at end of file
+
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo2-6d5979e4.svg
new file mode 100644
index 00000000000..b446284a4cd
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo2-6d5979e4.svg
@@ -0,0 +1,3 @@
+
diff --git a/test/chunking-form/samples/asset-emission/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js
similarity index 62%
rename from test/chunking-form/samples/asset-emission/_expected/es/main.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js
index 0b696340c5e..6145c907395 100644
--- a/test/chunking-form/samples/asset-emission/_expected/es/main.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js
@@ -1,6 +1,6 @@
import { s as showImage } from './nested/chunk.js';
-var logo = new URL('assets/logo1-25253976.svg', import.meta.url).href;
+var logo = new URL('assets/logo1-a5ec488b.svg', import.meta.url).href;
showImage(logo);
import('./nested/chunk2.js');
diff --git a/test/chunking-form/samples/asset-emission/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/asset-emission/_expected/es/nested/chunk.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk.js
diff --git a/test/chunking-form/samples/asset-emission/_expected/es/nested/chunk2.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk2.js
similarity index 53%
rename from test/chunking-form/samples/asset-emission/_expected/es/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk2.js
index e39c601ff41..509777851a0 100644
--- a/test/chunking-form/samples/asset-emission/_expected/es/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk2.js
@@ -1,5 +1,5 @@
import { s as showImage } from './chunk.js';
-var logo = new URL('../assets/logo2-25253976.svg', import.meta.url).href;
+var logo = new URL('../assets/logo2-6d5979e4.svg', import.meta.url).href;
showImage(logo);
diff --git a/test/chunking-form/samples/asset-emission/_expected/system/assets/logo1-25253976.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo1-a5ec488b.svg
similarity index 99%
rename from test/chunking-form/samples/asset-emission/_expected/system/assets/logo1-25253976.svg
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo1-a5ec488b.svg
index 20bb5dfe639..cb7e52c5130 100644
--- a/test/chunking-form/samples/asset-emission/_expected/system/assets/logo1-25253976.svg
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo1-a5ec488b.svg
@@ -1,3 +1,3 @@
\ No newline at end of file
+
diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo2-6d5979e4.svg
new file mode 100644
index 00000000000..b446284a4cd
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo2-6d5979e4.svg
@@ -0,0 +1,3 @@
+
diff --git a/test/chunking-form/samples/asset-emission/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js
similarity index 81%
rename from test/chunking-form/samples/asset-emission/_expected/system/main.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js
index cc36168b97d..3cef21c3600 100644
--- a/test/chunking-form/samples/asset-emission/_expected/system/main.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js
@@ -7,7 +7,7 @@ System.register(['./nested/chunk.js'], function (exports, module) {
}],
execute: function () {
- var logo = new URL('assets/logo1-25253976.svg', module.meta.url).href;
+ var logo = new URL('assets/logo1-a5ec488b.svg', module.meta.url).href;
showImage(logo);
module.import('./nested/chunk2.js');
diff --git a/test/chunking-form/samples/asset-emission/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk.js
similarity index 100%
rename from test/chunking-form/samples/asset-emission/_expected/system/nested/chunk.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk.js
diff --git a/test/chunking-form/samples/asset-emission/_expected/system/nested/chunk2.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk2.js
similarity index 78%
rename from test/chunking-form/samples/asset-emission/_expected/system/nested/chunk2.js
rename to test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk2.js
index b748c0bd130..6c53572799d 100644
--- a/test/chunking-form/samples/asset-emission/_expected/system/nested/chunk2.js
+++ b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk2.js
@@ -7,7 +7,7 @@ System.register(['./chunk.js'], function (exports, module) {
}],
execute: function () {
- var logo = new URL('../assets/logo2-25253976.svg', module.meta.url).href;
+ var logo = new URL('../assets/logo2-6d5979e4.svg', module.meta.url).href;
showImage(logo);
diff --git a/test/chunking-form/samples/deprecated/emit-asset/index-amd.html b/test/chunking-form/samples/deprecated/emit-asset/index-amd.html
new file mode 100644
index 00000000000..cd17b62967d
--- /dev/null
+++ b/test/chunking-form/samples/deprecated/emit-asset/index-amd.html
@@ -0,0 +1,10 @@
+
+
+
+
+ AMD
+
+
+
+
+
diff --git a/test/chunking-form/samples/asset-emission/index-es.html b/test/chunking-form/samples/deprecated/emit-asset/index-es.html
similarity index 100%
rename from test/chunking-form/samples/asset-emission/index-es.html
rename to test/chunking-form/samples/deprecated/emit-asset/index-es.html
diff --git a/test/chunking-form/samples/emit-chunk-worker/index-system.html b/test/chunking-form/samples/deprecated/emit-asset/index-system.html
similarity index 71%
rename from test/chunking-form/samples/emit-chunk-worker/index-system.html
rename to test/chunking-form/samples/deprecated/emit-asset/index-system.html
index 96c687c1eb7..d4b3890b337 100644
--- a/test/chunking-form/samples/emit-chunk-worker/index-system.html
+++ b/test/chunking-form/samples/deprecated/emit-asset/index-system.html
@@ -5,7 +5,7 @@
SystemJS
-
+