diff --git a/src/Chunk.ts b/src/Chunk.ts index f37bb70eee6..773f4b03001 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -136,6 +136,7 @@ export default class Chunk { ) { chunk.dependencies.add(facadedModule.chunk!); } + chunk.ensureReexportsAreAvailableForModule(facadedModule); chunk.facadeModule = facadedModule; chunk.strictFacade = true; return chunk; @@ -214,7 +215,7 @@ export default class Chunk { } } - canModuleBeFacade(module: Module, exposedNamespaces: NamespaceVariable[]): boolean { + canModuleBeFacade(module: Module, exposedVariables: Set): boolean { const moduleExportNamesByVariable = module.getExportNamesByVariable(); for (const exposedVariable of this.exports) { if (!moduleExportNamesByVariable.has(exposedVariable)) { @@ -236,7 +237,7 @@ export default class Chunk { return false; } } - for (const exposedVariable of exposedNamespaces) { + for (const exposedVariable of exposedVariables) { if ( !(moduleExportNamesByVariable.has(exposedVariable) || exposedVariable.module === module) ) { @@ -279,7 +280,14 @@ export default class Chunk { module.includedDynamicImporters.some(importingModule => importingModule.chunk !== this) ); this.isDynamicEntry = dynamicEntryModules.length > 0; - const exposedNamespaces = dynamicEntryModules.map(module => module.namespace); + const exposedVariables = new Set(dynamicEntryModules.map(module => module.namespace)); + for (const module of this.entryModules) { + if (module.preserveSignature) { + for (const exportedVariable of module.getExportNamesByVariable().keys()) { + exposedVariables.add(exportedVariable); + } + } + } for (const module of this.entryModules) { const requiredFacades: FacadeName[] = [...module.userChunkNames].map(name => ({ name @@ -295,11 +303,14 @@ export default class Chunk { !this.facadeModule && (this.graph.preserveModules || module.preserveSignature !== 'strict' || - this.canModuleBeFacade(module, exposedNamespaces)) + this.canModuleBeFacade(module, exposedVariables)) ) { this.facadeModule = module; module.facadeChunk = this; - this.strictFacade = module.preserveSignature === 'strict'; + if (module.preserveSignature) { + this.strictFacade = module.preserveSignature === 'strict'; + this.ensureReexportsAreAvailableForModule(module); + } this.assignFacadeName(requiredFacades.shift()!, module); } @@ -308,7 +319,7 @@ export default class Chunk { } } for (const module of dynamicEntryModules) { - if (!this.facadeModule && this.canModuleBeFacade(module, exposedNamespaces)) { + if (!this.facadeModule && this.canModuleBeFacade(module, exposedVariables)) { this.facadeModule = module; module.facadeChunk = this; this.strictFacade = true; @@ -316,7 +327,7 @@ export default class Chunk { } else if ( this.facadeModule === module && !this.strictFacade && - this.canModuleBeFacade(module, exposedNamespaces) + this.canModuleBeFacade(module, exposedVariables) ) { this.strictFacade = true; } else if (!(module.facadeChunk && module.facadeChunk.strictFacade)) { @@ -749,6 +760,28 @@ export default class Chunk { return hash.digest('hex').substr(0, 8); } + private ensureReexportsAreAvailableForModule(module: Module) { + const map = module.getExportNamesByVariable(); + for (const exportedVariable of map.keys()) { + const isSynthetic = exportedVariable instanceof SyntheticNamedExportVariable; + const importedVariable = isSynthetic + ? (exportedVariable as SyntheticNamedExportVariable).getBaseVariable() + : exportedVariable; + const exportingModule = importedVariable.module; + if ( + exportingModule && + exportingModule.chunk && + exportingModule.chunk !== this && + !(importedVariable instanceof NamespaceVariable && this.graph.preserveModules) + ) { + exportingModule.chunk.exports.add(importedVariable); + if (isSynthetic) { + this.imports.add(importedVariable); + } + } + } + } + private finaliseDynamicImports(options: OutputOptions) { const stripKnownJsExtensions = options.format === 'amd'; for (const [module, code] of this.renderedModuleSources) { @@ -1067,11 +1100,8 @@ export default class Chunk { if (variable instanceof ExportDefaultVariable) { variable = variable.getOriginalVariable(); } - while (variable instanceof SyntheticNamedExportVariable) { + if (variable instanceof SyntheticNamedExportVariable) { variable = variable.getBaseVariable(); - if (variable instanceof ExportDefaultVariable) { - variable = variable.getOriginalVariable(); - } } if (variable.module && (variable.module as Module).chunk !== this) { this.imports.add(variable); @@ -1085,44 +1115,21 @@ export default class Chunk { } if ( (module.isEntryPoint && module.preserveSignature !== false) || - module.includedDynamicImporters.some(importer => importer.chunk !== this) + module.includedDynamicImporters.some(importer => importer.chunk !== this) || + module.namespace.included ) { - const map = module.getExportNamesByVariable(); - for (const exportedVariable of map.keys()) { - if (module.isEntryPoint && module.preserveSignature !== false) { - this.exports.add(exportedVariable); - } - const isSynthetic = exportedVariable instanceof SyntheticNamedExportVariable; - const importedVariable = isSynthetic - ? (exportedVariable as SyntheticNamedExportVariable).getBaseVariable() - : exportedVariable; - const exportingModule = importedVariable.module; - if ( - exportingModule && - exportingModule.chunk && - exportingModule.chunk !== this && - !(importedVariable instanceof NamespaceVariable && this.graph.preserveModules) - ) { - exportingModule.chunk.exports.add(importedVariable); - if (isSynthetic) { - this.imports.add(importedVariable); - } - } - } - } - if (module.namespace.included) { - for (const reexportName of Object.keys(module.reexportDescriptions)) { - const reexport = module.reexportDescriptions[reexportName]; - const variable = reexport.module.getVariableForExportName(reexport.localName); - if ((variable.module as Module).chunk && (variable.module as Module).chunk !== this) { - this.imports.add(variable); - (variable.module as Module).chunk!.exports.add(variable); - } - } + this.ensureReexportsAreAvailableForModule(module); } for (const { node, resolution } of module.dynamicImports) { - if (node.included && resolution instanceof Module && resolution.chunk === this) + if ( + node.included && + resolution instanceof Module && + resolution.chunk === this && + !resolution.namespace.included + ) { resolution.namespace.include(); + this.ensureReexportsAreAvailableForModule(resolution); + } } } } diff --git a/src/ast/variables/SyntheticNamedExportVariable.ts b/src/ast/variables/SyntheticNamedExportVariable.ts index 079997da185..cce4cdb8f9b 100644 --- a/src/ast/variables/SyntheticNamedExportVariable.ts +++ b/src/ast/variables/SyntheticNamedExportVariable.ts @@ -1,4 +1,5 @@ import Module, { AstContext } from '../../Module'; +import ExportDefaultVariable from './ExportDefaultVariable'; import Variable from './Variable'; export default class SyntheticNamedExportVariable extends Variable { @@ -14,9 +15,14 @@ export default class SyntheticNamedExportVariable extends Variable { } getBaseVariable(): Variable { - return this.defaultVariable instanceof SyntheticNamedExportVariable - ? this.defaultVariable.getBaseVariable() - : this.defaultVariable; + let baseVariable = this.defaultVariable; + if (baseVariable instanceof ExportDefaultVariable) { + baseVariable = baseVariable.getOriginalVariable(); + } + if (baseVariable instanceof SyntheticNamedExportVariable) { + baseVariable = baseVariable.getBaseVariable(); + } + return baseVariable; } getName(): string { diff --git a/test/chunking-form/samples/circular-entry-points2/_config.js b/test/chunking-form/samples/circular-entry-points2/_config.js new file mode 100644 index 00000000000..4894b95c53b --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_config.js @@ -0,0 +1,7 @@ +module.exports = { + description: 'does not create a facade for one circular entry point if possible', + expectedWarnings: ['CIRCULAR_DEPENDENCY'], + options: { + input: ['main1.js', 'main2.js'] + } +}; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js new file mode 100644 index 00000000000..0c0e9f7352f --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js @@ -0,0 +1,9 @@ +define(['exports', './main2'], function (exports, main2) { 'use strict'; + + + + exports.p = main2.p2; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js new file mode 100644 index 00000000000..87ad8f15065 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js @@ -0,0 +1,28 @@ +define(['exports'], function (exports) { 'use strict'; + + class C { + fn (num) { + console.log(num - p$1); + } + } + + var p = 43; + + new C().fn(p); + + class C$1 { + fn (num) { + console.log(num - p); + } + } + + var p$1 = 42; + + new C$1().fn(p$1); + + exports.p = p; + exports.p2 = p$1; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js new file mode 100644 index 00000000000..3e8554d3bd1 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = require('./main2.js'); + + + +exports.p = main2.p2; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js new file mode 100644 index 00000000000..050aa9c4289 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js @@ -0,0 +1,26 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 43; + +new C().fn(p); + +class C$1 { + fn (num) { + console.log(num - p); + } +} + +var p$1 = 42; + +new C$1().fn(p$1); + +exports.p = p; +exports.p2 = p$1; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/es/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/es/main1.js new file mode 100644 index 00000000000..1f1e926d922 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/es/main1.js @@ -0,0 +1 @@ +export { p2 as p } from './main2.js'; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js new file mode 100644 index 00000000000..d530e34835b --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js @@ -0,0 +1,21 @@ +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 43; + +new C().fn(p); + +class C$1 { + fn (num) { + console.log(num - p); + } +} + +var p$1 = 42; + +new C$1().fn(p$1); + +export { p, p$1 as p2 }; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js new file mode 100644 index 00000000000..2b0dfa618c7 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js @@ -0,0 +1,13 @@ +System.register(['./main2.js'], function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports('p', module.p2); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js new file mode 100644 index 00000000000..ce9269d446a --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js @@ -0,0 +1,28 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + class C { + fn (num) { + console.log(num - p$1); + } + } + + var p = exports('p', 43); + + new C().fn(p); + + class C$1 { + fn (num) { + console.log(num - p); + } + } + + var p$1 = exports('p2', 42); + + new C$1().fn(p$1); + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points2/dep1.js b/test/chunking-form/samples/circular-entry-points2/dep1.js new file mode 100644 index 00000000000..799a8a1dd37 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/dep1.js @@ -0,0 +1,7 @@ +import { p } from './main2.js'; + +export class C { + fn (num) { + console.log(num - p); + } +} \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points2/dep2.js b/test/chunking-form/samples/circular-entry-points2/dep2.js new file mode 100644 index 00000000000..447c825cfe5 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/dep2.js @@ -0,0 +1,7 @@ +import { p } from './main1.js'; + +export class C { + fn (num) { + console.log(num - p); + } +} \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points2/main1.js b/test/chunking-form/samples/circular-entry-points2/main1.js new file mode 100644 index 00000000000..7f72c878ec7 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/main1.js @@ -0,0 +1,4 @@ +import { C } from './dep1.js'; +export var p = 42; + +new C().fn(p); \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points2/main2.js b/test/chunking-form/samples/circular-entry-points2/main2.js new file mode 100644 index 00000000000..d6d2a17e0f9 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points2/main2.js @@ -0,0 +1,5 @@ +import { C } from './dep2.js'; +export var p = 43; +export {p as p2} from './main1' + +new C().fn(p); \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points3/_config.js b/test/chunking-form/samples/circular-entry-points3/_config.js new file mode 100644 index 00000000000..8902b116aef --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_config.js @@ -0,0 +1,8 @@ +module.exports = { + description: + 'creates facades for all circular entry points if they become tainted by another entry', + expectedWarnings: ['CIRCULAR_DEPENDENCY'], + options: { + input: ['main1.js', 'main2.js', 'main3.js'] + } +}; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js new file mode 100644 index 00000000000..510ed213e53 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js @@ -0,0 +1,27 @@ +define(['exports'], function (exports) { 'use strict'; + + class C { + fn (num) { + console.log(num - p$1); + } + } + + var p = 43; + + new C().fn(p); + + class C$1 { + fn (num) { + console.log(num - p); + } + } + + var p$1 = 42; + + new C$1().fn(p$1); + + exports.C = C; + exports.p = p; + exports.p$1 = p$1; + +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js new file mode 100644 index 00000000000..0ab330944b0 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js @@ -0,0 +1,9 @@ +define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; + + + + exports.p = main2.p$1; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js new file mode 100644 index 00000000000..5c35d167805 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js @@ -0,0 +1,10 @@ +define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; + + + + exports.p = main2.p; + exports.p2 = main2.p$1; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js new file mode 100644 index 00000000000..18d49d297a1 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js @@ -0,0 +1,9 @@ +define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; + + + + exports.C = main2.C; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js new file mode 100644 index 00000000000..e69eb1f0aa2 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js @@ -0,0 +1,25 @@ +'use strict'; + +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 43; + +new C().fn(p); + +class C$1 { + fn (num) { + console.log(num - p); + } +} + +var p$1 = 42; + +new C$1().fn(p$1); + +exports.C = C; +exports.p = p; +exports.p$1 = p$1; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js new file mode 100644 index 00000000000..a5ec2910766 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = require('./generated-main1.js'); + + + +exports.p = main2.p$1; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js new file mode 100644 index 00000000000..bc1e103d7c1 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js @@ -0,0 +1,10 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = require('./generated-main1.js'); + + + +exports.p = main2.p; +exports.p2 = main2.p$1; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js new file mode 100644 index 00000000000..e89188ab5e8 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js @@ -0,0 +1,9 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = require('./generated-main1.js'); + + + +exports.C = main2.C; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js new file mode 100644 index 00000000000..15084775e00 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js @@ -0,0 +1,21 @@ +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 43; + +new C().fn(p); + +class C$1 { + fn (num) { + console.log(num - p); + } +} + +var p$1 = 42; + +new C$1().fn(p$1); + +export { C, p$1 as a, p }; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js new file mode 100644 index 00000000000..0a83cdd426e --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js @@ -0,0 +1 @@ +export { a as p } from './generated-main1.js'; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js new file mode 100644 index 00000000000..422b3e863a5 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js @@ -0,0 +1 @@ +export { p, a as p2 } from './generated-main1.js'; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js new file mode 100644 index 00000000000..541321f375e --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js @@ -0,0 +1 @@ +export { C } from './generated-main1.js'; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js new file mode 100644 index 00000000000..893f1592c4c --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js @@ -0,0 +1,28 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + class C { + fn (num) { + console.log(num - p$1); + } + } exports('C', C); + + var p = exports('p', 43); + + new C().fn(p); + + class C$1 { + fn (num) { + console.log(num - p); + } + } + + var p$1 = exports('a', 42); + + new C$1().fn(p$1); + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js new file mode 100644 index 00000000000..491c2be1e9f --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js @@ -0,0 +1,13 @@ +System.register(['./generated-main1.js'], function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports('p', module.a); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js new file mode 100644 index 00000000000..f3c05e2aa76 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js @@ -0,0 +1,16 @@ +System.register(['./generated-main1.js'], function (exports) { + 'use strict'; + return { + setters: [function (module) { + var _setter = {}; + _setter.p = module.p; + _setter.p2 = module.a; + exports(_setter); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js new file mode 100644 index 00000000000..d4d8510a240 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js @@ -0,0 +1,13 @@ +System.register(['./generated-main1.js'], function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports('C', module.C); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/circular-entry-points3/dep1.js b/test/chunking-form/samples/circular-entry-points3/dep1.js new file mode 100644 index 00000000000..799a8a1dd37 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/dep1.js @@ -0,0 +1,7 @@ +import { p } from './main2.js'; + +export class C { + fn (num) { + console.log(num - p); + } +} \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points3/dep2.js b/test/chunking-form/samples/circular-entry-points3/dep2.js new file mode 100644 index 00000000000..447c825cfe5 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/dep2.js @@ -0,0 +1,7 @@ +import { p } from './main1.js'; + +export class C { + fn (num) { + console.log(num - p); + } +} \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points3/main1.js b/test/chunking-form/samples/circular-entry-points3/main1.js new file mode 100644 index 00000000000..7f72c878ec7 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/main1.js @@ -0,0 +1,4 @@ +import { C } from './dep1.js'; +export var p = 42; + +new C().fn(p); \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points3/main2.js b/test/chunking-form/samples/circular-entry-points3/main2.js new file mode 100644 index 00000000000..d6d2a17e0f9 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/main2.js @@ -0,0 +1,5 @@ +import { C } from './dep2.js'; +export var p = 43; +export {p as p2} from './main1' + +new C().fn(p); \ No newline at end of file diff --git a/test/chunking-form/samples/circular-entry-points3/main3.js b/test/chunking-form/samples/circular-entry-points3/main3.js new file mode 100644 index 00000000000..c4ff0c3fe85 --- /dev/null +++ b/test/chunking-form/samples/circular-entry-points3/main3.js @@ -0,0 +1 @@ +export { C } from './dep2.js'; diff --git a/test/chunking-form/samples/default-reexport-namespace/Component_one.js b/test/chunking-form/samples/default-reexport-namespace/Component_one.js new file mode 100644 index 00000000000..c1d4cb56ebd --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/Component_one.js @@ -0,0 +1,4 @@ +import * as icons from './icons/index'; +const __component__ = { icons }; + +export default __component__; diff --git a/test/chunking-form/samples/default-reexport-namespace/_config.js b/test/chunking-form/samples/default-reexport-namespace/_config.js new file mode 100644 index 00000000000..20ee29986bd --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'Properly handle adding a default reexport to a namespace (#3583)', + options: { + input: ['main.js', 'icons/one.js'] + } +}; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js new file mode 100644 index 00000000000..c28f6995097 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js @@ -0,0 +1,17 @@ +define(['exports', './one'], function (exports, one) { 'use strict'; + + const __icon__ = {}; + + var icons = /*#__PURE__*/Object.freeze({ + __proto__: null, + one: one, + two: __icon__ + }); + + const __component__ = { icons }; + + exports.Component_one = __component__; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js new file mode 100644 index 00000000000..19ec22efce4 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js @@ -0,0 +1,7 @@ +define(function () { 'use strict'; + + const __icon__ = {}; + + return __icon__; + +}); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js new file mode 100644 index 00000000000..9333ccc880a --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js @@ -0,0 +1,17 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var one = require('./one.js'); + +const __icon__ = {}; + +var icons = /*#__PURE__*/Object.freeze({ + __proto__: null, + one: one, + two: __icon__ +}); + +const __component__ = { icons }; + +exports.Component_one = __component__; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/one.js new file mode 100644 index 00000000000..15bdec56a09 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/one.js @@ -0,0 +1,5 @@ +'use strict'; + +const __icon__ = {}; + +module.exports = __icon__; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/es/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/es/main.js new file mode 100644 index 00000000000..b6f196aa931 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/es/main.js @@ -0,0 +1,13 @@ +import __icon__$1 from './one.js'; + +const __icon__ = {}; + +var icons = /*#__PURE__*/Object.freeze({ + __proto__: null, + one: __icon__$1, + two: __icon__ +}); + +const __component__ = { icons }; + +export { __component__ as Component_one }; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js new file mode 100644 index 00000000000..db8b271506d --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js @@ -0,0 +1,3 @@ +const __icon__ = {}; + +export default __icon__; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js new file mode 100644 index 00000000000..f8bec502907 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js @@ -0,0 +1,22 @@ +System.register(['./one.js'], function (exports) { + 'use strict'; + var __icon__$1; + return { + setters: [function (module) { + __icon__$1 = module.default; + }], + execute: function () { + + const __icon__ = {}; + + var icons = /*#__PURE__*/Object.freeze({ + __proto__: null, + one: __icon__$1, + two: __icon__ + }); + + const __component__ = exports('Component_one', { icons }); + + } + }; +}); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js new file mode 100644 index 00000000000..1db761192aa --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js @@ -0,0 +1,10 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + const __icon__ = exports('default', {}); + + } + }; +}); diff --git a/test/chunking-form/samples/default-reexport-namespace/icons/index.js b/test/chunking-form/samples/default-reexport-namespace/icons/index.js new file mode 100644 index 00000000000..c2796004c63 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/icons/index.js @@ -0,0 +1,2 @@ +export { default as one } from './one'; +export { default as two } from './two'; diff --git a/test/chunking-form/samples/default-reexport-namespace/icons/one.js b/test/chunking-form/samples/default-reexport-namespace/icons/one.js new file mode 100644 index 00000000000..57ec7d457cc --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/icons/one.js @@ -0,0 +1,3 @@ +const __icon__ = {} + +export default __icon__ \ No newline at end of file diff --git a/test/chunking-form/samples/default-reexport-namespace/icons/two.js b/test/chunking-form/samples/default-reexport-namespace/icons/two.js new file mode 100644 index 00000000000..57ec7d457cc --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/icons/two.js @@ -0,0 +1,3 @@ +const __icon__ = {} + +export default __icon__ \ No newline at end of file diff --git a/test/chunking-form/samples/default-reexport-namespace/main.js b/test/chunking-form/samples/default-reexport-namespace/main.js new file mode 100644 index 00000000000..56ed900bc54 --- /dev/null +++ b/test/chunking-form/samples/default-reexport-namespace/main.js @@ -0,0 +1 @@ +export { default as Component_one } from './Component_one.js' \ No newline at end of file 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-m1.js index 83a962f60e6..6eb70776913 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-m1.js @@ -5,7 +5,6 @@ define(['exports', './m2'], function (exports, m2) { 'use strict'; m2: m2 }); - exports.m2 = m2; exports.ms = 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-m1.js index d23d73ad3a4..eea2266f351 100644 --- 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-m1.js @@ -7,5 +7,4 @@ var ms = /*#__PURE__*/Object.freeze({ m2: m2 }); -exports.m2 = m2; exports.ms = 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-m1.js index 4e392790970..ccd9e9db623 100644 --- 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-m1.js @@ -1,5 +1,4 @@ import m2 from './m2.js'; -export { default as a } from './m2.js'; var ms = /*#__PURE__*/Object.freeze({ __proto__: null, 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-m1.js index 78363f16b3c..b34ac383826 100644 --- 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-m1.js @@ -4,7 +4,6 @@ System.register(['./m2.js'], function (exports) { return { setters: [function (module) { m2 = module.default; - exports('a', module.default); }], execute: function () { diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js index f9e5cec4b44..ee94337e5c7 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js @@ -9,7 +9,6 @@ define(['exports', './hsl2hsv'], function (exports, hsl2hsv$1) { 'use strict'; hsl2hsv: hsl2hsv$1.default }); - exports.hsl2hsv = hsl2hsv$1.default; exports.lib = 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-index.js index e6feee3b2d5..ba17616743a 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js @@ -11,5 +11,4 @@ var lib = /*#__PURE__*/Object.freeze({ hsl2hsv: hsl2hsv$1.default }); -exports.hsl2hsv = hsl2hsv$1.default; exports.lib = 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-index.js index 8909c925361..336402c5e5a 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/generated-index.js @@ -1,5 +1,4 @@ import hsl2hsv$1 from './hsl2hsv.js'; -export { default as h } from './hsl2hsv.js'; var hsl2hsv = 'asdf'; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js index 69c57be6889..118caaa4461 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js @@ -4,7 +4,6 @@ System.register(['./hsl2hsv.js'], function (exports) { return { setters: [function (module) { hsl2hsv$1 = module.default; - exports('h', module.default); }], execute: function () { diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/amd/generated-main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/amd/generated-main.js index cc76c0ee790..fe09f7042fa 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/amd/generated-main.js @@ -10,6 +10,5 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.component = component; exports.lib = lib; - exports.named = lib.named.named; }); diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/cjs/generated-main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/cjs/generated-main.js index 93fa468efbc..8a2ad71358c 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/cjs/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/cjs/generated-main.js @@ -10,4 +10,3 @@ const component = Promise.resolve().then(function () { return require('./generat exports.component = component; exports.lib = lib; -exports.named = lib.named.named; diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/generated-main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/generated-main.js index 3d845ab0477..b8598bac797 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/generated-main.js @@ -6,5 +6,4 @@ console.log('side-effect', lib.named.named); const component = import('./generated-component.js'); -var named = lib.named.named; -export { component as c, lib as l, named as n }; +export { component as c, lib as l }; diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/main.js index 9ab84eae5f0..cb24dd95a18 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/es/main.js @@ -1,3 +1,4 @@ +import { l as lib } from './generated-main.js'; export { c as component } from './generated-main.js'; diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/generated-main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/generated-main.js index 9c6835cb9f0..b1a94a5bd00 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/generated-main.js @@ -11,8 +11,6 @@ System.register([], function (exports, module) { const component = exports('c', module.import('./generated-component.js')); - exports('n', lib.named.named); - } }; }); diff --git a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/main.js index 299247f67aa..93f798d3b7d 100644 --- a/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports-chained-default-reexport/_expected/system/main.js @@ -1,7 +1,9 @@ System.register(['./generated-main.js'], function (exports) { 'use strict'; + var lib; return { setters: [function (module) { + lib = module.l; exports('component', module.c); }], execute: function () {