diff --git a/bin/src/run/loadConfigFile.ts b/bin/src/run/loadConfigFile.ts index 03c02d28565..3fbba121fe6 100644 --- a/bin/src/run/loadConfigFile.ts +++ b/bin/src/run/loadConfigFile.ts @@ -19,9 +19,8 @@ export default function loadConfigFile( return rollup .rollup({ - external: (id: string) => { - return (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json'; - }, + external: (id: string) => + (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json', input: configFile, onwarn: warnings.add, treeshake: false diff --git a/docs/05-plugins.md b/docs/05-plugins.md index c94dd895529..a0e89a842e6 100644 --- a/docs/05-plugins.md +++ b/docs/05-plugins.md @@ -181,37 +181,39 @@ Kind: `async, parallel` Called initially each time `bundle.generate()` or `bundle.write()` is called. To get notified when generation has completed, use the `generateBundle` and `renderError` hooks. -#### `resolveAssetUrl` -Type: `({assetFileName: string, relativeAssetPath: string, chunkId: string, moduleId: string, format: string}) => string | null`
+#### `resolveDynamicImport` +Type: `(specifier: string | ESTree.Node, importer: string) => string | false | null`
+Kind: `async, first` + +Defines a custom resolver for dynamic imports. In case a dynamic import is not passed a string as argument, this hook gets access to the raw AST nodes to analyze. Returning `null` will defer to other resolvers and eventually to `resolveId` if this is possible; returning `false` signals that the import should be kept as it is and not be passed to other resolvers thus making it external. 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.resolveId(importee, importer)` on the plugin context. + +#### `resolveFileUrl` +Type: `({assetReferenceId: string | null, chunkId: string, chunkReferenceId: string | null, fileName: string, format: string, moduleId: string, relativePath: string}) => string | null`
Kind: `sync, first` -Allows to customize how Rollup resolves URLs of assets emitted via `this.emitAsset` by plugins. By default, Rollup will generate code for `import.meta.ROLLUP_ASSET_URL_[assetId]` that should correctly generate absolute URLs of emitted assets independent of the output format and the host system where the code is deployed. +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. For that, all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available. In case that fails or to generate more optimized code, this hook can be used to customize this behaviour. To do that, the following information is available: -- `assetFileName`: The path and file name of the emitted asset, relative to `output.dir` without a leading `./`. -- `relativeAssetPath`: The path and file name of the emitted asset, relative to the chunk from which the asset is referenced via `import.meta.ROLLUP_ASSET_URL_[assetId]`. This will also contain no leading `./` but may contain a leading `../`. -- `moduleId`: The id of the original module this asset is referenced from. Useful for conditionally resolving certain assets differently. -- `chunkId`: The id of the chunk this asset is referenced from. +- `assetReferenceId`: The asset reference id if we are resolving `import.meta.ROLLUP_ASSET_URL_assetReferenceId`, otherwise `null`. +- `chunkId`: The id of the chunk this file is referenced from. +- `chunkReferenceId`: The chunk reference id if we are resolving `import.meta.ROLLUP_CHUNK_URL_chunkReferenceId`, otherwise `null`. +- `fileName`: The path and file name of the emitted asset, relative to `output.dir` without a leading `./`. - `format`: The rendered output format. +- `moduleId`: The id of the original module this file is referenced from. Useful for conditionally resolving certain assets differently. +- `relativePath`: The path and file name of the emitted file, relative to the chunk the file is referenced from. This will path will contain no leading `./` but may contain a leading `../`. Note that since this hook has access to the filename of the current chunk, its return value will not be considered when generating the hash of this chunk. -The following plugin will always resolve all assets relative to the current document: +The following plugin will always resolve all files relative to the current document: ```javascript // rollup.config.js -resolveAssetUrl({assetFileName}) { - return `new URL('${assetFileName}', document.baseURI).href`; +resolveFileUrl({fileName}) { + return `new URL('${fileName}', document.baseURI).href`; } ``` -#### `resolveDynamicImport` -Type: `(specifier: string | ESTree.Node, importer: string) => string | false | null`
-Kind: `async, first` - -Defines a custom resolver for dynamic imports. In case a dynamic import is not passed a string as argument, this hook gets access to the raw AST nodes to analyze. Returning `null` will defer to other resolvers and eventually to `resolveId` if this is possible; returning `false` signals that the import should be kept as it is and not be passed to other resolvers thus making it external. 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.resolveId(importee, importer)` on the plugin context. - #### `resolveId` Type: `(importee: string, importer: string) => string | false | null | {id: string, external?: boolean}`
Kind: `async, first` @@ -281,6 +283,8 @@ called when `bundle.generate()` is being executed. called when `bundle.write()` is being executed, after the file has been written to disk. +- `resolveAssetUrl` - _**Use [`resolveFileUrl`](guide/en#resolvefileurl)**_ - Function hook that allows to customize the generated code for asset URLs. + - `transformBundle` – _**Use [`renderChunk`](guide/en#renderchunk)**_ - A `( source, { format } ) => code` or `( source, { format } ) => { code, map }` bundle transformer function. @@ -303,15 +307,31 @@ In general, it is recommended to use `this.addWatchfile` from within the hook th #### `this.emitAsset(assetName: string, source: string) => string` -Emits a custom file to include in the build output, returning its `assetId`. You can defer setting the source if you provide it later via `this.setAssetSource(assetId, source)`. 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 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#this-setassetsource-assetreferenceid-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#output-assetfilenames) 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#this-getassetfilename-assetreferenceid-string-string) to determine the file name. + +#### `this.emitChunk(moduleId: string, options?: {name?: string}) => 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#output-chunkfilenames), [`output.entryFileNames`](guide/en#output-entryfilenames) 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.getChunkFileName(chunkReferenceId)`](guide/en#this-getchunkfilename-chunkreferenceid-string-string) to determine the file name. #### `this.error(error: string | Error, position?: number) => void` Structurally equivalent to `this.warn`, except that it will also abort the bundling process. -#### `this.getAssetFileName(assetId: string) => string` +#### `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`. -Get the file name of an asset, according to the `assetFileNames` output option pattern. +#### `this.getChunkFileName(chunkReferenceId: string) => string` + +Get the file name of an emitted chunk. The file name will be relative to `outputOptions.dir`. #### `this.getModuleInfo(moduleId: string) => ModuleInfo` @@ -349,11 +369,11 @@ or converted into an Array via `Array.from(this.moduleIds)`. Use Rollup's internal acorn instance to parse code to an AST. -#### `this.resolveId(importee: string, importer: string) => string` +#### `this.resolveId(importee: string, importer: string) => Promise` Resolve imports to module ids (i.e. file names). Uses the same hooks as Rollup itself. -#### `this.setAssetSource(assetId: string, source: string | Buffer) => void` +#### `this.setAssetSource(assetReferenceId: string, source: string | Buffer) => void` Set the deferred source of an asset. @@ -375,7 +395,7 @@ The `position` argument is a character index where the warning was raised. If pr ### Asset URLs -To reference an asset URL reference from within JS code, use the `import.meta.ROLLUP_ASSET_URL_[assetId]` 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 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. 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: @@ -390,11 +410,11 @@ export default function svgResolverPlugin () { }, load(id) { if (id.endsWith('.svg')) { - const assetId = this.emitAsset( + const assetReferenceId = this.emitAsset( path.basename(id), fs.readFileSync(id) ); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; + return `export default import.meta.ROLLUP_ASSET_URL_${assetReferenceId};`; } } }); @@ -407,6 +427,69 @@ 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. + +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`. + +```js +// plugin +const REGISTER_WORKLET = 'register-paint-worklet:'; +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) + )});`; + } + }, + resolveId(id, importee) { + // 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 (id.startsWith(REGISTER_WORKLET)) { + return this.resolveId(id.slice(REGISTER_WORKLET.length), importee).then( + id => REGISTER_WORKLET + id + ); + } + return null; + } + }); +} +``` + +Usage: + +```js +// main.js +import 'register-paint-worklet:./worklet.js'; +import { color, size } from './config.js'; +document.body.innerHTML += `

color: ${color}, size: ${size}

`; + +// worklet.js +import { color, size } from './config.js'; +registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / size; x++) { + ctx.beginPath(); + ctx.fillStyle = color; + ctx.rect(x * size, 0, 2, geom.height); + ctx.fill(); + } + } + } +); + +// config.js +export const color = 'greenyellow'; +export const size = 6; +``` + +If you build this code, both the main chunk and the worklet will share the code from `config.js` via a shared chunk. This enables us to make use of the browser cache to reduce transmitted data and speed up loading the worklet. + ### Advanced Loaders The `load` hook can optionally return a `{ code, ast }` object. The `ast` must be a standard ESTree AST with `start` and `end` properties for each node. diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index ffc103d6839..acd4735a55b 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -322,7 +322,7 @@ The pattern to use for naming custom emitted assets to include in the build outp * `[hash]`: A hash based on the name and content of the asset. * `[name]`: The file name of the asset excluding any extension. -Forward slashes `/` can be used to place files in sub-directories. See also [`output.chunkFileNames`](guide/en#output-chunkfilenames), [`output.entryFileNames`](guide/en#output-entryfilenames). +Forward slashes `/` can be used to place files in sub-directories. See also `[`output.chunkFileNames`](guide/en#output-chunkfilenames)`, [`output.entryFileNames`](guide/en#output-entryfilenames). #### output.banner/output.footer Type: `string | (() => string | Promise)`
diff --git a/src/Chunk.ts b/src/Chunk.ts index 2e2fb2da111..5eeff82240f 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -30,7 +30,7 @@ import { sortByExecutionOrder } from './utils/executionOrder'; import getIndentString from './utils/getIndentString'; import { makeLegal } from './utils/identifierHelpers'; import { basename, dirname, isAbsolute, normalize, relative, resolve } from './utils/path'; -import relativeId from './utils/relativeId'; +import relativeId, { getAliasName } from './utils/relativeId'; import renderChunk from './utils/renderChunk'; import { RenderOptions } from './utils/renderHelpers'; import { makeUnique, renderNamePattern } from './utils/renderNamePattern'; @@ -107,6 +107,10 @@ function getGlobalName( } } +export function isChunkRendered(chunk: Chunk): boolean { + return !chunk.isEmpty || chunk.entryModules.length > 0 || chunk.manualChunkAlias !== null; +} + export default class Chunk { entryModules: Module[] = []; execIndex: number; @@ -117,7 +121,7 @@ export default class Chunk { id: string = undefined; indentString: string = undefined; isEmpty: boolean; - isManualChunk: boolean = false; + manualChunkAlias: string | null = null; orderedModules: Module[]; renderedModules: { [moduleId: string]: RenderedModule; @@ -152,8 +156,8 @@ export default class Chunk { if (this.isEmpty && module.isIncluded()) { this.isEmpty = false; } - if (module.chunkAlias) { - this.isManualChunk = true; + if (module.manualChunkAlias) { + this.manualChunkAlias = module.manualChunkAlias; } module.chunk = this; if ( @@ -164,14 +168,16 @@ export default class Chunk { } } - if (this.entryModules.length > 0) { + const entryModule = this.entryModules[0]; + if (entryModule) { this.variableName = makeLegal( basename( - this.entryModules.map(module => module.chunkAlias).find(Boolean) || - this.entryModules[0].id + entryModule.chunkAlias || entryModule.manualChunkAlias || getAliasName(entryModule.id) ) ); - } else this.variableName = '__chunk_' + ++graph.curChunkIndex; + } else { + this.variableName = '__chunk_' + ++graph.curChunkIndex; + } } generateEntryExportsOrMarkAsTainted() { @@ -187,6 +193,13 @@ export default class Chunk { const exposedVariables = Array.from(this.exports); checkNextEntryModule: for (const { map, module } of exportVariableMaps) { if (!this.graph.preserveModules) { + if ( + this.manualChunkAlias && + module.chunkAlias && + this.manualChunkAlias !== module.chunkAlias + ) { + continue checkNextEntryModule; + } for (const exposedVariable of exposedVariables) { if (!map.has(exposedVariable)) { continue checkNextEntryModule; @@ -590,7 +603,7 @@ export default class Chunk { renderedDependency.id = relPath; } - this.finaliseDynamicImports(); + this.finaliseDynamicImports(options.format); const needsAmdModule = this.finaliseImportMetas(options); const hasExports = @@ -748,8 +761,11 @@ export default class Chunk { } private computeChunkName(): string { - if (this.facadeModule !== null && this.facadeModule.chunkAlias) { - return sanitizeFileName(this.facadeModule.chunkAlias); + 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); @@ -772,23 +788,23 @@ export default class Chunk { return hash.digest('hex').substr(0, 8); } - private finaliseDynamicImports() { + private finaliseDynamicImports(format: string) { for (let i = 0; i < this.orderedModules.length; i++) { const module = this.orderedModules[i]; const code = this.renderedModuleSources[i]; for (const { node, resolution } of module.dynamicImports) { if (!resolution) continue; if (resolution instanceof Module) { - if (!resolution.chunk.isEmpty && resolution.chunk !== this) { + if (resolution.chunk !== this && isChunkRendered(resolution.chunk)) { const resolutionChunk = resolution.facadeChunk || resolution.chunk; let relPath = normalize(relative(dirname(this.id), resolutionChunk.id)); if (!relPath.startsWith('../')) relPath = './' + relPath; - node.renderFinalResolution(code, `'${relPath}'`); + node.renderFinalResolution(code, `'${relPath}'`, format); } } else if (resolution instanceof ExternalModule) { - node.renderFinalResolution(code, `'${resolution.id}'`); + node.renderFinalResolution(code, `'${resolution.id}'`, format); } else { - node.renderFinalResolution(code, resolution); + node.renderFinalResolution(code, resolution, format); } } } diff --git a/src/Graph.ts b/src/Graph.ts index 2657d6ef9ff..5a20e022243 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -5,35 +5,31 @@ import injectImportMeta from 'acorn-import-meta'; import * as ESTree from 'estree'; import GlobalScope from './ast/scopes/GlobalScope'; import { EntityPathTracker } from './ast/utils/EntityPathTracker'; -import Chunk from './Chunk'; +import Chunk, { isChunkRendered } from './Chunk'; import ExternalModule from './ExternalModule'; import Module, { defaultAcornOptions } from './Module'; +import { ModuleLoader, UnresolvedModuleWithAlias } from './ModuleLoader'; import { Asset, InputOptions, - IsExternal, ModuleJSON, OutputBundle, - ResolvedId, - ResolveIdResult, RollupCache, RollupWarning, RollupWatcher, SerializablePluginCache, - SourceDescription, 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'; -import { error } from './utils/error'; import { analyseModuleExecution, sortByExecutionOrder } from './utils/executionOrder'; -import { isRelative, resolve } from './utils/path'; +import { resolve } from './utils/path'; import { createPluginDriver, PluginDriver } from './utils/pluginDriver'; -import relativeId, { getAliasName } from './utils/relativeId'; +import relativeId from './utils/relativeId'; import { timeEnd, timeStart } from './utils/timers'; -import transform from './utils/transform'; function makeOnwarn() { const warned = Object.create(null); @@ -46,24 +42,35 @@ function makeOnwarn() { }; } -function normalizeRelativeExternalId(importee: string, source: string) { - return isRelative(source) ? resolve(importee, '..', source) : source; +function normalizeEntryModules( + entryModules: string | string[] | Record +): UnresolvedModuleWithAlias[] { + if (typeof entryModules === 'string') { + return [{ alias: null, unresolvedId: entryModules }]; + } + if (Array.isArray(entryModules)) { + return entryModules.map(unresolvedId => ({ alias: null, unresolvedId })); + } + return Object.keys(entryModules).map(alias => ({ + alias, + unresolvedId: entryModules[alias] + })); } 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; - // track graph build status as each graph instance is used only once - finished = false; getModuleContext: (id: string) => string; - isExternal: IsExternal; isPureExternalModule: (id: string) => boolean; moduleById = new Map(); + moduleLoader: ModuleLoader; needsTreeshakingPass: boolean = false; + phase: BuildPhase = BuildPhase.LOAD_AND_PARSE; pluginDriver: PluginDriver; preserveModules: boolean; scope: GlobalScope; @@ -73,7 +80,6 @@ export default class Graph { treeshakingOptions: TreeshakingOptions; watchFiles: Record = Object.create(null); - private cachedModules: Map; private cacheExpiry: number; private context: string; private externalModules: ExternalModule[] = []; @@ -102,10 +108,6 @@ export default class Graph { this.cacheExpiry = options.experimentalCacheExpiry; - if (!options.input) { - throw new Error('You must supply options.input to rollup'); - } - this.treeshake = options.treeshake !== false; if (this.treeshake) { this.treeshakingOptions = options.treeshake @@ -130,13 +132,12 @@ export default class Graph { this.isPureExternalModule = () => false; } - this.contextParse = (code: string, options: acorn.Options = {}) => { - return this.acornParser.parse(code, { + this.contextParse = (code: string, options: acorn.Options = {}) => + this.acornParser.parse(code, { ...defaultAcornOptions, ...options, ...this.acornOptions }) as any; - }; this.pluginDriver = createPluginDriver(this, options, this.pluginCache, watcher); @@ -148,16 +149,6 @@ export default class Graph { }); } - if (typeof options.external === 'function') { - const external = options.external; - this.isExternal = (id, parentId, isResolved) => - !id.startsWith('\0') && external(id, parentId, isResolved); - } else { - const external = options.external; - const ids = new Set(Array.isArray(external) ? external : external ? [external] : []); - this.isExternal = id => ids.has(id); - } - this.shimMissingExports = options.shimMissingExports; this.scope = new GlobalScope(); this.context = String(options.context); @@ -196,6 +187,12 @@ export default class Graph { : []) ); this.acornParser = acorn.Parser.extend(...acornPluginsToInject); + this.moduleLoader = new ModuleLoader( + this, + this.moduleById, + this.pluginDriver, + options.external + ); } build( @@ -209,135 +206,129 @@ export default class Graph { timeStart('parse modules', 2); - return this.loadEntryModules(entryModules, manualChunks).then( - ({ entryModules, entryModuleAliases, manualChunkModules }) => { - timeEnd('parse modules', 2); - - // Phase 2 - linking. We populate the module dependency links and - // determine the topological execution order for the bundle - timeStart('analyse dependency graph', 2); - - for (let i = 0; i < entryModules.length; i++) { - const entryModule = entryModules[i]; - const duplicateIndex = entryModules.indexOf(entryModule, i + 1); - if (duplicateIndex !== -1) { - error({ - code: 'DUPLICATE_ENTRY_POINTS', - message: `Duplicate entry points detected. The input entries ${ - entryModuleAliases[i] - } and ${entryModuleAliases[duplicateIndex]} both point to the same module, ${ - entryModule.id - }` - }); - } + return Promise.all([ + this.moduleLoader.addEntryModules(normalizeEntryModules(entryModules), true), + manualChunks && this.moduleLoader.addManualChunks(manualChunks) + ]).then(([{ entryModules, manualChunkModulesByAlias }]) => { + if (entryModules.length === 0) { + throw new Error('You must supply options.input to rollup'); + } + for (const module of Array.from(this.moduleById.values())) { + if (module instanceof Module) { + this.modules.push(module); + this.watchFiles[module.id] = true; + } else { + this.externalModules.push(module); } + } + timeEnd('parse modules', 2); + + this.phase = BuildPhase.ANALYSE; - this.link(entryModules); + // Phase 2 - linking. We populate the module dependency links and + // determine the topological execution order for the bundle + timeStart('analyse dependency graph', 2); - timeEnd('analyse dependency graph', 2); + this.link(entryModules); - // Phase 3 – marking. We include all statements that should be included - timeStart('mark included statements', 2); + timeEnd('analyse dependency graph', 2); - if (inlineDynamicImports) { - if (entryModules.length > 1) - throw new Error( - 'Internal Error: can only inline dynamic imports for single-file builds.' - ); + // Phase 3 – marking. We include all statements that should be included + timeStart('mark included statements', 2); + + if (inlineDynamicImports) { + if (entryModules.length > 1) { + throw new Error( + 'Internal Error: can only inline dynamic imports for single-file builds.' + ); } - for (const entryModule of entryModules) entryModule.includeAllExports(); - this.includeMarked(this.modules); + } + for (const module of entryModules) { + module.includeAllExports(); + } + this.includeMarked(this.modules); - // check for unused external imports - for (const externalModule of this.externalModules) externalModule.warnUnusedImports(); + // check for unused external imports + for (const externalModule of this.externalModules) externalModule.warnUnusedImports(); - timeEnd('mark included statements', 2); + timeEnd('mark included statements', 2); - // Phase 4 – we construct the chunks, working out the optimal chunking using - // entry point graph colouring, before generating the import and export facades - timeStart('generate chunks', 2); + // Phase 4 – we construct the chunks, working out the optimal chunking using + // entry point graph colouring, before generating the import and export facades + timeStart('generate chunks', 2); - if (!this.preserveModules && !inlineDynamicImports) { - assignChunkColouringHashes(entryModules, manualChunkModules); - } + if (!this.preserveModules && !inlineDynamicImports) { + assignChunkColouringHashes(entryModules, manualChunkModulesByAlias); + } - if (entryModuleAliases) { - for (let i = entryModules.length - 1; i >= 0; i--) { - entryModules[i].chunkAlias = entryModuleAliases[i]; + // TODO: there is one special edge case unhandled here and that is that any module + // exposed as an unresolvable export * (to a graph external export *, + // either as a namespace import reexported or top-level export *) + // should be made to be its own entry point module before chunking + let chunks: Chunk[] = []; + if (this.preserveModules) { + for (const module of this.modules) { + const chunk = new Chunk(this, [module]); + if (module.isEntryPoint || !chunk.isEmpty) { + chunk.entryModules = [module]; } + chunks.push(chunk); } - - // TODO: there is one special edge case unhandled here and that is that any module - // exposed as an unresolvable export * (to a graph external export *, - // either as a namespace import reexported or top-level export *) - // should be made to be its own entry point module before chunking - let chunks: Chunk[] = []; - if (this.preserveModules) { - for (const module of this.modules) { - const chunk = new Chunk(this, [module]); - if (module.isEntryPoint || !chunk.isEmpty) { - chunk.entryModules = [module]; - } - chunks.push(chunk); - } - } else { - const chunkModules: { [entryHashSum: string]: Module[] } = {}; - for (const module of this.modules) { - const entryPointsHashStr = Uint8ArrayToHexString(module.entryPointsHash); - const curChunk = chunkModules[entryPointsHashStr]; - if (curChunk) { - curChunk.push(module); - } else { - chunkModules[entryPointsHashStr] = [module]; - } - } - - for (const entryHashSum in chunkModules) { - const chunkModulesOrdered = chunkModules[entryHashSum]; - sortByExecutionOrder(chunkModulesOrdered); - const chunk = new Chunk(this, chunkModulesOrdered); - chunks.push(chunk); + } else { + const chunkModules: { [entryHashSum: string]: Module[] } = {}; + for (const module of this.modules) { + const entryPointsHashStr = Uint8ArrayToHexString(module.entryPointsHash); + const curChunk = chunkModules[entryPointsHashStr]; + if (curChunk) { + curChunk.push(module); + } else { + chunkModules[entryPointsHashStr] = [module]; } } - // for each chunk module, set up its imports to other - // chunks, if those variables are included after treeshaking - for (const chunk of chunks) { - chunk.link(); + for (const entryHashSum in chunkModules) { + const chunkModulesOrdered = chunkModules[entryHashSum]; + sortByExecutionOrder(chunkModulesOrdered); + const chunk = new Chunk(this, chunkModulesOrdered); + chunks.push(chunk); } + } - // filter out empty dependencies - chunks = chunks.filter( - chunk => !chunk.isEmpty || chunk.entryModules.length > 0 || chunk.isManualChunk - ); + // for each chunk module, set up its imports to other + // chunks, if those variables are included after treeshaking + for (const chunk of chunks) { + chunk.link(); + } - // then go over and ensure all entry chunks export their variables - for (const chunk of chunks) { - if (this.preserveModules || chunk.entryModules.length > 0) { - chunk.generateEntryExportsOrMarkAsTainted(); - } + // filter out empty dependencies + chunks = chunks.filter(isChunkRendered); + + // then go over and ensure all entry chunks export their variables + for (const chunk of chunks) { + if (this.preserveModules || chunk.entryModules.length > 0) { + chunk.generateEntryExportsOrMarkAsTainted(); } + } - // create entry point facades for entry module chunks that have tainted exports - const facades = []; - if (!this.preserveModules) { - for (const chunk of chunks) { - for (const entryModule of chunk.entryModules) { - if (chunk.facadeModule !== entryModule) { - const entryPointFacade = new Chunk(this, []); - entryPointFacade.turnIntoFacade(entryModule); - facades.push(entryPointFacade); - } + // create entry point facades for entry module chunks that have tainted exports + const facades = []; + if (!this.preserveModules) { + for (const chunk of chunks) { + for (const entryModule of chunk.entryModules) { + if (chunk.facadeModule !== entryModule) { + const entryPointFacade = new Chunk(this, []); + entryPointFacade.turnIntoFacade(entryModule); + facades.push(entryPointFacade); } } } + } - timeEnd('generate chunks', 2); + timeEnd('generate chunks', 2); - this.finished = true; - return chunks.concat(facades); - } - ); + this.phase = BuildPhase.GENERATE; + return chunks.concat(facades); + }); } finaliseAssets(assetFileNames: string) { @@ -398,151 +389,6 @@ export default class Graph { this.onwarn(warning); } - private fetchAllDependencies(module: Module) { - const fetchDynamicImportsPromise = Promise.all( - module.getDynamicImportExpressions().map((dynamicImportExpression, index) => - this.pluginDriver - .hookFirst('resolveDynamicImport', [dynamicImportExpression, module.id]) - .then(replacement => { - if (!replacement) return; - const dynamicImport = module.dynamicImports[index]; - dynamicImport.alias = getAliasName( - replacement, - typeof dynamicImportExpression === 'string' ? dynamicImportExpression : undefined - ); - if (typeof dynamicImportExpression !== 'string') { - dynamicImport.resolution = replacement; - } else if (this.isExternal(replacement, module.id, true)) { - let externalModule; - if (!this.moduleById.has(replacement)) { - externalModule = new ExternalModule({ - graph: this, - id: replacement - }); - this.externalModules.push(externalModule); - this.moduleById.set(replacement, module); - } else { - externalModule = this.moduleById.get(replacement); - } - dynamicImport.resolution = externalModule; - externalModule.exportsNamespace = true; - } else { - return this.fetchModule(replacement, module.id).then(depModule => { - dynamicImport.resolution = depModule; - }); - } - }) - ) - ); - fetchDynamicImportsPromise.catch(() => {}); - - return Promise.all( - module.sources.map(source => this.resolveAndFetchDependency(module, source)) - ).then(() => fetchDynamicImportsPromise); - } - - private fetchModule(id: string, importer: string): Promise { - // short-circuit cycles - const existingModule = this.moduleById.get(id); - if (existingModule) { - if (existingModule.isExternal) throw new Error(`Cannot fetch external module ${id}`); - return Promise.resolve(existingModule); - } - - const module: Module = new Module(this, id); - this.moduleById.set(id, module); - this.watchFiles[id] = true; - - timeStart('load modules', 3); - return Promise.resolve(this.pluginDriver.hookFirst('load', [id])) - .catch((err: Error) => { - timeEnd('load modules', 3); - let msg = `Could not load ${id}`; - if (importer) msg += ` (imported by ${importer})`; - - msg += `: ${err.message}`; - throw new Error(msg); - }) - .then(source => { - timeEnd('load modules', 3); - if (typeof source === 'string') return source; - if (source && typeof source === 'object' && typeof source.code === 'string') return source; - - // TODO report which plugin failed - error({ - code: 'BAD_LOADER', - message: `Error loading ${relativeId( - id - )}: plugin load hook should return a string, a { code, map } object, or nothing/null` - }); - }) - .then(source => { - const sourceDescription: SourceDescription = - typeof source === 'string' - ? { - ast: null, - code: source - } - : source; - - const cachedModule = this.cachedModules.get(id); - if ( - cachedModule && - !cachedModule.customTransformCache && - cachedModule.originalCode === sourceDescription.code - ) { - // re-emit transform assets - if (cachedModule.transformAssets) { - for (const asset of cachedModule.transformAssets) - this.pluginDriver.emitAsset(asset.name, asset.source); - } - return cachedModule; - } - - return transform(this, sourceDescription, module); - }) - .then((source: ModuleJSON) => { - module.setSource(source); - - this.modules.push(module); - this.moduleById.set(id, module); - - return this.fetchAllDependencies(module).then(() => { - for (const name in module.exports) { - if (name !== 'default') { - module.exportsAll[name] = module.id; - } - } - module.exportAllSources.forEach(source => { - const id = module.resolvedIds[source].id; - const exportAllModule = this.moduleById.get(id); - if (exportAllModule.isExternal) return; - - for (const name in (exportAllModule).exportsAll) { - if (name in module.exportsAll) { - this.warn({ - code: 'NAMESPACE_CONFLICT', - message: `Conflicting namespaces: ${relativeId( - module.id - )} re-exports '${name}' from both ${relativeId( - module.exportsAll[name] - )} and ${relativeId( - (exportAllModule).exportsAll[name] - )} (will be ignored)`, - name, - reexporter: module.id, - sources: [module.exportsAll[name], (exportAllModule).exportsAll[name]] - }); - } else { - module.exportsAll[name] = (exportAllModule).exportsAll[name]; - } - } - }); - return module; - }); - }); - } - private link(entryModules: Module[]) { for (const module of this.modules) { module.linkDependencies(); @@ -562,160 +408,6 @@ export default class Graph { this.warnForMissingExports(); } - private loadEntryModules( - entryModules: string | string[] | Record, - manualChunks: Record | void - ) { - let removeAliasExtensions = false; - let entryModuleIds: string[]; - let entryModuleAliases: string[]; - if (typeof entryModules === 'string') entryModules = [entryModules]; - - if (Array.isArray(entryModules)) { - removeAliasExtensions = true; - entryModuleAliases = entryModules.concat([]); - entryModuleIds = entryModules; - } else { - entryModuleAliases = Object.keys(entryModules); - entryModuleIds = entryModuleAliases.map(name => (>entryModules)[name]); - } - - const entryAndManualChunkIds = entryModuleIds.concat([]); - if (manualChunks) { - Object.keys(manualChunks).forEach(name => { - const manualChunkIds = manualChunks[name]; - manualChunkIds.forEach(id => { - if (entryAndManualChunkIds.indexOf(id) === -1) entryAndManualChunkIds.push(id); - }); - }); - } - - return Promise.all(entryAndManualChunkIds.map(id => this.loadModule(id))).then( - entryAndChunkModules => { - if (removeAliasExtensions) { - for (let i = 0; i < entryModuleAliases.length; i++) - entryModuleAliases[i] = getAliasName(entryAndChunkModules[i].id, entryModuleAliases[i]); - } - - const entryModules = entryAndChunkModules.slice(0, entryModuleIds.length); - - let manualChunkModules: { [chunkName: string]: Module[] }; - if (manualChunks) { - manualChunkModules = {}; - for (const chunkName of Object.keys(manualChunks)) { - const chunk = manualChunks[chunkName]; - manualChunkModules[chunkName] = chunk.map(entryId => { - const entryIndex = entryAndManualChunkIds.indexOf(entryId); - return entryAndChunkModules[entryIndex]; - }); - } - } - - return { entryModules, entryModuleAliases, manualChunkModules }; - } - ); - } - - private loadModule(entryName: string) { - return this.pluginDriver - .hookFirst('resolveId', [entryName, undefined]) - .then(id => { - if (id === false) { - error({ - code: 'UNRESOLVED_ENTRY', - message: `Entry module cannot be external` - }); - } - - if (id == null) { - error({ - code: 'UNRESOLVED_ENTRY', - message: `Could not resolve entry (${entryName})` - }); - } - - return this.fetchModule(id, undefined); - }); - } - - private normalizeResolveIdResult( - resolveIdResult: ResolveIdResult, - module: Module, - source: string - ): ResolvedId { - let id = ''; - let external = false; - if (resolveIdResult) { - if (typeof resolveIdResult === 'object') { - id = resolveIdResult.id; - if (resolveIdResult.external) { - external = true; - } - } else { - id = resolveIdResult; - if (this.isExternal(id, module.id, true)) { - external = true; - } - } - if (external) { - id = normalizeRelativeExternalId(module.id, id); - } - } else { - id = normalizeRelativeExternalId(module.id, source); - external = true; - if (resolveIdResult !== false && !this.isExternal(id, module.id, true)) { - if (isRelative(source)) { - error({ - code: 'UNRESOLVED_IMPORT', - message: `Could not resolve '${source}' from ${relativeId(module.id)}` - }); - } - this.warn({ - code: 'UNRESOLVED_IMPORT', - importer: relativeId(module.id), - message: `'${source}' is imported by ${relativeId( - module.id - )}, but could not be resolved – treating it as an external dependency`, - source, - url: 'https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency' - }); - } - } - return { id, external }; - } - - private resolveAndFetchDependency(module: Module, source: string): Promise { - return Promise.resolve( - module.resolvedIds[source] || - Promise.resolve( - this.isExternal(source, module.id, false) - ? { id: source, external: true } - : this.pluginDriver.hookFirst('resolveId', [source, module.id]) - ).then(result => this.normalizeResolveIdResult(result, module, source)) - ).then(resolvedId => { - module.resolvedIds[source] = resolvedId; - if (resolvedId.external) { - if (!this.moduleById.has(resolvedId.id)) { - const module = new ExternalModule({ graph: this, id: resolvedId.id }); - this.externalModules.push(module); - this.moduleById.set(resolvedId.id, module); - } - - const externalModule = this.moduleById.get(resolvedId.id); - if (externalModule instanceof ExternalModule === false) { - error({ - code: 'INVALID_EXTERNAL_ID', - message: `'${source}' is imported as an external by ${relativeId( - module.id - )}, but is already an existing non-external module id.` - }); - } - } else { - return this.fetchModule(resolvedId.id, module.id); - } - }); - } - private warnForMissingExports() { for (const module of this.modules) { for (const importName of Object.keys(module.importDescriptions)) { diff --git a/src/Module.ts b/src/Module.ts index a122ad6b877..b0c82fcb352 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -88,7 +88,8 @@ export interface AstContext { deoptimizationTracker: EntityPathTracker; error: (props: RollupError, pos: number) => void; fileName: string; - getAssetFileName: (assetId: string) => string; + getAssetFileName: (assetReferenceId: string) => string; + getChunkFileName: (chunkReferenceId: string) => string; getExports: () => string[]; getModuleExecIndex: () => number; getModuleName: () => string; @@ -163,7 +164,7 @@ const MISSING_EXPORT_SHIM_DESCRIPTION: ExportDescription = { export default class Module { chunk: Chunk; - chunkAlias: string = undefined; + chunkAlias: string = null; code: string; comments: CommentDescription[] = []; customTransformCache: boolean; @@ -191,6 +192,8 @@ export default class Module { isEntryPoint: boolean = false; isExecuted: boolean = false; isExternal: false; + isUserDefinedEntryPoint: boolean = false; + manualChunkAlias: string = null; originalCode: string; originalSourcemap: RawSourceMap | void; reexports: { [name: string]: ReexportDescription } = Object.create(null); @@ -199,7 +202,6 @@ export default class Module { sourcemapChain: RawSourceMap[]; sources: string[] = []; transformAssets: Asset[]; - type: 'Module'; usesTopLevelAwait: boolean = false; private ast: Program; @@ -522,6 +524,7 @@ export default class Module { 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), getModuleExecIndex: () => this.execIndex, getModuleName: this.basename.bind(this), diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts new file mode 100644 index 00000000000..524722ec41d --- /dev/null +++ b/src/ModuleLoader.ts @@ -0,0 +1,430 @@ +import * as ESTree from 'estree'; +import ExternalModule from './ExternalModule'; +import Graph from './Graph'; +import Module from './Module'; +import { + ExternalOption, + IsExternal, + ModuleJSON, + ResolvedId, + ResolveIdResult, + SourceDescription +} from './rollup/types'; +import { + error, + errorCannotAssignModuleToChunk, + errorChunkNotGeneratedForFileName, + errorChunkReferenceIdNotFoundForFilename +} from './utils/error'; +import { isRelative, resolve } from './utils/path'; +import { PluginDriver } from './utils/pluginDriver'; +import { addWithNewReferenceId } from './utils/referenceIds'; +import relativeId, { getAliasName } 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 { + isManualChunkEntry?: boolean; +} + +function normalizeRelativeExternalId(importee: string, source: string) { + return isRelative(source) ? resolve(importee, '..', source) : source; +} + +export class ModuleLoader { + readonly isExternal: IsExternal; + private readonly entriesByReferenceId = new Map< + string, + { module: Module | null; name: string } + >(); + private readonly entryModules: Module[] = []; + private readonly graph: Graph; + private latestLoadModulesPromise: Promise = Promise.resolve(); + private readonly manualChunkModules: Record = {}; + private readonly modulesById: Map; + private readonly pluginDriver: PluginDriver; + + constructor( + graph: Graph, + modulesById: Map, + pluginDriver: PluginDriver, + external: ExternalOption + ) { + this.graph = graph; + this.modulesById = modulesById; + this.pluginDriver = pluginDriver; + if (typeof external === 'function') { + this.isExternal = (id, parentId, isResolved) => + !id.startsWith('\0') && external(id, parentId, isResolved); + } else { + const ids = new Set(Array.isArray(external) ? external : external ? [external] : []); + this.isExternal = id => ids.has(id); + } + } + + 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[], + isUserDefined: boolean + ): Promise<{ + entryModules: Module[]; + manualChunkModulesByAlias: Record; + newEntryModules: Module[]; + }> { + const loadNewEntryModulesPromise = Promise.all( + unresolvedEntryModules.map(this.loadEntryModule) + ).then(entryModules => { + for (const entryModule of entryModules) { + entryModule.isUserDefinedEntryPoint = entryModule.isUserDefinedEntryPoint || isUserDefined; + const existingEntryModule = this.entryModules.find(module => module.id === entryModule.id); + if (!existingEntryModule) { + this.entryModules.push(entryModule); + } + } + return entryModules; + }); + return this.awaitLoadModulesPromise(loadNewEntryModulesPromise).then(newEntryModules => ({ + entryModules: this.entryModules, + manualChunkModulesByAlias: this.manualChunkModules, + newEntryModules + })); + } + + addManualChunks(manualChunks: Record): Promise { + const unresolvedManualChunks: UnresolvedEntryModuleWithAlias[] = []; + for (const alias of Object.keys(manualChunks)) { + const manualChunkIds = manualChunks[alias]; + for (const unresolvedId of manualChunkIds) { + unresolvedManualChunks.push({ alias, unresolvedId, isManualChunkEntry: true }); + } + } + const loadNewManualChunkModulesPromise = Promise.all( + unresolvedManualChunks.map(this.loadEntryModule) + ).then(manualChunkModules => { + for (const module of manualChunkModules) { + if (!this.manualChunkModules[module.manualChunkAlias]) { + this.manualChunkModules[module.manualChunkAlias] = []; + } + this.manualChunkModules[module.manualChunkAlias].push(module); + } + }); + + return this.awaitLoadModulesPromise(loadNewManualChunkModulesPromise); + } + + getChunkFileName(referenceId: string): string { + const entryRecord = this.entriesByReferenceId.get(referenceId); + if (!entryRecord) errorChunkReferenceIdNotFoundForFilename(referenceId); + const fileName = + entryRecord.module && + (entryRecord.module.facadeChunk + ? entryRecord.module.facadeChunk.id + : entryRecord.module.chunk.id); + if (!fileName) errorChunkNotGeneratedForFileName(entryRecord); + return fileName; + } + + private awaitLoadModulesPromise(loadNewModulesPromise: Promise): Promise { + this.latestLoadModulesPromise = Promise.all([ + loadNewModulesPromise, + this.latestLoadModulesPromise + ]); + + const getCombinedPromise = (): Promise => { + const startingPromise = this.latestLoadModulesPromise; + return startingPromise.then(() => { + if (this.latestLoadModulesPromise !== startingPromise) { + return getCombinedPromise(); + } + }); + }; + + return getCombinedPromise().then(() => loadNewModulesPromise); + } + + private fetchAllDependencies(module: Module) { + const fetchDynamicImportsPromise = Promise.all( + module.getDynamicImportExpressions().map((dynamicImportExpression, index) => + // TODO we only should expose the acorn AST here + this.pluginDriver + .hookFirst('resolveDynamicImport', [ + dynamicImportExpression as string | ESTree.Node, + module.id + ]) + .then((replacement: string | void) => { + if (!replacement) return; + const dynamicImport = module.dynamicImports[index]; + dynamicImport.alias = getAliasName(replacement); + if (typeof dynamicImportExpression !== 'string') { + dynamicImport.resolution = replacement; + } else if (this.isExternal(replacement, module.id, true)) { + let externalModule; + if (!this.modulesById.has(replacement)) { + externalModule = new ExternalModule({ + graph: this.graph, + id: replacement + }); + this.modulesById.set(replacement, module); + } else { + externalModule = this.modulesById.get(replacement); + } + dynamicImport.resolution = externalModule; + externalModule.exportsNamespace = true; + } else { + return this.fetchModule(replacement, module.id).then(depModule => { + dynamicImport.resolution = depModule; + }); + } + }) + ) + ); + fetchDynamicImportsPromise.catch(() => {}); + + return Promise.all( + module.sources.map(source => this.resolveAndFetchDependency(module, source)) + ).then(() => fetchDynamicImportsPromise); + } + + private fetchModule(id: string, importer: string): Promise { + const existingModule = this.modulesById.get(id); + if (existingModule) { + if (existingModule.isExternal) throw new Error(`Cannot fetch external module ${id}`); + return Promise.resolve(existingModule); + } + + const module: Module = new Module(this.graph, id); + this.modulesById.set(id, module); + + timeStart('load modules', 3); + return Promise.resolve( + this.pluginDriver.hookFirst<'load', string | SourceDescription>('load', [id]) + ) + .catch((err: Error) => { + timeEnd('load modules', 3); + let msg = `Could not load ${id}`; + if (importer) msg += ` (imported by ${importer})`; + + msg += `: ${err.message}`; + throw new Error(msg); + }) + .then(source => { + timeEnd('load modules', 3); + if (typeof source === 'string') return source; + if (source && typeof source === 'object' && typeof source.code === 'string') return source; + + error({ + code: 'BAD_LOADER', + message: `Error loading ${relativeId( + id + )}: plugin load hook should return a string, a { code, map } object, or nothing/null` + }); + }) + .then(source => { + const sourceDescription: SourceDescription = + typeof source === 'string' + ? { + ast: null, + code: source + } + : source; + + const cachedModule = this.graph.cachedModules.get(id); + if ( + cachedModule && + !cachedModule.customTransformCache && + cachedModule.originalCode === sourceDescription.code + ) { + // re-emit transform assets + if (cachedModule.transformAssets) { + for (const asset of cachedModule.transformAssets) + this.pluginDriver.emitAsset(asset.name, asset.source); + } + return cachedModule; + } + + return transform(this.graph, sourceDescription, module); + }) + .then((source: ModuleJSON) => { + module.setSource(source); + + this.modulesById.set(id, module); + + return this.fetchAllDependencies(module).then(() => { + for (const name in module.exports) { + if (name !== 'default') { + module.exportsAll[name] = module.id; + } + } + module.exportAllSources.forEach(source => { + const id = module.resolvedIds[source].id; + const exportAllModule = this.modulesById.get(id); + if (exportAllModule.isExternal) return; + + for (const name in (exportAllModule).exportsAll) { + if (name in module.exportsAll) { + this.graph.warn({ + code: 'NAMESPACE_CONFLICT', + message: `Conflicting namespaces: ${relativeId( + module.id + )} re-exports '${name}' from both ${relativeId( + module.exportsAll[name] + )} and ${relativeId( + (exportAllModule).exportsAll[name] + )} (will be ignored)`, + name, + reexporter: module.id, + sources: [module.exportsAll[name], (exportAllModule).exportsAll[name]] + }); + } else { + module.exportsAll[name] = (exportAllModule).exportsAll[name]; + } + } + }); + return module; + }); + }); + } + + private loadEntryModule = ({ + alias, + unresolvedId, + isManualChunkEntry + }: UnresolvedEntryModuleWithAlias): Promise => { + return this.pluginDriver.hookFirst('resolveId', [unresolvedId, undefined]).then(id => { + if (id === false) { + error({ + code: 'UNRESOLVED_ENTRY', + message: `Entry module cannot be external` + }); + } + + if (id == null) { + error({ + code: 'UNRESOLVED_ENTRY', + message: `Could not resolve entry (${unresolvedId})` + }); + } + + return this.fetchModule(id, undefined).then(module => { + if (alias !== null) { + if (isManualChunkEntry) { + if (module.manualChunkAlias !== null && module.manualChunkAlias !== alias) { + errorCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias); + } + module.manualChunkAlias = alias; + return module; + } + if (module.chunkAlias !== null && module.chunkAlias !== alias) { + errorCannotAssignModuleToChunk(module.id, alias, module.chunkAlias); + } + module.chunkAlias = alias; + } + return module; + }); + }); + }; + + private normalizeResolveIdResult( + resolveIdResult: ResolveIdResult, + module: Module, + source: string + ): ResolvedId { + let id = ''; + let external = false; + if (resolveIdResult) { + if (typeof resolveIdResult === 'object') { + id = resolveIdResult.id; + if (resolveIdResult.external) { + external = true; + } + } else { + id = resolveIdResult; + if (this.isExternal(id, module.id, true)) { + external = true; + } + } + if (external) { + id = normalizeRelativeExternalId(module.id, id); + } + } else { + id = normalizeRelativeExternalId(module.id, source); + external = true; + if (resolveIdResult !== false && !this.isExternal(id, module.id, true)) { + if (isRelative(source)) { + error({ + code: 'UNRESOLVED_IMPORT', + message: `Could not resolve '${source}' from ${relativeId(module.id)}` + }); + } + this.graph.warn({ + code: 'UNRESOLVED_IMPORT', + importer: relativeId(module.id), + message: `'${source}' is imported by ${relativeId( + module.id + )}, but could not be resolved – treating it as an external dependency`, + source, + url: 'https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency' + }); + } + } + return { id, external }; + } + + private resolveAndFetchDependency(module: Module, source: string): Promise { + return Promise.resolve( + module.resolvedIds[source] || + Promise.resolve( + this.isExternal(source, module.id, false) + ? { id: source, external: true } + : this.pluginDriver.hookFirst('resolveId', [source, module.id]) + ).then((result: ResolveIdResult) => this.normalizeResolveIdResult(result, module, source)) + ).then(resolvedId => { + module.resolvedIds[source] = resolvedId; + if (resolvedId.external) { + if (!this.modulesById.has(resolvedId.id)) { + this.modulesById.set( + resolvedId.id, + new ExternalModule({ graph: this.graph, id: resolvedId.id }) + ); + } + + const externalModule = this.modulesById.get(resolvedId.id); + if (externalModule instanceof ExternalModule === false) { + error({ + code: 'INVALID_EXTERNAL_ID', + message: `'${source}' is imported as an external by ${relativeId( + module.id + )}, but is already an existing non-external module id.` + }); + } + } else { + return this.fetchModule(resolvedId.id, module.id); + } + }); + } +} diff --git a/src/ast/nodes/Import.ts b/src/ast/nodes/Import.ts index cc562b7ea6f..501010507d7 100644 --- a/src/ast/nodes/Import.ts +++ b/src/ast/nodes/Import.ts @@ -91,8 +91,11 @@ export default class Import extends NodeBase { } } - renderFinalResolution(code: MagicString, resolution: string) { + renderFinalResolution(code: MagicString, resolution: string, format: string) { if (this.included) { + if (format === 'amd' && resolution.startsWith("'.") && resolution.endsWith(".js'")) { + resolution = resolution.slice(0, -4) + "'"; + } code.overwrite(this.parent.arguments[0].start, this.parent.arguments[0].end, resolution); } } diff --git a/src/ast/nodes/MetaProperty.ts b/src/ast/nodes/MetaProperty.ts index 4bbbc30eace..08e6dc0047c 100644 --- a/src/ast/nodes/MetaProperty.ts +++ b/src/ast/nodes/MetaProperty.ts @@ -1,16 +1,24 @@ import MagicString from 'magic-string'; import { dirname, normalize, relative } from '../../utils/path'; import { PluginDriver } from '../../utils/pluginDriver'; +import { ObjectPathKey } from '../values'; import Identifier from './Identifier'; import MemberExpression from './MemberExpression'; import * as NodeType from './NodeType'; import { NodeBase } from './shared/Node'; +const ASSET_PREFIX = 'ROLLUP_ASSET_URL_'; +const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_'; + export default class MetaProperty extends NodeBase { meta: Identifier; property: Identifier; type: NodeType.tMetaProperty; + hasEffectsWhenAccessedAtPath(path: ObjectPathKey[]): boolean { + return path.length > 1; + } + initialise() { if (this.meta.name === 'import') { this.context.addImportMeta(this); @@ -31,19 +39,47 @@ export default class MetaProperty extends NodeBase { ? parent.propertyKey : null; - // support import.meta.ROLLUP_ASSET_URL_[ID] - if (importMetaProperty && importMetaProperty.startsWith('ROLLUP_ASSET_URL_')) { - const assetFileName = this.context.getAssetFileName(importMetaProperty.substr(17)); - const relativeAssetPath = normalize(relative(dirname(chunkId), assetFileName)); - const replacement = pluginDriver.hookFirstSync('resolveAssetUrl', [ - { - assetFileName, - chunkId, - format, - moduleId: this.context.module.id, - relativeAssetPath - } - ]); + if ( + importMetaProperty && + (importMetaProperty.startsWith(ASSET_PREFIX) || importMetaProperty.startsWith(CHUNK_PREFIX)) + ) { + 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); + } else { + chunkReferenceId = importMetaProperty.substr(CHUNK_PREFIX.length); + fileName = this.context.getChunkFileName(chunkReferenceId); + } + const relativePath = normalize(relative(dirname(chunkId), fileName)); + let replacement; + if (assetReferenceId !== null) { + // deprecated hook for assets + replacement = pluginDriver.hookFirstSync('resolveAssetUrl', [ + { + assetFileName: fileName, + chunkId, + format, + moduleId: this.context.module.id, + relativeAssetPath: relativePath + } + ]); + } + if (!replacement) { + replacement = pluginDriver.hookFirstSync<'resolveFileUrl', string>('resolveFileUrl', [ + { + assetReferenceId, + chunkId, + chunkReferenceId, + fileName, + format, + moduleId: this.context.module.id, + relativePath + } + ]); + } code.overwrite( (parent as MemberExpression).start, @@ -53,7 +89,7 @@ export default class MetaProperty extends NodeBase { return true; } - const replacement = pluginDriver.hookFirstSync('resolveImportMeta', [ + const replacement = pluginDriver.hookFirstSync('resolveImportMeta', [ importMetaProperty, { chunkId, diff --git a/src/chunk-optimization.ts b/src/chunk-optimization.ts index 757df08d1fe..46c29749874 100644 --- a/src/chunk-optimization.ts +++ b/src/chunk-optimization.ts @@ -36,7 +36,7 @@ export function optimizeChunks( nextChunk = execGroup[1]; const isMergeCandidate = (chunk: Chunk) => { - if (chunk.facadeModule !== null || chunk.isManualChunk) { + if (chunk.facadeModule !== null || chunk.manualChunkAlias !== null) { return false; } if (!nextChunk || nextChunk.facadeModule !== null) { diff --git a/src/finalisers/amd.ts b/src/finalisers/amd.ts index 963bc462b59..534c41fb778 100644 --- a/src/finalisers/amd.ts +++ b/src/finalisers/amd.ts @@ -6,6 +6,19 @@ import getExportBlock from './shared/getExportBlock'; import getInteropBlock from './shared/getInteropBlock'; import warnOnBuiltins from './shared/warnOnBuiltins'; +// TODO consider using improved AMD relative imports: +// https://requirejs.org/docs/api.html#modulenotes-urls + +// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted. +// The assumption is that this makes sense for all relative ids: +// https://requirejs.org/docs/api.html#jsfiles +function removeExtensionFromRelativeAmdId(id: string) { + if (id[0] === '.' && id.endsWith('.js')) { + return id.slice(0, -3); + } + return id; +} + export default function amd( magicString: MagicStringBundle, { @@ -26,7 +39,7 @@ export default function amd( ) { warnOnBuiltins(warn, dependencies); - const deps = dependencies.map(m => `'${m.id}'`); + const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`); const args = dependencies.map(m => m.name); const n = options.compact ? '' : '\n'; const _ = options.compact ? '' : ' '; diff --git a/src/finalisers/system.ts b/src/finalisers/system.ts index 5502862cfc2..88294083e4a 100644 --- a/src/finalisers/system.ts +++ b/src/finalisers/system.ts @@ -57,8 +57,8 @@ function getExportsBlock( ); } -const getHoistedExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => { - return getExportsBlock( +const getHoistedExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => + getExportsBlock( exports .filter(expt => expt.hoisted || expt.uninitialized) .map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), @@ -66,7 +66,6 @@ const getHoistedExportsBlock = (exports: ChunkExports, _: string, t: string, n: t, n ); -}; const getMissingExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => getExportsBlock( diff --git a/src/rollup/index.ts b/src/rollup/index.ts index c1faac31ca2..f35cf6aca88 100644 --- a/src/rollup/index.ts +++ b/src/rollup/index.ts @@ -67,7 +67,7 @@ function applyOptionHook(inputOptions: InputOptions, plugin: Plugin) { return inputOptions; } -function getInputOptions(rawInputOptions: GenericConfigObject): any { +function getInputOptions(rawInputOptions: GenericConfigObject): InputOptions { if (!rawInputOptions) { throw new Error('You must supply an options object to rollup'); } @@ -156,10 +156,7 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise - graph.pluginDriver.hookParallel('buildEnd').then(() => { - return chunks; - }), + chunks => graph.pluginDriver.hookParallel('buildEnd', []).then(() => chunks), err => graph.pluginDriver.hookParallel('buildEnd', [err]).then(() => { throw err; @@ -188,7 +185,7 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise createAddons(graph, outputOptions)) .then(addons => { // pre-render all chunks @@ -326,9 +323,9 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise { - return writeOutputFile(graph, result, bundle[chunkId], outputOptions); - }) + Object.keys(bundle).map(chunkId => + writeOutputFile(graph, result, bundle[chunkId], outputOptions) + ) ) .then(() => graph.pluginDriver.hookParallel('writeBundle', [bundle])) .then(() => createOutput(bundle)); diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 86b5fffe558..19f07e2fe99 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -62,12 +62,12 @@ export interface SourceMap { } export interface SourceDescription { + ast?: ESTree.Program; code: string; map?: string | RawSourceMap; } export interface TransformSourceDescription extends SourceDescription { - ast?: ESTree.Program; dependencies?: string[]; } @@ -103,10 +103,17 @@ export interface MinimalPluginContext { meta: PluginContextMeta; } +export type EmitAsset = (name: string, source?: string | Buffer) => string; +export type EmitChunk = (name: string, options?: { name?: string }) => string; + export interface PluginContext extends MinimalPluginContext { addWatchFile: (id: string) => void; cache: PluginCache; - getAssetFileName: (assetId: string) => string; + emitAsset: EmitAsset; + emitChunk: EmitChunk; + error: (err: RollupError | string, pos?: { column: number; line: number }) => void; + getAssetFileName: (assetReferenceId: string) => string; + getChunkFileName: (chunkReferenceId: string) => string; getModuleInfo: ( moduleId: string ) => { @@ -117,13 +124,11 @@ export interface PluginContext extends MinimalPluginContext { isExternal: IsExternal; moduleIds: IterableIterator; parse: (input: string, options: any) => ESTree.Program; - resolveId: ResolveIdHook; - setAssetSource: (assetId: string, source: string | Buffer) => void; + resolveId: (id: string, parent: string) => Promise; + setAssetSource: (assetReferenceId: string, source: string | Buffer) => void; + warn: (warning: RollupWarning | string, pos?: { column: number; line: number }) => void; /** @deprecated */ watcher: EventEmitter; - emitAsset(name: string, source?: string | Buffer): string; - error(err: RollupError | string, pos?: { column: number; line: number }): void; - warn(warning: RollupWarning | string, pos?: { column: number; line: number }): void; } export interface PluginContextMeta { @@ -185,6 +190,7 @@ export type RenderChunkHook = ( | string | null; +// TODO this should probably return ResolveIdResult export type ResolveDynamicImportHook = ( this: PluginContext, specifier: string | ESTree.Node, @@ -208,6 +214,19 @@ export type ResolveAssetUrlHook = ( } ) => string | void; +export type ResolveFileUrlHook = ( + this: PluginContext, + options: { + assetReferenceId: string | null; + chunkId: string; + chunkReferenceId: string | null; + fileName: string; + format: string; + moduleId: string; + relativePath: string; + } +) => string | void; + export type AddonHook = string | ((this: PluginContext) => string | Promise); /** @@ -226,41 +245,45 @@ export interface OutputBundle { [fileName: string]: OutputAsset | OutputChunk; } -export interface Plugin { - banner?: AddonHook; +interface OnGenerateOptions extends OutputOptions { + bundle: OutputChunk; +} + +interface OnWriteOptions extends OutputOptions { + bundle: RollupBuild; +} + +export interface PluginHooks { buildEnd?: (this: PluginContext, err?: Error) => Promise | void; buildStart?: (this: PluginContext, options: InputOptions) => Promise | void; - cacheKey?: string; - footer?: AddonHook; generateBundle?: ( this: PluginContext, options: OutputOptions, bundle: OutputBundle, isWrite: boolean ) => void | Promise; - intro?: AddonHook; load?: LoadHook; - name: string; /** @deprecated */ ongenerate?: ( this: PluginContext, - options: OutputOptions, + options: OnGenerateOptions, chunk: OutputChunk ) => void | Promise; /** @deprecated */ onwrite?: ( this: PluginContext, - options: OutputOptions, + options: OnWriteOptions, chunk: OutputChunk ) => void | Promise; options?: (this: MinimalPluginContext, options: InputOptions) => InputOptions | void | null; outputOptions?: (this: PluginContext, options: OutputOptions) => OutputOptions | void | null; - outro?: AddonHook; renderChunk?: RenderChunkHook; renderError?: (this: PluginContext, err?: Error) => Promise | void; renderStart?: (this: PluginContext) => Promise | void; + /** @deprecated */ resolveAssetUrl?: ResolveAssetUrlHook; resolveDynamicImport?: ResolveDynamicImportHook; + resolveFileUrl?: ResolveFileUrlHook; resolveId?: ResolveIdHook; resolveImportMeta?: ResolveImportMetaHook; transform?: TransformHook; @@ -272,6 +295,15 @@ export interface Plugin { writeBundle?: (this: PluginContext, bundle: OutputBundle) => void | Promise; } +export interface Plugin extends PluginHooks { + banner?: AddonHook; + cacheKey?: string; + footer?: AddonHook; + intro?: AddonHook; + name: string; + outro?: AddonHook; +} + export interface TreeshakingOptions { annotations?: boolean; propertyReadSideEffects?: boolean; @@ -293,7 +325,7 @@ export interface InputOptions { experimentalTopLevelAwait?: boolean; external?: ExternalOption; inlineDynamicImports?: boolean; - input: InputOption; + input?: InputOption; manualChunks?: { [chunkAlias: string]: string[] }; moduleContext?: ((id: string) => string) | { [id: string]: string }; onwarn?: WarningHandler; diff --git a/src/utils/assetHooks.ts b/src/utils/assetHooks.ts index 619757f426a..3d3b66a0be4 100644 --- a/src/utils/assetHooks.ts +++ b/src/utils/assetHooks.ts @@ -1,23 +1,25 @@ import sha256 from 'hash.js/lib/hash/sha/256'; -import { Asset, OutputBundle } from '../rollup/types'; -import { error } from './error'; +import { Asset, EmitAsset, OutputBundle } from '../rollup/types'; +import { + errorAssetNotFinalisedForFileName, + errorAssetReferenceIdNotFoundForFilename, + errorAssetReferenceIdNotFoundForSetSource, + errorAssetSourceAlreadySet, + errorAssetSourceMissingForSetSource, + errorInvalidAssetName, + errorNoAssetSourceSet +} from './error'; import { extname } from './path'; +import { addWithNewReferenceId } from './referenceIds'; import { isPlainName } from './relativeId'; import { makeUnique, renderNamePattern } from './renderNamePattern'; -export type EmitAsset = (name: string, source?: string | Buffer) => string; - export function getAssetFileName( asset: Asset, existingNames: Record, assetFileNames: string ) { - if (asset.source === undefined) - error({ - code: 'ASSET_SOURCE_NOT_FOUND', - message: `Plugin error creating asset ${asset.name} - no asset source set.` - }); - + if (asset.source === undefined) errorNoAssetSourceSet(asset); if (asset.fileName) return asset.fileName; return makeUnique( @@ -42,69 +44,31 @@ export function getAssetFileName( } export function createAssetPluginHooks( - assetsById: Map, + assetsByReferenceId: Map, outputBundle?: OutputBundle, assetFileNames?: string ) { return { emitAsset(name: string, source?: string | Buffer) { - if (typeof name !== 'string' || !isPlainName(name)) - error({ - code: 'INVALID_ASSET_NAME', - message: `Plugin error creating asset, name is not a plain (non relative or absolute URL) string name.` - }); - - let assetId: string; - do { - const assetHash = sha256(); - if (assetId) { - // if there is a collision, chain until there isn't - assetHash.update(assetId); - } else { - assetHash.update(name); - } - assetId = assetHash.digest('hex').substr(0, 8); - } while (assetsById.has(assetId)); - + if (typeof name !== 'string' || !isPlainName(name)) errorInvalidAssetName(name); const asset: Asset = { name, source, fileName: undefined }; if (outputBundle && source !== undefined) finaliseAsset(asset, outputBundle, assetFileNames); - assetsById.set(assetId, asset); - return assetId; + return addWithNewReferenceId(asset, assetsByReferenceId, name); }, - setAssetSource(assetId: string, source?: string | Buffer) { - const asset = assetsById.get(assetId); - if (!asset) - error({ - code: 'ASSET_NOT_FOUND', - message: `Plugin error - Unable to set asset source for unknown asset ${assetId}.` - }); - if (asset.source !== undefined) - error({ - code: 'ASSET_SOURCE_ALREADY_SET', - message: `Plugin error - Unable to set asset source for ${ - asset.name - }, source already set.` - }); - if (typeof source !== 'string' && !source) - error({ - code: 'ASSET_SOURCE_MISSING', - message: `Plugin error creating asset ${name}, setAssetSource call without a source.` - }); + + setAssetSource(assetReferenceId: string, source?: string | Buffer) { + const asset = assetsByReferenceId.get(assetReferenceId); + if (!asset) errorAssetReferenceIdNotFoundForSetSource(assetReferenceId); + if (asset.source !== undefined) errorAssetSourceAlreadySet(asset); + if (typeof source !== 'string' && !source) errorAssetSourceMissingForSetSource(asset); asset.source = source; if (outputBundle) finaliseAsset(asset, outputBundle, assetFileNames); }, - getAssetFileName(assetId: string) { - const asset = assetsById.get(assetId); - if (!asset) - error({ - code: 'ASSET_NOT_FOUND', - message: `Plugin error - Unable to get asset filename for unknown asset ${assetId}.` - }); - if (asset.fileName === undefined) - error({ - code: 'ASSET_NOT_FINALISED', - message: `Plugin error - Unable to get asset file name for asset ${assetId}. Ensure that the source is set and that generate is called first.` - }); + + getAssetFileName(assetReferenceId: string) { + const asset = assetsByReferenceId.get(assetReferenceId); + if (!asset) errorAssetReferenceIdNotFoundForFilename(assetReferenceId); + if (asset.fileName === undefined) errorAssetNotFinalisedForFileName(asset); return asset.fileName; } }; @@ -120,20 +84,22 @@ export function finaliseAsset(asset: Asset, outputBundle: OutputBundle, assetFil }; } -export function createTransformEmitAsset(assetsById: Map, emitAsset: EmitAsset) { +export function createTransformEmitAsset( + assetsByReferenceId: Map, + emitAsset: EmitAsset +) { const assets: Asset[] = []; return { assets, emitAsset: (name: string, source?: string | Buffer) => { - const assetId = emitAsset(name, source); - const asset = assetsById.get(assetId); - // distinguish transform assets + const assetReferenceId = emitAsset(name, source); + const asset = assetsByReferenceId.get(assetReferenceId); assets.push({ fileName: undefined, name: asset.name, source: asset.source }); - return assetId; + return assetReferenceId; } }; } diff --git a/src/utils/assignChunkIds.ts b/src/utils/assignChunkIds.ts index 4386eb01e50..a538f027926 100644 --- a/src/utils/assignChunkIds.ts +++ b/src/utils/assignChunkIds.ts @@ -13,9 +13,10 @@ export function assignChunkIds( const usedIds: Record = {}; const [entryChunks, otherChunks] = chunks.reduce( ([entryChunks, otherChunks], chunk) => { - (chunk.facadeModule && chunk.facadeModule.isEntryPoint ? entryChunks : otherChunks).push( - chunk - ); + (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint + ? entryChunks + : otherChunks + ).push(chunk); return [entryChunks, otherChunks]; }, [[], []] @@ -32,7 +33,7 @@ export function assignChunkIds( chunk.generateIdPreserveModules(inputBase, usedIds); } else { let pattern, patternName; - if (chunk.facadeModule && chunk.facadeModule.isEntryPoint) { + if (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint) { pattern = outputOptions.entryFileNames || '[name].js'; patternName = 'output.entryFileNames'; } else { diff --git a/src/utils/buildPhase.ts b/src/utils/buildPhase.ts new file mode 100644 index 00000000000..f5b530b034b --- /dev/null +++ b/src/utils/buildPhase.ts @@ -0,0 +1,5 @@ +export enum BuildPhase { + LOAD_AND_PARSE = 0, + ANALYSE, + GENERATE +} diff --git a/src/utils/chunkColouring.ts b/src/utils/chunkColouring.ts index 577c7da97da..3c8efadefb0 100644 --- a/src/utils/chunkColouring.ts +++ b/src/utils/chunkColouring.ts @@ -1,40 +1,42 @@ import ExternalModule from '../ExternalModule'; import Module from '../Module'; import { randomUint8Array, Uint8ArrayXor } from './entryHashing'; -import { error } from './error'; -import { relative } from './path'; export function assignChunkColouringHashes( entryModules: Module[], manualChunkModules: Record ) { let currentEntry: Module, currentEntryHash: Uint8Array; - let modulesVisitedForCurrentEntry: { [id: string]: boolean }; - const handledEntryPoints: { [id: string]: boolean } = {}; + let modulesVisitedForCurrentEntry: Set; + const handledEntryPoints: Set = new Set(); const dynamicImports: Module[] = []; const addCurrentEntryColourToModule = (module: Module) => { - if (currentEntry.chunkAlias) { - module.chunkAlias = currentEntry.chunkAlias; + if (currentEntry.manualChunkAlias) { + module.manualChunkAlias = currentEntry.manualChunkAlias; module.entryPointsHash = currentEntryHash; } else { Uint8ArrayXor(module.entryPointsHash, currentEntryHash); } for (const dependency of module.dependencies) { - if (dependency instanceof ExternalModule || dependency.id in modulesVisitedForCurrentEntry) { + if ( + dependency instanceof ExternalModule || + modulesVisitedForCurrentEntry.has(dependency.id) + ) { continue; } - modulesVisitedForCurrentEntry[dependency.id] = true; - if (!handledEntryPoints[dependency.id] && !dependency.chunkAlias) + modulesVisitedForCurrentEntry.add(dependency.id); + if (!handledEntryPoints.has(dependency.id) && !dependency.manualChunkAlias) { addCurrentEntryColourToModule(dependency); + } } for (const { resolution } of module.dynamicImports) { if ( resolution instanceof Module && resolution.dynamicallyImportedBy.length > 0 && - !resolution.chunkAlias + !resolution.manualChunkAlias ) { dynamicImports.push(resolution); } @@ -46,39 +48,28 @@ export function assignChunkColouringHashes( currentEntryHash = randomUint8Array(10); for (currentEntry of manualChunkModules[chunkName]) { - if (currentEntry.chunkAlias) { - error({ - code: 'INVALID_CHUNK', - message: `Cannot assign ${relative( - process.cwd(), - currentEntry.id - )} to the "${chunkName}" chunk as it is already in the "${ - currentEntry.chunkAlias - }" chunk. -Try defining "${chunkName}" first in the manualChunks definitions of the Rollup configuration.` - }); - } - currentEntry.chunkAlias = chunkName; - modulesVisitedForCurrentEntry = { [currentEntry.id]: true }; + modulesVisitedForCurrentEntry = new Set(currentEntry.id); addCurrentEntryColourToModule(currentEntry); } } } for (currentEntry of entryModules) { - handledEntryPoints[currentEntry.id] = true; + handledEntryPoints.add(currentEntry.id); currentEntryHash = randomUint8Array(10); - modulesVisitedForCurrentEntry = { [currentEntry.id]: null }; - addCurrentEntryColourToModule(currentEntry); + modulesVisitedForCurrentEntry = new Set(currentEntry.id); + if (!currentEntry.manualChunkAlias) { + addCurrentEntryColourToModule(currentEntry); + } } for (currentEntry of dynamicImports) { - if (handledEntryPoints[currentEntry.id]) { + if (handledEntryPoints.has(currentEntry.id)) { continue; } - handledEntryPoints[currentEntry.id] = true; + handledEntryPoints.add(currentEntry.id); currentEntryHash = randomUint8Array(10); - modulesVisitedForCurrentEntry = { [currentEntry.id]: null }; + modulesVisitedForCurrentEntry = new Set(currentEntry.id); addCurrentEntryColourToModule(currentEntry); } } diff --git a/src/utils/collapseSourcemaps.ts b/src/utils/collapseSourcemaps.ts index 1a2c07bdf5a..ee7a3310ebe 100644 --- a/src/utils/collapseSourcemaps.ts +++ b/src/utils/collapseSourcemaps.ts @@ -184,9 +184,9 @@ export default function collapseSourcemaps( const directory = dirname(module.id) || '.'; const sourceRoot = originalSourcemap.sourceRoot || '.'; - const baseSources = sources.map((source, i) => { - return new Source(resolve(directory, sourceRoot, source), sourcesContent[i]); - }); + const baseSources = sources.map( + (source, i) => new Source(resolve(directory, sourceRoot, source), sourcesContent[i]) + ); source = new Link(originalSourcemap, baseSources); } diff --git a/src/utils/defaultPlugin.ts b/src/utils/defaultPlugin.ts index b8e4d8e84ba..c5b6f390cf8 100644 --- a/src/utils/defaultPlugin.ts +++ b/src/utils/defaultPlugin.ts @@ -12,10 +12,11 @@ export function getRollupDefaultPlugin(options: InputOptions): Plugin { }, resolveDynamicImport(specifier, parentId) { if (typeof specifier === 'string' && !this.isExternal(specifier, parentId, false)) + // TODO this typecast will cause problems if resolveId returns false or an object return >this.resolveId(specifier, parentId); }, - resolveAssetUrl({ relativeAssetPath, format }) { - return relativeUrlMechanisms[format](relativeAssetPath); + resolveFileUrl({ relativePath, format }) { + return relativeUrlMechanisms[format](relativePath); }, resolveImportMeta(prop, { chunkId, format }) { const mechanism = importMetaMechanisms[format] && importMetaMechanisms[format](prop, chunkId); diff --git a/src/utils/error.ts b/src/utils/error.ts index d32b3d56ee8..dd2fe14e979 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -1,6 +1,7 @@ import { locate } from 'locate-character'; -import { RollupError, RollupWarning } from '../rollup/types'; +import { Asset, RollupError, RollupWarning } from '../rollup/types'; import getCodeFrame from './getCodeFrame'; +import relativeId from './relativeId'; export function error(base: Error | RollupError, props?: RollupError) { if (base instanceof Error === false) base = Object.assign(new Error(base.message), base); @@ -28,3 +29,97 @@ export function augmentCodeLocation( object.frame = getCodeFrame(source, line, column); } } + +export enum Errors { + ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', + ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', + ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', + ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', + CHUNK_NOT_FOUND = 'CHUNK_NOT_FOUND', + CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', + INVALID_ASSET_NAME = 'INVALID_ASSET_NAME', + INVALID_CHUNK = 'INVALID_CHUNK', + INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE' +} + +export function errorAssetNotFinalisedForFileName(asset: Asset) { + error({ + 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.` + }); +} + +export function errorChunkNotGeneratedForFileName(entry: { name: string }) { + error({ + code: Errors.CHUNK_NOT_GENERATED, + message: `Plugin error - Unable to get file name for chunk "${ + entry.name + }". Ensure that generate is called first.` + }); +} + +export function errorAssetReferenceIdNotFoundForFilename(assetReferenceId: string) { + error({ + code: Errors.ASSET_NOT_FOUND, + message: `Plugin error - Unable to get file name for unknown asset "${assetReferenceId}".` + }); +} + +export function errorAssetReferenceIdNotFoundForSetSource(assetReferenceId: string) { + error({ + code: Errors.ASSET_NOT_FOUND, + message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".` + }); +} + +export function errorAssetSourceAlreadySet(asset: Asset) { + error({ + code: Errors.ASSET_SOURCE_ALREADY_SET, + message: `Plugin error - Unable to set the source for asset "${ + asset.name + }", source already set.` + }); +} + +export function errorAssetSourceMissingForSetSource(asset: Asset) { + error({ + code: Errors.ASSET_SOURCE_MISSING, + message: `Plugin error creating asset "${asset.name}", setAssetSource call without a source.` + }); +} + +export function errorNoAssetSourceSet(asset: Asset) { + error({ + code: Errors.ASSET_SOURCE_MISSING, + message: `Plugin error creating asset "${asset.name}" - no asset source set.` + }); +} + +export function errorChunkReferenceIdNotFoundForFilename(chunkReferenceId: string) { + error({ + code: Errors.CHUNK_NOT_FOUND, + message: `Plugin error - Unable to get file name for unknown chunk "${chunkReferenceId}".` + }); +} + +export function errorInvalidAssetName(name: string) { + error({ + code: Errors.INVALID_ASSET_NAME, + message: `Plugin error creating asset, name "${name}" is not a plain (non relative or absolute URL) string name.` + }); +} + +export function errorCannotAssignModuleToChunk( + moduleId: string, + assignToAlias: string, + currentAlias: string +) { + error({ + code: Errors.INVALID_CHUNK, + message: `Cannot assign ${relativeId( + moduleId + )} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.` + }); +} diff --git a/src/utils/mergeOptions.ts b/src/utils/mergeOptions.ts index a91739eb166..37016d94b5f 100644 --- a/src/utils/mergeOptions.ts +++ b/src/utils/mergeOptions.ts @@ -88,7 +88,7 @@ export default function mergeOptions({ config: GenericConfigObject; defaultOnWarnHandler?: WarningHandler; }): { - inputOptions: any; + inputOptions: InputOptions; optionError: string | null; outputOptions: any; } { @@ -204,7 +204,7 @@ function getInputOptions( experimentalTopLevelAwait: getOption('experimentalTopLevelAwait'), external: getExternal(config, command), inlineDynamicImports: getOption('inlineDynamicImports', false), - input: getOption('input'), + input: getOption('input', []), manualChunks: getOption('manualChunks'), moduleContext: config.moduleContext, onwarn: getOnWarn(config, command, defaultOnWarnHandler), diff --git a/src/utils/pluginDriver.ts b/src/utils/pluginDriver.ts index 2c32d9403d5..f1464e0171b 100644 --- a/src/utils/pluginDriver.ts +++ b/src/utils/pluginDriver.ts @@ -3,39 +3,55 @@ import { version as rollupVersion } from 'package.json'; import Graph from '../Graph'; import Module from '../Module'; import { + EmitAsset, InputOptions, Plugin, PluginCache, PluginContext, - RollupError, + PluginHooks, RollupWarning, RollupWatcher, SerializablePluginCache } from '../rollup/types'; -import { createAssetPluginHooks, EmitAsset } from './assetHooks'; +import { createAssetPluginHooks } from './assetHooks'; +import { BuildPhase } from './buildPhase'; import { getRollupDefaultPlugin } from './defaultPlugin'; -import { error } from './error'; +import { error, Errors } from './error'; import { NameCollection } from './reservedNames'; +type Args = T extends (...args: infer K) => any ? K : never; + export interface PluginDriver { emitAsset: EmitAsset; hasLoadersOrTransforms: boolean; - getAssetFileName(assetId: string): string; - hookFirst(hook: string, args?: any[], hookContext?: HookContext): Promise; - hookFirstSync(hook: string, args?: any[], hookContext?: HookContext): T; - hookParallel(hook: string, args?: any[], hookContext?: HookContext): Promise; - hookReduceArg0( - hook: string, + getAssetFileName(assetReferenceId: string): string; + hookFirst>( + hook: H, + args: Args, + hookContext?: HookContext + ): Promise; + hookFirstSync>( + hook: H, + args: Args, + hookContext?: HookContext + ): R; + hookParallel( + hook: H, + args: Args, + hookContext?: HookContext + ): Promise; + hookReduceArg0>( + hook: H, args: any[], - reduce: Reduce, + reduce: Reduce, hookContext?: HookContext - ): Promise; - hookReduceArg0Sync( - hook: string, + ): Promise; + hookReduceArg0Sync>( + hook: H, args: any[], - reduce: Reduce, + reduce: Reduce, hookContext?: HookContext - ): T; + ): R; hookReduceValue( hook: string, value: T | Promise, @@ -43,8 +59,16 @@ export interface PluginDriver { reduce: Reduce, hookContext?: HookContext ): Promise; - hookSeq(hook: string, args?: any[], context?: HookContext): Promise; - hookSeqSync(hook: string, args?: any[], context?: HookContext): void; + hookSeq( + hook: H, + args: Args, + context?: HookContext + ): Promise; + hookSeqSync( + hook: H, + args: Args, + context?: HookContext + ): void; } export type Reduce = (reduction: T, result: R, plugin: Plugin) => T; @@ -111,24 +135,42 @@ export function createPluginDriver( } const context: PluginContext = { - addWatchFile(id: string) { - if (graph.finished) this.error('addWatchFile can only be called during the build.'); + addWatchFile(id) { + if (graph.phase >= BuildPhase.GENERATE) + this.error({ + code: Errors.INVALID_ROLLUP_PHASE, + message: `Cannot call addWatchFile after the build has finished.` + }); graph.watchFiles[id] = true; }, cache: cacheInstance, emitAsset, - error: (err: RollupError | string) => { + emitChunk(id, options) { + if (graph.phase > BuildPhase.LOAD_AND_PARSE) + this.error({ + code: Errors.INVALID_ROLLUP_PHASE, + message: `Cannot call emitChunk after module loading has finished.` + }); + return graph.moduleLoader.addEntryModuleAndGetReferenceId({ + alias: (options && options.name) || null, + unresolvedId: id + }); + }, + error(err) { if (typeof err === 'string') err = { message: err }; if (err.code) err.pluginCode = err.code; err.code = 'PLUGIN_ERROR'; err.plugin = plugin.name || `Plugin at position ${pidx + 1}`; error(err); }, - isExternal(id: string, parentId: string, isResolved = false) { - return graph.isExternal(id, parentId, isResolved); + isExternal(id, parentId, isResolved = false) { + return graph.moduleLoader.isExternal(id, parentId, isResolved); }, getAssetFileName, - getModuleInfo: (moduleId: string) => { + getChunkFileName(chunkReferenceId) { + return graph.moduleLoader.getChunkFileName(chunkReferenceId); + }, + getModuleInfo(moduleId) { const foundModule = graph.moduleById.get(moduleId); if (foundModule == null) { throw new Error(`Unable to find module ${moduleId}`); @@ -147,11 +189,11 @@ export function createPluginDriver( }, moduleIds: graph.moduleById.keys(), parse: graph.contextParse, - resolveId(id: string, parent: string) { + resolveId(id, parent) { return pluginDriver.hookFirst('resolveId', [id, parent]); }, setAssetSource, - warn: (warning: RollupWarning | string) => { + warn(warning) { if (typeof warning === 'string') warning = { message: warning } as RollupWarning; if (warning.code) warning.pluginCode = warning.code; warning.code = 'PLUGIN_WARNING'; @@ -268,9 +310,7 @@ export function createPluginDriver( hookSeq(name, args, hookContext) { let promise: Promise = Promise.resolve(); for (let i = 0; i < plugins.length; i++) - promise = promise.then(() => { - return runHook(name, args, i, false, hookContext); - }); + promise = promise.then(() => runHook(name, args, i, false, hookContext)); return promise; }, @@ -342,9 +382,9 @@ export function createPluginDriver( promise = promise.then(value => { const hookPromise = runHook(name, args, i, true, hookContext); if (!hookPromise) return value; - return hookPromise.then((result: any) => { - return reduce.call(pluginContexts[i], value, result, plugins[i]); - }); + return hookPromise.then((result: any) => + reduce.call(pluginContexts[i], value, result, plugins[i]) + ); }); } return promise; diff --git a/src/utils/referenceIds.ts b/src/utils/referenceIds.ts new file mode 100644 index 00000000000..a7daf938468 --- /dev/null +++ b/src/utils/referenceIds.ts @@ -0,0 +1,16 @@ +import sha256 from 'hash.js/lib/hash/sha/256'; + +export function addWithNewReferenceId(item: T, idMap: Map, hashBase: string): string { + let referenceId: string; + 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 59012a1e206..56c0160d860 100644 --- a/src/utils/relativeId.ts +++ b/src/utils/relativeId.ts @@ -1,10 +1,8 @@ import { basename, extname, isAbsolute, relative } from './path'; -export function getAliasName(resolved: string, unresolved?: string) { - let alias = basename(unresolved || resolved); - const ext = extname(resolved); - if (alias.endsWith(ext)) alias = alias.substr(0, alias.length - ext.length); - return alias; +export function getAliasName(id: string) { + const base = basename(id); + return base.substr(0, base.length - extname(id).length); } export default function relativeId(id: string) { @@ -14,10 +12,8 @@ export default function relativeId(id: string) { export function isPlainName(name: string) { // not starting with "./", "/". "../" - if ( + return !( name[0] === '/' || (name[1] === '.' && (name[2] === '/' || (name[2] === '.' && name[3] === '/'))) - ) - return false; - return true; + ); } diff --git a/src/utils/transform.ts b/src/utils/transform.ts index b388d3e5f4b..21b32dda282 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -5,6 +5,7 @@ import Graph from '../Graph'; import Module from '../Module'; import { Asset, + EmitAsset, Plugin, PluginCache, PluginContext, @@ -13,7 +14,7 @@ import { RollupWarning, TransformSourceDescription } from '../rollup/types'; -import { createTransformEmitAsset, EmitAsset } from './assetHooks'; +import { createTransformEmitAsset } from './assetHooks'; import { augmentCodeLocation, error } from './error'; import { dirname, resolve } from './path'; import { trackPluginCache } from './pluginDriver'; @@ -132,8 +133,8 @@ export default function transform( transformDependencies.push(id); pluginContext.addWatchFile(id); }, - setAssetSource(assetId, source) { - pluginContext.setAssetSource(assetId, source); + setAssetSource(assetReferenceId, source) { + pluginContext.setAssetSource(assetReferenceId, source); if (!customTransformCache && !setAssetSourceErr) { try { this.error({ diff --git a/src/watch/index.ts b/src/watch/index.ts index 8798b026603..519ad166a2e 100644 --- a/src/watch/index.ts +++ b/src/watch/index.ts @@ -9,7 +9,8 @@ import { RollupBuild, RollupCache, RollupWatcher, - RollupWatchOptions + RollupWatchOptions, + WatcherOptions } from '../rollup/types'; import mergeOptions from '../utils/mergeOptions'; import chokidar from './chokidar'; @@ -28,7 +29,7 @@ export class Watcher { private tasks: Task[]; constructor(configs: RollupWatchOptions[]) { - this.emitter = new class extends EventEmitter implements RollupWatcher { + this.emitter = new (class extends EventEmitter implements RollupWatcher { close: () => void; constructor(close: () => void) { super(); @@ -37,7 +38,7 @@ export class Watcher { // showing the `MaxListenersExceededWarning` to the user. this.setMaxListeners(Infinity); } - }(this.close.bind(this)); + })(this.close.bind(this)); this.tasks = (Array.isArray(configs) ? configs : configs ? [configs] : []).map( config => new Task(this, config) ); @@ -144,8 +145,9 @@ export class Task { if (output.file || output.dir) return path.resolve(output.file || output.dir); }); - const watchOptions = inputOptions.watch || {}; - if ('useChokidar' in watchOptions) watchOptions.chokidar = watchOptions.useChokidar; + const watchOptions: WatcherOptions = inputOptions.watch || {}; + if ('useChokidar' in watchOptions) + (watchOptions as any).chokidar = (watchOptions as any).useChokidar; let chokidarOptions = 'chokidar' in watchOptions ? watchOptions.chokidar : !!chokidar; if (chokidarOptions) { chokidarOptions = { @@ -161,7 +163,7 @@ export class Task { ); } - this.chokidarOptions = chokidarOptions; + this.chokidarOptions = chokidarOptions as WatchOptions; this.chokidarOptionsHash = JSON.stringify(chokidarOptions); this.filter = createFilter(watchOptions.include, watchOptions.exclude); @@ -229,11 +231,7 @@ export class Task { if (!watched.has(id)) deleteTask(id, this, this.chokidarOptionsHash); }); - return Promise.all( - this.outputs.map(output => { - return result.write(output); - }) - ).then(() => result); + return Promise.all(this.outputs.map(output => result.write(output))).then(() => result); }) .then((result: RollupBuild) => { this.watcher.emit('event', { diff --git a/test/chunking-form/index.js b/test/chunking-form/index.js index 25bf35f3608..3858d7e26e3 100644 --- a/test/chunking-form/index.js +++ b/test/chunking-form/index.js @@ -49,8 +49,20 @@ runTestSuiteWithSamples('chunking form', path.resolve(__dirname, 'samples'), (di ); }); -function generateAndTestBundle(bundle, outputOptions, expectedDir) { +function generateAndTestBundle(bundle, outputOptions, expectedDir, config) { return bundle .write(outputOptions) + .then(() => { + if (outputOptions.format === 'amd' && config.runAmd) { + return new Promise(resolve => { + global.assert = require('assert'); + const requirejs = require('requirejs'); + requirejs.config({ baseUrl: outputOptions.dir }); + requirejs(['main'], main => { + Promise.resolve(config.runAmd.exports && config.runAmd.exports(main)).then(resolve); + }); + }); + } + }) .then(() => assertDirectoriesAreEqual(outputOptions.dir, expectedDir)); } diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-chunk.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-chunk.js rename to test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-chunk2.js rename to test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js index 97a0f22a858..faa948b5725 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js @@ -1,7 +1,7 @@ define(['require'], function (require) { 'use strict'; console.log('main1'); - new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }); - new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-main4.dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-main5'], resolve, reject) }); }); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-main4.dynamic.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-chunk.js rename to test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-main4.dynamic.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-main5.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-chunk2.js rename to test/chunking-form/samples/aliasing-extensions/_expected/cjs/generated-main5.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/cjs/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/cjs/main1.js index ffb10b14b6d..4e8cf4fb59f 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/cjs/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/cjs/main1.js @@ -1,5 +1,5 @@ 'use strict'; console.log('main1'); -Promise.resolve(require('./generated-chunk.js')); -Promise.resolve(require('./generated-chunk2.js')); +Promise.resolve(require('./generated-main4.dynamic.js')); +Promise.resolve(require('./generated-main5.js')); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/es/generated-chunk.js b/test/chunking-form/samples/aliasing-extensions/_expected/es/generated-main4.dynamic.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/es/generated-chunk.js rename to test/chunking-form/samples/aliasing-extensions/_expected/es/generated-main4.dynamic.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/es/generated-chunk2.js b/test/chunking-form/samples/aliasing-extensions/_expected/es/generated-main5.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/aliasing-extensions/_expected/es/generated-main5.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/es/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/es/main1.js index de1c78214cd..17a9dcfce67 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/es/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/es/main1.js @@ -1,3 +1,3 @@ console.log('main1'); -import('./generated-chunk.js'); -import('./generated-chunk2.js'); +import('./generated-main4.dynamic.js'); +import('./generated-main5.js'); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-chunk.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/system/generated-chunk.js rename to test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-chunk2.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js similarity index 100% rename from test/chunking-form/samples/aliasing-extensions/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js index fe72dd01fb6..7ca66f3c42e 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js @@ -4,8 +4,8 @@ System.register([], function (exports, module) { execute: function () { console.log('main1'); - module.import('./generated-chunk.js'); - module.import('./generated-chunk2.js'); + module.import('./generated-main4.dynamic.js'); + module.import('./generated-main5.js'); } }; diff --git a/test/chunking-form/samples/asset-emission/_expected/amd/main.js b/test/chunking-form/samples/asset-emission/_expected/amd/main.js index 88a74ef7790..ecd1444b38d 100644 --- a/test/chunking-form/samples/asset-emission/_expected/amd/main.js +++ b/test/chunking-form/samples/asset-emission/_expected/amd/main.js @@ -1,8 +1,8 @@ -define(['module', 'require', './nested/chunk.js'], function (module, require, __chunk_1) { 'use strict'; +define(['module', 'require', './nested/chunk'], function (module, require, __chunk_1) { 'use strict'; var logo = new URL(module.uri + '/../assets/logo1-25253976.svg', document.baseURI).href; __chunk_1.showImage(logo); - new Promise(function (resolve, reject) { require(['./nested/chunk2.js'], resolve, reject) }); + 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 index f4f035d353e..c3c0a8c5af7 100644 --- a/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk2.js +++ b/test/chunking-form/samples/asset-emission/_expected/amd/nested/chunk2.js @@ -1,4 +1,4 @@ -define(['module', './chunk.js'], function (module, __chunk_1) { 'use strict'; +define(['module', './chunk'], function (module, __chunk_1) { 'use strict'; var logo = new URL(module.uri + '/../../assets/logo2-25253976.svg', document.baseURI).href; 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 c28862eef55..ac14c9b6c66 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { console.log('dep1 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 efd7525d8f1..111b5a4ace0 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { console.log('lib1 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 26b4d40d458..81990cfcc0b 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,4 +1,4 @@ -define(['exports', './generated-chunk.js', './generated-chunk3.js'], function (exports, __chunk_1, __chunk_3) { 'use strict'; +define(['exports', './generated-chunk', './generated-chunk3'], function (exports, __chunk_1, __chunk_3) { 'use strict'; var x = __chunk_1.x + 1; 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 433f5b9e4c5..ebe790c766a 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,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js', './generated-chunk3.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; console.log(__chunk_2.x + __chunk_2.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 e672a31543d..6924458be25 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.js', './generated-chunk2.js', './generated-chunk3.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { '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 7829aea9079..80869868e48 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { '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 8cfcfb33c4a..57661f926d5 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.js'], function (__chunk_3) { 'use strict'; +define(['./generated-chunk3'], function (__chunk_3) { 'use strict'; 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 1cb52024d4c..63b1b2fef74 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.js', './generated-chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { '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 ccdadcbc5a0..84e0fbc0088 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,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js', './generated-chunk3.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; console.log('1'); 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 e672a31543d..6924458be25 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.js', './generated-chunk2.js', './generated-chunk3.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { '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 7829aea9079..80869868e48 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { '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 c2fd988e2c2..01a1c62db72 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.js'], function (__chunk_2) { 'use strict'; +define(['./generated-chunk2'], function (__chunk_2) { 'use strict'; 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 1030e98d0cc..166cf5b87f0 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; class Main1 { constructor () { 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 879ad390277..2755a1f1093 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; class Main2 { constructor () { 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 042aa5e2ef2..b2e05fcc77c 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,4 +1,4 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; 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 296df6af6d0..5817de20203 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,4 +1,4 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; class Two { test() { 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 77482994344..aa788e1c4dc 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { var emptyFunction = __chunk_1.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 7829aea9079..80869868e48 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; 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 0918612bfae..d618cb1c2d6 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; class Main1 { constructor () { 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 93a48a8dd14..c49699c2b2c 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; class Main2 { constructor () { 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 685de59a288..2167f01dcf8 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; __chunk_1.commonjsGlobal.fn = d => d + 1; var cjs = __chunk_1.commonjsGlobal.fn; 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 bc56788609f..aaabc773106 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main2 = __chunk_1.d.map(d => d + 2); 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 820d0876029..0996f9cb03b 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,4 +1,4 @@ -define(['../chunks/chunk.js', '../chunks/chunk3.js'], function (__chunk_1, __chunk_3) { 'use strict'; +define(['../chunks/chunk', '../chunks/chunk3'], function (__chunk_1, __chunk_3) { 'use strict'; console.log(__chunk_1.num + __chunk_3.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 320b1c5e8ed..587db5114ca 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js @@ -1,4 +1,4 @@ -define(['./chunks/chunk.js', './chunks/chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./chunks/chunk', './chunks/chunk2'], function (__chunk_1, __chunk_2) { 'use strict'; console.log(__chunk_1.num + __chunk_2.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 8a4dcc5a765..66a2dc57923 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js @@ -1,4 +1,4 @@ -define(['./chunks/chunk2.js', './chunks/chunk3.js'], function (__chunk_2, __chunk_3) { 'use strict'; +define(['./chunks/chunk2', './chunks/chunk3'], function (__chunk_2, __chunk_3) { 'use strict'; console.log(__chunk_2.num + __chunk_3.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 56c322f18fb..c4aa8295a3d 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'],function(__chunk_1){'use strict';function fn () { +define(['./generated-chunk'],function(__chunk_1){'use strict';function fn () { console.log('dep1 fn'); }class Main1 { constructor () { 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 79d0d2e16b7..7ff5ce00cee 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.js','external'],function(__chunk_1,external){'use strict';function fn () { +define(['./generated-chunk','external'],function(__chunk_1,external){'use strict';function fn () { console.log('lib1 fn'); external.fn(); }function fn$1 () { 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 c28862eef55..ac14c9b6c66 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { console.log('dep1 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 3691e83b8f2..c6f58144aa8 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.js', 'external'], function (__chunk_1, external) { 'use strict'; +define(['./generated-chunk', 'external'], function (__chunk_1, external) { 'use strict'; function fn () { console.log('lib1 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 2aaaa7c33cb..46adba2f54f 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.js'], function (exports, external, __chunk_1) { 'use strict'; +define(['exports', 'external', './generated-chunk'], function (exports, external, __chunk_1) { '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 2aaaa7c33cb..46adba2f54f 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.js'], function (exports, external, __chunk_1) { 'use strict'; +define(['exports', 'external', './generated-chunk'], function (exports, external, __chunk_1) { '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 8628ce47de6..e69175e6288 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { console.log('dep1 fn'); 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 8d5ee940efa..2a762c5f878 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.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; function fn () { console.log('lib1 fn'); 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 274e709b0fb..e695a654e92 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.js'], function (exports, starexternal1, external1, starexternal2, external2, __chunk_1) { 'use strict'; +define(['exports', 'starexternal1', 'external1', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal1, external1, starexternal2, external2, __chunk_1) { 'use strict'; var main = '1'; 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 43b41d0322b..43214ab663d 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.js'], function (exports, starexternal2, external2, __chunk_1) { 'use strict'; +define(['exports', 'starexternal2', 'external2', './generated-chunk'], function (exports, starexternal2, external2, __chunk_1) { 'use strict'; var main = '2'; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js index 4ca2e731aca..85ab96efabc 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['exports', './main2.js'], function (exports, main2) { 'use strict'; +define(['exports', './main2'], function (exports, main2) { 'use strict'; class C { fn (num) { diff --git a/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js index 251e0f1f4f2..3eb8db12220 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['exports', './main1.js'], function (exports, main1) { 'use strict'; +define(['exports', './main1'], function (exports, main1) { 'use strict'; class C { fn (num) { diff --git a/test/chunking-form/samples/configure-asset-url/_expected/amd/main.js b/test/chunking-form/samples/configure-asset-url/_expected/amd/main.js index 3d245c68235..47bef05d750 100644 --- a/test/chunking-form/samples/configure-asset-url/_expected/amd/main.js +++ b/test/chunking-form/samples/configure-asset-url/_expected/amd/main.js @@ -4,6 +4,6 @@ define(['module', 'require'], function (module, require) { 'use strict'; var asset3 = new URL(module.uri + '/../assets/asset-unresolved-9548436d.txt', document.baseURI).href; - new Promise(function (resolve, reject) { require(['./nested/chunk.js'], resolve, reject) }).then(result => console.log(result, asset2, asset3)); + new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }).then(result => console.log(result, asset2, asset3)); }); diff --git a/test/chunking-form/samples/configure-file-url/_config.js b/test/chunking-form/samples/configure-file-url/_config.js new file mode 100644 index 00000000000..9ee4fa22535 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_config.js @@ -0,0 +1,55 @@ +module.exports = { + description: 'allows to configure file urls', + options: { + output: { + chunkFileNames: 'nested/chunk.js' + }, + plugins: [ + { + resolveId(id) { + if (id.endsWith('solved')) { + return id; + } + }, + load(id) { + if (id.endsWith('solved')) { + const assetId = this.emitAsset(`asset-${id}.txt`, `Asset for: ${id}`); + const chunkId = this.emitChunk('chunk.js'); + return ( + `export const asset = import.meta.ROLLUP_ASSET_URL_${assetId};\n` + + `export const chunk = import.meta.ROLLUP_CHUNK_URL_${chunkId};` + ); + } + }, + resolveFileUrl({ + assetReferenceId, + chunkId, + chunkReferenceId, + fileName, + format, + moduleId, + relativePath + }) { + if (!moduleId.endsWith('resolved')) { + return `'chunkId=${chunkId}:moduleId=${moduleId + .replace(/\\/g, '/') + .split('/') + .slice(-2) + .join( + '/' + )}:fileName=${fileName}:format=${format}:relativePath=${relativePath}:assetReferenceId=${assetReferenceId}:chunkReferenceId=${chunkReferenceId}'`; + } + return null; + } + }, + { + resolveFileUrl({ moduleId }) { + if (moduleId === 'resolved') { + return `'resolved'`; + } + return null; + } + } + ] + } +}; diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-resolved-dfc93baf.txt new file mode 100644 index 00000000000..31fb300f988 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-resolved-dfc93baf.txt @@ -0,0 +1 @@ +Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-solved-9b321da2.txt new file mode 100644 index 00000000000..07c7a096c7e --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-solved-9b321da2.txt @@ -0,0 +1 @@ +Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-unresolved-9548436d.txt new file mode 100644 index 00000000000..fd3ad6261cc --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/assets/asset-unresolved-9548436d.txt @@ -0,0 +1 @@ +Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/main.js b/test/chunking-form/samples/configure-file-url/_expected/amd/main.js new file mode 100644 index 00000000000..3877c193000 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/main.js @@ -0,0 +1,11 @@ +define(['module', 'require'], function (module, require) { 'use strict'; + + const asset = 'resolved'; + const chunk = 'resolved'; + + const asset$1 = new URL(module.uri + '/../assets/asset-unresolved-9548436d.txt', document.baseURI).href; + const chunk$1 = new URL(module.uri + '/../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/configure-file-url/_expected/amd/nested/chunk.js new file mode 100644 index 00000000000..32f0814a584 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + console.log('chunk'); + +}); diff --git a/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js new file mode 100644 index 00000000000..6adfcf6b0fe --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/amd/nested/chunk2.js @@ -0,0 +1,9 @@ +define(['module', 'exports'], function (module, 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 chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=amd:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7' + + exports.asset = asset; + exports.chunk = chunk; + +}); diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt new file mode 100644 index 00000000000..31fb300f988 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-resolved-dfc93baf.txt @@ -0,0 +1 @@ +Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-solved-9b321da2.txt new file mode 100644 index 00000000000..07c7a096c7e --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-solved-9b321da2.txt @@ -0,0 +1 @@ +Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-unresolved-9548436d.txt new file mode 100644 index 00000000000..fd3ad6261cc --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/assets/asset-unresolved-9548436d.txt @@ -0,0 +1 @@ +Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/main.js b/test/chunking-form/samples/configure-file-url/_expected/cjs/main.js new file mode 100644 index 00000000000..53e5508203c --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +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((document.currentScript && document.currentScript.src || document.baseURI) + '/../assets/asset-unresolved-9548436d.txt').href); +const chunk$1 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/nested/chunk.js').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../nested/chunk.js').href); + +Promise.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/configure-file-url/_expected/cjs/nested/chunk.js new file mode 100644 index 00000000000..9bd6f06e964 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('chunk'); diff --git a/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js new file mode 100644 index 00000000000..9c12e75444e --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/cjs/nested/chunk2.js @@ -0,0 +1,7 @@ +'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 chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=cjs:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7' + +exports.asset = asset; +exports.chunk = chunk; diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-resolved-dfc93baf.txt new file mode 100644 index 00000000000..31fb300f988 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-resolved-dfc93baf.txt @@ -0,0 +1 @@ +Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-solved-9b321da2.txt new file mode 100644 index 00000000000..07c7a096c7e --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-solved-9b321da2.txt @@ -0,0 +1 @@ +Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-unresolved-9548436d.txt new file mode 100644 index 00000000000..fd3ad6261cc --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/assets/asset-unresolved-9548436d.txt @@ -0,0 +1 @@ +Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/main.js b/test/chunking-form/samples/configure-file-url/_expected/es/main.js new file mode 100644 index 00000000000..3234da07909 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/main.js @@ -0,0 +1,7 @@ +const asset = 'resolved'; +const chunk = 'resolved'; + +const asset$1 = new URL('assets/asset-unresolved-9548436d.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/configure-file-url/_expected/es/nested/chunk.js new file mode 100644 index 00000000000..36b1d61dd25 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk.js @@ -0,0 +1 @@ +console.log('chunk'); diff --git a/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js b/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js new file mode 100644 index 00000000000..11a45614417 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/es/nested/chunk2.js @@ -0,0 +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 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/configure-file-url/_expected/system/assets/asset-resolved-dfc93baf.txt b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-resolved-dfc93baf.txt new file mode 100644 index 00000000000..31fb300f988 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-resolved-dfc93baf.txt @@ -0,0 +1 @@ +Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-solved-9b321da2.txt b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-solved-9b321da2.txt new file mode 100644 index 00000000000..07c7a096c7e --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-solved-9b321da2.txt @@ -0,0 +1 @@ +Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-unresolved-9548436d.txt b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-unresolved-9548436d.txt new file mode 100644 index 00000000000..fd3ad6261cc --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/assets/asset-unresolved-9548436d.txt @@ -0,0 +1 @@ +Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/main.js b/test/chunking-form/samples/configure-file-url/_expected/system/main.js new file mode 100644 index 00000000000..f45bae342b0 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/main.js @@ -0,0 +1,16 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const asset = 'resolved'; + const chunk = 'resolved'; + + const asset$1 = new URL('assets/asset-unresolved-9548436d.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/configure-file-url/_expected/system/nested/chunk.js new file mode 100644 index 00000000000..8f0f1907cfd --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('chunk'); + + } + }; +}); diff --git a/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js b/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js new file mode 100644 index 00000000000..c0df71d70a9 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/_expected/system/nested/chunk2.js @@ -0,0 +1,11 @@ +System.register([], function (exports, module) { + 'use strict'; + 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 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/configure-file-url/chunk.js new file mode 100644 index 00000000000..36b1d61dd25 --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/chunk.js @@ -0,0 +1 @@ +console.log('chunk'); diff --git a/test/chunking-form/samples/configure-file-url/main.js b/test/chunking-form/samples/configure-file-url/main.js new file mode 100644 index 00000000000..c7b101dfc5b --- /dev/null +++ b/test/chunking-form/samples/configure-file-url/main.js @@ -0,0 +1,5 @@ +import { asset as asset1, chunk as chunk1 } from 'resolved'; +import { asset as asset2, chunk as chunk2 } from 'unresolved'; + +import('solved').then(result => console.log(result, chunk1, chunk2, asset1, asset2)); + 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 ecf5ce1bd53..875ce56c7de 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.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 178cb27ad02..5d18b330e59 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(x, __chunk_1.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 302e4c4da46..4116f89dc57 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.bar, __chunk_1.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 302e4c4da46..4116f89dc57 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.bar, __chunk_1.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 302e4c4da46..4116f89dc57 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.bar, __chunk_1.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 302e4c4da46..4116f89dc57 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.bar, __chunk_1.bar); 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 c9e4318d314..d67cb599463 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main1 = __chunk_1.d.map(d => d + 1); 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 bc56788609f..aaabc773106 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,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main2 = __chunk_1.d.map(d => d + 2); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js similarity index 81% rename from test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js index dd1c3279a6c..83e82a16985 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-chunk2.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; console.log('dep1'); - new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject) }); }); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-chunk.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js index 5ccfb90eecb..a337561f677 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; console.log('main'); - new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject) }); }); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-chunk2.js deleted file mode 100644 index 264ed3db946..00000000000 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-chunk2.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -console.log('dep1'); -Promise.resolve(require('./generated-chunk.js')); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-dep1.js new file mode 100644 index 00000000000..8f77bed67fc --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-dep1.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('dep1'); +Promise.resolve(require('./generated-dep2.js')); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/cjs/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/main.js index f94f250a8bb..aeff3cd02fb 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/cjs/main.js @@ -1,4 +1,4 @@ 'use strict'; console.log('main'); -Promise.resolve(require('./generated-chunk2.js')); +Promise.resolve(require('./generated-dep1.js')); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-chunk2.js deleted file mode 100644 index 829d0490ba6..00000000000 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-chunk2.js +++ /dev/null @@ -1,2 +0,0 @@ -console.log('dep1'); -import('./generated-chunk.js'); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-dep1.js b/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-dep1.js new file mode 100644 index 00000000000..a644729548a --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-dep1.js @@ -0,0 +1,2 @@ +console.log('dep1'); +import('./generated-dep2.js'); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-chunk.js b/test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/es/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/es/main.js index 8e124b5d186..0844106d368 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/es/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/es/main.js @@ -1,2 +1,2 @@ console.log('main'); -import('./generated-chunk2.js'); +import('./generated-dep1.js'); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js similarity index 76% rename from test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js index 83e8602aefd..40c0c5a289e 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-chunk2.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js @@ -4,7 +4,7 @@ System.register([], function (exports, module) { execute: function () { console.log('dep1'); - module.import('./generated-chunk.js'); + module.import('./generated-dep2.js'); } }; diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-chunk.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js index 7dfd4a28cae..818a9966643 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js @@ -4,7 +4,7 @@ System.register([], function (exports, module) { execute: function () { console.log('main'); - module.import('./generated-chunk2.js'); + module.import('./generated-dep1.js'); } }; diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js similarity index 51% rename from test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js index e7a09c0f4e9..d6192e01c21 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-chunk2.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; function mult (num) { return num + __chunk_1.multiplier; diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js index 67da9d2aa86..ef675ab6761 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['require', './generated-chunk.js'], function (require, __chunk_1) { 'use strict'; +define(['require', './generated-chunk'], function (require, __chunk_1) { 'use strict'; function calc (num) { return num * __chunk_1.multiplier; @@ -9,7 +9,7 @@ define(['require', './generated-chunk.js'], function (require, __chunk_1) { 'use } function dynamic (num) { - return new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }) + return new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject) }) .then(dep2 => { return dep2.mult(num); }); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/main.js index 5f57de05b13..cb2d4803bf4 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/cjs/main.js @@ -11,7 +11,7 @@ function fn (num) { } function dynamic (num) { - return Promise.resolve(require('./generated-chunk2.js')) + return Promise.resolve(require('./generated-dep2.js')) .then(dep2 => { return dep2.mult(num); }); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/es/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/es/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chunking/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chunking/_expected/es/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/es/main.js index cae50cac305..d1c97541a75 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/es/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/es/main.js @@ -9,7 +9,7 @@ function fn (num) { } function dynamic (num) { - return import('./generated-chunk2.js') + return import('./generated-dep2.js') .then(dep2 => { return dep2.mult(num); }); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js index 02815d8471c..361619daf83 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js @@ -16,7 +16,7 @@ System.register(['./generated-chunk.js'], function (exports, module) { } function dynamic (num) { - return module.import('./generated-chunk2.js') + return module.import('./generated-dep2.js') .then(dep2 => { return dep2.mult(num); }); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-chunk2.js deleted file mode 100644 index 872563addeb..00000000000 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports', './generated-chunk.js'], function (exports, dynamic_js) { 'use strict'; - - - - exports.dynamic = dynamic_js.dynamic; - -}); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js new file mode 100644 index 00000000000..f5831da416e --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js @@ -0,0 +1,7 @@ +define(['exports', './generated-chunk'], function (exports, dynamic) { 'use strict'; + + + + exports.dynamic = dynamic.dynamic; + +}); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js index 570ef4f354d..4dc4a80e97f 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js @@ -1,5 +1,5 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }).then(({dynamic}) => console.log('main1', dynamic)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({dynamic}) => console.log('main1', dynamic)); }); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js index 050d46670e8..0efdba2aa84 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-chunk.js'], function (dynamic_js) { 'use strict'; +define(['./generated-chunk'], function (dynamic) { 'use strict'; - console.log('main2', dynamic_js.dynamic, dynamic_js.dep); + console.log('main2', dynamic.dynamic, dynamic.dep); }); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-chunk2.js deleted file mode 100644 index 760a1b8ffb8..00000000000 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dynamic_js = require('./generated-chunk.js'); - - - -exports.dynamic = dynamic_js.dynamic; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-dynamic.js new file mode 100644 index 00000000000..9ce0252a483 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/generated-dynamic.js @@ -0,0 +1,7 @@ +'use strict'; + +var dynamic = require('./generated-chunk.js'); + + + +exports.dynamic = dynamic.dynamic; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main1.js index 3c929ea0738..374a10ce818 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main1.js @@ -1,3 +1,3 @@ 'use strict'; -Promise.resolve(require('./generated-chunk2.js')).then(({dynamic}) => console.log('main1', dynamic)); +Promise.resolve(require('./generated-dynamic.js')).then(({dynamic}) => console.log('main1', dynamic)); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main2.js index e9c43ce79ee..924410b061d 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/main2.js @@ -1,5 +1,5 @@ 'use strict'; -var dynamic_js = require('./generated-chunk.js'); +var dynamic = require('./generated-chunk.js'); -console.log('main2', dynamic_js.dynamic, dynamic_js.dep); +console.log('main2', dynamic.dynamic, dynamic.dep); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/es/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/es/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-facade/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-facade/_expected/es/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/es/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/es/main1.js index e895a10f9a4..2fbb59a4af9 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/es/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/es/main1.js @@ -1 +1 @@ -import('./generated-chunk2.js').then(({dynamic}) => console.log('main1', dynamic)); +import('./generated-dynamic.js').then(({dynamic}) => console.log('main1', dynamic)); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js index c4de0a21d81..c49f55149f2 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk2.js').then(({dynamic}) => console.log('main1', dynamic)); + module.import('./generated-dynamic.js').then(({dynamic}) => console.log('main1', dynamic)); } }; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-chunk.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-inlined.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-inlined.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js index 5f4d1a82f33..ab477ff73b1 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['require', 'exports', './generated-chunk.js', './generated-chunk2.js'], function (require, exports, inlined_js, separate_js) { 'use strict'; +define(['require', 'exports', './generated-inlined', './generated-separate'], function (require, exports, inlined$1, separate$1) { 'use strict'; - const inlined = new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }); - const separate = new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + const inlined = new Promise(function (resolve, reject) { require(['./generated-inlined'], resolve, reject) }); + const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject) }); exports.inlined = inlined; exports.separate = separate; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js index daa2ff23c23..0be3fee1ac0 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js @@ -1,6 +1,6 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; - const separate = new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject) }); exports.separate = separate; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-inlined.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-inlined.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-separate.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/generated-separate.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js index a0422c52ed6..7154e55ccc7 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, '__esModule', { value: true }); -require('./generated-chunk.js'); -require('./generated-chunk2.js'); +require('./generated-inlined.js'); +require('./generated-separate.js'); -const inlined = Promise.resolve(require('./generated-chunk.js')); -const separate = Promise.resolve(require('./generated-chunk2.js')); +const inlined = Promise.resolve(require('./generated-inlined.js')); +const separate = Promise.resolve(require('./generated-separate.js')); exports.inlined = inlined; exports.separate = separate; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js index bdaaa5d1ad3..62e8058aba0 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js @@ -2,6 +2,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); -const separate = Promise.resolve(require('./generated-chunk2.js')); +const separate = Promise.resolve(require('./generated-separate.js')); exports.separate = separate; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-chunk.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-inlined.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-inlined.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js index 8f43588ea64..4a8004df29f 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js @@ -1,7 +1,7 @@ -import './generated-chunk.js'; -import './generated-chunk2.js'; +import './generated-inlined.js'; +import './generated-separate.js'; -const inlined = import('./generated-chunk.js'); -const separate = import('./generated-chunk2.js'); +const inlined = import('./generated-inlined.js'); +const separate = import('./generated-separate.js'); export { inlined, separate }; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main2.js index 0175fd44065..1ede98ed451 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main2.js @@ -1,3 +1,3 @@ -const separate = import('./generated-chunk2.js'); +const separate = import('./generated-separate.js'); export { separate }; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-chunk.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-inlined.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-inlined.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js index 25ed60fd12a..9523ff96e05 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-chunk.js', './generated-chunk2.js'], function (exports, module) { +System.register(['./generated-inlined.js', './generated-separate.js'], function (exports, module) { 'use strict'; return { setters: [function () {}, function () {}], execute: function () { - const inlined = exports('inlined', module.import('./generated-chunk.js')); - const separate = exports('separate', module.import('./generated-chunk2.js')); + const inlined = exports('inlined', module.import('./generated-inlined.js')); + const separate = exports('separate', module.import('./generated-separate.js')); } }; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js index 4e5e7630150..f54417af5a0 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - const separate = exports('separate', module.import('./generated-chunk2.js')); + const separate = exports('separate', module.import('./generated-separate.js')); } }; diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-chunk.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js index fdc21863cbe..86ed8240329 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js @@ -1,5 +1,5 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }).then(({ value }) => console.log(value)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({ value }) => console.log(value)); }); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/main.js index 53775291ad7..8da97186d0e 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/cjs/main.js @@ -1,3 +1,3 @@ 'use strict'; -Promise.resolve(require('./generated-chunk.js')).then(({ value }) => console.log(value)); +Promise.resolve(require('./generated-dynamic.js')).then(({ value }) => console.log(value)); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/generated-chunk.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/main.js index 97a57b60b65..4b8de10a9a7 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/es/main.js @@ -1 +1 @@ -import('./generated-chunk.js').then(({ value }) => console.log(value)); +import('./generated-dynamic.js').then(({ value }) => console.log(value)); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-chunk.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-chunk.js rename to test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js index 67f17ffe8c5..c9a3d7a8e03 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk.js').then(({ value }) => console.log(value)); + module.import('./generated-dynamic.js').then(({ value }) => console.log(value)); } }; diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-chunk2.js deleted file mode 100644 index add64858457..00000000000 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports', './generated-chunk.js'], function (exports, dep1_js) { 'use strict'; - - - - exports.bar = dep1_js.bar; - -}); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js new file mode 100644 index 00000000000..4c6c80f1699 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js @@ -0,0 +1,7 @@ +define(['exports', './generated-chunk'], function (exports, dep1) { 'use strict'; + + + + exports.bar = dep1.bar; + +}); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js index 3644b7ffb2f..5f16b4ed626 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-chunk.js'], function (dep1_js) { 'use strict'; +define(['./generated-chunk'], function (dep1) { 'use strict'; - console.log(dep1_js.foo(), dep1_js.bar()); + console.log(dep1.foo(), dep1.bar()); }); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js index f9a67e79b6a..86ec013aaab 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js @@ -1,5 +1,5 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }).then(({ bar }) => console.log(bar())); + new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject) }).then(({ bar }) => console.log(bar())); }); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-chunk2.js deleted file mode 100644 index ea4786b677e..00000000000 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep1_js = require('./generated-chunk.js'); - - - -exports.bar = dep1_js.bar; diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-dep1.js new file mode 100644 index 00000000000..cf4187f08c2 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/generated-dep1.js @@ -0,0 +1,7 @@ +'use strict'; + +var dep1 = require('./generated-chunk.js'); + + + +exports.bar = dep1.bar; diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main.js index e2eac98455c..12c7a0a7c3b 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main.js @@ -1,5 +1,5 @@ 'use strict'; -var dep1_js = require('./generated-chunk.js'); +var dep1 = require('./generated-chunk.js'); -console.log(dep1_js.foo(), dep1_js.bar()); +console.log(dep1.foo(), dep1.bar()); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main2.js index 04aab10a99b..41b25026533 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/cjs/main2.js @@ -1,3 +1,3 @@ 'use strict'; -Promise.resolve(require('./generated-chunk2.js')).then(({ bar }) => console.log(bar())); +Promise.resolve(require('./generated-dep1.js')).then(({ bar }) => console.log(bar())); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/generated-dep1.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/generated-dep1.js diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/main2.js index c93316e9992..00aba354edb 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/es/main2.js @@ -1 +1 @@ -import('./generated-chunk2.js').then(({ bar }) => console.log(bar())); +import('./generated-dep1.js').then(({ bar }) => console.log(bar())); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-chunk2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js similarity index 100% rename from test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js index 24b8ca32f1c..2f2c41db6e5 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk2.js').then(({ bar }) => console.log(bar())); + module.import('./generated-dep1.js').then(({ bar }) => console.log(bar())); } }; diff --git a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js index d90b886ebac..b9e9c31e762 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log(__chunk_1.foo(), __chunk_1.bar()); diff --git a/test/chunking-form/samples/dynamic-import/_config.js b/test/chunking-form/samples/dynamic-import/_config.js new file mode 100644 index 00000000000..c62aae20125 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_config.js @@ -0,0 +1,14 @@ +module.exports = { + description: 'handles dynamic imports with a shared dependency', + options: { + input: ['main'], + output: { + chunkFileNames: 'chunks/[name].js' + } + }, + runAmd: { + exports(exports) { + return exports.promise; + } + } +}; diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/chunk.js b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/chunk.js new file mode 100644 index 00000000000..65e59158953 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + const sharedValue = 'shared'; + + exports.sharedValue = sharedValue; + +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js new file mode 100644 index 00000000000..3aab0b0cf74 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js @@ -0,0 +1,7 @@ +define(['exports', './chunk'], function (exports, __chunk_1) { 'use strict'; + + + + exports.value = __chunk_1.sharedValue; + +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import/_expected/amd/main.js new file mode 100644 index 00000000000..205e4fcd0fc --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['require', 'exports', './chunks/chunk'], function (require, exports, __chunk_1) { 'use strict'; + + assert.equal(__chunk_1.sharedValue, 'shared'); + + const promise = new Promise(function (resolve, reject) { require(['./chunks/other'], resolve, reject) }).then(result => + assert.deepEqual(result, { value: 'shared' }) + ); + + exports.promise = promise; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/chunk.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/chunk.js new file mode 100644 index 00000000000..5a6d40af489 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +const sharedValue = 'shared'; + +exports.sharedValue = sharedValue; diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js new file mode 100644 index 00000000000..04b27928561 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js @@ -0,0 +1,7 @@ +'use strict'; + +var __chunk_1 = require('./chunk.js'); + + + +exports.value = __chunk_1.sharedValue; diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js new file mode 100644 index 00000000000..e4241fd2cf8 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js @@ -0,0 +1,13 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var __chunk_1 = require('./chunks/chunk.js'); + +assert.equal(__chunk_1.sharedValue, 'shared'); + +const promise = Promise.resolve(require('./chunks/other.js')).then(result => + assert.deepEqual(result, { value: 'shared' }) +); + +exports.promise = promise; diff --git a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/chunk.js b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/chunk.js new file mode 100644 index 00000000000..94dca2d35b3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/chunk.js @@ -0,0 +1,3 @@ +const sharedValue = 'shared'; + +export { sharedValue as a }; diff --git a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js new file mode 100644 index 00000000000..614213eb1d2 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js @@ -0,0 +1 @@ +export { a as value } from './chunk.js'; diff --git a/test/chunking-form/samples/dynamic-import/_expected/es/main.js b/test/chunking-form/samples/dynamic-import/_expected/es/main.js new file mode 100644 index 00000000000..0bc9c02af44 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/es/main.js @@ -0,0 +1,9 @@ +import { a as sharedValue } from './chunks/chunk.js'; + +assert.equal(sharedValue, 'shared'); + +const promise = import('./chunks/other.js').then(result => + assert.deepEqual(result, { value: 'shared' }) +); + +export { promise }; diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/chunk.js b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/chunk.js new file mode 100644 index 00000000000..f4a5045db1a --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const sharedValue = exports('a', 'shared'); + + } + }; +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js new file mode 100644 index 00000000000..91d13a25f79 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js @@ -0,0 +1,13 @@ +System.register(['./chunk.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('value', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/main.js b/test/chunking-form/samples/dynamic-import/_expected/system/main.js new file mode 100644 index 00000000000..cd01a25c888 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/_expected/system/main.js @@ -0,0 +1,18 @@ +System.register(['./chunks/chunk.js'], function (exports, module) { + 'use strict'; + var sharedValue; + return { + setters: [function (module) { + sharedValue = module.a; + }], + execute: function () { + + assert.equal(sharedValue, 'shared'); + + const promise = exports('promise', module.import('./chunks/other.js').then(result => + assert.deepEqual(result, { value: 'shared' }) + )); + + } + }; +}); diff --git a/test/chunking-form/samples/dynamic-import/main.js b/test/chunking-form/samples/dynamic-import/main.js new file mode 100644 index 00000000000..cf97619c11b --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/main.js @@ -0,0 +1,6 @@ +import { sharedValue } from './shared'; +assert.equal(sharedValue, 'shared'); + +export const promise = import('./other').then(result => + assert.deepEqual(result, { value: 'shared' }) +); diff --git a/test/chunking-form/samples/dynamic-import/other.js b/test/chunking-form/samples/dynamic-import/other.js new file mode 100644 index 00000000000..e662538f8b4 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/other.js @@ -0,0 +1 @@ +export { sharedValue as value } from './shared'; diff --git a/test/chunking-form/samples/dynamic-import/shared.js b/test/chunking-form/samples/dynamic-import/shared.js new file mode 100644 index 00000000000..7a5200e8ec7 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import/shared.js @@ -0,0 +1 @@ +export const sharedValue = 'shared'; diff --git a/test/chunking-form/samples/emit-chunk-existing/_config.js b/test/chunking-form/samples/emit-chunk-existing/_config.js new file mode 100644 index 00000000000..3f626f6076e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_config.js @@ -0,0 +1,19 @@ +module.exports = { + description: 'allows adding modules already in the graph as entry points', + options: { + input: { + 'first-main': 'main1', + 'second-main': 'main2' + }, + plugins: { + buildStart() { + // it should be possible to add existing entry points while not overriding their alias + this.emitChunk('main1'); + + // if an existing dependency is added, all references should use the new name + this.emitChunk('dep.js'); + this.emitChunk('dep'); + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/amd/first-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/first-main.js new file mode 100644 index 00000000000..fd823ca54c7 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/first-main.js @@ -0,0 +1,5 @@ +define(['./generated-dep'], function (dep) { 'use strict'; + + console.log('main1', dep); + +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/amd/generated-dep.js b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..e14fcf80133 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/generated-dep.js @@ -0,0 +1,7 @@ +define(function () { 'use strict'; + + var value = 42; + + return value; + +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/amd/second-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/second-main.js new file mode 100644 index 00000000000..fd823ca54c7 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/amd/second-main.js @@ -0,0 +1,5 @@ +define(['./generated-dep'], function (dep) { 'use strict'; + + console.log('main1', dep); + +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/first-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/first-main.js new file mode 100644 index 00000000000..54bee5af979 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/first-main.js @@ -0,0 +1,5 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/generated-dep.js b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..07d7bfe2962 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/generated-dep.js @@ -0,0 +1,5 @@ +'use strict'; + +var value = 42; + +module.exports = value; diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/second-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/second-main.js new file mode 100644 index 00000000000..54bee5af979 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/cjs/second-main.js @@ -0,0 +1,5 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/es/first-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/es/first-main.js new file mode 100644 index 00000000000..d77500b5810 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/es/first-main.js @@ -0,0 +1,3 @@ +import value from './generated-dep.js'; + +console.log('main1', value); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/es/generated-dep.js b/test/chunking-form/samples/emit-chunk-existing/_expected/es/generated-dep.js new file mode 100644 index 00000000000..630536069ae --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/es/generated-dep.js @@ -0,0 +1,3 @@ +var value = 42; + +export default value; diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/es/second-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/es/second-main.js new file mode 100644 index 00000000000..d77500b5810 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/es/second-main.js @@ -0,0 +1,3 @@ +import value from './generated-dep.js'; + +console.log('main1', value); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/system/first-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/system/first-main.js new file mode 100644 index 00000000000..d3cb55d1a7c --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/system/first-main.js @@ -0,0 +1,14 @@ +System.register(['./generated-dep.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.default; + }], + execute: function () { + + console.log('main1', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/system/generated-dep.js b/test/chunking-form/samples/emit-chunk-existing/_expected/system/generated-dep.js new file mode 100644 index 00000000000..a90fc7ba918 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/system/generated-dep.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var value = exports('default', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/_expected/system/second-main.js b/test/chunking-form/samples/emit-chunk-existing/_expected/system/second-main.js new file mode 100644 index 00000000000..d3cb55d1a7c --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/_expected/system/second-main.js @@ -0,0 +1,14 @@ +System.register(['./generated-dep.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.default; + }], + execute: function () { + + console.log('main1', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-existing/dep.js b/test/chunking-form/samples/emit-chunk-existing/dep.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/dep.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/chunking-form/samples/emit-chunk-existing/main1.js b/test/chunking-form/samples/emit-chunk-existing/main1.js new file mode 100644 index 00000000000..e384824c6f2 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/main1.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('main1', value); diff --git a/test/chunking-form/samples/emit-chunk-existing/main2.js b/test/chunking-form/samples/emit-chunk-existing/main2.js new file mode 100644 index 00000000000..e384824c6f2 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-existing/main2.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('main1', value); diff --git a/test/chunking-form/samples/emit-chunk-facade/_config.js b/test/chunking-form/samples/emit-chunk-facade/_config.js new file mode 100644 index 00000000000..4f15ed7ab82 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_config.js @@ -0,0 +1,20 @@ +const assert = require('assert'); +let referenceId; + +module.exports = { + description: 'retrieves the correct name of an emitted chunk in case a facade is created', + options: { + input: 'main', + manualChunks: { + 'build-starter': ['buildStart'] + }, + plugins: { + buildStart() { + referenceId = this.emitChunk('buildStart'); + }, + renderChunk() { + assert.strictEqual(this.getChunkFileName(referenceId), 'generated-buildStart.js'); + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-build-starter.js b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-build-starter.js new file mode 100644 index 00000000000..4974a348248 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-build-starter.js @@ -0,0 +1,11 @@ +define(['exports'], function (exports) { 'use strict'; + + const value = 42; + const otherValue = 43; + + console.log('startBuild', value); + + exports.otherValue = otherValue; + exports.value = value; + +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-buildStart.js new file mode 100644 index 00000000000..06143748495 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/generated-buildStart.js @@ -0,0 +1,9 @@ +define(['exports', './generated-build-starter'], function (exports, buildStarter) { 'use strict'; + + + + exports.buildStartValue = buildStarter.value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/amd/main.js b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/main.js new file mode 100644 index 00000000000..f9191ee8ad4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-build-starter'], function (buildStarter) { 'use strict'; + + console.log('main', buildStarter.value, buildStarter.otherValue); + +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-build-starter.js b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-build-starter.js new file mode 100644 index 00000000000..fecf7a3cd4c --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-build-starter.js @@ -0,0 +1,9 @@ +'use strict'; + +const value = 42; +const otherValue = 43; + +console.log('startBuild', value); + +exports.otherValue = otherValue; +exports.value = value; diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-buildStart.js new file mode 100644 index 00000000000..66c05cca4ba --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/generated-buildStart.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var buildStarter = require('./generated-build-starter.js'); + + + +exports.buildStartValue = buildStarter.value; diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/main.js b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/main.js new file mode 100644 index 00000000000..666c396846a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var buildStarter = require('./generated-build-starter.js'); + +console.log('main', buildStarter.value, buildStarter.otherValue); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-build-starter.js b/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-build-starter.js new file mode 100644 index 00000000000..99728ea9c48 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-build-starter.js @@ -0,0 +1,6 @@ +const value = 42; +const otherValue = 43; + +console.log('startBuild', value); + +export { value as a, otherValue as b }; diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-buildStart.js b/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-buildStart.js new file mode 100644 index 00000000000..56b50340df5 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/es/generated-buildStart.js @@ -0,0 +1 @@ +export { a as buildStartValue } from './generated-build-starter.js'; diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/es/main.js b/test/chunking-form/samples/emit-chunk-facade/_expected/es/main.js new file mode 100644 index 00000000000..eeb48762412 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/es/main.js @@ -0,0 +1,3 @@ +import { a as value, b as otherValue } from './generated-build-starter.js'; + +console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-build-starter.js b/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-build-starter.js new file mode 100644 index 00000000000..e3d0622be44 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-build-starter.js @@ -0,0 +1,13 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const value = exports('a', 42); + const otherValue = exports('b', 43); + + console.log('startBuild', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-buildStart.js b/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-buildStart.js new file mode 100644 index 00000000000..205a5d5e0f8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/system/generated-buildStart.js @@ -0,0 +1,13 @@ +System.register(['./generated-build-starter.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('buildStartValue', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/_expected/system/main.js b/test/chunking-form/samples/emit-chunk-facade/_expected/system/main.js new file mode 100644 index 00000000000..bdb5d51f748 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/_expected/system/main.js @@ -0,0 +1,15 @@ +System.register(['./generated-build-starter.js'], function (exports, module) { + 'use strict'; + var value, otherValue; + return { + setters: [function (module) { + value = module.a; + otherValue = module.b; + }], + execute: function () { + + console.log('main', value, otherValue); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-facade/buildStart.js b/test/chunking-form/samples/emit-chunk-facade/buildStart.js new file mode 100644 index 00000000000..49baee4964e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/buildStart.js @@ -0,0 +1,5 @@ +import {value} from './dep.js'; + +console.log('startBuild', value); + +export { value as buildStartValue }; diff --git a/test/chunking-form/samples/emit-chunk-facade/dep.js b/test/chunking-form/samples/emit-chunk-facade/dep.js new file mode 100644 index 00000000000..a2db6341120 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/dep.js @@ -0,0 +1,2 @@ +export const value = 42; +export const otherValue = 43; diff --git a/test/chunking-form/samples/emit-chunk-facade/main.js b/test/chunking-form/samples/emit-chunk-facade/main.js new file mode 100644 index 00000000000..df41d56376c --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-facade/main.js @@ -0,0 +1,3 @@ +import { value, otherValue } from './dep'; + +console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/emit-chunk-named/_config.js b/test/chunking-form/samples/emit-chunk-named/_config.js new file mode 100644 index 00000000000..8b171c6146e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_config.js @@ -0,0 +1,17 @@ +const assert = require('assert'); +let referenceId; + +module.exports = { + description: 'allows naming emitted chunks', + options: { + input: 'main', + plugins: { + buildStart() { + referenceId = this.emitChunk('buildStart', { name: 'nested/my-chunk' }); + }, + renderChunk() { + assert.strictEqual(this.getChunkFileName(referenceId), 'generated-nested/my-chunk.js'); + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-chunk.js new file mode 100644 index 00000000000..5e2f9f02968 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + var value = 42; + + exports.value = value; + +}); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js new file mode 100644 index 00000000000..9b82e0fcc17 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js @@ -0,0 +1,5 @@ +define(['../generated-chunk'], function (__chunk_1) { 'use strict'; + + console.log('startBuild', __chunk_1.value); + +}); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/amd/main.js b/test/chunking-form/samples/emit-chunk-named/_expected/amd/main.js new file mode 100644 index 00000000000..56bd65658a2 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; + + console.log('main', __chunk_1.value); + +}); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-chunk.js new file mode 100644 index 00000000000..6cec42c9a07 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +var value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-nested/my-chunk.js new file mode 100644 index 00000000000..c193d450be5 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/generated-nested/my-chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('../generated-chunk.js'); + +console.log('startBuild', __chunk_1.value); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/cjs/main.js b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/main.js new file mode 100644 index 00000000000..04040e8d4f8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('./generated-chunk.js'); + +console.log('main', __chunk_1.value); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-chunk.js new file mode 100644 index 00000000000..637e70967d1 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-chunk.js @@ -0,0 +1,3 @@ +var value = 42; + +export { value as a }; diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-nested/my-chunk.js new file mode 100644 index 00000000000..27feabf6e10 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/es/generated-nested/my-chunk.js @@ -0,0 +1,3 @@ +import { a as value } from '../generated-chunk.js'; + +console.log('startBuild', value); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/es/main.js b/test/chunking-form/samples/emit-chunk-named/_expected/es/main.js new file mode 100644 index 00000000000..6647a955386 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/es/main.js @@ -0,0 +1,3 @@ +import { a as value } from './generated-chunk.js'; + +console.log('main', value); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-chunk.js new file mode 100644 index 00000000000..28865ae6188 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var value = exports('a', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-nested/my-chunk.js new file mode 100644 index 00000000000..2fb89fd0319 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/system/generated-nested/my-chunk.js @@ -0,0 +1,14 @@ +System.register(['../generated-chunk.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.a; + }], + execute: function () { + + console.log('startBuild', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-named/_expected/system/main.js b/test/chunking-form/samples/emit-chunk-named/_expected/system/main.js new file mode 100644 index 00000000000..9db3c59931a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.a; + }], + execute: function () { + + console.log('main', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-named/buildStart.js b/test/chunking-form/samples/emit-chunk-named/buildStart.js new file mode 100644 index 00000000000..f9b1b414da5 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/buildStart.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('startBuild', value); diff --git a/test/chunking-form/samples/emit-chunk-named/dep.js b/test/chunking-form/samples/emit-chunk-named/dep.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/dep.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/chunking-form/samples/emit-chunk-named/main.js b/test/chunking-form/samples/emit-chunk-named/main.js new file mode 100644 index 00000000000..4a9b3a3f405 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-named/main.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('main', value); diff --git a/test/chunking-form/samples/emit-chunk-worker/_config.js b/test/chunking-form/samples/emit-chunk-worker/_config.js new file mode 100644 index 00000000000..168b5d3bb62 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_config.js @@ -0,0 +1,54 @@ +const path = require('path'); + +let workerId; +let proxyId; + +module.exports = { + description: 'allows adding additional chunks to be used in workers', + options: { + input: 'main', + output: { + chunkFileNames: 'chunks/[name].js' + }, + plugins: { + load(id) { + if (id === 'merged' || id === 'nested') { + if (!workerId) { + workerId = this.emitChunk('worker'); + proxyId = this.emitChunk('worker-proxy'); + } + return ` +export const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(import.meta.ROLLUP_CHUNK_URL_${proxyId}); + worker.onmessage = resolve; +});`; + } + if (id === 'worker-proxy') { + return `PLACEHOLDER(import.meta.ROLLUP_CHUNK_URL_${workerId})`; + } + }, + renderChunk(code, chunk, options) { + if (chunk.facadeModuleId === 'worker-proxy') { + const chunkFileName = `./${path.relative( + path.dirname(chunk.fileName), + this.getChunkFileName(workerId) + )}`; + if (options.format === 'system') { + return `importScripts('../../../../../../../node_modules/systemjs/dist/system.js'); +System.import('${chunkFileName}');`; + } + if (options.format === 'amd') { + return `importScripts('../../../../../../../node_modules/requirejs/require.js'); +requirejs(['${chunkFileName}']);`; + } + } + }, + resolveId(id) { + if (id === 'merged' || id === 'nested' || id === 'worker-proxy') { + return id; + } + return null; + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/chunk.js new file mode 100644 index 00000000000..b188047d8e0 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + const shared = 'shared'; + + exports.shared = shared; + +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/nested.js b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/nested.js new file mode 100644 index 00000000000..9ea6f6a2f08 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/nested.js @@ -0,0 +1,10 @@ +define(['module', 'exports'], function (module, exports) { 'use strict'; + + const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(new URL(module.uri + '/../worker-proxy.js', document.baseURI).href); + worker.onmessage = resolve; + }); + + exports.getWorkerMessage = getWorkerMessage; + +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js new file mode 100644 index 00000000000..4f2962c005b --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js @@ -0,0 +1,2 @@ +importScripts('../../../../../../../node_modules/requirejs/require.js'); +requirejs(['./worker.js']); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker.js b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker.js new file mode 100644 index 00000000000..4cfe5e26c29 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/chunks/worker.js @@ -0,0 +1,5 @@ +define(['./chunk'], function (__chunk_1) { 'use strict'; + + postMessage(`from worker: ${__chunk_1.shared}`); + +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/amd/main.js b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/main.js new file mode 100644 index 00000000000..287f2f571b1 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/amd/main.js @@ -0,0 +1,15 @@ +define(['module', 'require', './chunks/chunk'], function (module, require, __chunk_1) { 'use strict'; + + const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(new URL(module.uri + '/../chunks/worker-proxy.js', document.baseURI).href); + worker.onmessage = resolve; + }); + + document.body.innerHTML += `

main: ${__chunk_1.shared}

`; + getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); + + new Promise(function (resolve, reject) { require(['./chunks/nested'], resolve, reject) }) + .then(result => result.getWorkerMessage()) + .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); + +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/chunk.js new file mode 100644 index 00000000000..e2dc6ecb8ef --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +const shared = 'shared'; + +exports.shared = shared; diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/nested.js b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/nested.js new file mode 100644 index 00000000000..e7ed919b078 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/nested.js @@ -0,0 +1,8 @@ +'use strict'; + +const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker-proxy.js').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../worker-proxy.js').href)); + worker.onmessage = resolve; +}); + +exports.getWorkerMessage = getWorkerMessage; diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js new file mode 100644 index 00000000000..cc45d6af87d --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js @@ -0,0 +1,3 @@ +'use strict'; + +PLACEHOLDER((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker.js').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../worker.js').href)); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker.js b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker.js new file mode 100644 index 00000000000..3e14edd224a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/chunks/worker.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('./chunk.js'); + +postMessage(`from worker: ${__chunk_1.shared}`); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/main.js b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/main.js new file mode 100644 index 00000000000..2fb3a0fd077 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/cjs/main.js @@ -0,0 +1,15 @@ +'use strict'; + +var __chunk_1 = require('./chunks/chunk.js'); + +const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worker-proxy.js').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../chunks/worker-proxy.js').href)); + worker.onmessage = resolve; +}); + +document.body.innerHTML += `

main: ${__chunk_1.shared}

`; +getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); + +Promise.resolve(require('./chunks/nested.js')) + .then(result => result.getWorkerMessage()) + .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/chunk.js new file mode 100644 index 00000000000..7e7f4f90302 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/chunk.js @@ -0,0 +1,3 @@ +const shared = 'shared'; + +export { shared as a }; diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/nested.js b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/nested.js new file mode 100644 index 00000000000..13c379e9742 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/nested.js @@ -0,0 +1,6 @@ +const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(new URL('worker-proxy.js', import.meta.url).href); + worker.onmessage = resolve; +}); + +export { getWorkerMessage }; diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker-proxy.js b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker-proxy.js new file mode 100644 index 00000000000..88e9531a22e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker-proxy.js @@ -0,0 +1 @@ +PLACEHOLDER(new URL('worker.js', import.meta.url).href); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker.js b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker.js new file mode 100644 index 00000000000..c3bd7baebed --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/es/chunks/worker.js @@ -0,0 +1,3 @@ +import { a as shared } from './chunk.js'; + +postMessage(`from worker: ${shared}`); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/es/main.js b/test/chunking-form/samples/emit-chunk-worker/_expected/es/main.js new file mode 100644 index 00000000000..69ed05a894e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/es/main.js @@ -0,0 +1,13 @@ +import { a as shared } from './chunks/chunk.js'; + +const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(new URL('chunks/worker-proxy.js', import.meta.url).href); + worker.onmessage = resolve; +}); + +document.body.innerHTML += `

main: ${shared}

`; +getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); + +import('./chunks/nested.js') + .then(result => result.getWorkerMessage()) + .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/chunk.js new file mode 100644 index 00000000000..69b5ccbdda5 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const shared = exports('a', 'shared'); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/nested.js b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/nested.js new file mode 100644 index 00000000000..1c41e726447 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/nested.js @@ -0,0 +1,13 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const getWorkerMessage = exports('getWorkerMessage', () => new Promise(resolve => { + const worker = new Worker(new URL('worker-proxy.js', module.meta.url).href); + worker.onmessage = resolve; + })); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker-proxy.js b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker-proxy.js new file mode 100644 index 00000000000..44eb3bb9210 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker-proxy.js @@ -0,0 +1,2 @@ +importScripts('../../../../../../../node_modules/systemjs/dist/system.js'); +System.import('./worker.js'); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker.js b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker.js new file mode 100644 index 00000000000..0436f8885e4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/system/chunks/worker.js @@ -0,0 +1,14 @@ +System.register(['./chunk.js'], function (exports, module) { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.a; + }], + execute: function () { + + postMessage(`from worker: ${shared}`); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/_expected/system/main.js b/test/chunking-form/samples/emit-chunk-worker/_expected/system/main.js new file mode 100644 index 00000000000..1d7867c7769 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/_expected/system/main.js @@ -0,0 +1,24 @@ +System.register(['./chunks/chunk.js'], function (exports, module) { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.a; + }], + execute: function () { + + const getWorkerMessage = () => new Promise(resolve => { + const worker = new Worker(new URL('chunks/worker-proxy.js', module.meta.url).href); + worker.onmessage = resolve; + }); + + document.body.innerHTML += `

main: ${shared}

`; + getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); + + module.import('./chunks/nested.js') + .then(result => result.getWorkerMessage()) + .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worker/index-amd.html b/test/chunking-form/samples/emit-chunk-worker/index-amd.html new file mode 100644 index 00000000000..476b9ce3df1 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/index-amd.html @@ -0,0 +1,10 @@ + + + + + AMD + + + + + diff --git a/test/chunking-form/samples/emit-chunk-worker/index-system.html b/test/chunking-form/samples/emit-chunk-worker/index-system.html new file mode 100644 index 00000000000..96c687c1eb7 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/index-system.html @@ -0,0 +1,11 @@ + + + + + SystemJS + + + + + + diff --git a/test/chunking-form/samples/emit-chunk-worker/main.js b/test/chunking-form/samples/emit-chunk-worker/main.js new file mode 100644 index 00000000000..4c03186f74e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/main.js @@ -0,0 +1,9 @@ +import { getWorkerMessage } from 'merged'; +import { shared } from './shared'; + +document.body.innerHTML += `

main: ${shared}

`; +getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); + +import('nested') + .then(result => result.getWorkerMessage()) + .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/emit-chunk-worker/shared.js b/test/chunking-form/samples/emit-chunk-worker/shared.js new file mode 100644 index 00000000000..cd35843de7a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/shared.js @@ -0,0 +1 @@ +export const shared = 'shared'; diff --git a/test/chunking-form/samples/emit-chunk-worker/worker.js b/test/chunking-form/samples/emit-chunk-worker/worker.js new file mode 100644 index 00000000000..824aa26d2e0 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worker/worker.js @@ -0,0 +1,3 @@ +import {shared} from './shared'; + +postMessage(`from worker: ${shared}`); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_config.js b/test/chunking-form/samples/emit-chunk-worklet/_config.js new file mode 100644 index 00000000000..a9579f1f9d8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_config.js @@ -0,0 +1,28 @@ +const REGISTER_WORKLET = 'register-paint-worklet:'; + +module.exports = { + description: 'allows adding additional chunks to be used in worklets', + options: { + input: 'main', + output: { + chunkFileNames: 'chunks/[name].js' + }, + plugins: { + load(id) { + if (id.startsWith(REGISTER_WORKLET)) { + return `CSS.paintWorklet.addModule(import.meta.ROLLUP_CHUNK_URL_${this.emitChunk( + id.slice(REGISTER_WORKLET.length) + )});`; + } + }, + resolveId(id, importee) { + if (id.startsWith(REGISTER_WORKLET)) { + return this.resolveId(id.slice(REGISTER_WORKLET.length), importee).then( + id => REGISTER_WORKLET + id + ); + } + return null; + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/chunk.js new file mode 100644 index 00000000000..931cd5869bc --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/chunk.js @@ -0,0 +1,9 @@ +define(['exports'], function (exports) { 'use strict'; + + const color = 'greenyellow'; + const size = 6; + + exports.color = color; + exports.size = size; + +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/worklet.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/worklet.js new file mode 100644 index 00000000000..6b97d5f9e07 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/chunks/worklet.js @@ -0,0 +1,17 @@ +define(['./chunk'], function (__chunk_1) { 'use strict'; + + registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / __chunk_1.size; x++) { + ctx.beginPath(); + ctx.fillStyle = __chunk_1.color; + ctx.rect(x * __chunk_1.size, 0, 2, geom.height); + ctx.fill(); + } + } + } + ); + +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/main.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/main.js new file mode 100644 index 00000000000..7cdcf91f2ac --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['module', './chunks/chunk'], function (module, __chunk_1) { 'use strict'; + + CSS.paintWorklet.addModule(new URL(module.uri + '/../chunks/worklet.js', document.baseURI).href); + + document.body.innerHTML += `

color: ${__chunk_1.color}, size: ${__chunk_1.size}

`; + +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/chunk.js new file mode 100644 index 00000000000..baee02947f7 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/chunk.js @@ -0,0 +1,7 @@ +'use strict'; + +const color = 'greenyellow'; +const size = 6; + +exports.color = color; +exports.size = size; diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/worklet.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/worklet.js new file mode 100644 index 00000000000..b3eec36c862 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/chunks/worklet.js @@ -0,0 +1,17 @@ +'use strict'; + +var __chunk_1 = require('./chunk.js'); + +registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / __chunk_1.size; x++) { + ctx.beginPath(); + ctx.fillStyle = __chunk_1.color; + ctx.rect(x * __chunk_1.size, 0, 2, geom.height); + ctx.fill(); + } + } + } +); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/main.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/main.js new file mode 100644 index 00000000000..ca4d7d2e014 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +var __chunk_1 = require('./chunks/chunk.js'); + +CSS.paintWorklet.addModule((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worklet.js').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../chunks/worklet.js').href)); + +document.body.innerHTML += `

color: ${__chunk_1.color}, size: ${__chunk_1.size}

`; diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/chunk.js new file mode 100644 index 00000000000..766aa80086a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/chunk.js @@ -0,0 +1,4 @@ +const color = 'greenyellow'; +const size = 6; + +export { color as a, size as b }; diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/worklet.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/worklet.js new file mode 100644 index 00000000000..7e6de10220d --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/chunks/worklet.js @@ -0,0 +1,15 @@ +import { b as size, a as color } from './chunk.js'; + +registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / size; x++) { + ctx.beginPath(); + ctx.fillStyle = color; + ctx.rect(x * size, 0, 2, geom.height); + ctx.fill(); + } + } + } +); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/es/main.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/main.js new file mode 100644 index 00000000000..a2e8f846702 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/es/main.js @@ -0,0 +1,5 @@ +import { a as color, b as size } from './chunks/chunk.js'; + +CSS.paintWorklet.addModule(new URL('chunks/worklet.js', import.meta.url).href); + +document.body.innerHTML += `

color: ${color}, size: ${size}

`; diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/chunk.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/chunk.js new file mode 100644 index 00000000000..d41169b77d4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/chunk.js @@ -0,0 +1,11 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const color = exports('a', 'greenyellow'); + const size = exports('b', 6); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/worklet.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/worklet.js new file mode 100644 index 00000000000..0b48cd0f63e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/chunks/worklet.js @@ -0,0 +1,27 @@ +System.register(['./chunk.js'], function (exports, module) { + 'use strict'; + var size, color; + return { + setters: [function (module) { + size = module.b; + color = module.a; + }], + execute: function () { + + registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / size; x++) { + ctx.beginPath(); + ctx.fillStyle = color; + ctx.rect(x * size, 0, 2, geom.height); + ctx.fill(); + } + } + } + ); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/_expected/system/main.js b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/main.js new file mode 100644 index 00000000000..7cf17827eee --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/_expected/system/main.js @@ -0,0 +1,17 @@ +System.register(['./chunks/chunk.js'], function (exports, module) { + 'use strict'; + var color, size; + return { + setters: [function (module) { + color = module.a; + size = module.b; + }], + execute: function () { + + CSS.paintWorklet.addModule(new URL('chunks/worklet.js', module.meta.url).href); + + document.body.innerHTML += `

color: ${color}, size: ${size}

`; + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk-worklet/index-es.html b/test/chunking-form/samples/emit-chunk-worklet/index-es.html new file mode 100644 index 00000000000..af223f6c5c1 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/index-es.html @@ -0,0 +1,10 @@ + + + + + ESM + + + + + diff --git a/test/chunking-form/samples/emit-chunk-worklet/main.js b/test/chunking-form/samples/emit-chunk-worklet/main.js new file mode 100644 index 00000000000..60bad6751e8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/main.js @@ -0,0 +1,4 @@ +import 'register-paint-worklet:./worklet.js'; +import { color, size } from './shared'; + +document.body.innerHTML += `

color: ${color}, size: ${size}

`; diff --git a/test/chunking-form/samples/emit-chunk-worklet/shared.js b/test/chunking-form/samples/emit-chunk-worklet/shared.js new file mode 100644 index 00000000000..5a94b80cdd8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/shared.js @@ -0,0 +1,2 @@ +export const color = 'greenyellow'; +export const size = 6; diff --git a/test/chunking-form/samples/emit-chunk-worklet/worklet.js b/test/chunking-form/samples/emit-chunk-worklet/worklet.js new file mode 100644 index 00000000000..2274b010e02 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk-worklet/worklet.js @@ -0,0 +1,15 @@ +import { color, size } from './shared'; + +registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / size; x++) { + ctx.beginPath(); + ctx.fillStyle = color; + ctx.rect(x * size, 0, 2, geom.height); + ctx.fill(); + } + } + } +); diff --git a/test/chunking-form/samples/emit-chunk/_config.js b/test/chunking-form/samples/emit-chunk/_config.js new file mode 100644 index 00000000000..225c6722e8e --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_config.js @@ -0,0 +1,17 @@ +const assert = require('assert'); +let referenceId; + +module.exports = { + description: 'allows adding additional chunks and retrieving their file name', + options: { + input: 'main', + plugins: { + buildStart() { + referenceId = this.emitChunk('buildStart'); + }, + renderChunk() { + assert.strictEqual(this.getChunkFileName(referenceId), 'generated-buildStart.js'); + } + } + } +}; diff --git a/test/chunking-form/samples/emit-chunk/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/emit-chunk/_expected/amd/generated-buildStart.js new file mode 100644 index 00000000000..e313dd4eb35 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/amd/generated-buildStart.js @@ -0,0 +1,5 @@ +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; + + console.log('startBuild', __chunk_1.value); + +}); diff --git a/test/chunking-form/samples/emit-chunk/_expected/amd/generated-chunk.js b/test/chunking-form/samples/emit-chunk/_expected/amd/generated-chunk.js new file mode 100644 index 00000000000..5e2f9f02968 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/amd/generated-chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + var value = 42; + + exports.value = value; + +}); diff --git a/test/chunking-form/samples/emit-chunk/_expected/amd/main.js b/test/chunking-form/samples/emit-chunk/_expected/amd/main.js new file mode 100644 index 00000000000..56bd65658a2 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; + + console.log('main', __chunk_1.value); + +}); diff --git a/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-buildStart.js new file mode 100644 index 00000000000..806bebd797b --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-buildStart.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('./generated-chunk.js'); + +console.log('startBuild', __chunk_1.value); diff --git a/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-chunk.js new file mode 100644 index 00000000000..6cec42c9a07 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/cjs/generated-chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +var value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/emit-chunk/_expected/cjs/main.js b/test/chunking-form/samples/emit-chunk/_expected/cjs/main.js new file mode 100644 index 00000000000..04040e8d4f8 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('./generated-chunk.js'); + +console.log('main', __chunk_1.value); diff --git a/test/chunking-form/samples/emit-chunk/_expected/es/generated-buildStart.js b/test/chunking-form/samples/emit-chunk/_expected/es/generated-buildStart.js new file mode 100644 index 00000000000..0aa63110db2 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/es/generated-buildStart.js @@ -0,0 +1,3 @@ +import { a as value } from './generated-chunk.js'; + +console.log('startBuild', value); diff --git a/test/chunking-form/samples/emit-chunk/_expected/es/generated-chunk.js b/test/chunking-form/samples/emit-chunk/_expected/es/generated-chunk.js new file mode 100644 index 00000000000..637e70967d1 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/es/generated-chunk.js @@ -0,0 +1,3 @@ +var value = 42; + +export { value as a }; diff --git a/test/chunking-form/samples/emit-chunk/_expected/es/main.js b/test/chunking-form/samples/emit-chunk/_expected/es/main.js new file mode 100644 index 00000000000..6647a955386 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/es/main.js @@ -0,0 +1,3 @@ +import { a as value } from './generated-chunk.js'; + +console.log('main', value); diff --git a/test/chunking-form/samples/emit-chunk/_expected/system/generated-buildStart.js b/test/chunking-form/samples/emit-chunk/_expected/system/generated-buildStart.js new file mode 100644 index 00000000000..77070033222 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/system/generated-buildStart.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.a; + }], + execute: function () { + + console.log('startBuild', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk/_expected/system/generated-chunk.js b/test/chunking-form/samples/emit-chunk/_expected/system/generated-chunk.js new file mode 100644 index 00000000000..28865ae6188 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/system/generated-chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var value = exports('a', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk/_expected/system/main.js b/test/chunking-form/samples/emit-chunk/_expected/system/main.js new file mode 100644 index 00000000000..9db3c59931a --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.a; + }], + execute: function () { + + console.log('main', value); + + } + }; +}); diff --git a/test/chunking-form/samples/emit-chunk/buildStart.js b/test/chunking-form/samples/emit-chunk/buildStart.js new file mode 100644 index 00000000000..f9b1b414da5 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/buildStart.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('startBuild', value); diff --git a/test/chunking-form/samples/emit-chunk/dep.js b/test/chunking-form/samples/emit-chunk/dep.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/dep.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/chunking-form/samples/emit-chunk/main.js b/test/chunking-form/samples/emit-chunk/main.js new file mode 100644 index 00000000000..4a9b3a3f405 --- /dev/null +++ b/test/chunking-form/samples/emit-chunk/main.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +console.log('main', value); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js index cb06afa3a2b..0d61613c51f 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./main2.js'], function (main2) { 'use strict'; +define(['./main2'], function (main2) { 'use strict'; main2(); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-chunk.js similarity index 58% rename from test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js rename to test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-chunk.js index 77ebf9c9248..d23351b5be1 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-chunk.js @@ -1,4 +1,4 @@ -define(['exports', './m2.js'], function (exports, m2) { 'use strict'; +define(['exports', './m2'], function (exports, m2) { 'use strict'; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js index 0103e34d77d..2e73f2c4072 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js @@ -1,4 +1,4 @@ -define(['exports', './m2.js', './generated-m1.js'], function (exports, m2, m1) { 'use strict'; +define(['exports', './m2', './generated-chunk'], function (exports, m2, m1) { 'use strict'; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js index e57685b8d41..c56ed5a438c 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./m2.js', './generated-m1.js'], function (m2, m1) { 'use strict'; +define(['./m2', './generated-chunk'], function (m2, m1) { 'use strict'; console.log(m1.ms); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/generated-m1.js rename to test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/generated-chunk.js diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js index 9b97781f444..69e845c1c87 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var m2 = require('./m2.js'); -require('./generated-m1.js'); +require('./generated-chunk.js'); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/main.js index a7ba4a72c65..cab9d88907e 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/main.js @@ -1,6 +1,6 @@ 'use strict'; require('./m2.js'); -var m1 = require('./generated-m1.js'); +var m1 = require('./generated-chunk.js'); console.log(m1.ms); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entry-point-without-own-code/_expected/es/generated-m1.js rename to test/chunking-form/samples/entry-point-without-own-code/_expected/es/generated-chunk.js diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1.js index a0461824120..60888641454 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1.js @@ -1,2 +1,2 @@ export { default as m2 } from './m2.js'; -import './generated-m1.js'; +import './generated-chunk.js'; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/main.js index 107671de693..b68936e6d94 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/main.js @@ -1,4 +1,4 @@ import './m2.js'; -import { a as ms } from './generated-m1.js'; +import { a as ms } from './generated-chunk.js'; console.log(ms); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js rename to test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-chunk.js diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js index 936faa85f6b..f2f6739d8c4 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js @@ -1,4 +1,4 @@ -System.register(['./m2.js', './generated-m1.js'], function (exports, module) { +System.register(['./m2.js', './generated-chunk.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js index d3e75023a03..ea34b06467b 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./m2.js', './generated-m1.js'], function (exports, module) { +System.register(['./m2.js', './generated-chunk.js'], function (exports, module) { 'use strict'; var ms; return { diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js index 24677c96bb0..bac6f259fff 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js @@ -1,4 +1,4 @@ -define(['./generated-main2alias.js'], function (main2alias) { 'use strict'; +define(['./generated-main2alias'], function (main2alias) { 'use strict'; main2alias.log(main2alias.dep); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js index 1fdf53588c5..2747e887cd9 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js @@ -1,4 +1,4 @@ -define(['./generated-main2alias.js'], function (main2alias) { 'use strict'; +define(['./generated-main2alias'], function (main2alias) { 'use strict'; diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js rename to test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-chunk.js diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js index 800083d483f..4b813479b19 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-main2.js'], function (main2) { 'use strict'; +define(['./generated-chunk'], function (main2) { 'use strict'; main2.log(main2.dep); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js index 9d820bbf99a..dca57e6bdbb 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-main2.js'], function (main2) { 'use strict'; +define(['./generated-chunk'], function (main2) { 'use strict'; diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entrypoint-facade/_expected/cjs/generated-main2.js rename to test/chunking-form/samples/entrypoint-facade/_expected/cjs/generated-chunk.js diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main1.js index 6c0864d0770..0f9129ef76b 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main1.js @@ -1,5 +1,5 @@ 'use strict'; -var main2 = require('./generated-main2.js'); +var main2 = require('./generated-chunk.js'); main2.log(main2.dep); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2.js index 1cca608acf8..30320fc1844 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2.js @@ -1,6 +1,6 @@ 'use strict'; -var main2 = require('./generated-main2.js'); +var main2 = require('./generated-chunk.js'); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/es/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/es/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entrypoint-facade/_expected/es/generated-main2.js rename to test/chunking-form/samples/entrypoint-facade/_expected/es/generated-chunk.js diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/es/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/es/main1.js index 3eed7498c84..c647800f0c5 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/es/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/es/main1.js @@ -1,3 +1,3 @@ -import { a as log, b as dep } from './generated-main2.js'; +import { a as log, b as dep } from './generated-chunk.js'; log(dep); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/es/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/es/main2.js index 11f1b8ce08c..a16a620d03f 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/es/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/es/main2.js @@ -1 +1 @@ -export { a as default } from './generated-main2.js'; +export { a as default } from './generated-chunk.js'; diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js rename to test/chunking-form/samples/entrypoint-facade/_expected/system/generated-chunk.js diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js index ad2a738b972..ab11cc92c57 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function (exports, module) { +System.register(['./generated-chunk.js'], function (exports, module) { 'use strict'; var log, dep; return { diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js index 99ccd7b3796..2ec2077c897 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function (exports, module) { +System.register(['./generated-chunk.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js b/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js index f34747d3cdb..515a0bbe1cf 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports', './dep.js'], function (exports, dep) { 'use strict'; +define(['exports', './dep'], function (exports, dep) { 'use strict'; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-6bb39c19-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-chunk-6bb39c19-amd.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-6bb39c19-amd.js rename to test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-chunk-6bb39c19-amd.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-e7c7d1b5-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-e7c7d1b5-amd.js index 5cf1f787f69..16b886110fd 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-e7c7d1b5-amd.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-e7c7d1b5-amd.js @@ -1,4 +1,4 @@ -define(['./chunk-main2-6bb39c19-amd.js'], function (main2) { 'use strict'; +define(['./chunk-chunk-6bb39c19-amd'], function (main2) { 'use strict'; main2.log(main2.dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-f9a2200a-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-f9a2200a-amd.js index 8bfb309da5e..eb0faba5282 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-f9a2200a-amd.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-f9a2200a-amd.js @@ -1,4 +1,4 @@ -define(['./chunk-main2-6bb39c19-amd.js'], function (main2) { 'use strict'; +define(['./chunk-chunk-6bb39c19-amd'], function (main2) { 'use strict'; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-33c8b40d-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-chunk-33c8b40d-cjs.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-33c8b40d-cjs.js rename to test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-chunk-33c8b40d-cjs.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-639831da-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-639831da-cjs.js index df68f3f3591..c6c3e337b7a 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-639831da-cjs.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-639831da-cjs.js @@ -1,5 +1,5 @@ 'use strict'; -var main2 = require('./chunk-main2-33c8b40d-cjs.js'); +var main2 = require('./chunk-chunk-33c8b40d-cjs.js'); main2.log(main2.dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-4508233a-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-4508233a-cjs.js index 60dc76f979f..b4586862b9a 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-4508233a-cjs.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-4508233a-cjs.js @@ -1,6 +1,6 @@ 'use strict'; -var main2 = require('./chunk-main2-33c8b40d-cjs.js'); +var main2 = require('./chunk-chunk-33c8b40d-cjs.js'); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-88db1d1d-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-chunk-88db1d1d-esm.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-88db1d1d-esm.js rename to test/chunking-form/samples/filenames-patterns/_expected/es/chunk-chunk-88db1d1d-esm.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-0152a638-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-0152a638-esm.js index 9acd03d4111..e8e34075cbd 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-0152a638-esm.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-0152a638-esm.js @@ -1,3 +1,3 @@ -import { a as log, b as dep } from './chunk-main2-88db1d1d-esm.js'; +import { a as log, b as dep } from './chunk-chunk-88db1d1d-esm.js'; log(dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-5a78ab60-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-5a78ab60-esm.js index 9796d7f6e44..a3bc712a1a2 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-5a78ab60-esm.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-5a78ab60-esm.js @@ -1 +1 @@ -export { a as default } from './chunk-main2-88db1d1d-esm.js'; +export { a as default } from './chunk-chunk-88db1d1d-esm.js'; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-26e1391e-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-chunk-26e1391e-system.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-26e1391e-system.js rename to test/chunking-form/samples/filenames-patterns/_expected/system/chunk-chunk-26e1391e-system.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-2c874064-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-2c874064-system.js index 69a08d534b2..a1f541a5733 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-2c874064-system.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-2c874064-system.js @@ -1,4 +1,4 @@ -System.register(['./chunk-main2-26e1391e-system.js'], function (exports, module) { +System.register(['./chunk-chunk-26e1391e-system.js'], function (exports, module) { 'use strict'; var log, dep; return { diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-dd802b9d-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-dd802b9d-system.js index c805a82f422..29c79bc8437 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-dd802b9d-system.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-dd802b9d-system.js @@ -1,4 +1,4 @@ -System.register(['./chunk-main2-26e1391e-system.js'], function (exports, module) { +System.register(['./chunk-chunk-26e1391e-system.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js index 03b232e9f26..70d5738bbcb 100644 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js +++ b/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main1 = __chunk_1.x + __chunk_1.y; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js index 0a3dfa0871e..4aef9d410a7 100644 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js +++ b/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main2 = __chunk_1.x + __chunk_1.z; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js index bd9fa6422ac..b42651359db 100644 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js +++ b/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; var main3 = __chunk_1.y + __chunk_1.z; diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main1.js b/test/chunking-form/samples/grouping-size/_expected/amd/main1.js index f18ba752f42..c21d934d51e 100644 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main1.js +++ b/test/chunking-form/samples/grouping-size/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { 'use strict'; var main1 = __chunk_1.x + __chunk_2.y; diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main2.js b/test/chunking-form/samples/grouping-size/_expected/amd/main2.js index df2bfa670de..0eb3cf0c0aa 100644 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main2.js +++ b/test/chunking-form/samples/grouping-size/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { 'use strict'; var main2 = __chunk_1.x + __chunk_2.z; diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main3.js b/test/chunking-form/samples/grouping-size/_expected/amd/main3.js index 1f8ae40d5d3..7d4ddbd4550 100644 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main3.js +++ b/test/chunking-form/samples/grouping-size/_expected/amd/main3.js @@ -1,4 +1,4 @@ -define(['./generated-chunk2.js'], function (__chunk_2) { 'use strict'; +define(['./generated-chunk2'], function (__chunk_2) { 'use strict'; var main3 = __chunk_2.y + __chunk_2.z; diff --git a/test/chunking-form/samples/import-meta-url/_expected/amd/main.js b/test/chunking-form/samples/import-meta-url/_expected/amd/main.js index d95c0efb5a9..97f96ccbbaf 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/amd/main.js +++ b/test/chunking-form/samples/import-meta-url/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['module', 'require', './nested/chunk.js'], function (module, require, __chunk_1) { 'use strict'; +define(['module', 'require', './nested/chunk'], function (module, require, __chunk_1) { 'use strict'; __chunk_1.log('main: ' + new URL(module.uri, document.baseURI).href); - new Promise(function (resolve, reject) { require(['./nested/chunk2.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) }); }); diff --git a/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk2.js index 0c78bb0ac8b..e63722d0646 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk2.js +++ b/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk2.js @@ -1,4 +1,4 @@ -define(['module', './chunk.js'], function (module, __chunk_1) { 'use strict'; +define(['module', './chunk'], function (module, __chunk_1) { 'use strict'; __chunk_1.log('nested: ' + new URL(module.uri, document.baseURI).href); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js index 17ef0fc0c25..4fee7a37979 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js @@ -1,4 +1,4 @@ -define(['./first.js'], function (first) { 'use strict'; +define(['./first'], function (first) { 'use strict'; diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js index ffbe8de995b..c1fbad76dd0 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./first.js'], function (first) { 'use strict'; +define(['./first'], function (first) { 'use strict'; console.log(first); console.log(first); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js index 7ad9926838b..638c64b4bd7 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./first.js'], function (first) { 'use strict'; +define(['./first'], function (first) { 'use strict'; diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js new file mode 100644 index 00000000000..3872987a3f1 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js @@ -0,0 +1,9 @@ +module.exports = { + description: 'avoid facades if possible when using manual chunks', + options: { + input: ['main1', 'main2'], + manualChunks: { + manual: ['main2'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js new file mode 100644 index 00000000000..6b16473382c --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./manual'], function (manual) { 'use strict'; + + console.log('main', manual.reexported); + +}); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/manual.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/manual.js new file mode 100644 index 00000000000..674f42a401c --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/manual.js @@ -0,0 +1,11 @@ +define(['exports'], function (exports) { 'use strict'; + + const value = 42; + + console.log('main2', value); + + exports.reexported = value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main1.js new file mode 100644 index 00000000000..05d27bd0aac --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var manual = require('./manual.js'); + +console.log('main', manual.reexported); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/manual.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/manual.js new file mode 100644 index 00000000000..f7d33362bcc --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/manual.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +const value = 42; + +console.log('main2', value); + +exports.reexported = value; diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/main1.js new file mode 100644 index 00000000000..4023c0017b1 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { reexported as value } from './manual.js'; + +console.log('main', value); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/manual.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/manual.js new file mode 100644 index 00000000000..897452bd66e --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/es/manual.js @@ -0,0 +1,5 @@ +const value = 42; + +console.log('main2', value); + +export { value as reexported }; diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js new file mode 100644 index 00000000000..64e1dc330b9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js @@ -0,0 +1,14 @@ +System.register(['./manual.js'], function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.reexported; + }], + execute: function () { + + console.log('main', value); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/manual.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/manual.js new file mode 100644 index 00000000000..80b775efdee --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/manual.js @@ -0,0 +1,12 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const value = exports('reexported', 42); + + console.log('main2', value); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/dep.js b/test/chunking-form/samples/manual-chunk-avoid-facade/dep.js new file mode 100644 index 00000000000..46d3ca8c61f --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/dep.js @@ -0,0 +1 @@ +export const value = 42; diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/main1.js new file mode 100644 index 00000000000..5da97663c3a --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/main1.js @@ -0,0 +1,3 @@ +import { value } from './dep'; + +console.log('main', value); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/main2.js b/test/chunking-form/samples/manual-chunk-avoid-facade/main2.js new file mode 100644 index 00000000000..868d23fd0a7 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/main2.js @@ -0,0 +1,5 @@ +import {value} from './dep.js'; + +console.log('main2', value); + +export { value as reexported }; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js new file mode 100644 index 00000000000..e77c4240f0f --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js @@ -0,0 +1,11 @@ +module.exports = { + description: 'Creates proper facades if manual chunks contain entry chunks with different alias', + options: { + input: { + main: 'main.js' + }, + manualChunks: { + outer: ['outer'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/generated-outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/generated-outer.js new file mode 100644 index 00000000000..659be70e586 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/generated-outer.js @@ -0,0 +1,11 @@ +define(['exports'], function (exports) { 'use strict'; + + console.log('dep'); + + console.log('main'); + + const value = 42; + + exports.value = value; + +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js new file mode 100644 index 00000000000..bf9d53b546e --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js @@ -0,0 +1,9 @@ +define(['exports', './generated-outer'], function (exports, main) { 'use strict'; + + + + exports.value = main.value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/generated-outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/generated-outer.js new file mode 100644 index 00000000000..fe59aaab6b9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/generated-outer.js @@ -0,0 +1,9 @@ +'use strict'; + +console.log('dep'); + +console.log('main'); + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js new file mode 100644 index 00000000000..d4b7fbb7259 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main = require('./generated-outer.js'); + + + +exports.value = main.value; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/generated-outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/generated-outer.js new file mode 100644 index 00000000000..799f32a0d48 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/generated-outer.js @@ -0,0 +1,7 @@ +console.log('dep'); + +console.log('main'); + +const value = 42; + +export { value as a }; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/main.js new file mode 100644 index 00000000000..5eb7786ffac --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/es/main.js @@ -0,0 +1 @@ +export { a as value } from './generated-outer.js'; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/generated-outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/generated-outer.js new file mode 100644 index 00000000000..7addc0e2fc9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/generated-outer.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('dep'); + + console.log('main'); + + const value = exports('a', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js new file mode 100644 index 00000000000..263739c45e1 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./generated-outer.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('value', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/dep.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/main.js new file mode 100644 index 00000000000..983ead17e5a --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/main.js @@ -0,0 +1,5 @@ +import './dep.js'; + +console.log('main'); + +export const value = 42; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/outer.js new file mode 100644 index 00000000000..26385b8a3c3 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/outer.js @@ -0,0 +1,3 @@ +import './main'; + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js new file mode 100644 index 00000000000..a08d4f85d17 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js @@ -0,0 +1,12 @@ +module.exports = { + description: + 'Identifies the entry chunk with the manual chunk that contains it if the aliases match', + options: { + input: { + main: 'main.js' + }, + manualChunks: { + main: ['outer'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js new file mode 100644 index 00000000000..fc91f027a0e --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['exports'], function (exports) { 'use strict'; + + console.log('dep'); + + console.log('main'); + + const value = 42; + + exports.value = value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js new file mode 100644 index 00000000000..5da9ebd5132 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +console.log('dep'); + +console.log('main'); + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/es/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/es/main.js new file mode 100644 index 00000000000..132b27a8d7c --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/es/main.js @@ -0,0 +1,7 @@ +console.log('dep'); + +console.log('main'); + +const value = 42; + +export { value }; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js new file mode 100644 index 00000000000..6c03a5d5fb7 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('dep'); + + console.log('main'); + + const value = exports('value', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/dep.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/main.js new file mode 100644 index 00000000000..983ead17e5a --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/main.js @@ -0,0 +1,5 @@ +import './dep.js'; + +console.log('main'); + +export const value = 42; diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/outer.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/outer.js new file mode 100644 index 00000000000..26385b8a3c3 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/outer.js @@ -0,0 +1,3 @@ +import './main'; + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js new file mode 100644 index 00000000000..d7c6eea6eba --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js @@ -0,0 +1,11 @@ +module.exports = { + description: 'Creates proper facades if manual chunks are entry chunks with different alias', + options: { + input: { + main: 'main.js' + }, + manualChunks: { + other: ['main'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/generated-other.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/generated-other.js new file mode 100644 index 00000000000..659be70e586 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/generated-other.js @@ -0,0 +1,11 @@ +define(['exports'], function (exports) { 'use strict'; + + console.log('dep'); + + console.log('main'); + + const value = 42; + + exports.value = value; + +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js new file mode 100644 index 00000000000..c5a19397b7d --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js @@ -0,0 +1,9 @@ +define(['exports', './generated-other'], function (exports, main) { 'use strict'; + + + + exports.value = main.value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/generated-other.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/generated-other.js new file mode 100644 index 00000000000..fe59aaab6b9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/generated-other.js @@ -0,0 +1,9 @@ +'use strict'; + +console.log('dep'); + +console.log('main'); + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js new file mode 100644 index 00000000000..830a223da0b --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main = require('./generated-other.js'); + + + +exports.value = main.value; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/generated-other.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/generated-other.js new file mode 100644 index 00000000000..799f32a0d48 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/generated-other.js @@ -0,0 +1,7 @@ +console.log('dep'); + +console.log('main'); + +const value = 42; + +export { value as a }; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/main.js new file mode 100644 index 00000000000..604a3884871 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/es/main.js @@ -0,0 +1 @@ +export { a as value } from './generated-other.js'; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/generated-other.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/generated-other.js new file mode 100644 index 00000000000..7addc0e2fc9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/generated-other.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('dep'); + + console.log('main'); + + const value = exports('a', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js new file mode 100644 index 00000000000..335cd2bb0ab --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./generated-other.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('value', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/dep.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/main.js new file mode 100644 index 00000000000..983ead17e5a --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/main.js @@ -0,0 +1,5 @@ +import './dep.js'; + +console.log('main'); + +export const value = 42; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js new file mode 100644 index 00000000000..f86733b33a7 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js @@ -0,0 +1,12 @@ +module.exports = { + description: + 'Identifies the entry chunk with the manual chunk that has the same entry if the aliases match', + options: { + input: { + main: 'main.js' + }, + manualChunks: { + main: ['main'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js new file mode 100644 index 00000000000..fc91f027a0e --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['exports'], function (exports) { 'use strict'; + + console.log('dep'); + + console.log('main'); + + const value = 42; + + exports.value = value; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js new file mode 100644 index 00000000000..5da9ebd5132 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +console.log('dep'); + +console.log('main'); + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/es/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/es/main.js new file mode 100644 index 00000000000..132b27a8d7c --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/es/main.js @@ -0,0 +1,7 @@ +console.log('dep'); + +console.log('main'); + +const value = 42; + +export { value }; diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js new file mode 100644 index 00000000000..6c03a5d5fb7 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('dep'); + + console.log('main'); + + const value = exports('value', 42); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/dep.js b/test/chunking-form/samples/manual-chunk-is-entry-match/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/main.js new file mode 100644 index 00000000000..983ead17e5a --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/main.js @@ -0,0 +1,5 @@ +import './dep.js'; + +console.log('main'); + +export const value = 42; diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_config.js b/test/chunking-form/samples/manual-chunks-different-nested/_config.js new file mode 100644 index 00000000000..ef32850d199 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_config.js @@ -0,0 +1,11 @@ +module.exports = { + description: 'manual chunks can have other manual chunks as dependencies', + options: { + input: ['main.js'], + manualChunks: { + 'manual-outer': ['outer.js'], + 'manual-inner': ['inner.js'], + 'manual-middle': ['middle.js'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js new file mode 100644 index 00000000000..5068b5fd910 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + console.log('inner'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js new file mode 100644 index 00000000000..d685b7251a8 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js @@ -0,0 +1,5 @@ +define(['./generated-manual-inner'], function (__chunk_1) { 'use strict'; + + console.log('middle'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js new file mode 100644 index 00000000000..13ebf2a438d --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js @@ -0,0 +1,5 @@ +define(['./generated-manual-middle'], function (__chunk_2) { 'use strict'; + + console.log('outer'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js new file mode 100644 index 00000000000..6bc9ac6c053 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-manual-inner', './generated-manual-middle', './generated-manual-outer'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; + + console.log('main'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js new file mode 100644 index 00000000000..02ef883da4e --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('inner'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js new file mode 100644 index 00000000000..77da3dd71c1 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./generated-manual-inner.js'); + +console.log('middle'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js new file mode 100644 index 00000000000..8a4efba721e --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./generated-manual-middle.js'); + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/main.js new file mode 100644 index 00000000000..7b5cf110cf4 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +require('./generated-manual-inner.js'); +require('./generated-manual-middle.js'); +require('./generated-manual-outer.js'); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-inner.js new file mode 100644 index 00000000000..8e1a29ca97f --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-inner.js @@ -0,0 +1 @@ +console.log('inner'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-middle.js new file mode 100644 index 00000000000..247a57bae80 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-middle.js @@ -0,0 +1,3 @@ +import './generated-manual-inner.js'; + +console.log('middle'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-outer.js new file mode 100644 index 00000000000..f348b38752c --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/generated-manual-outer.js @@ -0,0 +1,3 @@ +import './generated-manual-middle.js'; + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/main.js new file mode 100644 index 00000000000..de3b67e6685 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/es/main.js @@ -0,0 +1,5 @@ +import './generated-manual-inner.js'; +import './generated-manual-middle.js'; +import './generated-manual-outer.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js new file mode 100644 index 00000000000..bd48d6dccbe --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('inner'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js new file mode 100644 index 00000000000..b08dca795bb --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js @@ -0,0 +1,11 @@ +System.register(['./generated-manual-inner.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + console.log('middle'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js new file mode 100644 index 00000000000..1bb210ffd84 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js @@ -0,0 +1,11 @@ +System.register(['./generated-manual-middle.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + console.log('outer'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js new file mode 100644 index 00000000000..806c05886bf --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js @@ -0,0 +1,11 @@ +System.register(['./generated-manual-inner.js', './generated-manual-middle.js', './generated-manual-outer.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}, function () {}, function () {}], + execute: function () { + + console.log('main'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/inner.js b/test/chunking-form/samples/manual-chunks-different-nested/inner.js new file mode 100644 index 00000000000..8e1a29ca97f --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/inner.js @@ -0,0 +1 @@ +console.log('inner'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/main.js b/test/chunking-form/samples/manual-chunks-different-nested/main.js new file mode 100644 index 00000000000..b46ebb222d8 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/main.js @@ -0,0 +1,3 @@ +import './outer.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/middle.js b/test/chunking-form/samples/manual-chunks-different-nested/middle.js new file mode 100644 index 00000000000..0073259087e --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/middle.js @@ -0,0 +1,3 @@ +import './inner.js'; + +console.log('middle'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/outer.js b/test/chunking-form/samples/manual-chunks-different-nested/outer.js new file mode 100644 index 00000000000..c77196cec49 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-different-nested/outer.js @@ -0,0 +1,3 @@ +import './middle.js'; + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic2.js index d61d9fe71fc..89b1bf75c5c 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-dynamic.js'], function (exports, dynamic) { 'use strict'; +define(['exports', './generated-dynamic'], function (exports, dynamic) { 'use strict'; diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic3.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic3.js index d8b85da29fc..384c6292ada 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic3.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic3.js @@ -1,4 +1,4 @@ -define(['exports', './generated-dynamic.js'], function (exports, dynamic) { 'use strict'; +define(['exports', './generated-dynamic'], function (exports, dynamic) { 'use strict'; diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js index 3c9d3dbf487..9558e0b7837 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require', './generated-dynamic.js'], function (require, dynamic) { 'use strict'; +define(['require', './generated-dynamic'], function (require, dynamic) { 'use strict'; - Promise.all([new Promise(function (resolve, reject) { require(['./generated-dynamic.js'], resolve, reject) }), new Promise(function (resolve, reject) { require(['./generated-dynamic2.js'], resolve, reject) }), new Promise(function (resolve, reject) { require(['./generated-dynamic3.js'], resolve, reject) })]).then( + Promise.all([new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }), new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }), new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject) })]).then( results => console.log(results, dynamic.DEP) ); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic1.js new file mode 100644 index 00000000000..b0ba64ff7d0 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic1.js @@ -0,0 +1,8 @@ +define(['exports', './generated-dynamic'], function (exports, dynamic) { 'use strict'; + + + + exports.DYNAMIC_A = dynamic.DYNAMIC_B; + exports.DYNAMIC_B = dynamic.DYNAMIC_A; + +}); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic2.js deleted file mode 100644 index 4d555970c86..00000000000 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic2.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports', './generated-dynamic.js'], function (exports, dynamic) { 'use strict'; - - - - exports.DYNAMIC_A = dynamic.DYNAMIC_B; - exports.DYNAMIC_B = dynamic.DYNAMIC_A; - -}); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js index 0e20039a5ed..ca2fb108442 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2.js'], resolve, reject) }).then(result => console.log(result)); - new Promise(function (resolve, reject) { require(['./generated-dynamic.js'], resolve, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(result => console.log(result)); }); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic2.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic1.js similarity index 100% rename from test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic2.js rename to test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic1.js diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js index 0a28239769b..ad1107c73a0 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js @@ -1,4 +1,4 @@ 'use strict'; -Promise.resolve(require('./generated-dynamic2.js')).then(result => console.log(result)); +Promise.resolve(require('./generated-dynamic1.js')).then(result => console.log(result)); Promise.resolve(require('./generated-dynamic.js')).then(result => console.log(result)); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic1.js similarity index 100% rename from test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic2.js rename to test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic1.js diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/main.js index d191126a7d3..56b8f8a4d28 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/main.js @@ -1,2 +1,2 @@ -import('./generated-dynamic2.js').then(result => console.log(result)); +import('./generated-dynamic1.js').then(result => console.log(result)); import('./generated-dynamic.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic1.js similarity index 100% rename from test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic2.js rename to test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic1.js diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js index fa189fe4b60..f2c39c717c5 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-dynamic2.js').then(result => console.log(result)); + module.import('./generated-dynamic1.js').then(result => console.log(result)); module.import('./generated-dynamic.js').then(result => console.log(result)); } diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js index bf87287061c..7ade37c39c9 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js @@ -1,5 +1,5 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic.js'], resolve, reject) }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); }); diff --git a/test/chunking-form/samples/manual-chunks-nested/_config.js b/test/chunking-form/samples/manual-chunks-nested/_config.js new file mode 100644 index 00000000000..a617f04b21f --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_config.js @@ -0,0 +1,9 @@ +module.exports = { + description: 'manual chunks can contain nested modules', + options: { + input: ['main.js'], + manualChunks: { + manual: ['middle.js', 'inner.js', 'outer.js'] + } + } +}; diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js new file mode 100644 index 00000000000..e81d58f94e9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js @@ -0,0 +1,9 @@ +define(function () { 'use strict'; + + console.log('inner'); + + console.log('middle'); + + console.log('outer'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js new file mode 100644 index 00000000000..4cfe600e533 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-manual'], function (__chunk_1) { 'use strict'; + + console.log('main'); + +}); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/generated-manual.js new file mode 100644 index 00000000000..3ce3b1a69a1 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/generated-manual.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('inner'); + +console.log('middle'); + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/main.js new file mode 100644 index 00000000000..f679e51bff2 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./generated-manual.js'); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/es/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/es/generated-manual.js new file mode 100644 index 00000000000..7abdcd7f151 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/es/generated-manual.js @@ -0,0 +1,5 @@ +console.log('inner'); + +console.log('middle'); + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/es/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/es/main.js new file mode 100644 index 00000000000..ddeb648f149 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/es/main.js @@ -0,0 +1,3 @@ +import './generated-manual.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js new file mode 100644 index 00000000000..6b13800502d --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('inner'); + + console.log('middle'); + + console.log('outer'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js new file mode 100644 index 00000000000..34f054c95fd --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js @@ -0,0 +1,11 @@ +System.register(['./generated-manual.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + console.log('main'); + + } + }; +}); diff --git a/test/chunking-form/samples/manual-chunks-nested/inner.js b/test/chunking-form/samples/manual-chunks-nested/inner.js new file mode 100644 index 00000000000..8e1a29ca97f --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/inner.js @@ -0,0 +1 @@ +console.log('inner'); diff --git a/test/chunking-form/samples/manual-chunks-nested/main.js b/test/chunking-form/samples/manual-chunks-nested/main.js new file mode 100644 index 00000000000..b46ebb222d8 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/main.js @@ -0,0 +1,3 @@ +import './outer.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-nested/middle.js b/test/chunking-form/samples/manual-chunks-nested/middle.js new file mode 100644 index 00000000000..0073259087e --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/middle.js @@ -0,0 +1,3 @@ +import './inner.js'; + +console.log('middle'); diff --git a/test/chunking-form/samples/manual-chunks-nested/outer.js b/test/chunking-form/samples/manual-chunks-nested/outer.js new file mode 100644 index 00000000000..c77196cec49 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-nested/outer.js @@ -0,0 +1,3 @@ +import './middle.js'; + +console.log('outer'); diff --git a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js index db8359837ef..165b82f137a 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js +++ b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js @@ -1,4 +1,4 @@ -define(['exports', './generated-lib1.js'], function (exports, __chunk_2) { 'use strict'; +define(['exports', './generated-lib1'], function (exports, __chunk_2) { 'use strict'; function fn () { console.log('lib2 fn'); diff --git a/test/chunking-form/samples/manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks/_expected/amd/main.js index 9b6de0df0dd..beeca173eae 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./generated-deps2and3.js', './generated-lib1.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-deps2and3', './generated-lib1'], function (__chunk_1, __chunk_2) { 'use strict'; function fn () { console.log('dep1 fn'); diff --git a/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js b/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js index 6b26a92f175..99e530fa9c8 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js @@ -1,2 +1,2 @@ -define(['./dep.js'],function(dep){'use strict';dep.missingFn(); +define(['./dep'],function(dep){'use strict';dep.missingFn(); dep.x(dep.missingFn);}); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js index 771a3512c76..8fd12daee88 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./dep1.js', './dep2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./dep1', './dep2'], function (__chunk_1, __chunk_2) { 'use strict'; console.log(__chunk_1.missing1, __chunk_2.missing2, __chunk_2.previousShimmedExport); diff --git a/test/chunking-form/samples/missing-export/_expected/amd/main.js b/test/chunking-form/samples/missing-export/_expected/amd/main.js index bbdd8227b07..45cf3ece8f6 100644 --- a/test/chunking-form/samples/missing-export/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./dep.js'], function (dep) { 'use strict'; +define(['./dep'], function (dep) { 'use strict'; dep.missingFn(); dep.x(dep.missingFn, dep.missingFn); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js index 38b0814fc10..41ad8f756f1 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { 'use strict'; console.log(__chunk_1.num + __chunk_2.num); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js index 0907bafb19c..fb0872ff799 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk2.js', './generated-chunk3.js'], function (__chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk2', './generated-chunk3'], function (__chunk_2, __chunk_3) { 'use strict'; console.log(__chunk_2.num + __chunk_3.num); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js index 28d1860b9a0..3317ef0bd37 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk3.js'], function (__chunk_1, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk3'], function (__chunk_1, __chunk_3) { 'use strict'; console.log(__chunk_1.num + __chunk_3.num); diff --git a/test/chunking-form/samples/multiple-entry-points/_config.js b/test/chunking-form/samples/multiple-entry-points/_config.js new file mode 100644 index 00000000000..e8f588be523 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_config.js @@ -0,0 +1,10 @@ +module.exports = { + description: 'handles multiple entry points with a shared dependency', + options: { + input: ['main', 'other'], + output: { + chunkFileNames: 'chunks/[name].js' + } + }, + runAmd: true +}; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/chunk.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/chunk.js new file mode 100644 index 00000000000..65e59158953 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + const sharedValue = 'shared'; + + exports.sharedValue = sharedValue; + +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js new file mode 100644 index 00000000000..e8d75a79e14 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./chunks/chunk'], function (__chunk_1) { 'use strict'; + + assert.equal(__chunk_1.sharedValue, 'shared'); + +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js new file mode 100644 index 00000000000..1c4346af7f8 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js @@ -0,0 +1,9 @@ +define(['exports', './chunks/chunk'], function (exports, __chunk_1) { 'use strict'; + + + + exports.sharedValue = __chunk_1.sharedValue; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/chunk.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/chunk.js new file mode 100644 index 00000000000..5a6d40af489 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +const sharedValue = 'shared'; + +exports.sharedValue = sharedValue; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js new file mode 100644 index 00000000000..276798be0e4 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_1 = require('./chunks/chunk.js'); + +assert.equal(__chunk_1.sharedValue, 'shared'); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js new file mode 100644 index 00000000000..bdb6a8f4c55 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var __chunk_1 = require('./chunks/chunk.js'); + + + +exports.sharedValue = __chunk_1.sharedValue; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/chunk.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/chunk.js new file mode 100644 index 00000000000..94dca2d35b3 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/chunk.js @@ -0,0 +1,3 @@ +const sharedValue = 'shared'; + +export { sharedValue as a }; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js new file mode 100644 index 00000000000..793646ecb4c --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js @@ -0,0 +1,3 @@ +import { a as sharedValue } from './chunks/chunk.js'; + +assert.equal(sharedValue, 'shared'); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js new file mode 100644 index 00000000000..8e3d65b216d --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js @@ -0,0 +1 @@ +export { a as sharedValue } from './chunks/chunk.js'; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/chunk.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/chunk.js new file mode 100644 index 00000000000..f4a5045db1a --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const sharedValue = exports('a', 'shared'); + + } + }; +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js new file mode 100644 index 00000000000..11b81781952 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./chunks/chunk.js'], function (exports, module) { + 'use strict'; + var sharedValue; + return { + setters: [function (module) { + sharedValue = module.a; + }], + execute: function () { + + assert.equal(sharedValue, 'shared'); + + } + }; +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js new file mode 100644 index 00000000000..81bcc1cf806 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js @@ -0,0 +1,13 @@ +System.register(['./chunks/chunk.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('sharedValue', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/multiple-entry-points/main.js b/test/chunking-form/samples/multiple-entry-points/main.js new file mode 100644 index 00000000000..39653f0b622 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/main.js @@ -0,0 +1,3 @@ +import { sharedValue } from './shared'; + +assert.equal(sharedValue, 'shared'); diff --git a/test/chunking-form/samples/multiple-entry-points/other.js b/test/chunking-form/samples/multiple-entry-points/other.js new file mode 100644 index 00000000000..39347a6c304 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/other.js @@ -0,0 +1 @@ +export { sharedValue } from './shared'; diff --git a/test/chunking-form/samples/multiple-entry-points/shared.js b/test/chunking-form/samples/multiple-entry-points/shared.js new file mode 100644 index 00000000000..7a5200e8ec7 --- /dev/null +++ b/test/chunking-form/samples/multiple-entry-points/shared.js @@ -0,0 +1 @@ +export const sharedValue = 'shared'; diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js index 5dcc1bb7e82..40c8ca3127f 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./main1.js'], function (main1) { 'use strict'; +define(['./main1'], function (main1) { 'use strict'; console.log( main1.p ); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js rename to test/chunking-form/samples/namespace-object-import/_expected/amd/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js index 2fef00ce740..585aa959563 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-main2.js'], function (main2) { 'use strict'; +define(['./generated-chunk'], function (main2) { 'use strict'; console.log(main2.a); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js index 9558090c768..ab807b27492 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-main2.js'], function (exports, main2) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, main2) { 'use strict'; diff --git a/test/chunking-form/samples/namespace-object-import/_expected/cjs/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/cjs/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-object-import/_expected/cjs/generated-main2.js rename to test/chunking-form/samples/namespace-object-import/_expected/cjs/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main1.js index 76c02e55904..09ee475014d 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main1.js @@ -1,6 +1,6 @@ 'use strict'; -var main2 = require('./generated-main2.js'); +var main2 = require('./generated-chunk.js'); console.log(main2.a); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js index 688bfd2c811..ad7ea0780cc 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); -var main2 = require('./generated-main2.js'); +var main2 = require('./generated-chunk.js'); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/es/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/es/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-object-import/_expected/es/generated-main2.js rename to test/chunking-form/samples/namespace-object-import/_expected/es/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-object-import/_expected/es/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/es/main1.js index 2fc8d5876d7..50d073052f2 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/es/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/es/main1.js @@ -1,4 +1,4 @@ -import { a, b as main2 } from './generated-main2.js'; +import { a, b as main2 } from './generated-chunk.js'; console.log(a); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/es/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/es/main2.js index 8c213203342..086197544e8 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/es/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/es/main2.js @@ -1 +1 @@ -export { a, c as b } from './generated-main2.js'; +export { a, c as b } from './generated-chunk.js'; diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/system/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js rename to test/chunking-form/samples/namespace-object-import/_expected/system/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js index d39745288cb..f067ddbe178 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function (exports, module) { +System.register(['./generated-chunk.js'], function (exports, module) { 'use strict'; var a, main2; return { diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js index f4265e986bc..fb13e62e855 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function (exports, module) { +System.register(['./generated-chunk.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk2.js index 72fef366cb5..2d9441cbf54 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk2.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-chunk.js', 'external'], function (exports, __chunk_1, external) { 'use strict'; +define(['exports', './generated-chunk', 'external'], function (exports, __chunk_1, external) { 'use strict'; console.log(external.reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js index 3d3a5144d0b..51772b15d56 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', 'external', './generated-chunk2.js'], function (__chunk_1, external, __chunk_2) { 'use strict'; +define(['./generated-chunk', 'external', './generated-chunk2'], function (__chunk_1, external, __chunk_2) { 'use strict'; console.log(__chunk_2.lib); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js index 3ed815db8ae..cf6f7207880 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', 'external', './generated-chunk2.js'], function (__chunk_1, external, __chunk_2) { 'use strict'; +define(['./generated-chunk', 'external', './generated-chunk2'], function (__chunk_1, external, __chunk_2) { 'use strict'; console.log(__chunk_1.reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js index 7829aea9079..80869868e48 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-chunk.js similarity index 69% rename from test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js rename to test/chunking-form/samples/namespace-reexports/_expected/amd/generated-chunk.js index cbc8db134cb..1337d2c2adb 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-chunk.js @@ -1,4 +1,4 @@ -define(['exports', './hsl2hsv.js'], function (exports, hsl2hsv$1) { 'use strict'; +define(['exports', './hsl2hsv'], function (exports, hsl2hsv$1) { 'use strict'; var hsl2hsv = 'asdf'; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js index c51c47b4df8..403b5f70f60 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js @@ -1,4 +1,4 @@ -define(['exports', './hsl2hsv.js', './generated-index.js'], function (exports, hsl2hsv$1, index) { 'use strict'; +define(['exports', './hsl2hsv', './generated-chunk'], function (exports, hsl2hsv$1, index) { 'use strict'; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js index 71dd02c2f28..95dbd44f35d 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports', './hsl2hsv.js', './generated-index.js'], function (exports, hsl2hsv$1, index) { 'use strict'; +define(['exports', './hsl2hsv', './generated-chunk'], function (exports, hsl2hsv$1, index) { 'use strict'; console.log(hsl2hsv$1.p); var main = new Map(Object.entries(index.lib)); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js rename to test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js b/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js index cd95edf7d26..dc695449285 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var hsl2hsv$1 = require('./hsl2hsv.js'); -require('./generated-index.js'); +require('./generated-chunk.js'); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/cjs/main.js b/test/chunking-form/samples/namespace-reexports/_expected/cjs/main.js index f56ee42c2ad..19c3b6a8ff6 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/main.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var hsl2hsv$1 = require('./hsl2hsv.js'); -var index = require('./generated-index.js'); +var index = require('./generated-chunk.js'); console.log(hsl2hsv$1.p); var main = new Map(Object.entries(index.lib)); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/es/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/es/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-reexports/_expected/es/generated-index.js rename to test/chunking-form/samples/namespace-reexports/_expected/es/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-reexports/_expected/es/index.js b/test/chunking-form/samples/namespace-reexports/_expected/es/index.js index 18fe44189f4..bd43de91785 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/index.js @@ -1,2 +1,2 @@ export { default as hsl2hsv } from './hsl2hsv.js'; -import './generated-index.js'; +import './generated-chunk.js'; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/es/main.js b/test/chunking-form/samples/namespace-reexports/_expected/es/main.js index a41e4fe2ee9..d1c06ab9b87 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/main.js @@ -1,5 +1,5 @@ import { p } from './hsl2hsv.js'; -import { a as lib } from './generated-index.js'; +import { a as lib } from './generated-chunk.js'; console.log(p); var main = new Map(Object.entries(lib)); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/system/generated-chunk.js similarity index 100% rename from test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js rename to test/chunking-form/samples/namespace-reexports/_expected/system/generated-chunk.js diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/index.js b/test/chunking-form/samples/namespace-reexports/_expected/system/index.js index 6fcfedd47f1..f3063b0b8f0 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/index.js @@ -1,4 +1,4 @@ -System.register(['./hsl2hsv.js', './generated-index.js'], function (exports, module) { +System.register(['./hsl2hsv.js', './generated-chunk.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/main.js b/test/chunking-form/samples/namespace-reexports/_expected/system/main.js index f76be46c34c..30e0cc95052 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./hsl2hsv.js', './generated-index.js'], function (exports, module) { +System.register(['./hsl2hsv.js', './generated-chunk.js'], function (exports, module) { 'use strict'; var p, lib; return { diff --git a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js index 281c65d538f..b5a0e083248 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; __chunk_1.Other.doSomething(); __chunk_1.Broken.doSomething(); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js index 9d265d80d18..e2d4985dc13 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; __chunk_1.Other.doSomething(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk2.js index c31c4ebb3c6..0a3e8b14711 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk2.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; function foo() { console.log('foo'); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk3.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk3.js index 78fb02a11f2..6d8f8bf796c 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk3.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-chunk3.js @@ -1,4 +1,4 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; function bar() { console.log('bar'); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js index 906d540ccd9..116300fc7e0 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js'], function (__chunk_1, __chunk_2) { 'use strict'; +define(['./generated-chunk', './generated-chunk2'], function (__chunk_1, __chunk_2) { 'use strict'; __chunk_2.foo(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js index 35f5d479917..0f2eec7ca6d 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk2.js', './generated-chunk3.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk2', './generated-chunk3'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; __chunk_2.foo(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js index a9bad503da0..28477f9fa63 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js', './generated-chunk3.js'], function (__chunk_1, __chunk_3) { 'use strict'; +define(['./generated-chunk', './generated-chunk3'], function (__chunk_1, __chunk_3) { 'use strict'; __chunk_3.bar(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js similarity index 81% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js index 986051119fc..be41dd73ba2 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); console.log('dynamic1'); }); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js similarity index 81% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk2.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js index 1b30cdd57b8..109eafa86de 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk2.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk3.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject) }); console.log('dynamic2'); }); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js similarity index 81% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk3.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js index 429e468a258..87c99b617b8 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk3.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk4.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic4'], resolve, reject) }); console.log('dynamic3'); }); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js similarity index 81% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk4.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js index fd70ed340c9..eed6272d3aa 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk4.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk5.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic5'], resolve, reject) }); console.log('dynamic4'); }); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js similarity index 100% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-chunk5.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js index c8a31868ae7..317bb5f6206 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js @@ -1,6 +1,6 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); console.log('main'); }); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk.js deleted file mode 100644 index b09e30b302a..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -Promise.resolve(require('./generated-chunk2.js')); -console.log('dynamic1'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk2.js deleted file mode 100644 index 7d9a89fbaf2..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk2.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -Promise.resolve(require('./generated-chunk3.js')); -console.log('dynamic2'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk3.js deleted file mode 100644 index 88071473204..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk3.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -Promise.resolve(require('./generated-chunk4.js')); -console.log('dynamic3'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk4.js deleted file mode 100644 index 214f7ec28ca..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk4.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -Promise.resolve(require('./generated-chunk5.js')); -console.log('dynamic4'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic1.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic1.js new file mode 100644 index 00000000000..2e429ed58c4 --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic1.js @@ -0,0 +1,4 @@ +'use strict'; + +Promise.resolve(require('./generated-dynamic2.js')); +console.log('dynamic1'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic2.js new file mode 100644 index 00000000000..a9896858b47 --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic2.js @@ -0,0 +1,4 @@ +'use strict'; + +Promise.resolve(require('./generated-dynamic3.js')); +console.log('dynamic2'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic3.js new file mode 100644 index 00000000000..1e884c8b3db --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic3.js @@ -0,0 +1,4 @@ +'use strict'; + +Promise.resolve(require('./generated-dynamic4.js')); +console.log('dynamic3'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic4.js new file mode 100644 index 00000000000..aaafd7e6277 --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic4.js @@ -0,0 +1,4 @@ +'use strict'; + +Promise.resolve(require('./generated-dynamic5.js')); +console.log('dynamic4'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic5.js similarity index 100% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-chunk5.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/generated-dynamic5.js diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/main.js index 5b3ffb7c6e4..dcea8717078 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/cjs/main.js @@ -1,4 +1,4 @@ 'use strict'; -Promise.resolve(require('./generated-chunk.js')); +Promise.resolve(require('./generated-dynamic1.js')); console.log('main'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk.js deleted file mode 100644 index 04888332178..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./generated-chunk2.js'); -console.log('dynamic1'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk2.js deleted file mode 100644 index f43111637d5..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk2.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./generated-chunk3.js'); -console.log('dynamic2'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk3.js deleted file mode 100644 index b830dba19da..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk3.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./generated-chunk4.js'); -console.log('dynamic3'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk4.js deleted file mode 100644 index 0ea2bc62e07..00000000000 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk4.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./generated-chunk5.js'); -console.log('dynamic4'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic1.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic1.js new file mode 100644 index 00000000000..2db19197d94 --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic1.js @@ -0,0 +1,2 @@ +import('./generated-dynamic2.js'); +console.log('dynamic1'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic2.js new file mode 100644 index 00000000000..544cfec1ef5 --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic2.js @@ -0,0 +1,2 @@ +import('./generated-dynamic3.js'); +console.log('dynamic2'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic3.js new file mode 100644 index 00000000000..53e4eba921e --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic3.js @@ -0,0 +1,2 @@ +import('./generated-dynamic4.js'); +console.log('dynamic3'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic4.js new file mode 100644 index 00000000000..db04880a96f --- /dev/null +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic4.js @@ -0,0 +1,2 @@ +import('./generated-dynamic5.js'); +console.log('dynamic4'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic5.js similarity index 100% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-chunk5.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/es/generated-dynamic5.js diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/main.js index 0d08731bb46..eb9bbf2acfb 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/es/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/es/main.js @@ -1,2 +1,2 @@ -import('./generated-chunk.js'); +import('./generated-dynamic1.js'); console.log('main'); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js similarity index 75% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js index 10450928e02..4885888ccf8 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk2.js'); + module.import('./generated-dynamic2.js'); console.log('dynamic1'); } diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js similarity index 75% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js index 8a981954622..186a6116c10 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk2.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk3.js'); + module.import('./generated-dynamic3.js'); console.log('dynamic2'); } diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js similarity index 75% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk3.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js index 913ec0b469d..96e85221924 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk3.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk4.js'); + module.import('./generated-dynamic4.js'); console.log('dynamic3'); } diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js similarity index 75% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk4.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js index 928a453dd1c..d2859ce1ff5 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk4.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk5.js'); + module.import('./generated-dynamic5.js'); console.log('dynamic4'); } diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js similarity index 100% rename from test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-chunk5.js rename to test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js index 61f5627b5c3..356dfbd0378 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js @@ -3,7 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-chunk.js'); + module.import('./generated-dynamic1.js'); console.log('main'); } diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js index 2f18de25c3c..598a5312942 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js @@ -1,4 +1,4 @@ -define(['exports', '../other.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', '../other'], function (exports, __chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js index 84e944e5ced..005be973ac7 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js @@ -1,4 +1,4 @@ -define(['exports', 'external', './other.js', './_virtual/_commonjs-external-external', './_virtual/other.js'], function (exports, external, __chunk_1, __chunk_2, __chunk_3) { 'use strict'; +define(['exports', 'external', './other', './_virtual/_commonjs-external-external', './_virtual/other'], function (exports, external, __chunk_1, __chunk_2, __chunk_3) { 'use strict'; external = external && external.hasOwnProperty('default') ? external['default'] : external; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js index a8edbd239a5..d266f1602d4 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['external', './commonjs.js'], function (external, __chunk_4) { 'use strict'; +define(['external', './commonjs'], function (external, __chunk_4) { 'use strict'; external = external && external.hasOwnProperty('default') ? external['default'] : external; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js index 83b30a7c2ee..2ec310c64aa 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js @@ -1,5 +1,5 @@ define(['require'], function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./dynamic-included.js'], resolve, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./dynamic-included'], resolve, reject) }).then(result => console.log(result)); }); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js index 0788bf47212..c298602724e 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js @@ -1,4 +1,4 @@ -define(['exports', './m2.js', './m3.js'], function (exports, __chunk_1, __chunk_2) { 'use strict'; +define(['exports', './m2', './m3'], function (exports, __chunk_1, __chunk_2) { 'use strict'; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js index d2ddab26e51..72e7481571d 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./m1.js'], function (__chunk_3) { 'use strict'; +define(['./m1'], function (__chunk_3) { 'use strict'; console.log(__chunk_3); diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js index ec2c914ddc2..1ed84f69b0f 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./two.js'], function (__chunk_1) { 'use strict'; +define(['./two'], function (__chunk_1) { 'use strict'; window.APP = { a: __chunk_1.default }; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js index 8007ede60f3..eca24c0e300 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['exports', './dep.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './dep'], function (exports, __chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js index d02f9269af5..ce0c6142f0d 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['exports', './dep.js'], function (exports, __chunk_1) { 'use strict'; +define(['exports', './dep'], function (exports, __chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js index a80d55726c2..35ea0e4c3f7 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./dep2.js'], function (__chunk_1) { 'use strict'; +define(['./dep2'], function (__chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js index cca8c1fcfa9..0562844ec4c 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js @@ -1,4 +1,4 @@ -define(['../dep.js'], function (__chunk_1) { 'use strict'; +define(['../dep'], function (__chunk_1) { 'use strict'; class Main { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js index 5d99aeae9fe..babc3674287 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js @@ -1,4 +1,4 @@ -define(['exports', '../lib/lib2.js'], function (exports, __chunk_2) { 'use strict'; +define(['exports', '../lib/lib2'], function (exports, __chunk_2) { 'use strict'; function fn () { __chunk_2.fn(); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js index 4b2f9d41fe8..b3a7e253194 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js @@ -1,4 +1,4 @@ -define(['exports', '../lib/lib1.js'], function (exports, __chunk_4) { 'use strict'; +define(['exports', '../lib/lib1'], function (exports, __chunk_4) { 'use strict'; function fn () { __chunk_4.fn(); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js b/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js index 260cfa9dfef..59c09092c0b 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./deps/dep1.js', './deps/dep2.js'], function (__chunk_1, __chunk_3) { 'use strict'; +define(['./deps/dep1', './deps/dep2'], function (__chunk_1, __chunk_3) { 'use strict'; class Main1 { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js b/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js index 6e00984a2d4..4c0aa3659bf 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./deps/dep2.js', './deps/dep3.js'], function (__chunk_3, __chunk_5) { 'use strict'; +define(['./deps/dep2', './deps/dep3'], function (__chunk_3, __chunk_5) { 'use strict'; class Main2 { constructor () { diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js index e80b94da055..f1a34bad61f 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js index 7829aea9079..80869868e48 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js index 7829aea9079..80869868e48 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-chunk2.js deleted file mode 100644 index 11ea24da7fa..00000000000 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports', './generated-chunk.js'], function (exports, __chunk_1) { 'use strict'; - - var lazy = () => __chunk_1.v1; - - exports.default = lazy; - -}); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js new file mode 100644 index 00000000000..e42b35f00ff --- /dev/null +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js @@ -0,0 +1,7 @@ +define(['exports', './generated-chunk'], function (exports, __chunk_1) { 'use strict'; + + var lazy = () => __chunk_1.v1; + + exports.default = lazy; + +}); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js index f0e05ca8570..a5b743a2ca4 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require', 'exports', './generated-chunk.js'], function (require, exports, __chunk_1) { 'use strict'; +define(['require', 'exports', './generated-chunk'], function (require, exports, __chunk_1) { 'use strict'; - const lazy = new Promise(function (resolve, reject) { require(['./generated-chunk2.js'], resolve, reject) }); + const lazy = new Promise(function (resolve, reject) { require(['./generated-lazy'], resolve, reject) }); exports.v1 = __chunk_1.v1; exports.v10 = __chunk_1.v10; diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/generated-lazy.js similarity index 100% rename from test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/generated-chunk2.js rename to test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/generated-lazy.js diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js index 4687a5bb309..202e70c12c0 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js @@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var __chunk_1 = require('./generated-chunk.js'); -const lazy = Promise.resolve(require('./generated-chunk2.js')); +const lazy = Promise.resolve(require('./generated-lazy.js')); exports.v1 = __chunk_1.v1; exports.v10 = __chunk_1.v10; diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-chunk2.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js similarity index 100% rename from test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-chunk2.js rename to test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/es/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/es/main.js index 9820c00783c..8ce7e5984df 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/es/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/es/main.js @@ -1,5 +1,5 @@ export { a as v1, j as v10, aJ as v100, aK as v101, aL as v102, aM as v103, aN as v104, aO as v105, aP as v106, aQ as v107, aR as v108, aS as v109, k as v11, aT as v110, aU as v111, aV as v112, aW as v113, aX as v114, aY as v115, aZ as v116, a_ as v117, a$ as v118, b0 as v119, l as v12, b1 as v120, b2 as v121, b3 as v122, b4 as v123, b5 as v124, b6 as v125, b7 as v126, b8 as v127, b9 as v128, ba as v129, m as v13, bb as v130, bc as v131, bd as v132, be as v133, bf as v134, bg as v135, bh as v136, bi as v137, bj as v138, bk as v139, n as v14, bl as v140, bm as v141, bn as v142, bo as v143, bp as v144, bq as v145, br as v146, bs as v147, bt as v148, bu as v149, o as v15, bv as v150, bw as v151, bx as v152, by as v153, bz as v154, bA as v155, bB as v156, bC as v157, bD as v158, bE as v159, p as v16, bF as v160, bG as v161, bH as v162, bI as v163, bJ as v164, bK as v165, bL as v166, bM as v167, bN as v168, bO as v169, q as v17, bP as v170, bQ as v171, bR as v172, bS as v173, bT as v174, bU as v175, bV as v176, bW as v177, bX as v178, bY as v179, r as v18, bZ as v180, b_ as v181, b$ as v182, c0 as v183, c1 as v184, c2 as v185, c3 as v186, c4 as v187, c5 as v188, c6 as v189, s as v19, c7 as v190, c8 as v191, c9 as v192, ca as v193, cb as v194, cc as v195, cd as v196, ce as v197, cf as v198, cg as v199, b as v2, t as v20, ch as v200, ci as v201, cj as v202, ck as v203, cl as v204, cm as v205, cn as v206, co as v207, cp as v208, cq as v209, u as v21, cr as v210, cs as v211, ct as v212, cu as v213, cv as v214, cw as v215, cx as v216, cy as v217, cz as v218, cA as v219, v as v22, cB as v220, cC as v221, cD as v222, cE as v223, cF as v224, cG as v225, cH as v226, cI as v227, cJ as v228, cK as v229, w as v23, cL as v230, cM as v231, cN as v232, cO as v233, cP as v234, cQ as v235, cR as v236, cS as v237, cT as v238, cU as v239, x as v24, cV as v240, cW as v241, cX as v242, cY as v243, cZ as v244, c_ as v245, c$ as v246, d0 as v247, d1 as v248, d2 as v249, y as v25, d3 as v250, d4 as v251, d5 as v252, d6 as v253, d7 as v254, d8 as v255, d9 as v256, da as v257, db as v258, dc as v259, z as v26, dd as v260, de as v261, df as v262, dg as v263, dh as v264, di as v265, dj as v266, dk as v267, dl as v268, dm as v269, A as v27, dn as v270, dp as v271, dq as v272, B as v28, C as v29, c as v3, D as v30, E as v31, F as v32, G as v33, H as v34, I as v35, J as v36, K as v37, L as v38, M as v39, d as v4, N as v40, O as v41, P as v42, Q as v43, R as v44, S as v45, T as v46, U as v47, V as v48, W as v49, e as v5, X as v50, Y as v51, Z as v52, _ as v53, $ as v54, a0 as v55, a1 as v56, a2 as v57, a3 as v58, a4 as v59, f as v6, a5 as v60, a6 as v61, a7 as v62, a8 as v63, a9 as v64, aa as v65, ab as v66, ac as v67, ad as v68, ae as v69, g as v7, af as v70, ag as v71, ah as v72, ai as v73, aj as v74, ak as v75, al as v76, am as v77, an as v78, ao as v79, h as v8, ap as v80, aq as v81, ar as v82, as as v83, at as v84, au as v85, av as v86, aw as v87, ax as v88, ay as v89, i as v9, az as v90, aA as v91, aB as v92, aC as v93, aD as v94, aE as v95, aF as v96, aG as v97, aH as v98, aI as v99 } from './generated-chunk.js'; -const lazy = import('./generated-chunk2.js'); +const lazy = import('./generated-lazy.js'); export { lazy }; diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-chunk2.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js similarity index 100% rename from test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-chunk2.js rename to test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js index ffe78d9f1af..5ce83aac926 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js @@ -279,7 +279,7 @@ System.register(['./generated-chunk.js'], function (exports, module) { }], execute: function () { - const lazy = exports('lazy', module.import('./generated-chunk2.js')); + const lazy = exports('lazy', module.import('./generated-lazy.js')); } }; diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js index 47e0f71b87d..4d9e69640e1 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log('1', __chunk_1.dep); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js index d4fbe558080..b493172d6f7 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; +define(['./generated-chunk'], function (__chunk_1) { 'use strict'; console.log('2', __chunk_1.dep); diff --git a/test/form/samples/configure-file-url/_config.js b/test/form/samples/configure-file-url/_config.js new file mode 100644 index 00000000000..51f63117e90 --- /dev/null +++ b/test/form/samples/configure-file-url/_config.js @@ -0,0 +1,48 @@ +module.exports = { + description: 'allows to configure file urls', + options: { + plugins: [ + { + resolveId(id) { + if (id.endsWith('solved')) { + return id; + } + }, + load(id) { + if (id.endsWith('solved')) { + const assetId = this.emitAsset(`asset-${id}.txt`, `Asset for: ${id}`); + return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; + } + }, + resolveFileUrl({ + assetReferenceId, + chunkId, + chunkReferenceId, + fileName, + format, + moduleId, + relativePath + }) { + if (!moduleId.endsWith('resolved')) { + return `'chunkId=${chunkId}:moduleId=${moduleId + .replace(/\\/g, '/') + .split('/') + .slice(-2) + .join( + '/' + )}:fileName=${fileName}:format=${format}:relativePath=${relativePath}:assetReferenceId=${assetReferenceId}:chunkReferenceId=${chunkReferenceId}'`; + } + return null; + } + }, + { + resolveFileUrl({ moduleId }) { + if (moduleId === 'resolved') { + return `'resolved'`; + } + return null; + } + } + ] + } +}; diff --git a/test/form/samples/configure-file-url/_expected/amd.js b/test/form/samples/configure-file-url/_expected/amd.js new file mode 100644 index 00000000000..4f17cacf559 --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/amd.js @@ -0,0 +1,11 @@ +define(['module'], function (module) { 'use strict'; + + var asset1 = 'chunkId=amd.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=amd:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + + var asset2 = 'resolved'; + + var asset3 = new URL(module.uri + '/../assets/asset-unresolved-9548436d.txt', document.baseURI).href; + + console.log(asset1, asset2, asset3); + +}); diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-resolved-dfc93baf.txt b/test/form/samples/configure-file-url/_expected/assets/asset-resolved-dfc93baf.txt new file mode 100644 index 00000000000..31fb300f988 --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/assets/asset-resolved-dfc93baf.txt @@ -0,0 +1 @@ +Asset for: resolved \ No newline at end of file diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-solved-9b321da2.txt b/test/form/samples/configure-file-url/_expected/assets/asset-solved-9b321da2.txt new file mode 100644 index 00000000000..07c7a096c7e --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/assets/asset-solved-9b321da2.txt @@ -0,0 +1 @@ +Asset for: solved \ No newline at end of file diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-9548436d.txt b/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-9548436d.txt new file mode 100644 index 00000000000..fd3ad6261cc --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-9548436d.txt @@ -0,0 +1 @@ +Asset for: unresolved \ No newline at end of file diff --git a/test/form/samples/configure-file-url/_expected/cjs.js b/test/form/samples/configure-file-url/_expected/cjs.js new file mode 100644 index 00000000000..0cd0cf76d41 --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +var asset1 = 'chunkId=cjs.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=cjs:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + +var asset2 = 'resolved'; + +var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-9548436d.txt').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../assets/asset-unresolved-9548436d.txt').href); + +console.log(asset1, asset2, asset3); diff --git a/test/form/samples/configure-file-url/_expected/es.js b/test/form/samples/configure-file-url/_expected/es.js new file mode 100644 index 00000000000..df7dcc61d02 --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/es.js @@ -0,0 +1,7 @@ +var asset1 = 'chunkId=es.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=es:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + +var asset2 = 'resolved'; + +var asset3 = new URL('assets/asset-unresolved-9548436d.txt', import.meta.url).href; + +console.log(asset1, asset2, asset3); diff --git a/test/form/samples/configure-file-url/_expected/iife.js b/test/form/samples/configure-file-url/_expected/iife.js new file mode 100644 index 00000000000..08bb0ddca71 --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/iife.js @@ -0,0 +1,12 @@ +(function () { + 'use strict'; + + var asset1 = 'chunkId=iife.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=iife:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + + var asset2 = 'resolved'; + + var asset3 = new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../assets/asset-unresolved-9548436d.txt').href; + + console.log(asset1, asset2, asset3); + +}()); diff --git a/test/form/samples/configure-file-url/_expected/system.js b/test/form/samples/configure-file-url/_expected/system.js new file mode 100644 index 00000000000..b819b26364a --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/system.js @@ -0,0 +1,16 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var asset1 = 'chunkId=system.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=system:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + + var asset2 = 'resolved'; + + var asset3 = new URL('assets/asset-unresolved-9548436d.txt', module.meta.url).href; + + console.log(asset1, asset2, asset3); + + } + }; +}); diff --git a/test/form/samples/configure-file-url/_expected/umd.js b/test/form/samples/configure-file-url/_expected/umd.js new file mode 100644 index 00000000000..ce104bada6e --- /dev/null +++ b/test/form/samples/configure-file-url/_expected/umd.js @@ -0,0 +1,14 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + var asset1 = 'chunkId=umd.js:moduleId=solved:fileName=assets/asset-solved-9b321da2.txt:format=umd:relativePath=assets/asset-solved-9b321da2.txt:assetReferenceId=6296c678:chunkReferenceId=null'; + + var asset2 = 'resolved'; + + var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-9548436d.txt').href : new URL((document.currentScript && document.currentScript.src || document.baseURI) + '/../assets/asset-unresolved-9548436d.txt').href); + + console.log(asset1, asset2, asset3); + +})); diff --git a/test/form/samples/configure-file-url/main.js b/test/form/samples/configure-file-url/main.js new file mode 100644 index 00000000000..74a56461e3a --- /dev/null +++ b/test/form/samples/configure-file-url/main.js @@ -0,0 +1,5 @@ +import asset1 from 'solved'; +import asset2 from 'resolved'; +import asset3 from 'unresolved'; + +console.log(asset1, asset2, asset3); diff --git a/test/form/samples/relative-external-with-global/_expected/amd.js b/test/form/samples/relative-external-with-global/_expected/amd.js index 0520af02768..084748c64a2 100644 --- a/test/form/samples/relative-external-with-global/_expected/amd.js +++ b/test/form/samples/relative-external-with-global/_expected/amd.js @@ -1,4 +1,4 @@ -define(['./lib/throttle.js'], function (throttle) { 'use strict'; +define(['./lib/throttle'], function (throttle) { 'use strict'; throttle = throttle && throttle.hasOwnProperty('default') ? throttle['default'] : throttle; @@ -8,4 +8,4 @@ define(['./lib/throttle.js'], function (throttle) { 'use strict'; window.addEventListener( 'mousemove', throttle ); -}); \ No newline at end of file +}); diff --git a/test/form/samples/relative-external-with-global/_expected/cjs.js b/test/form/samples/relative-external-with-global/_expected/cjs.js index 1b74d5687f4..7ae442850ea 100644 --- a/test/form/samples/relative-external-with-global/_expected/cjs.js +++ b/test/form/samples/relative-external-with-global/_expected/cjs.js @@ -8,4 +8,4 @@ const fn = throttle( () => { console.log( '.' ); }, 500 ); -window.addEventListener( 'mousemove', throttle ); \ No newline at end of file +window.addEventListener( 'mousemove', throttle ); diff --git a/test/form/samples/relative-external-with-global/_expected/es.js b/test/form/samples/relative-external-with-global/_expected/es.js index fe8f7cf3d40..750ac953c06 100644 --- a/test/form/samples/relative-external-with-global/_expected/es.js +++ b/test/form/samples/relative-external-with-global/_expected/es.js @@ -4,4 +4,4 @@ const fn = throttle( () => { console.log( '.' ); }, 500 ); -window.addEventListener( 'mousemove', throttle ); \ No newline at end of file +window.addEventListener( 'mousemove', throttle ); diff --git a/test/form/samples/treeshake-import-meta/_config.js b/test/form/samples/treeshake-import-meta/_config.js new file mode 100644 index 00000000000..64d9f998bc0 --- /dev/null +++ b/test/form/samples/treeshake-import-meta/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'supports tree-shaking for meta properties' +}; diff --git a/test/form/samples/treeshake-import-meta/_expected.js b/test/form/samples/treeshake-import-meta/_expected.js new file mode 100644 index 00000000000..fbce83c5c52 --- /dev/null +++ b/test/form/samples/treeshake-import-meta/_expected.js @@ -0,0 +1 @@ +const retained = import.meta.a.b; diff --git a/test/form/samples/treeshake-import-meta/main.js b/test/form/samples/treeshake-import-meta/main.js new file mode 100644 index 00000000000..4a41ad2333a --- /dev/null +++ b/test/form/samples/treeshake-import-meta/main.js @@ -0,0 +1,4 @@ +const removed1 = import.meta; +const removed2 = import.meta.url; +const removed3 = import.meta.unknown; +const retained = import.meta.a.b; diff --git a/test/function/samples/add-watch-file-generate/_config.js b/test/function/samples/add-watch-file-generate/_config.js new file mode 100644 index 00000000000..38c4562c7eb --- /dev/null +++ b/test/function/samples/add-watch-file-generate/_config.js @@ -0,0 +1,20 @@ +const path = require('path'); + +module.exports = { + description: 'throws when adding watch files during generate', + options: { + plugins: { + name: 'test-plugin', + renderStart() { + this.addWatchFile(path.resolve(__dirname, 'watched.js')); + } + } + }, + generateError: { + code: 'PLUGIN_ERROR', + hook: 'renderStart', + message: 'Cannot call addWatchFile after the build has finished.', + plugin: 'test-plugin', + pluginCode: 'INVALID_ROLLUP_PHASE' + } +}; diff --git a/test/function/samples/add-watch-file-generate/main.js b/test/function/samples/add-watch-file-generate/main.js new file mode 100644 index 00000000000..a9244a453fb --- /dev/null +++ b/test/function/samples/add-watch-file-generate/main.js @@ -0,0 +1 @@ +throw new Error('Not executed'); diff --git a/test/function/samples/add-watch-file-generate/watched.js b/test/function/samples/add-watch-file-generate/watched.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/duplicate-input-entry-fails/_config.js b/test/function/samples/duplicate-input-entry-fails/_config.js deleted file mode 100644 index aa1b1b2e67f..00000000000 --- a/test/function/samples/duplicate-input-entry-fails/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'duplicate entry modules', - options: { - input: ['main.js', 'main.js'] - }, - error: { - code: 'DUPLICATE_ENTRY_POINTS', - message: `Duplicate entry points detected. The input entries main and main both point to the same module, ${path.resolve( - __dirname, - 'main.js' - )}` - } -}; diff --git a/test/function/samples/duplicate-input-entry-fails/main.js b/test/function/samples/duplicate-input-entry-fails/main.js deleted file mode 100644 index 20e41f60071..00000000000 --- a/test/function/samples/duplicate-input-entry-fails/main.js +++ /dev/null @@ -1 +0,0 @@ -export var main = 'main'; \ No newline at end of file diff --git a/test/function/samples/duplicate-input-entry/_config.js b/test/function/samples/duplicate-input-entry/_config.js new file mode 100644 index 00000000000..cecb19f2eeb --- /dev/null +++ b/test/function/samples/duplicate-input-entry/_config.js @@ -0,0 +1,11 @@ +const assert = require('assert'); + +module.exports = { + description: 'handles duplicate entry modules when using the object form', + options: { + input: ['entry', 'entry.js'] + }, + exports(exports) { + assert.deepStrictEqual(exports, { entry: 'main' }); + } +}; diff --git a/test/function/samples/duplicate-input-entry/entry.js b/test/function/samples/duplicate-input-entry/entry.js new file mode 100644 index 00000000000..735812c9c09 --- /dev/null +++ b/test/function/samples/duplicate-input-entry/entry.js @@ -0,0 +1 @@ +export var entry = 'main'; diff --git a/test/function/samples/emit-asset/asset-source-missing-2/_config.js b/test/function/samples/emit-asset/asset-source-missing-2/_config.js new file mode 100644 index 00000000000..722c1b9c225 --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing-2/_config.js @@ -0,0 +1,16 @@ +module.exports = { + description: 'throws when not setting the asset source and accessing the asset URL', + options: { + plugins: { + name: 'test-plugin', + load() { + return `export default import.meta.ROLLUP_ASSET_URL_${this.emitAsset('test.ext')};`; + } + } + }, + generateError: { + code: 'ASSET_NOT_FINALISED', + message: + 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first.' + } +}; diff --git a/test/function/samples/emit-asset/asset-source-missing-2/main.js b/test/function/samples/emit-asset/asset-source-missing-2/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing-2/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/asset-source-missing-3/_config.js b/test/function/samples/emit-asset/asset-source-missing-3/_config.js new file mode 100644 index 00000000000..8929ab542fb --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing-3/_config.js @@ -0,0 +1,19 @@ +module.exports = { + description: 'throws when setting an empty asset source', + options: { + plugins: { + name: 'test-plugin', + buildStart() { + const assetId = this.emitAsset('test.ext'); + this.setAssetSource(assetId, null); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: 'Plugin error creating asset "test.ext", setAssetSource call without a source.', + plugin: 'test-plugin', + pluginCode: 'ASSET_SOURCE_MISSING' + } +}; diff --git a/test/function/samples/emit-asset/asset-source-missing-3/main.js b/test/function/samples/emit-asset/asset-source-missing-3/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing-3/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/asset-source-missing/_config.js b/test/function/samples/emit-asset/asset-source-missing/_config.js new file mode 100644 index 00000000000..e29179abf9e --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing/_config.js @@ -0,0 +1,15 @@ +module.exports = { + description: 'throws when not setting the asset source', + options: { + plugins: { + name: 'test-plugin', + load() { + this.emitAsset('test.ext'); + } + } + }, + generateError: { + code: 'ASSET_SOURCE_MISSING', + message: 'Plugin error creating asset "test.ext" - no asset source set.' + } +}; diff --git a/test/function/samples/emit-asset/asset-source-missing/main.js b/test/function/samples/emit-asset/asset-source-missing/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/asset-source-missing/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/invalid-asset-id/_config.js b/test/function/samples/emit-asset/invalid-asset-id/_config.js new file mode 100644 index 00000000000..9e7898f97b8 --- /dev/null +++ b/test/function/samples/emit-asset/invalid-asset-id/_config.js @@ -0,0 +1,15 @@ +module.exports = { + description: 'throws for invalid asset ids', + options: { + plugins: { + name: 'test-plugin', + load() { + return `export default import.meta.ROLLUP_ASSET_URL_invalid;`; + } + } + }, + generateError: { + code: 'ASSET_NOT_FOUND', + message: 'Plugin error - Unable to get file name for unknown asset "invalid".' + } +}; diff --git a/test/function/samples/emit-asset/invalid-asset-id/main.js b/test/function/samples/emit-asset/invalid-asset-id/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/invalid-asset-id/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/invalid-asset-name/_config.js b/test/function/samples/emit-asset/invalid-asset-name/_config.js new file mode 100644 index 00000000000..ffbe4fa4a9b --- /dev/null +++ b/test/function/samples/emit-asset/invalid-asset-name/_config.js @@ -0,0 +1,19 @@ +module.exports = { + description: 'throws for invalid asset names', + options: { + plugins: { + name: 'test-plugin', + buildStart() { + this.emitAsset('/test.ext', 'content'); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: + 'Plugin error creating asset, name "/test.ext" is not a plain (non relative or absolute URL) string name.', + plugin: 'test-plugin', + pluginCode: 'INVALID_ASSET_NAME' + } +}; diff --git a/test/function/samples/emit-asset/invalid-asset-name/main.js b/test/function/samples/emit-asset/invalid-asset-name/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/invalid-asset-name/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/invalid-set-asset-source-id/_config.js b/test/function/samples/emit-asset/invalid-set-asset-source-id/_config.js new file mode 100644 index 00000000000..67ed85414a5 --- /dev/null +++ b/test/function/samples/emit-asset/invalid-set-asset-source-id/_config.js @@ -0,0 +1,18 @@ +module.exports = { + description: 'throws for invalid asset ids', + options: { + plugins: { + name: 'test-plugin', + buildStart() { + this.setAssetSource('invalid', 'content'); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: 'Plugin error - Unable to set the source for unknown asset "invalid".', + plugin: 'test-plugin', + pluginCode: 'ASSET_NOT_FOUND' + } +}; diff --git a/test/function/samples/emit-asset/invalid-set-asset-source-id/main.js b/test/function/samples/emit-asset/invalid-set-asset-source-id/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/invalid-set-asset-source-id/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/set-asset-source-transform/_config.js b/test/function/samples/emit-asset/set-asset-source-transform/_config.js new file mode 100644 index 00000000000..bb506dfd995 --- /dev/null +++ b/test/function/samples/emit-asset/set-asset-source-transform/_config.js @@ -0,0 +1,24 @@ +const path = require('path'); + +module.exports = { + description: 'throws when setting the asset source in the transform hook', + options: { + plugins: { + name: 'test-plugin', + transform(code) { + const assetId = this.emitAsset('test.ext'); + this.setAssetSource(assetId, 'asdf'); + return code; + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'transform', + id: path.join(__dirname, 'main.js'), + message: + 'setAssetSource cannot be called in transform for caching reasons. Use emitAsset with a source, or call setAssetSource in another hook.', + plugin: 'test-plugin', + pluginCode: 'INVALID_SETASSETSOURCE' + } +}; diff --git a/test/function/samples/emit-asset/set-asset-source-transform/main.js b/test/function/samples/emit-asset/set-asset-source-transform/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/set-asset-source-transform/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-asset/set-asset-source-twice/_config.js b/test/function/samples/emit-asset/set-asset-source-twice/_config.js new file mode 100644 index 00000000000..d009be672f8 --- /dev/null +++ b/test/function/samples/emit-asset/set-asset-source-twice/_config.js @@ -0,0 +1,20 @@ +module.exports = { + description: 'throws when setting the asset source twice', + options: { + plugins: { + name: 'test-plugin', + buildEnd() { + const assetId = this.emitAsset('test.ext'); + this.setAssetSource(assetId, 'hello world'); + this.setAssetSource(assetId, 'another'); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildEnd', + message: 'Plugin error - Unable to set the source for asset "test.ext", source already set.', + plugin: 'test-plugin', + pluginCode: 'ASSET_SOURCE_ALREADY_SET' + } +}; diff --git a/test/function/samples/emit-asset/set-asset-source-twice/main.js b/test/function/samples/emit-asset/set-asset-source-twice/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-asset/set-asset-source-twice/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-chunk/chunk-filename-not-available/_config.js b/test/function/samples/emit-chunk/chunk-filename-not-available/_config.js new file mode 100644 index 00000000000..eda4e487c82 --- /dev/null +++ b/test/function/samples/emit-chunk/chunk-filename-not-available/_config.js @@ -0,0 +1,21 @@ +module.exports = { + description: 'Throws when accessing the filename before it has been generated', + options: { + input: 'main.js', + plugins: { + name: 'test-plugin', + buildStart() { + const chunkId = this.emitChunk('chunk.js'); + this.getChunkFileName(chunkId); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: + 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', + plugin: 'test-plugin', + pluginCode: 'CHUNK_NOT_GENERATED' + } +}; diff --git a/test/function/samples/emit-chunk/chunk-filename-not-available/chunk.js b/test/function/samples/emit-chunk/chunk-filename-not-available/chunk.js new file mode 100644 index 00000000000..36b1d61dd25 --- /dev/null +++ b/test/function/samples/emit-chunk/chunk-filename-not-available/chunk.js @@ -0,0 +1 @@ +console.log('chunk'); diff --git a/test/function/samples/emit-chunk/chunk-filename-not-available/main.js b/test/function/samples/emit-chunk/chunk-filename-not-available/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/function/samples/emit-chunk/chunk-filename-not-available/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/function/samples/emit-chunk/chunk-not-found/_config.js b/test/function/samples/emit-chunk/chunk-not-found/_config.js new file mode 100644 index 00000000000..46e17ecb5ee --- /dev/null +++ b/test/function/samples/emit-chunk/chunk-not-found/_config.js @@ -0,0 +1,15 @@ +module.exports = { + description: 'Throws if an emitted entry chunk cannot be resolved', + options: { + input: 'main.js', + plugins: { + buildStart() { + this.emitChunk('not-found.js'); + } + } + }, + error: { + code: 'UNRESOLVED_ENTRY', + message: 'Could not resolve entry (not-found.js)' + } +}; diff --git a/test/function/samples/emit-chunk/chunk-not-found/main.js b/test/function/samples/emit-chunk/chunk-not-found/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/function/samples/emit-chunk/chunk-not-found/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/function/samples/emit-chunk/invalid-chunk-id/_config.js b/test/function/samples/emit-chunk/invalid-chunk-id/_config.js new file mode 100644 index 00000000000..878e67a24ff --- /dev/null +++ b/test/function/samples/emit-chunk/invalid-chunk-id/_config.js @@ -0,0 +1,15 @@ +module.exports = { + description: 'throws for invalid chunk ids', + options: { + plugins: { + name: 'test-plugin', + load() { + return `export default import.meta.ROLLUP_CHUNK_URL_invalid;`; + } + } + }, + generateError: { + code: 'CHUNK_NOT_FOUND', + message: 'Plugin error - Unable to get file name for unknown chunk "invalid".' + } +}; diff --git a/test/function/samples/emit-chunk/invalid-chunk-id/main.js b/test/function/samples/emit-chunk/invalid-chunk-id/main.js new file mode 100644 index 00000000000..c4b940fc952 --- /dev/null +++ b/test/function/samples/emit-chunk/invalid-chunk-id/main.js @@ -0,0 +1 @@ +throw new Error('should not build'); diff --git a/test/function/samples/emit-chunk/modules-loaded/_config.js b/test/function/samples/emit-chunk/modules-loaded/_config.js new file mode 100644 index 00000000000..1baeb21d1d2 --- /dev/null +++ b/test/function/samples/emit-chunk/modules-loaded/_config.js @@ -0,0 +1,19 @@ +module.exports = { + description: 'Throws when adding a chunk after the modules have finished loading', + options: { + input: 'main.js', + plugins: { + name: 'test-plugin', + buildEnd() { + this.emitChunk('chunk.js'); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildEnd', + message: 'Cannot call emitChunk after module loading has finished.', + plugin: 'test-plugin', + pluginCode: 'INVALID_ROLLUP_PHASE' + } +}; diff --git a/test/function/samples/emit-chunk/modules-loaded/chunk.js b/test/function/samples/emit-chunk/modules-loaded/chunk.js new file mode 100644 index 00000000000..a9244a453fb --- /dev/null +++ b/test/function/samples/emit-chunk/modules-loaded/chunk.js @@ -0,0 +1 @@ +throw new Error('Not executed'); diff --git a/test/function/samples/emit-chunk/modules-loaded/main.js b/test/function/samples/emit-chunk/modules-loaded/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/function/samples/emit-chunk/modules-loaded/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/function/samples/emit-chunk/no-input/_config.js b/test/function/samples/emit-chunk/no-input/_config.js new file mode 100644 index 00000000000..ec7d2de6ece --- /dev/null +++ b/test/function/samples/emit-chunk/no-input/_config.js @@ -0,0 +1,12 @@ +module.exports = { + description: 'It is not necessary to provide an input if a dynamic entry is emitted', + options: { + input: undefined, + plugins: { + name: 'test-plugin', + buildStart() { + this.emitChunk('chunk.js'); + } + } + } +}; diff --git a/test/function/samples/emit-chunk/no-input/chunk.js b/test/function/samples/emit-chunk/no-input/chunk.js new file mode 100644 index 00000000000..c40c320ba58 --- /dev/null +++ b/test/function/samples/emit-chunk/no-input/chunk.js @@ -0,0 +1 @@ +assert.equal(42, 42); diff --git a/test/function/samples/internal-reexports-from-external/_config.js b/test/function/samples/internal-reexports-from-external/_config.js index 79d4f56d24d..4b56fa1782d 100644 --- a/test/function/samples/internal-reexports-from-external/_config.js +++ b/test/function/samples/internal-reexports-from-external/_config.js @@ -10,6 +10,6 @@ module.exports = { code: 'NAMESPACE_CANNOT_CONTAIN_EXTERNAL', message: 'Cannot create an explicit namespace object for module "reexport" because it contains a reexported external namespace', - id: path.join(__dirname, '/reexport.js') + id: path.join(__dirname, 'reexport.js') } }; diff --git a/test/function/samples/manual-chunks-conflict/_config.js b/test/function/samples/manual-chunks-conflict/_config.js new file mode 100644 index 00000000000..e07a6cf5cbd --- /dev/null +++ b/test/function/samples/manual-chunks-conflict/_config.js @@ -0,0 +1,14 @@ +module.exports = { + description: 'Throws for conflicts between manual chunks', + options: { + input: ['main.js'], + manualChunks: { + dep1: ['dep.js'], + dep2: ['dep.js'] + } + }, + error: { + code: 'INVALID_CHUNK', + message: `Cannot assign dep.js to the "dep1" chunk as it is already in the "dep2" chunk.` + } +}; diff --git a/test/function/samples/manual-chunks-conflict/dep.js b/test/function/samples/manual-chunks-conflict/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/function/samples/manual-chunks-conflict/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/function/samples/manual-chunks-conflict/main.js b/test/function/samples/manual-chunks-conflict/main.js new file mode 100644 index 00000000000..d6cf3b02443 --- /dev/null +++ b/test/function/samples/manual-chunks-conflict/main.js @@ -0,0 +1 @@ +import './dep.js'; diff --git a/test/function/samples/manual-chunks-invalid/_config.js b/test/function/samples/manual-chunks-invalid/_config.js deleted file mode 100644 index bcab89c422f..00000000000 --- a/test/function/samples/manual-chunks-invalid/_config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - description: 'manual chunks support', - options: { - input: ['main.js'], - manualChunks: { - dep1: ['dep1.js'], - dep2: ['dep2.js'] - } - }, - error: { - code: 'INVALID_CHUNK', - message: `Cannot assign dep2.js to the "dep2" chunk as it is already in the "dep1" chunk.\nTry defining "dep2" first in the manualChunks definitions of the Rollup configuration.` - } -}; diff --git a/test/function/samples/manual-chunks-invalid/dep1.js b/test/function/samples/manual-chunks-invalid/dep1.js deleted file mode 100644 index f752f4ebdc9..00000000000 --- a/test/function/samples/manual-chunks-invalid/dep1.js +++ /dev/null @@ -1 +0,0 @@ -import './dep2.js'; \ No newline at end of file diff --git a/test/function/samples/manual-chunks-invalid/dep2.js b/test/function/samples/manual-chunks-invalid/dep2.js deleted file mode 100644 index 55c9255134f..00000000000 --- a/test/function/samples/manual-chunks-invalid/dep2.js +++ /dev/null @@ -1 +0,0 @@ -export var p = 5; \ No newline at end of file diff --git a/test/function/samples/manual-chunks-invalid/main.js b/test/function/samples/manual-chunks-invalid/main.js deleted file mode 100644 index ec8ef6016c0..00000000000 --- a/test/function/samples/manual-chunks-invalid/main.js +++ /dev/null @@ -1 +0,0 @@ -import './dep1.js'; \ No newline at end of file diff --git a/test/function/samples/module-tree/_config.js b/test/function/samples/module-tree/_config.js index d55fe7bd2b8..add3840062e 100644 --- a/test/function/samples/module-tree/_config.js +++ b/test/function/samples/module-tree/_config.js @@ -4,12 +4,10 @@ const assert = require('assert'); module.exports = { description: 'bundle.modules includes dependencies (#903)', bundle(bundle) { - const modules = bundle.cache.modules.map(module => { - return { - id: path.relative(__dirname, module.id), - dependencies: module.dependencies.map(id => path.relative(__dirname, id)) - }; - }); + const modules = bundle.cache.modules.map(module => ({ + id: path.relative(__dirname, module.id), + dependencies: module.dependencies.map(id => path.relative(__dirname, id)) + })); assert.deepEqual(modules, [ { diff --git a/test/hooks/index.js b/test/hooks/index.js index 6568c68e24c..292c75bf6b8 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -588,62 +588,6 @@ module.exports = input; }); }); - it('throws when calling setAssetSource in transform', () => { - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: `alert('hello')` }), - { - transform() { - const assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, 'asdf'); - return ''; - } - } - ] - }) - .then(({ output }) => { - throw new Error('should fail'); - }) - .catch(err => { - assert.equal(err.code, 'PLUGIN_ERROR'); - assert.equal(err.pluginCode, 'INVALID_SETASSETSOURCE'); - }); - }); - - it('throws when setting asset source twice', () => { - let thrown = false; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: `alert('hello')` }), - { - buildEnd() { - const assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, 'hello world'); - try { - this.setAssetSource(assetId, 'another'); - } catch (e) { - assert.equal(e.code, 'ASSET_SOURCE_ALREADY_SET'); - thrown = true; - return ''; - } - assert.fail(); - } - } - ] - }) - .then(bundle => { - return bundle.generate({ format: 'es' }); - }) - .then(({ output: [, output] }) => { - assert.equal(output.source, 'hello world'); - assert.equal(thrown, true); - }); - }); - it('allows setting asset source at generateBundle', () => { let assetId; return rollup @@ -1367,18 +1311,18 @@ module.exports = input; modules: ['input'] }, { - fileName: 'generated-chunk.js', - imports: ['generated-chunk2.js'], + fileName: 'generated-a.js', + imports: ['generated-chunk.js'], modules: ['d', 'a'] }, { - fileName: 'generated-chunk2.js', + fileName: 'generated-chunk.js', imports: [], modules: ['c'] }, { - fileName: 'generated-chunk3.js', - imports: ['generated-chunk2.js'], + fileName: 'generated-b.js', + imports: ['generated-chunk.js'], modules: ['b'] } ]); diff --git a/test/misc/bundle-information.js b/test/misc/bundle-information.js index 106417b9709..0ca67ba968d 100644 --- a/test/misc/bundle-information.js +++ b/test/misc/bundle-information.js @@ -109,7 +109,7 @@ describe('The bundle object', () => { .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['input1.js', 'input2.js', 'generated-input2.js'], + ['input1.js', 'input2.js', 'generated-chunk.js'], 'fileName' ); assert.deepEqual( @@ -150,7 +150,7 @@ describe('The bundle object', () => { .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['input1.js', 'input2.js', 'input22.js'], + ['input1.js', 'input2.js', 'chunk.js'], 'fileName' ); assert.deepEqual( @@ -184,14 +184,14 @@ describe('The bundle object', () => { .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['input.js', 'dynamic1.js', 'generated-chunk.js'], + ['input.js', 'dynamic1.js', 'generated-dynamic2.js'], 'fileName' ); assert.deepEqual(output.map(chunk => chunk.isEntry), [true, true, false], 'isEntry'); assert.deepEqual( output.map(chunk => chunk.code), [ - `Promise.all([import('./dynamic1.js'), import('./generated-chunk.js')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));\n`, + `Promise.all([import('./dynamic1.js'), import('./generated-dynamic2.js')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));\n`, 'const dynamic1 = "dynamic1";\n\nexport { dynamic1 };\n', 'const dynamic2 = "dynamic2";\n\nexport { dynamic2 };\n' ], @@ -209,7 +209,7 @@ describe('The bundle object', () => { ); assert.deepEqual( output.map(chunk => chunk.dynamicImports), - [['dynamic1.js', 'generated-chunk.js'], [], []], + [['dynamic1.js', 'generated-dynamic2.js'], [], []], 'dynamicImports' ); }); @@ -239,7 +239,7 @@ describe('The bundle object', () => { .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['input1.js', 'input2.js', 'generated-chunk.js', 'generated-chunk2.js'], + ['input1.js', 'input2.js', 'generated-chunk.js', 'generated-dynamic.js'], 'fileName' ); assert.deepEqual( @@ -348,7 +348,7 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the ); assert.deepEqual( output.map(chunk => chunk.name), - ['input', 'dynamic1', 'chunk', 'chunk'], + ['input', 'dynamic1', 'other', 'dynamic2'], 'name' ); assert.deepEqual( diff --git a/test/misc/misc.js b/test/misc/misc.js index 9336ab25605..1a59e2a0fd5 100644 --- a/test/misc/misc.js +++ b/test/misc/misc.js @@ -92,7 +92,7 @@ describe('misc', () => { 'main1.js', 'main2.js', 'chunk-9d1272f4.js', - 'chunk-80285050.js' + 'dyndep-80285050.js' ]); }); }); diff --git a/test/misc/write-bundle.js b/test/misc/write-bundle.js index 1ef523fe9cc..decb030012e 100644 --- a/test/misc/write-bundle.js +++ b/test/misc/write-bundle.js @@ -9,12 +9,8 @@ describe('bundle.write()', () => { input: 'x', plugins: [ { - resolveId: () => { - return 'test'; - }, - load: () => { - return '// empty'; - } + resolveId: () => 'test', + load: () => '// empty' } ] }) @@ -37,12 +33,8 @@ describe('bundle.write()', () => { input: 'x', plugins: [ { - resolveId: () => { - return 'test'; - }, - load: () => { - return 'export var foo = 42;'; - } + resolveId: () => 'test', + load: () => 'export var foo = 42;' } ] }) diff --git a/test/watch/index.js b/test/watch/index.js index 6f65562713e..1af42233e9e 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -605,13 +605,13 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - [chunkName, dynamicName, staticName] = sander.readdirSync('test/_tmp/output').sort(); + [dynamicName, staticName, chunkName] = sander.readdirSync('test/_tmp/output').sort(); sander.rimrafSync('test/_tmp/output'); // this should only update the hash of that particular entry point sander.writeFileSync( 'test/_tmp/input/main-static.js', - "import {value} from './shared';export default 2*value;" + "import {value} from './shared';\nexport default 2 * value;" ); }, 'START', @@ -619,7 +619,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - const [newChunkName, newDynamicName, newStaticName] = sander + const [newDynamicName, newStaticName, newChunkName] = sander .readdirSync('test/_tmp/output') .sort(); sander.rimrafSync('test/_tmp/output'); @@ -636,7 +636,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - const [newChunkName, newDynamicName, newStaticName] = sander + const [newDynamicName, newStaticName, newChunkName] = sander .readdirSync('test/_tmp/output') .sort(); assert.notEqual(newStaticName, staticName);