From 4dacac6a40239b59aeb6cdc370d0e1896ab73a91 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 1 Dec 2018 12:45:52 +0100 Subject: [PATCH] A chunk may only ever be facade for a single module to simplify the logic Also delete tests that have been skipped for years. Let's rather make a fresh start should the problem still persists and someone care to address it. --- src/Chunk.ts | 56 ++++++++----------- src/Graph.ts | 32 ++++------- src/chunk-optimization.ts | 4 +- src/rollup/index.ts | 13 ++--- src/rollup/types.d.ts | 2 +- src/utils/assignChunkIds.ts | 9 ++- src/utils/executionOrder.ts | 2 +- src/utils/getExportMode.ts | 3 +- .../_expected/amd/generated-dynamic.js | 4 +- .../_expected/amd/generated-dynamic2.js | 2 +- .../_expected/amd/main.js | 2 +- .../_expected/cjs/generated-dynamic.js | 4 +- .../_expected/cjs/generated-dynamic2.js | 2 +- .../_expected/cjs/main.js | 2 +- .../_expected/es/generated-dynamic.js | 2 +- .../_expected/es/generated-dynamic2.js | 2 +- .../_expected/es/main.js | 2 +- .../_expected/system/generated-dynamic.js | 4 +- .../_expected/system/generated-dynamic2.js | 2 +- .../_expected/system/main.js | 2 +- .../function/samples/cycles-pathological/A.js | 11 ---- .../function/samples/cycles-pathological/B.js | 8 --- .../function/samples/cycles-pathological/C.js | 8 --- .../function/samples/cycles-pathological/D.js | 11 ---- .../samples/cycles-pathological/_config.js | 17 ------ .../samples/cycles-pathological/main.js | 12 ---- .../samples/iife-strong-dependencies/A.js | 15 ----- .../samples/iife-strong-dependencies/B.js | 11 ---- .../samples/iife-strong-dependencies/C.js | 11 ---- .../samples/iife-strong-dependencies/D.js | 15 ----- .../iife-strong-dependencies/_config.js | 16 ------ .../samples/iife-strong-dependencies/main.js | 14 ----- test/misc/bundle-information.js | 37 ++++++------ 33 files changed, 83 insertions(+), 254 deletions(-) delete mode 100644 test/function/samples/cycles-pathological/A.js delete mode 100644 test/function/samples/cycles-pathological/B.js delete mode 100644 test/function/samples/cycles-pathological/C.js delete mode 100644 test/function/samples/cycles-pathological/D.js delete mode 100644 test/function/samples/cycles-pathological/_config.js delete mode 100644 test/function/samples/cycles-pathological/main.js delete mode 100644 test/function/samples/iife-strong-dependencies/A.js delete mode 100644 test/function/samples/iife-strong-dependencies/B.js delete mode 100644 test/function/samples/iife-strong-dependencies/C.js delete mode 100644 test/function/samples/iife-strong-dependencies/D.js delete mode 100644 test/function/samples/iife-strong-dependencies/_config.js delete mode 100644 test/function/samples/iife-strong-dependencies/main.js diff --git a/src/Chunk.ts b/src/Chunk.ts index d9d6c064a45..5264fc3b818 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -127,9 +127,8 @@ export default class Chunk { private exportNames: { [name: string]: Variable } = Object.create(null); private dependencies: (ExternalModule | Chunk)[] = undefined; - // an entry module chunk is a chunk that exactly exports the exports of - // an input entry point module - entryModules: Set = new Set(); + entryModules: Module[] = []; + facadeModule: Module | null = null; isEmpty: boolean; isManualChunk: boolean = false; @@ -159,14 +158,16 @@ export default class Chunk { } module.chunk = this; if (module.isEntryPoint || (module.isDynamicEntryPoint && !inlineDynamicImports)) { - this.entryModules.add(module); + this.entryModules.push(module); } } - if (this.entryModules.size > 0) { - const entryModules = Array.from(this.entryModules); + if (this.entryModules.length > 0) { this.variableName = makeLegal( - basename(entryModules.map(module => module.chunkAlias).find(Boolean) || entryModules[0].id) + basename( + this.entryModules.map(module => module.chunkAlias).find(Boolean) || + this.entryModules[0].id + ) ); } else this.variableName = '__chunk_' + ++graph.curChunkIndex; } @@ -193,7 +194,7 @@ export default class Chunk { turnIntoFacade(facadedModule: Module) { this.dependencies = [facadedModule.chunk]; - this.entryModules.add(facadedModule); + this.facadeModule = facadedModule; facadedModule.facadeChunk = this; for (const exportName of facadedModule.getAllExports()) { const tracedVariable = facadedModule.traceExport(exportName); @@ -244,42 +245,29 @@ export default class Chunk { } } - // TODO Lukas dynamic imports -> always named export mode! - // TODO Lukas multiple entry points -> always generate facade for more than one - // TODO Lukas handle circularly connected entries generateEntryExportsOrMarkAsTainted() { - const exportVariableMaps = Array.from(this.entryModules).map(module => ({ + const exportVariableMaps = this.entryModules.map(module => ({ module, map: this.getExportVariableMapForModule(module) })); - const variableByExportName: Map = new Map(); for (const { map } of exportVariableMaps) { for (const exposedVariable of Array.from(map.keys())) { this.exports.set(exposedVariable, map.get(exposedVariable).module); - for (const exportName of map.get(exposedVariable).exportNames) { - variableByExportName.set(exportName, exposedVariable); - } } } checkNextEntryModule: for (const { map, module } of exportVariableMaps) { for (const exposedVariable of Array.from(this.exports.keys())) { - if ( - !map.has(exposedVariable) || - map - .get(exposedVariable) - .exportNames.some( - exportName => variableByExportName.get(exportName) !== exposedVariable - ) - ) { - this.entryModules.delete(module); + if (!map.has(exposedVariable)) { continue checkNextEntryModule; } } + this.facadeModule = module; for (const [variable, { exportNames }] of Array.from(map)) { for (const exportName of exportNames) { this.exportNames[exportName] = variable; } } + return; } } @@ -333,7 +321,9 @@ export default class Chunk { this.traceAndInitializeImport(importName, traced.variable.module); } else { const externalVariable = traced.variable.module.traceExport(importName); - if (externalVariable.included) this.imports.set(original, traced.variable.module); + if (externalVariable.included) { + this.imports.set(original, traced.variable.module); + } } } } @@ -401,7 +391,7 @@ export default class Chunk { } generateInternalExports(options: OutputOptions) { - if (this.entryModules.size > 0) return; + if (this.facadeModule !== null) return; const mangle = options.format === 'system' || options.format === 'es' || options.compact; let i = 0, safeExportName: string; @@ -818,7 +808,7 @@ export default class Chunk { }; // if an entry point facade or dynamic entry point, inline the execution list to avoid loading latency - if (this.entryModules.size > 0) { + if (this.facadeModule !== null) { for (const dep of this.dependencies) { if (dep instanceof Chunk) this.inlineChunkDependencies(dep, true); } @@ -919,7 +909,7 @@ export default class Chunk { * A new facade will be added to chunkList if tainting exports of either as an entry point */ merge(chunk: Chunk, chunkList: Chunk[], options: OutputOptions, inputBase: string) { - if (this.entryModules.size > 0 || chunk.entryModules.size > 0) + if (this.facadeModule !== null || chunk.facadeModule !== null) throw new Error('Internal error: Code splitting chunk merges not supported for facades'); for (const module of chunk.orderedModules) { @@ -1061,10 +1051,8 @@ export default class Chunk { } private computeChunkName(): string { - if (this.entryModules.size > 0) { - for (const entryModule of Array.from(this.entryModules)) { - if (entryModule.chunkAlias) return entryModule.chunkAlias; - } + if (this.facadeModule !== null && this.facadeModule.chunkAlias) { + return this.facadeModule.chunkAlias; } for (const module of this.orderedModules) { if (module.chunkAlias) return module.chunkAlias; @@ -1136,7 +1124,7 @@ export default class Chunk { dependencies: this.renderedDeclarations.dependencies, exports: this.renderedDeclarations.exports, graph: this.graph, - isEntryModuleFacade: !!Array.from(this.entryModules).find(module => module.isEntryPoint), + isEntryModuleFacade: this.facadeModule !== null && this.facadeModule.isEntryPoint, usesTopLevelAwait }, options diff --git a/src/Graph.ts b/src/Graph.ts index 58f42f36040..f98b5c1264d 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -369,7 +369,7 @@ export default class Graph { this.link(); - const { orderedModules, cyclePaths, dynamicImports } = analyseModuleExecution(entryModules); + const { orderedModules, cyclePaths } = analyseModuleExecution(entryModules); for (const cyclePath of cyclePaths) { this.warn({ code: 'CIRCULAR_DEPENDENCY', @@ -419,7 +419,9 @@ export default class Graph { if (preserveModules) { for (const module of orderedModules) { const chunk = new Chunk(this, [module], inlineDynamicImports); - if (module.isEntryPoint || !chunk.isEmpty) chunk.entryModules.add(module); + if (module.isEntryPoint || !chunk.isEmpty) { + chunk.entryModules = [module]; + } chunks.push(chunk); } } else { @@ -450,35 +452,25 @@ export default class Graph { // filter out empty dependencies chunks = chunks.filter( - chunk => !chunk.isEmpty || chunk.entryModules.size > 0 || chunk.isManualChunk + chunk => !chunk.isEmpty || chunk.entryModules.length > 0 || chunk.isManualChunk ); // then go over and ensure all entry chunks export their variables for (const chunk of chunks) { - if (preserveModules || chunk.entryModules.size > 0) { + if (preserveModules || chunk.entryModules.length > 0) { chunk.generateEntryExportsOrMarkAsTainted(); } } // create entry point facades for entry module chunks that have tainted exports + const facades = []; if (!preserveModules) { - for (const entryModule of entryModules) { - if (!entryModule.chunk.entryModules.has(entryModule)) { - const entryPointFacade = new Chunk(this, [], inlineDynamicImports); - entryPointFacade.turnIntoFacade(entryModule); - chunks.push(entryPointFacade); - } - } - if (!inlineDynamicImports) { - for (const entryModule of dynamicImports) { - if ( - entryModule.isDynamicEntryPoint && - !entryModule.chunk.entryModules.has(entryModule) && - !entryModule.facadeChunk - ) { + for (const chunk of chunks) { + for (const entryModule of chunk.entryModules) { + if (chunk.facadeModule !== entryModule) { const entryPointFacade = new Chunk(this, [], inlineDynamicImports); entryPointFacade.turnIntoFacade(entryModule); - chunks.push(entryPointFacade); + facades.push(entryPointFacade); } } } @@ -487,7 +479,7 @@ export default class Graph { timeEnd('generate chunks', 2); this.finished = true; - return chunks; + return chunks.concat(facades); } ); } diff --git a/src/chunk-optimization.ts b/src/chunk-optimization.ts index 68debb60722..5c706f60fc7 100644 --- a/src/chunk-optimization.ts +++ b/src/chunk-optimization.ts @@ -36,10 +36,10 @@ export function optimizeChunks( nextChunk = execGroup[1]; const isMergeCandidate = (chunk: Chunk) => { - if (chunk.entryModules.size > 0 || chunk.isManualChunk) { + if (chunk.facadeModule !== null || chunk.isManualChunk) { return false; } - if (!nextChunk || nextChunk.entryModules.size > 0) { + if (!nextChunk || nextChunk.facadeModule !== null) { return false; } if (chunk.getRenderedSourceLength() > CHUNK_GROUPING_SIZE) { diff --git a/src/rollup/index.ts b/src/rollup/index.ts index c831e79c547..f1763e8fd69 100644 --- a/src/rollup/index.ts +++ b/src/rollup/index.ts @@ -68,7 +68,7 @@ function checkOutputOptions(options: OutputOptions) { function getAbsoluteEntryModulePaths(chunks: Chunk[]): string[] { const absoluteEntryModulePaths: string[] = []; for (const chunk of chunks) { - for (const entryModule of Array.from(chunk.entryModules)) { + for (const entryModule of chunk.entryModules) { if (isAbsolute(entryModule.id)) { absoluteEntryModulePaths.push(entryModule.id); } @@ -282,7 +282,7 @@ export default function rollup( for (const chunk of chunks) { if (!inputOptions.experimentalPreserveModules) chunk.generateInternalExports(outputOptions); - if (Array.from(chunk.entryModules).find(module => module.isEntryPoint)) + if (chunk.facadeModule && chunk.facadeModule.isEntryPoint) chunk.exportMode = getExportMode(chunk, outputOptions); } for (const chunk of chunks) { @@ -298,17 +298,16 @@ export default function rollup( // assign to outputBundle for (let i = 0; i < chunks.length; i++) { const chunk = chunks[i]; + const facadeModule = chunk.facadeModule; outputBundle[chunk.id] = { code: undefined, - entryModuleIds: Array.from(chunk.entryModules).map(module => module.id), + facadeModuleId: facadeModule && facadeModule.id, exports: chunk.getExportNames(), fileName: chunk.id, imports: chunk.getImportIds(), - isDynamicEntry: !!Array.from(chunk.entryModules).find( - module => module.isDynamicEntryPoint - ), - isEntry: !!Array.from(chunk.entryModules).find(module => module.isEntryPoint), + isDynamicEntry: facadeModule !== null && facadeModule.isDynamicEntryPoint, + isEntry: facadeModule !== null && facadeModule.isEntryPoint, map: undefined, modules: chunk.renderedModules, get name() { diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 519d582f298..3265f35c621 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -363,8 +363,8 @@ export interface RenderedModule { } export interface RenderedChunk { - entryModuleIds: string[]; exports: string[]; + facadeModuleId: string | null; fileName: string; imports: string[]; isDynamicEntry: boolean; diff --git a/src/utils/assignChunkIds.ts b/src/utils/assignChunkIds.ts index 75b6c592fa1..bd5fbcb667a 100644 --- a/src/utils/assignChunkIds.ts +++ b/src/utils/assignChunkIds.ts @@ -14,10 +14,9 @@ export function assignChunkIds( const usedIds: Record = {}; const [entryChunks, otherChunks] = chunks.reduce( ([entryChunks, otherChunks], chunk) => { - (Array.from(chunk.entryModules).find(module => module.isEntryPoint) - ? entryChunks - : otherChunks - ).push(chunk); + (chunk.facadeModule && chunk.facadeModule.isEntryPoint ? entryChunks : otherChunks).push( + chunk + ); return [entryChunks, otherChunks]; }, [[], []] @@ -37,7 +36,7 @@ export function assignChunkIds( chunk.generateIdPreserveModules(inputBase, usedIds); } else { let pattern, patternName; - if (Array.from(chunk.entryModules).find(module => module.isEntryPoint)) { + if (chunk.facadeModule && chunk.facadeModule.isEntryPoint) { pattern = outputOptions.entryFileNames || '[name].js'; patternName = 'output.entryFileNames'; } else { diff --git a/src/utils/executionOrder.ts b/src/utils/executionOrder.ts index 929f1958ba6..8cc2d12d9a9 100644 --- a/src/utils/executionOrder.ts +++ b/src/utils/executionOrder.ts @@ -75,7 +75,7 @@ export function analyseModuleExecution(entryModules: Module[]) { } } - return { orderedModules, dynamicImports, cyclePaths }; + return { orderedModules, cyclePaths }; } function getCyclePath(id: string, parentId: string, parents: { [id: string]: string | null }) { diff --git a/src/utils/getExportMode.ts b/src/utils/getExportMode.ts index 34d8dad23dc..174719b7a27 100644 --- a/src/utils/getExportMode.ts +++ b/src/utils/getExportMode.ts @@ -32,7 +32,8 @@ export default function getExportMode( exportMode = 'default'; } else { if ( - Array.from(chunk.entryModules).find(module => module.isEntryPoint) && + chunk.facadeModule !== null && + chunk.facadeModule.isEntryPoint && format !== 'es' && exportKeys.indexOf('default') !== -1 ) { diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js index 2e04f94135d..1c1ce78581c 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js @@ -7,7 +7,7 @@ define(['exports'], function (exports) { 'use strict'; console.log('dynamic1'); - exports.DYNAMIC_B = DYNAMIC_A; - exports.DYNAMIC_A = DYNAMIC_B; + exports.DYNAMIC_A = DYNAMIC_A; + exports.DYNAMIC_B = DYNAMIC_B; }); 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 index 4d555970c86..3fc5bfad3d6 100644 --- 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 @@ -2,7 +2,7 @@ define(['exports', './generated-dynamic.js'], function (exports, dynamic) { 'use - exports.DYNAMIC_A = dynamic.DYNAMIC_B; exports.DYNAMIC_B = dynamic.DYNAMIC_A; + exports.DYNAMIC_A = dynamic.DYNAMIC_B; }); 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 f23b8bdba20..0e20039a5ed 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-dynamic.js'], resolve, reject) }).then(result => console.log(result)); 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)); }); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js index b7a92cd20a5..19dd5e249f1 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js @@ -7,5 +7,5 @@ const DYNAMIC_B = 'DYNAMIC_B'; console.log('dynamic1'); -exports.DYNAMIC_B = DYNAMIC_A; -exports.DYNAMIC_A = DYNAMIC_B; +exports.DYNAMIC_A = DYNAMIC_A; +exports.DYNAMIC_B = DYNAMIC_B; 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-dynamic2.js index 836352671d2..e053e77b359 100644 --- 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-dynamic2.js @@ -4,5 +4,5 @@ var dynamic = require('./generated-dynamic.js'); -exports.DYNAMIC_A = dynamic.DYNAMIC_B; exports.DYNAMIC_B = dynamic.DYNAMIC_A; +exports.DYNAMIC_A = dynamic.DYNAMIC_B; 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 a23070ddb0b..0a28239769b 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-dynamic.js')).then(result => console.log(result)); Promise.resolve(require('./generated-dynamic2.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-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js index 395087d22e1..a819dae41d1 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js @@ -5,4 +5,4 @@ const DYNAMIC_B = 'DYNAMIC_B'; console.log('dynamic1'); -export { DYNAMIC_A as DYNAMIC_B, DYNAMIC_B as DYNAMIC_A }; +export { DYNAMIC_A, DYNAMIC_B }; 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-dynamic2.js index c1ec5610d56..c994f0671ad 100644 --- 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-dynamic2.js @@ -1 +1 @@ -export { DYNAMIC_B as DYNAMIC_A, DYNAMIC_A as DYNAMIC_B } from './generated-dynamic.js'; +export { DYNAMIC_A as DYNAMIC_B, DYNAMIC_B as DYNAMIC_A } from './generated-dynamic.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 e3074e5b20f..d191126a7d3 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-dynamic.js').then(result => console.log(result)); import('./generated-dynamic2.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-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js index 2f4e9da17e3..213666c17ca 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js @@ -5,8 +5,8 @@ System.register([], function (exports, module) { console.log('dynamic2'); - const DYNAMIC_A = exports('DYNAMIC_B', 'DYNAMIC_A'); - const DYNAMIC_B = exports('DYNAMIC_A', 'DYNAMIC_B'); + const DYNAMIC_A = exports('DYNAMIC_A', 'DYNAMIC_A'); + const DYNAMIC_B = exports('DYNAMIC_B', 'DYNAMIC_B'); console.log('dynamic1'); 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-dynamic2.js index f4755fbc899..27e6e17fb12 100644 --- 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-dynamic2.js @@ -3,8 +3,8 @@ System.register(['./generated-dynamic.js'], function (exports, module) { return { setters: [function (module) { var _setter = {}; - _setter.DYNAMIC_A = module.DYNAMIC_B; _setter.DYNAMIC_B = module.DYNAMIC_A; + _setter.DYNAMIC_A = module.DYNAMIC_B; exports(_setter); }], execute: function () { 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 e9f22dd3854..fa189fe4b60 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,8 +3,8 @@ System.register([], function (exports, module) { return { execute: function () { - module.import('./generated-dynamic.js').then(result => console.log(result)); module.import('./generated-dynamic2.js').then(result => console.log(result)); + module.import('./generated-dynamic.js').then(result => console.log(result)); } }; diff --git a/test/function/samples/cycles-pathological/A.js b/test/function/samples/cycles-pathological/A.js deleted file mode 100644 index 9e0fd2e72cc..00000000000 --- a/test/function/samples/cycles-pathological/A.js +++ /dev/null @@ -1,11 +0,0 @@ -import B from './B'; - -export default class A { - constructor () { - this.isA = true; - } - - b () { - return new B(); - } -} diff --git a/test/function/samples/cycles-pathological/B.js b/test/function/samples/cycles-pathological/B.js deleted file mode 100644 index 1c8e9b4b3e5..00000000000 --- a/test/function/samples/cycles-pathological/B.js +++ /dev/null @@ -1,8 +0,0 @@ -import A from './A'; - -export default class B extends A { - constructor () { - super(); - this.isB = true; - } -} diff --git a/test/function/samples/cycles-pathological/C.js b/test/function/samples/cycles-pathological/C.js deleted file mode 100644 index 313bba7af02..00000000000 --- a/test/function/samples/cycles-pathological/C.js +++ /dev/null @@ -1,8 +0,0 @@ -import D from './D'; - -export default class C extends D { - constructor () { - super(); - this.isC = true; - } -} diff --git a/test/function/samples/cycles-pathological/D.js b/test/function/samples/cycles-pathological/D.js deleted file mode 100644 index 2d8a405328d..00000000000 --- a/test/function/samples/cycles-pathological/D.js +++ /dev/null @@ -1,11 +0,0 @@ -import C from './C'; - -export default class D { - constructor () { - this.isD = true; - } - - c () { - return new C(); - } -} diff --git a/test/function/samples/cycles-pathological/_config.js b/test/function/samples/cycles-pathological/_config.js deleted file mode 100644 index c400adbf775..00000000000 --- a/test/function/samples/cycles-pathological/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - skip: true, - description: 'resolves pathological cyclical dependencies gracefully', - buble: true, - warnings: [ - { - code: 'CIRCULAR_DEPENDENCY', - importer: 'A.js', - message: 'Circular dependency: A.js -> B.js -> A.js' - }, - { - code: 'CIRCULAR_DEPENDENCY', - importer: 'C.js', - message: 'Circular dependency: C.js -> D.js -> C.js' - } - ] -}; diff --git a/test/function/samples/cycles-pathological/main.js b/test/function/samples/cycles-pathological/main.js deleted file mode 100644 index f4c19dbcddb..00000000000 --- a/test/function/samples/cycles-pathological/main.js +++ /dev/null @@ -1,12 +0,0 @@ -import A from './A'; -import B from './B'; - -import C from './C'; -import D from './D'; - -export const a = new A(); -export const b1 = a.b(); -export const b2 = new B(); -export const c1 = new C(); -export const d = new D(); -export const c2 = d.c(); diff --git a/test/function/samples/iife-strong-dependencies/A.js b/test/function/samples/iife-strong-dependencies/A.js deleted file mode 100644 index 2c51ca572ab..00000000000 --- a/test/function/samples/iife-strong-dependencies/A.js +++ /dev/null @@ -1,15 +0,0 @@ -import { B } from './B'; - -export var A = function () { - this.isA = true; -}; - -A.prototype = { - b: function () { - var Constructor = B; - - return function () { - return new Constructor(); - }; - }() -}; diff --git a/test/function/samples/iife-strong-dependencies/B.js b/test/function/samples/iife-strong-dependencies/B.js deleted file mode 100644 index f06d45d100e..00000000000 --- a/test/function/samples/iife-strong-dependencies/B.js +++ /dev/null @@ -1,11 +0,0 @@ -import { A } from './A'; - -export var B = function () { - this.isB = true; -}; - -B.prototype = { - a: function () { - return new A(); - } -}; diff --git a/test/function/samples/iife-strong-dependencies/C.js b/test/function/samples/iife-strong-dependencies/C.js deleted file mode 100644 index 9da83316bec..00000000000 --- a/test/function/samples/iife-strong-dependencies/C.js +++ /dev/null @@ -1,11 +0,0 @@ -import { D } from './D'; - -export var C = function () { - this.isC = true; -}; - -C.prototype = { - d: function () { - return new D(); - } -}; diff --git a/test/function/samples/iife-strong-dependencies/D.js b/test/function/samples/iife-strong-dependencies/D.js deleted file mode 100644 index ad3afa0b7e3..00000000000 --- a/test/function/samples/iife-strong-dependencies/D.js +++ /dev/null @@ -1,15 +0,0 @@ -import { C } from './C'; - -export var D = function () { - this.isD = true; -}; - -D.prototype = { - c: function () { - var Constructor = C; - - return function () { - return new Constructor(); - }; - }() -}; diff --git a/test/function/samples/iife-strong-dependencies/_config.js b/test/function/samples/iife-strong-dependencies/_config.js deleted file mode 100644 index f1e515689ab..00000000000 --- a/test/function/samples/iife-strong-dependencies/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - skip: true, - description: 'does not treat references inside IIFEs as weak dependencies', // edge case encountered in THREE.js codebase - warnings: [ - { - code: 'CIRCULAR_DEPENDENCY', - importer: 'A.js', - message: 'Circular dependency: A.js -> B.js -> A.js' - }, - { - code: 'CIRCULAR_DEPENDENCY', - importer: 'C.js', - message: 'Circular dependency: C.js -> D.js -> C.js' - } - ] -}; diff --git a/test/function/samples/iife-strong-dependencies/main.js b/test/function/samples/iife-strong-dependencies/main.js deleted file mode 100644 index 1eaa49de80e..00000000000 --- a/test/function/samples/iife-strong-dependencies/main.js +++ /dev/null @@ -1,14 +0,0 @@ -import { A } from './A'; -import { B } from './B'; -import { C } from './C'; -import { D } from './D'; - -export var a1 = new A(); -export var b1 = new B(); -export var c1 = new C(); -export var d1 = new D(); - -export var a2 = b1.a(); -export var b2 = a1.b(); -export var c2 = d1.c(); -export var d2 = c1.d(); diff --git a/test/misc/bundle-information.js b/test/misc/bundle-information.js index 724b1d8bddc..bfeb5ffcc95 100644 --- a/test/misc/bundle-information.js +++ b/test/misc/bundle-information.js @@ -2,7 +2,6 @@ const assert = require('assert'); const rollup = require('../../dist/rollup'); const { loader } = require('../utils.js'); -// TODO Lukas test multiple entry module ids describe('The bundle object', () => { it('contains information about the generated chunks', () => { return rollup @@ -51,9 +50,9 @@ describe('The bundle object', () => { 'name' ); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [[], ['input1'], ['input2']], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + [null, 'input1', 'input2'], + 'facadeModuleId' ); assert.deepEqual( sortedOutput.map(chunk => chunk.imports), @@ -131,9 +130,9 @@ describe('The bundle object', () => { ); assert.deepEqual(sortedOutput.map(chunk => chunk.isEntry), [false, true, true], 'isEntry'); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [[], ['input1'], ['input2']], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + [null, 'input1', 'input2'], + 'facadeModuleId' ); }); }); @@ -170,9 +169,9 @@ describe('The bundle object', () => { 'fileName' ); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [['input1'], ['input2'], []], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + ['input1', 'input2', null], + 'facadeModuleId' ); }); }); @@ -224,9 +223,9 @@ describe('The bundle object', () => { 'isDynamicEntry' ); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [['dynamic1'], ['dynamic2'], ['input']], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + ['dynamic1', 'dynamic2', 'input'], + 'facadeModuleId' ); }); }); @@ -273,9 +272,9 @@ describe('The bundle object', () => { 'isDynamicEntry' ); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [[], ['dynamic'], ['input1'], ['input2']], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + [null, 'dynamic', 'input1', 'input2'], + 'facadeModuleId' ); }); }); @@ -381,9 +380,9 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the 'isDynamicEntry' ); assert.deepEqual( - sortedOutput.map(chunk => chunk.entryModuleIds), - [['dynamic1'], ['dynamic2'], ['input'], ['other']], - 'entryModuleIds' + sortedOutput.map(chunk => chunk.facadeModuleId), + ['dynamic1', 'dynamic2', 'input', 'other'], + 'facadeModuleId' ); }); });