diff --git a/src/Chunk.ts b/src/Chunk.ts index a1e52a87fa6..ee499483cd0 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -3,7 +3,7 @@ import MagicString, { Bundle as MagicStringBundle, SourceMap } from 'magic-strin import * as NodeType from './ast/nodes/NodeType'; import { UNDEFINED_EXPRESSION } from './ast/values'; import { isExportDefaultVariable } from './ast/variables/ExportDefaultVariable'; -import ExternalVariable from './ast/variables/ExternalVariable'; +import ExportShimVariable from './ast/variables/ExportShimVariable'; import GlobalVariable from './ast/variables/GlobalVariable'; import LocalVariable from './ast/variables/LocalVariable'; import NamespaceVariable from './ast/variables/NamespaceVariable'; @@ -31,6 +31,7 @@ import renderChunk from './utils/renderChunk'; import { RenderOptions } from './utils/renderHelpers'; import { makeUnique, renderNamePattern } from './utils/renderNamePattern'; import { timeEnd, timeStart } from './utils/timers'; +import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; export interface ModuleDeclarations { exports: ChunkExports; @@ -99,50 +100,39 @@ function getGlobalName( } } -function isNamespaceVariable(variable: Variable): variable is NamespaceVariable | ExternalVariable { - return variable.isNamespace; -} - export default class Chunk { - hasDynamicImport: boolean = false; - indentString: string = undefined; + execIndex: number; + entryModules: Module[] = []; exportMode: string = 'named'; - usedModules: Module[] = undefined; - id: string = undefined; - variableName: string; + facadeModule: Module | null = null; graph: Graph; + hasDynamicImport: boolean = false; + id: string = undefined; + indentString: string = undefined; + isEmpty: boolean; + isManualChunk: boolean = false; orderedModules: Module[]; - execIndex: number; - renderedModules: { [moduleId: string]: RenderedModule; }; + usedModules: Module[] = undefined; + variableName: string; - // this represents the chunk module wrappings - // which form the output dependency graph - private imports = new Map(); - // module can be in or out of chunk - // if module is out of the chunk then it is a reexport - private exports = new Map(); - private exportNames: { [name: string]: Variable } = Object.create(null); - + private chunkName: string | void; private dependencies: (ExternalModule | Chunk)[] = undefined; private dynamicDependencies: (ExternalModule | Chunk)[] = undefined; - entryModules: Module[] = []; - facadeModule: Module | null = null; - isEmpty: boolean; - isManualChunk: boolean = false; - - private renderedHash: string = undefined; - private renderedModuleSources: MagicString[] = undefined; - private renderedSource: MagicStringBundle = undefined; - private renderedSourceLength: number = undefined; + private exportNames: { [name: string]: Variable } = Object.create(null); + private exports = new Set(); + private imports = new Set(); private needsExportsShim: boolean = false; private renderedDeclarations: { dependencies: ChunkDependencies; exports: ChunkExports; } = undefined; - private chunkName: string | void; + private renderedHash: string = undefined; + private renderedModuleSources: MagicString[] = undefined; + private renderedSource: MagicStringBundle = undefined; + private renderedSourceLength: number = undefined; constructor(graph: Graph, orderedModules: Module[], inlineDynamicImports: boolean) { this.graph = graph; @@ -203,8 +193,8 @@ export default class Chunk { this.facadeModule = facadedModule; facadedModule.facadeChunk = this; for (const exportName of facadedModule.getAllExports()) { - const tracedVariable = facadedModule.traceExport(exportName); - this.exports.set(tracedVariable, facadedModule); + const tracedVariable = facadedModule.getVariableForExportName(exportName); + this.exports.add(tracedVariable); this.exportNames[exportName] = tracedVariable; } } @@ -219,7 +209,6 @@ export default class Chunk { } this.dependencies = Array.from(dependencies); this.dynamicDependencies = Array.from(dynamicDependencies); - sortByExecutionOrder(this.dependencies); } private addChunksFromDependencies( @@ -244,9 +233,25 @@ export default class Chunk { } private setUpModuleImports(module: Module) { - for (const importName of Object.keys(module.imports)) { - const declaration = module.imports[importName]; - this.traceAndInitializeImport(declaration.name, declaration.module); + for (const variable of Array.from(module.imports)) { + if (variable.module.chunk !== this) { + this.imports.add(variable); + if (variable.module instanceof Module) { + variable.module.chunk.exports.add(variable); + } + } + } + if (module.getOrCreateNamespace().included) { + for (const reexportName of Object.keys(module.reexports)) { + const reexport = module.reexports[reexportName]; + const variable = reexport.module.getVariableForExportName(reexport.localName); + if (variable.module.chunk !== this) { + this.imports.add(variable); + if (variable.module instanceof Module) { + variable.module.chunk.exports.add(variable); + } + } + } } for (const { node, resolution } of module.dynamicImports) { if (node.included) { @@ -260,21 +265,24 @@ export default class Chunk { generateEntryExportsOrMarkAsTainted() { const exportVariableMaps = this.entryModules.map(module => ({ module, - map: this.getExportVariableMapForModule(module) + map: this.getVariableExportNamesForModule(module) })); for (const { map } of exportVariableMaps) { for (const exposedVariable of Array.from(map.keys())) { - this.exports.set(exposedVariable, map.get(exposedVariable).module); + this.exports.add(exposedVariable); } } + const exposedVariables = Array.from(this.exports); checkNextEntryModule: for (const { map, module } of exportVariableMaps) { - for (const exposedVariable of Array.from(this.exports.keys())) { - if (!map.has(exposedVariable)) { - continue checkNextEntryModule; + if (!this.graph.preserveModules) { + for (const exposedVariable of exposedVariables) { + if (!map.has(exposedVariable)) { + continue checkNextEntryModule; + } } } this.facadeModule = module; - for (const [variable, { exportNames }] of Array.from(map)) { + for (const [variable, exportNames] of Array.from(map)) { for (const exportName of exportNames) { this.exportNames[exportName] = variable; } @@ -283,120 +291,31 @@ export default class Chunk { } } - private getExportVariableMapForModule(module: Module) { - const tracedEntryExports: Map< - Variable, - { exportNames: string[]; module: Module | ExternalModule } - > = new Map(); + private getVariableExportNamesForModule(module: Module) { + const exportNamesByVariable: Map = new Map(); for (const exportName of module.getAllExports()) { - const tracedExport = this.traceExport(exportName, module); - if ( - !tracedExport || - !tracedExport.variable || - !(tracedExport.variable.included || tracedExport.variable.isExternal) - ) { + const tracedVariable = module.getVariableForExportName(exportName); + if (!tracedVariable || !(tracedVariable.included || tracedVariable.isExternal)) { continue; } - const existingExport = tracedEntryExports.get(tracedExport.variable); - if (existingExport) { - existingExport.exportNames.push(exportName); + const existingExportNames = exportNamesByVariable.get(tracedVariable); + if (existingExportNames) { + existingExportNames.push(exportName); } else { - tracedEntryExports.set(tracedExport.variable, { - exportNames: [exportName], - module: tracedExport.module - }); - } - if (tracedExport.module.chunk && tracedExport.module.chunk !== this) { - tracedExport.module.chunk.exports.set(tracedExport.variable, tracedExport.module); - } - } - return tracedEntryExports; - } - - private traceAndInitializeImport(exportName: string, module: Module | ExternalModule) { - const traced = this.traceExport(exportName, module); - - if (!traced) return; - - // namespace variable can indicate multiple imports - if (isNamespaceVariable(traced.variable)) { - const namespaceVariables = - (traced.variable).originals || - (traced.variable).module.declarations; - - for (const importName of Object.keys(namespaceVariables)) { - const original = namespaceVariables[importName]; - if (original.included) { - // namespace exports could be imported themselves, so retrace - // this handles recursive namespace exported on namespace cases as well - if (traced.variable.module instanceof Module) { - this.traceAndInitializeImport(importName, traced.variable.module); - } else { - const externalVariable = traced.variable.module.traceExport(importName); - if (externalVariable.included) { - this.imports.set(original, traced.variable.module); - } - } - } - } - } - - // ignore unincluded or imports to modules already in this chunk - if (traced.module.chunk === this || !traced.variable.included) return traced; - - this.imports.set(traced.variable, traced.module); - if (traced.module instanceof Module) - traced.module.chunk.exports.set(traced.variable, traced.module); - return traced; - } - - // trace a module export to its exposed chunk module export - // either in this chunk or in another - traceExport( - name: string, - module: Module | ExternalModule - ): { - variable: Variable; - module: Module | ExternalModule; - } | void { - if (name[0] === '*' || module instanceof ExternalModule) { - return { variable: module.traceExport(name), module }; - } - - if (module.chunk !== this) { - return module.chunk.traceExport(name, module); - } - - const exportDeclaration = module.exports[name]; - if (exportDeclaration) { - // if export binding is itself an import binding then continue tracing - const importDeclaration = module.imports[exportDeclaration.localName]; - if (importDeclaration) { - return this.traceAndInitializeImport(importDeclaration.name, importDeclaration.module); + exportNamesByVariable.set(tracedVariable, [exportName]); } - return { variable: module.traceExport(name), module }; - } - - const reexportDeclaration = module.reexports[name]; - if (reexportDeclaration) { - return this.traceExport(reexportDeclaration.localName, reexportDeclaration.module); - } - - if (name === 'default') { - return; - } - - // resolve known star exports - for (let i = 0; i < module.exportAllModules.length; i++) { - const exportAllModule = module.exportAllModules[i]; - // we have to ensure the right export all module - if (exportAllModule.traceExport(name, true)) { - return this.traceExport(name, exportAllModule); + const exportingModule = tracedVariable.module; + if (exportingModule && exportingModule.chunk && exportingModule.chunk !== this) { + exportingModule.chunk.exports.add(tracedVariable); } } + return exportNamesByVariable; } getVariableExportName(variable: Variable) { + if (this.graph.preserveModules && variable instanceof NamespaceVariable) { + return '*'; + } for (const exportName of Object.keys(this.exportNames)) { if (this.exportNames[exportName] === variable) return exportName; } @@ -408,7 +327,7 @@ export default class Chunk { let i = 0, safeExportName: string; this.exportNames = Object.create(null); - const exportedVariables = Array.from(this.exports.keys()); + const exportedVariables = Array.from(this.exports); if (mangle) { for (const variable of exportedVariables) { safeExportName = toBase64(++i); @@ -520,28 +439,29 @@ export default class Chunk { for (const exportName of Object.keys(this.exportNames)) { const exportVariable = this.exportNames[exportName]; - if (exportVariable === this.graph.exportShimVariable) this.needsExportsShim = true; - if (exportVariable && exportVariable.exportName !== exportName) + if (exportVariable instanceof ExportShimVariable) this.needsExportsShim = true; + if (exportVariable && exportVariable.exportName !== exportName) { exportVariable.exportName = exportName; + } } - Array.from(this.imports.entries()).forEach(([variable, module]) => { + for (const variable of Array.from(this.imports)) { let safeName; - if (module instanceof ExternalModule) { + if (variable.module instanceof ExternalModule) { if (variable.name === '*') { - safeName = module.variableName; + safeName = variable.module.variableName; } else if (variable.name === 'default') { if ( options.interop !== false && - (module.exportsNamespace || (!esm && module.exportsNames)) + (variable.module.exportsNamespace || (!esm && variable.module.exportsNames)) ) { - safeName = `${module.variableName}__default`; + safeName = `${variable.module.variableName}__default`; } else { - safeName = module.variableName; + safeName = variable.module.variableName; } } else { - safeName = esm ? variable.name : `${module.variableName}.${variable.name}`; + safeName = esm ? variable.name : `${variable.module.variableName}.${variable.name}`; } if (esm) { safeName = getSafeName(safeName); @@ -551,12 +471,20 @@ export default class Chunk { safeName = getSafeName(variable.name); toDeshadow.add(safeName); } else { - const chunk = module.chunk; - if (chunk.exportMode === 'default') safeName = chunk.variableName; - else safeName = `${chunk.variableName}.${module.chunk.getVariableExportName(variable)}`; + const chunk = variable.module.chunk; + if ( + chunk.exportMode === 'default' || + (this.graph.preserveModules && variable.isNamespace) + ) { + safeName = chunk.variableName; + } else { + safeName = `${chunk.variableName}.${variable.module.chunk.getVariableExportName( + variable + )}`; + } } if (safeName) variable.setSafeName(safeName); - }); + } this.orderedModules.forEach(module => { this.deconflictExportsOfModule(module, getSafeName, esm); @@ -591,10 +519,11 @@ export default class Chunk { variable.setSafeName(safeName); } }); + module.exportShimVariable.setSafeName(null); // deconflict reified namespaces const namespace = module.getOrCreateNamespace(); - if (namespace.needsNamespaceBlock) { + if (namespace.included) { namespace.setSafeName(getSafeName(namespace.name)); } } @@ -613,9 +542,9 @@ export default class Chunk { importName = exportName = '*'; } else { const variable = this.exportNames[exportName]; - const module = this.exports.get(variable); + const module = variable.module; // skip local exports - if (module.chunk === this) continue; + if (!module || module.chunk === this) continue; if (module instanceof Module) { exportModule = module.chunk; importName = module.chunk.getVariableExportName(variable); @@ -632,20 +561,23 @@ export default class Chunk { const dependencies: ChunkDependencies = []; this.dependencies.forEach(dep => { - const importSpecifiers = Array.from(this.imports.entries()).filter(([, module]) => - module instanceof Module ? module.chunk === dep : module === dep + const importsFromDependency = Array.from(this.imports).filter( + variable => + variable.module instanceof Module + ? variable.module.chunk === dep + : variable.module === dep ); let imports: ImportSpecifier[]; - if (importSpecifiers.length) { + if (importsFromDependency.length) { imports = []; - for (const [variable, module] of importSpecifiers) { + for (const variable of importsFromDependency) { const local = variable.safeName || variable.name; let imported; - if (module instanceof ExternalModule) { + if (variable.module instanceof ExternalModule) { imported = variable.name; } else { - imported = module.chunk.getVariableExportName(variable); + imported = variable.module.chunk.getVariableExportName(variable); } imports.push({ local, imported }); } @@ -700,12 +632,9 @@ export default class Chunk { if (exportName[0] === '*') continue; const variable = this.exportNames[exportName]; - const module = this.exports.get(variable); - - // skip external exports - if (module.chunk !== this) continue; + const module = variable.module; - // determine if a hoisted export (function) + if (module && module.chunk !== this) continue; let hoisted = false; let uninitialized = false; if (variable instanceof LocalVariable) { @@ -744,7 +673,7 @@ export default class Chunk { /* * Chunk dependency output graph post-visitor - * Visitor can return "true" to indicate a propogated stop condition + * Visitor can return "true" to indicate a propagated stop condition */ postVisitChunkDependencies(visitor: (dep: Chunk | ExternalModule) => any): boolean { const seen = new Set(); @@ -767,11 +696,7 @@ export default class Chunk { // own rendered source, except for finalizer wrapping hash.update(this.getRenderedHash()); - - // hash of addons hash.update(addons.hash); - - // output options hash.update(options.format); // import names of dependency sources @@ -806,19 +731,19 @@ export default class Chunk { format: options.format }; - // if an entry point facade or dynamic entry point, inline the execution list to avoid loading latency - if (this.facadeModule !== null) { + // Make sure the direct dependencies of a chunk are present to maintain execution order + for (const { module } of Array.from(this.imports)) { + if (module.chunk === this) console.log(module.id); + const chunkOrExternal = module instanceof Module ? module.chunk : module; + if (this.dependencies.indexOf(chunkOrExternal) === -1) { + this.dependencies.push(chunkOrExternal); + } + } + // for static and dynamic entry points, inline the execution list to avoid loading latency + if (!this.graph.preserveModules && this.facadeModule !== null) { for (const dep of this.dependencies) { if (dep instanceof Chunk) this.inlineChunkDependencies(dep, true); } - } else { - // shortcut cross-chunk relations can be added by traceExport - for (const module of Array.from(this.imports.values())) { - const chunkOrExternal = module instanceof Module ? module.chunk : module; - if (this.dependencies.indexOf(chunkOrExternal) === -1) { - this.dependencies.push(chunkOrExternal); - } - } } // prune empty dependency chunks, inlining their side-effect dependencies for (let i = 0; i < this.dependencies.length; i++) { @@ -828,6 +753,7 @@ export default class Chunk { this.inlineChunkDependencies(dep, false); } } + sortByExecutionOrder(this.dependencies); this.setIdentifierRenderResolutions(options); this.prepareDynamicImports(); @@ -853,11 +779,11 @@ export default class Chunk { }; const namespace = module.getOrCreateNamespace(); - if (namespace.needsNamespaceBlock || !source.isEmpty()) { + if (namespace.included || !source.isEmpty()) { magicString.addSource(source); this.usedModules.push(module); - if (namespace.needsNamespaceBlock) { + if (namespace.included && !this.graph.preserveModules) { const rendered = namespace.renderBlock(renderOptions); if (namespace.renderFirst()) hoistedSource += n + rendered; else magicString.addSource(new MagicString(rendered)); @@ -869,7 +795,7 @@ export default class Chunk { if (this.needsExportsShim) { magicString.prepend( - `${n}${this.graph.varOrConst} _missingExportShim${_}=${_}void 0;${n}${n}` + `${n}${this.graph.varOrConst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}` ); } @@ -916,17 +842,17 @@ export default class Chunk { this.orderedModules.push(module); } - for (const [variable, module] of Array.from(chunk.imports.entries())) { - if (!this.imports.has(variable) && module.chunk !== this) { - this.imports.set(variable, module); + for (const variable of Array.from(chunk.imports)) { + if (!this.imports.has(variable) && variable.module.chunk !== this) { + this.imports.add(variable); } } // NB detect when exported variables are orphaned by the merge itself // (involves reverse tracing dependents) - for (const [variable, module] of Array.from(chunk.exports.entries())) { + for (const variable of Array.from(chunk.exports)) { if (!this.exports.has(variable)) { - this.exports.set(variable, module); + this.exports.add(variable); } } diff --git a/src/ExternalModule.ts b/src/ExternalModule.ts index 3d488a82bb5..29e182a4793 100644 --- a/src/ExternalModule.ts +++ b/src/ExternalModule.ts @@ -1,5 +1,4 @@ import ExternalVariable from './ast/variables/ExternalVariable'; -import Variable from './ast/variables/Variable'; import Graph from './Graph'; import { OutputOptions } from './rollup/types'; import { makeLegal } from './utils/identifierHelpers'; @@ -87,7 +86,7 @@ export default class ExternalModule { }); } - traceExport(name: string, _isExportAllSearch?: boolean): Variable { + getVariableForExportName(name: string, _isExportAllSearch?: boolean): ExternalVariable { if (name !== 'default' && name !== '*') this.exportsNames = true; if (name === '*') this.exportsNamespace = true; diff --git a/src/Graph.ts b/src/Graph.ts index 7a3d89e5b28..8145ba389e4 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -4,7 +4,6 @@ import injectImportMeta from 'acorn-import-meta/inject'; import { Program } from 'estree'; import GlobalScope from './ast/scopes/GlobalScope'; import { EntityPathTracker } from './ast/utils/EntityPathTracker'; -import GlobalVariable from './ast/variables/GlobalVariable'; import Chunk from './Chunk'; import ExternalModule from './ExternalModule'; import Module, { defaultAcornOptions } from './Module'; @@ -32,6 +31,7 @@ import { createPluginDriver, PluginDriver } from './utils/pluginDriver'; import relativeId, { getAliasName } from './utils/relativeId'; import { timeEnd, timeStart } from './utils/timers'; import transform from './utils/transform'; +import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; function makeOnwarn() { const warned = Object.create(null); @@ -61,9 +61,9 @@ export default class Graph { deoptimizationTracker: EntityPathTracker; scope: GlobalScope; shimMissingExports: boolean; - exportShimVariable: GlobalVariable; treeshakingOptions: TreeshakingOptions; varOrConst: 'var' | 'const'; + preserveModules: boolean; isExternal: IsExternal; @@ -97,6 +97,7 @@ export default class Graph { for (const key of Object.keys(cache)) cache[key][0]++; } } + this.preserveModules = options.experimentalPreserveModules; this.cacheExpiry = options.experimentalCacheExpiry; @@ -155,11 +156,9 @@ export default class Graph { this.shimMissingExports = options.shimMissingExports; this.scope = new GlobalScope(); - // Strictly speaking, this only applies with non-ES6, non-default-only bundles - for (const name of ['module', 'exports', '_interopDefault']) { + for (const name of ['module', 'exports', '_interopDefault', MISSING_EXPORT_SHIM_VARIABLE]) { this.scope.findVariable(name); // creates global variable as side-effect } - this.exportShimVariable = this.scope.findVariable('_missingExportShim'); this.context = String(options.context); @@ -335,8 +334,7 @@ export default class Graph { build( entryModules: string | string[] | Record, manualChunks: Record | void, - inlineDynamicImports: boolean, - preserveModules: boolean + inlineDynamicImports: boolean ): Promise { // Phase 1 – discovery. We load the entry module and find which // modules it imports, and import those, until we have all @@ -401,7 +399,7 @@ export default class Graph { // entry point graph colouring, before generating the import and export facades timeStart('generate chunks', 2); - if (!preserveModules && !inlineDynamicImports) { + if (!this.preserveModules && !inlineDynamicImports) { assignChunkColouringHashes(entryModules, manualChunkModules); } @@ -416,7 +414,7 @@ export default class Graph { // 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 (preserveModules) { + if (this.preserveModules) { for (const module of orderedModules) { const chunk = new Chunk(this, [module], inlineDynamicImports); if (module.isEntryPoint || !chunk.isEmpty) { @@ -457,14 +455,14 @@ export default class Graph { // then go over and ensure all entry chunks export their variables for (const chunk of chunks) { - if (preserveModules || chunk.entryModules.length > 0) { + if (this.preserveModules || chunk.entryModules.length > 0) { chunk.generateEntryExportsOrMarkAsTainted(); } } // create entry point facades for entry module chunks that have tainted exports const facades = []; - if (!preserveModules) { + if (!this.preserveModules) { for (const chunk of chunks) { for (const entryModule of chunk.entryModules) { if (chunk.facadeModule !== entryModule) { @@ -687,12 +685,12 @@ export default class Graph { }); } - // add external declarations so we can detect which are never used - for (const name in module.imports) { - const importDeclaration = module.imports[name]; + for (const name in module.importDescriptions) { + const importDeclaration = module.importDescriptions[name]; if (importDeclaration.source !== source) return; - externalModule.traceExport(importDeclaration.name); + // this will trigger a warning for unused external imports + externalModule.getVariableForExportName(importDeclaration.name); } } else { module.resolvedIds[source] = resolvedId; diff --git a/src/Module.ts b/src/Module.ts index 3d1d5624099..224577fecdf 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -21,6 +21,7 @@ import ModuleScope from './ast/scopes/ModuleScope'; import { EntityPathTracker } from './ast/utils/EntityPathTracker'; import extractNames from './ast/utils/extractNames'; import { UNKNOWN_PATH } from './ast/values'; +import ExportShimVariable from './ast/variables/ExportShimVariable'; import ExternalVariable from './ast/variables/ExternalVariable'; import NamespaceVariable from './ast/variables/NamespaceVariable'; import Variable from './ast/variables/Variable'; @@ -38,6 +39,7 @@ import { RenderOptions } from './utils/renderHelpers'; import { SOURCEMAPPING_URL_RE } from './utils/sourceMappingURL'; import { timeEnd, timeStart } from './utils/timers'; import { visitStaticDependencies } from './utils/traverseStaticDependencies'; +import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; export interface CommentDescription { block: boolean; @@ -81,16 +83,17 @@ export interface AstContext { getModuleExecIndex: () => number; getModuleName: () => string; getReexports: () => string[]; - imports: { [name: string]: ImportDescription }; + importDescriptions: { [name: string]: ImportDescription }; isCrossChunkImport: (importDescription: ImportDescription) => boolean; - includeNamespace: () => void; includeDynamicImport: (node: Import) => void; + includeVariable: (variable: Variable) => void; magicString: MagicString; moduleContext: string; + module: Module; // not to be used for tree-shaking nodeConstructors: { [name: string]: typeof NodeBase }; + preserveModules: boolean; propertyReadSideEffects: boolean; deoptimizationTracker: EntityPathTracker; - requestTreeshakingPass: () => void; traceExport: (name: string) => Variable; traceVariable: (name: string) => Variable; treeshake: boolean; @@ -147,6 +150,10 @@ function handleMissingExport( ); } +const MISSING_EXPORT_SHIM_DESCRIPTION: ExportDescription = { + localName: MISSING_EXPORT_SHIM_VARIABLE +}; + export default class Module { type: 'Module'; chunk: Chunk; @@ -163,6 +170,7 @@ export default class Module { }[] = []; entryPointsHash: Uint8Array = new Uint8Array(10); exportAllModules: (Module | ExternalModule)[] = null; + exportShimVariable: ExportShimVariable = new ExportShimVariable(this); excludeFromSourcemap: boolean; execIndex: number = Infinity; exports: { [name: string]: ExportDescription } = Object.create(null); @@ -170,8 +178,9 @@ export default class Module { exportAllSources: string[] = []; facadeChunk: Chunk | null = null; id: string; + importDescriptions: { [name: string]: ImportDescription } = Object.create(null); importMetas: MetaProperty[] = []; - imports: { [name: string]: ImportDescription } = Object.create(null); + imports = new Set(); isDynamicEntryPoint: boolean = false; isEntryPoint: boolean = false; isExecuted: boolean = false; @@ -252,18 +261,19 @@ export default class Module { getReexports: this.getReexports.bind(this), getModuleExecIndex: () => this.execIndex, getModuleName: this.basename.bind(this), - imports: this.imports, + importDescriptions: this.importDescriptions, includeDynamicImport: this.includeDynamicImport.bind(this), - includeNamespace: this.includeNamespace.bind(this), + includeVariable: this.includeVariable.bind(this), isCrossChunkImport: importDescription => importDescription.module.chunk !== this.chunk, magicString: this.magicString, + module: this, moduleContext: this.context, nodeConstructors, + preserveModules: this.graph.preserveModules, propertyReadSideEffects: !this.graph.treeshake || this.graph.treeshakingOptions.propertyReadSideEffects, deoptimizationTracker: this.graph.deoptimizationTracker, - requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true), - traceExport: this.traceExport.bind(this), + traceExport: this.getVariableForExportName.bind(this), traceVariable: this.traceVariable.bind(this), treeshake: this.graph.treeshake, usesTopLevelAwait: false, @@ -390,7 +400,7 @@ export default class Module { for (const specifier of node.specifiers) { const localName = specifier.local.name; - if (this.imports[localName]) { + if (this.importDescriptions[localName]) { this.error( { code: 'DUPLICATE_IMPORT', @@ -408,7 +418,7 @@ export default class Module { : isNamespace ? '*' : (specifier).imported.name; - this.imports[localName] = { source, start: specifier.start, name, module: null }; + this.importDescriptions[localName] = { source, start: specifier.start, name, module: null }; } } @@ -438,21 +448,17 @@ export default class Module { } for (const exportName of this.getExports()) { - const variable = this.traceExport(exportName); + const variable = this.getVariableForExportName(exportName); variable.deoptimizePath(UNKNOWN_PATH); if (!variable.included) { variable.include(); this.graph.needsTreeshakingPass = true; } - - if (variable.isNamespace) { - (variable).needsNamespaceBlock = true; - } } for (const name of this.getReexports()) { - const variable = this.traceExport(name); + const variable = this.getVariableForExportName(name); if (variable.isExternal) { variable.reexported = (variable).module.reexported = true; @@ -479,19 +485,8 @@ export default class Module { } } - const resolveSpecifiers = (specifiers: { - [name: string]: ImportDescription | ReexportDescription; - }) => { - for (const name of Object.keys(specifiers)) { - const specifier = specifiers[name]; - - const id = this.resolvedIds[specifier.source]; - specifier.module = this.graph.moduleById.get(id); - } - }; - - resolveSpecifiers(this.imports); - resolveSpecifiers(this.reexports); + this.addModulesToSpecifiers(this.importDescriptions); + this.addModulesToSpecifiers(this.reexports); this.exportAllModules = this.exportAllSources.map(source => { const id = this.resolvedIds[source]; @@ -499,6 +494,15 @@ export default class Module { }); } + private addModulesToSpecifiers(specifiers: { + [name: string]: ImportDescription | ReexportDescription; + }) { + for (const name of Object.keys(specifiers)) { + const specifier = specifiers[name]; + specifier.module = this.graph.moduleById.get(this.resolvedIds[specifier.source]); + } + } + bindReferences() { this.ast.bind(); } @@ -601,7 +605,7 @@ export default class Module { } isIncluded() { - return this.ast.included; + return this.ast.included || (this.namespaceVariable && this.namespaceVariable.included); } include(): void { @@ -609,9 +613,9 @@ export default class Module { } getOrCreateNamespace(): NamespaceVariable { - if (this.namespaceVariable) return this.namespaceVariable; - - return (this.namespaceVariable = new NamespaceVariable(this.astContext, this)); + return ( + this.namespaceVariable || (this.namespaceVariable = new NamespaceVariable(this.astContext)) + ); } private includeDynamicImport(node: Import) { @@ -623,19 +627,13 @@ export default class Module { } } - private includeNamespace() { - const namespace = this.getOrCreateNamespace(); - if (namespace.needsNamespaceBlock) return; - - for (const importName in this.reexports) { - const reexport = this.reexports[importName]; - this.imports[importName] = { - source: reexport.source, - start: reexport.start, - name: reexport.localName, - module: reexport.module - }; - namespace.originals[importName] = reexport.module.traceExport(reexport.localName); + private includeVariable(variable: Variable) { + if (!variable.included) { + variable.include(); + this.graph.needsTreeshakingPass = true; + } + if (variable.module && variable.module !== this) { + this.imports.add(variable); } } @@ -662,21 +660,20 @@ export default class Module { }; } - traceVariable(name: string): Variable { - // TODO this is slightly circular + traceVariable(name: string): Variable | null { if (name in this.scope.variables) { return this.scope.variables[name]; } - if (name in this.imports) { - const importDeclaration = this.imports[name]; + if (name in this.importDescriptions) { + const importDeclaration = this.importDescriptions[name]; const otherModule = importDeclaration.module; if (!otherModule.isExternal && importDeclaration.name === '*') { return (otherModule).getOrCreateNamespace(); } - const declaration = otherModule.traceExport(importDeclaration.name); + const declaration = otherModule.getVariableForExportName(importDeclaration.name); if (!declaration) { handleMissingExport(importDeclaration.name, this, otherModule.id, importDeclaration.start); @@ -699,22 +696,23 @@ export default class Module { return { renderedExports, removedExports }; } - traceExport(name: string, isExportAllSearch?: boolean): Variable { + getVariableForExportName(name: string, isExportAllSearch?: boolean): Variable | null { if (name[0] === '*') { - // namespace if (name.length === 1) { return this.getOrCreateNamespace(); - // export * from 'external' } else { + // export * from 'external' const module = this.graph.moduleById.get(name.slice(1)); - return module.traceExport('*'); + return module.getVariableForExportName('*'); } } // export { foo } from './other' const reexportDeclaration = this.reexports[name]; if (reexportDeclaration) { - const declaration = reexportDeclaration.module.traceExport(reexportDeclaration.localName); + const declaration = reexportDeclaration.module.getVariableForExportName( + reexportDeclaration.localName + ); if (!declaration) { handleMissingExport( @@ -730,16 +728,17 @@ export default class Module { const exportDeclaration = this.exports[name]; if (exportDeclaration) { + if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) { + return this.exportShimVariable; + } const name = exportDeclaration.localName; - const declaration = this.traceVariable(name) || this.graph.scope.findVariable(name); - - return declaration; + return this.traceVariable(name) || this.graph.scope.findVariable(name); } if (name !== 'default') { for (let i = 0; i < this.exportAllModules.length; i += 1) { const module = this.exportAllModules[i]; - const declaration = module.traceExport(name, true); + const declaration = module.getVariableForExportName(name, true); if (declaration) return declaration; } @@ -748,7 +747,8 @@ export default class Module { // we don't want to create shims when we are just // probing export * modules for exports if (this.graph.shimMissingExports && !isExportAllSearch) { - return this.shimMissingExport(name); + this.shimMissingExport(name); + return this.exportShimVariable; } } @@ -766,18 +766,15 @@ export default class Module { this.graph.warn(warning); } - shimMissingExport(name: string) { - // could have already been generated - if (!this.exports[name]) + private shimMissingExport(name: string): void { + if (!this.exports[name]) { this.graph.warn({ message: `Missing export "${name}" has been shimmed in module ${relativeId(this.id)}.`, code: 'SHIMMED_EXPORT', exportName: name, exporter: relativeId(this.id) }); - this.exports[name] = { - localName: '_missingExportShim' - }; - return this.graph.exportShimVariable; + this.exports[name] = MISSING_EXPORT_SHIM_DESCRIPTION; + } } } diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts index 1580cd96136..e8b870f3ba4 100644 --- a/src/ast/nodes/ArrowFunctionExpression.ts +++ b/src/ast/nodes/ArrowFunctionExpression.ts @@ -17,7 +17,7 @@ export default class ArrowFunctionExpression extends NodeBase { preventChildBlockScope: true; createScope(parentScope: Scope) { - this.scope = new ReturnValueScope(parentScope, this.context.deoptimizationTracker); + this.scope = new ReturnValueScope(parentScope, this.context); } getReturnExpressionWhenCalledAtPath(path: ObjectPath) { diff --git a/src/ast/nodes/CatchClause.ts b/src/ast/nodes/CatchClause.ts index 442193fe07a..dd4df0e1aba 100644 --- a/src/ast/nodes/CatchClause.ts +++ b/src/ast/nodes/CatchClause.ts @@ -15,7 +15,7 @@ export default class CatchClause extends NodeBase { preventChildBlockScope: true; createScope(parentScope: Scope) { - this.scope = new CatchScope(parentScope, this.context.deoptimizationTracker); + this.scope = new CatchScope(parentScope, this.context); } initialise() { diff --git a/src/ast/nodes/ExportDefaultDeclaration.ts b/src/ast/nodes/ExportDefaultDeclaration.ts index b73d0e6b4f7..1917f19ea05 100644 --- a/src/ast/nodes/ExportDefaultDeclaration.ts +++ b/src/ast/nodes/ExportDefaultDeclaration.ts @@ -53,7 +53,7 @@ export default class ExportDefaultDeclaration extends NodeBase { this.variable = this.scope.addExportDefaultDeclaration( this.declarationName || this.context.getModuleName(), this, - this.context.deoptimizationTracker + this.context ); this.context.addExport(this); } diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index b512dd83b09..3d7241ad368 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -45,22 +45,12 @@ export default class Identifier extends NodeBase { switch (kind) { case 'var': case 'function': - this.variable = this.scope.addDeclaration( - this, - this.context.deoptimizationTracker, - init, - true - ); + this.variable = this.scope.addDeclaration(this, this.context, init, true); break; case 'let': case 'const': case 'class': - this.variable = this.scope.addDeclaration( - this, - this.context.deoptimizationTracker, - init, - false - ); + this.variable = this.scope.addDeclaration(this, this.context, init, false); break; case 'parameter': this.variable = (this.scope).addParameterDeclaration(this); @@ -111,9 +101,8 @@ export default class Identifier extends NodeBase { include(_includeAllChildrenRecursively: boolean) { if (!this.included) { this.included = true; - if (this.variable !== null && !this.variable.included) { - this.variable.include(); - this.context.requestTreeshakingPass(); + if (this.variable !== null) { + this.context.includeVariable(this.variable); } } } @@ -132,7 +121,7 @@ export default class Identifier extends NodeBase { if (this.variable !== null) { if ( path.length === 0 && - this.name in this.context.imports && + this.name in this.context.importDescriptions && !this.scope.contains(this.name) ) { this.disallowImportReassignment(); diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index b4cfc8a685a..e494589b17e 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -179,9 +179,8 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE include(includeAllChildrenRecursively: boolean) { if (!this.included) { this.included = true; - if (this.variable !== null && !this.variable.included) { - this.variable.include(); - this.context.requestTreeshakingPass(); + if (this.variable !== null) { + this.context.includeVariable(this.variable); } } this.object.include(includeAllChildrenRecursively); @@ -253,7 +252,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE if (!baseVariable.isNamespace) return null; const exportName = path[0].key; const variable = baseVariable.isExternal - ? (baseVariable).module.traceExport(exportName) + ? (baseVariable).module.getVariableForExportName(exportName) : (baseVariable).context.traceExport(exportName); if (!variable) { const fileName = baseVariable.isExternal diff --git a/src/ast/nodes/shared/FunctionNode.ts b/src/ast/nodes/shared/FunctionNode.ts index 3ae5c3ce695..a75483b7f99 100644 --- a/src/ast/nodes/shared/FunctionNode.ts +++ b/src/ast/nodes/shared/FunctionNode.ts @@ -20,7 +20,7 @@ export default class FunctionNode extends NodeBase { private isPrototypeDeoptimized: boolean; createScope(parentScope: FunctionScope) { - this.scope = new FunctionScope(parentScope, this.context.deoptimizationTracker); + this.scope = new FunctionScope(parentScope, this.context); } getReturnExpressionWhenCalledAtPath(path: ObjectPath) { diff --git a/src/ast/scopes/BlockScope.ts b/src/ast/scopes/BlockScope.ts index 78a11b8b385..838e6a2b7d8 100644 --- a/src/ast/scopes/BlockScope.ts +++ b/src/ast/scopes/BlockScope.ts @@ -1,6 +1,6 @@ +import { AstContext } from '../../Module'; import Identifier from '../nodes/Identifier'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import LocalVariable from '../variables/LocalVariable'; import Scope from './Scope'; @@ -9,19 +9,14 @@ export default class BlockScope extends Scope { addDeclaration( identifier: Identifier, - deoptimizationTracker: EntityPathTracker, + context: AstContext, init: ExpressionEntity | null = null, isHoisted: boolean = false ) { if (isHoisted) { - return this.parent.addDeclaration( - identifier, - deoptimizationTracker, - init, - true - ) as LocalVariable; + return this.parent.addDeclaration(identifier, context, init, true) as LocalVariable; } else { - return super.addDeclaration(identifier, deoptimizationTracker, init, false) as LocalVariable; + return super.addDeclaration(identifier, context, init, false) as LocalVariable; } } } diff --git a/src/ast/scopes/CatchScope.ts b/src/ast/scopes/CatchScope.ts index dbf30863663..913c4dc9e31 100644 --- a/src/ast/scopes/CatchScope.ts +++ b/src/ast/scopes/CatchScope.ts @@ -1,25 +1,20 @@ +import { AstContext } from '../../Module'; import Identifier from '../nodes/Identifier'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import LocalVariable from '../variables/LocalVariable'; import ParameterScope from './ParameterScope'; export default class CatchScope extends ParameterScope { addDeclaration( identifier: Identifier, - deoptimizationTracker: EntityPathTracker, + context: AstContext, init: ExpressionEntity | null = null, isHoisted: boolean = false ) { if (isHoisted) { - return this.parent.addDeclaration( - identifier, - deoptimizationTracker, - init, - true - ) as LocalVariable; + return this.parent.addDeclaration(identifier, context, init, true) as LocalVariable; } else { - return super.addDeclaration(identifier, deoptimizationTracker, init, false) as LocalVariable; + return super.addDeclaration(identifier, context, init, false) as LocalVariable; } } } diff --git a/src/ast/scopes/FunctionScope.ts b/src/ast/scopes/FunctionScope.ts index 47b9cd0497a..733b7451140 100644 --- a/src/ast/scopes/FunctionScope.ts +++ b/src/ast/scopes/FunctionScope.ts @@ -1,6 +1,6 @@ +import { AstContext } from '../../Module'; import CallOptions from '../CallOptions'; import { ExecutionPathOptions } from '../ExecutionPathOptions'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import { UNKNOWN_EXPRESSION, UnknownObjectExpression } from '../values'; import ArgumentsVariable from '../variables/ArgumentsVariable'; import ExportDefaultVariable from '../variables/ExportDefaultVariable'; @@ -19,13 +19,10 @@ export default class FunctionScope extends ReturnValueScope { [name: string]: LocalVariable | GlobalVariable | ExternalVariable | ArgumentsVariable; }; - constructor(parent: Scope, deoptimizationTracker: EntityPathTracker) { - super(parent, deoptimizationTracker); - this.variables.arguments = new ArgumentsVariable( - super.getParameterVariables(), - deoptimizationTracker - ); - this.variables.this = new ThisVariable(deoptimizationTracker); + constructor(parent: Scope, context: AstContext) { + super(parent, context); + this.variables.arguments = new ArgumentsVariable(super.getParameterVariables(), context); + this.variables.this = new ThisVariable(context); } findLexicalBoundary() { diff --git a/src/ast/scopes/ModuleScope.ts b/src/ast/scopes/ModuleScope.ts index f4e60f7495c..710f059978b 100644 --- a/src/ast/scopes/ModuleScope.ts +++ b/src/ast/scopes/ModuleScope.ts @@ -22,28 +22,25 @@ export default class ModuleScope extends Scope { super(parent); this.context = context; this.isModuleScope = true; - this.variables.this = new LocalVariable( - 'this', - null, - UNDEFINED_EXPRESSION, - context.deoptimizationTracker - ); + this.variables.this = new LocalVariable('this', null, UNDEFINED_EXPRESSION, context); } deshadow(names: Set, children = this.children) { const localNames = new Set(names); - for (const importName of Object.keys(this.context.imports)) { - const importDescription = this.context.imports[importName]; + for (const importName of Object.keys(this.context.importDescriptions)) { + const importDescription = this.context.importDescriptions[importName]; if (importDescription.module.isExternal || this.context.isCrossChunkImport(importDescription)) continue; for (const name of (importDescription.module).getAllExports()) - addDeclaredNames(importDescription.module.traceExport(name), localNames); + addDeclaredNames(importDescription.module.getVariableForExportName(name), localNames); if (importDescription.name !== '*') { - const declaration = importDescription.module.traceExport(importDescription.name); + const declaration = importDescription.module.getVariableForExportName( + importDescription.name + ); if (!declaration) { this.context.warn( { diff --git a/src/ast/scopes/ParameterScope.ts b/src/ast/scopes/ParameterScope.ts index 72fb1f9fd46..dc7cd4d97f9 100644 --- a/src/ast/scopes/ParameterScope.ts +++ b/src/ast/scopes/ParameterScope.ts @@ -1,5 +1,5 @@ +import { AstContext } from '../../Module'; import Identifier from '../nodes/Identifier'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import { UNKNOWN_EXPRESSION } from '../values'; import LocalVariable from '../variables/LocalVariable'; import Scope from './Scope'; @@ -9,11 +9,11 @@ export default class ParameterScope extends Scope { hoistedBodyVarScope: Scope; private parameters: LocalVariable[] = []; - private deoptimizationTracker: EntityPathTracker; + private context: AstContext; - constructor(parent: Scope, deoptimizationTracker: EntityPathTracker) { + constructor(parent: Scope, context: AstContext) { super(parent); - this.deoptimizationTracker = deoptimizationTracker; + this.context = context; this.hoistedBodyVarScope = new Scope(this); } @@ -28,12 +28,7 @@ export default class ParameterScope extends Scope { variable = this.hoistedBodyVarScope.variables[name] as LocalVariable; variable.addDeclaration(identifier, null); } else { - variable = new LocalVariable( - name, - identifier, - UNKNOWN_EXPRESSION, - this.deoptimizationTracker - ); + variable = new LocalVariable(name, identifier, UNKNOWN_EXPRESSION, this.context); } this.variables[name] = variable; this.parameters.push(variable); diff --git a/src/ast/scopes/Scope.ts b/src/ast/scopes/Scope.ts index 6dae5aca31f..16b83e470c6 100644 --- a/src/ast/scopes/Scope.ts +++ b/src/ast/scopes/Scope.ts @@ -1,8 +1,8 @@ +import { AstContext } from '../../Module'; import { toBase64 } from '../../utils/base64'; import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import Identifier from '../nodes/Identifier'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import { UNDEFINED_EXPRESSION } from '../values'; import ArgumentsVariable from '../variables/ArgumentsVariable'; import ExportDefaultVariable from '../variables/ExportDefaultVariable'; @@ -30,7 +30,7 @@ export default class Scope { addDeclaration( identifier: Identifier, - deoptimizationTracker: EntityPathTracker, + context: AstContext, init: ExpressionEntity | null = null, _isHoisted: boolean ) { @@ -42,7 +42,7 @@ export default class Scope { identifier.name, identifier, init || UNDEFINED_EXPRESSION, - deoptimizationTracker + context ); } return this.variables[name]; @@ -51,13 +51,9 @@ export default class Scope { addExportDefaultDeclaration( name: string, exportDefaultDeclaration: ExportDefaultDeclaration, - deoptimizationTracker: EntityPathTracker + context: AstContext ): ExportDefaultVariable { - this.variables.default = new ExportDefaultVariable( - name, - exportDefaultDeclaration, - deoptimizationTracker - ); + this.variables.default = new ExportDefaultVariable(name, exportDefaultDeclaration, context); return this.variables.default; } diff --git a/src/ast/variables/ArgumentsVariable.ts b/src/ast/variables/ArgumentsVariable.ts index 4daaf5f5a7a..b9cdfcc5030 100644 --- a/src/ast/variables/ArgumentsVariable.ts +++ b/src/ast/variables/ArgumentsVariable.ts @@ -1,6 +1,6 @@ +import { AstContext } from '../../Module'; import CallOptions from '../CallOptions'; import { ExecutionPathOptions } from '../ExecutionPathOptions'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import { ObjectPath, UNKNOWN_EXPRESSION } from '../values'; import LocalVariable from './LocalVariable'; @@ -17,8 +17,8 @@ const getParameterVariable = (path: ObjectPath, options: ExecutionPathOptions) = export default class ArgumentsVariable extends LocalVariable { private parameters: LocalVariable[]; - constructor(parameters: LocalVariable[], deoptimizationTracker: EntityPathTracker) { - super('arguments', null, UNKNOWN_EXPRESSION, deoptimizationTracker); + constructor(parameters: LocalVariable[], context: AstContext) { + super('arguments', null, UNKNOWN_EXPRESSION, context); this.parameters = parameters; } diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index 92a6bd838ab..63bfd73e96e 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -1,9 +1,9 @@ +import { AstContext } from '../../Module'; import ClassDeclaration from '../nodes/ClassDeclaration'; import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; import Identifier from '../nodes/Identifier'; import * as NodeType from '../nodes/NodeType'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import LocalVariable from './LocalVariable'; import Variable from './Variable'; @@ -21,14 +21,9 @@ export default class ExportDefaultVariable extends LocalVariable { constructor( name: string, exportDefaultDeclaration: ExportDefaultDeclaration, - deoptimizationTracker: EntityPathTracker + context: AstContext ) { - super( - name, - exportDefaultDeclaration, - exportDefaultDeclaration.declaration, - deoptimizationTracker - ); + super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context); const declaration = exportDefaultDeclaration.declaration; if ( (declaration.type === NodeType.FunctionDeclaration || diff --git a/src/ast/variables/ExportShimVariable.ts b/src/ast/variables/ExportShimVariable.ts new file mode 100644 index 00000000000..f790182325a --- /dev/null +++ b/src/ast/variables/ExportShimVariable.ts @@ -0,0 +1,10 @@ +import Module from '../../Module'; +import { MISSING_EXPORT_SHIM_VARIABLE } from '../../utils/variableNames'; +import Variable from './Variable'; + +export default class ExportShimVariable extends Variable { + constructor(module: Module) { + super(MISSING_EXPORT_SHIM_VARIABLE); + this.module = module; + } +} diff --git a/src/ast/variables/GlobalVariable.ts b/src/ast/variables/GlobalVariable.ts index 89d5b8fc630..fcaa5280dc2 100644 --- a/src/ast/variables/GlobalVariable.ts +++ b/src/ast/variables/GlobalVariable.ts @@ -3,7 +3,6 @@ import { ObjectPath } from '../values'; import Variable from './Variable'; export default class GlobalVariable extends Variable { - isExternal: true; included = true; hasEffectsWhenAccessedAtPath(path: ObjectPath) { diff --git a/src/ast/variables/LocalVariable.ts b/src/ast/variables/LocalVariable.ts index efd9fa95ff2..9949e1a9582 100644 --- a/src/ast/variables/LocalVariable.ts +++ b/src/ast/variables/LocalVariable.ts @@ -1,3 +1,4 @@ +import Module, { AstContext } from '../../Module'; import CallOptions from '../CallOptions'; import { DeoptimizableEntity } from '../DeoptimizableEntity'; import { ExecutionPathOptions } from '../ExecutionPathOptions'; @@ -24,6 +25,7 @@ export default class LocalVariable extends Variable { declarations: (Identifier | ExportDefaultDeclaration)[]; init: ExpressionEntity | null; isLocal: true; + module: Module; additionalInitializers: ExpressionEntity[] | null = null; // Caching and deoptimization: @@ -35,12 +37,13 @@ export default class LocalVariable extends Variable { name: string, declarator: Identifier | ExportDefaultDeclaration | null, init: ExpressionEntity | null, - deoptimizationTracker: EntityPathTracker + context: AstContext ) { super(name); this.declarations = declarator ? [declarator] : []; this.init = init; - this.deoptimizationTracker = deoptimizationTracker; + this.deoptimizationTracker = context.deoptimizationTracker; + this.module = context.module; } addDeclaration(identifier: Identifier, init: ExpressionEntity | null) { diff --git a/src/ast/variables/NamespaceVariable.ts b/src/ast/variables/NamespaceVariable.ts index fd59ac472ed..f1221f5a401 100644 --- a/src/ast/variables/NamespaceVariable.ts +++ b/src/ast/variables/NamespaceVariable.ts @@ -7,24 +7,22 @@ import Variable from './Variable'; export default class NamespaceVariable extends Variable { isNamespace: true; context: AstContext; + module: Module; // Not initialised during construction - originals: { [name: string]: Variable } = Object.create(null); - needsNamespaceBlock: boolean = false; + memberVariables: { [name: string]: Variable } = Object.create(null); - // only to be used for chunk-to-chunk import tracing, use context for data manipulation - module: Module; private referencedEarly: boolean = false; private references: Identifier[] = []; private containsExternalNamespace: boolean = false; - constructor(context: AstContext, module: Module) { + constructor(context: AstContext) { super(context.getModuleName()); this.context = context; - this.module = module; + this.module = context.module; for (const name of this.context.getExports().concat(this.context.getReexports())) { if (name[0] === '*' && name.length > 1) this.containsExternalNamespace = true; - this.originals[name] = this.context.traceExport(name); + this.memberVariables[name] = this.context.traceExport(name); } } @@ -45,16 +43,20 @@ export default class NamespaceVariable extends Variable { undefined ); } - this.context.includeNamespace(); this.included = true; - this.needsNamespaceBlock = true; for (const identifier of this.references) { if (identifier.context.getModuleExecIndex() <= this.context.getModuleExecIndex()) { this.referencedEarly = true; break; } } - for (const original of Object.keys(this.originals)) this.originals[original].include(); + if (this.context.preserveModules) { + for (const memberName of Object.keys(this.memberVariables)) + this.memberVariables[memberName].include(); + } else { + for (const memberName of Object.keys(this.memberVariables)) + this.context.includeVariable(this.memberVariables[memberName]); + } } } @@ -67,8 +69,8 @@ export default class NamespaceVariable extends Variable { // the reassignment to the right variable. This means we lost track of this variable and thus // need to reassign all exports. deoptimizePath() { - for (const key in this.originals) { - this.originals[key].deoptimizePath(UNKNOWN_PATH); + for (const key in this.memberVariables) { + this.memberVariables[key].deoptimizePath(UNKNOWN_PATH); } } @@ -77,8 +79,8 @@ export default class NamespaceVariable extends Variable { const n = options.compact ? '' : '\n'; const t = options.indent; - const members = Object.keys(this.originals).map(name => { - const original = this.originals[name]; + const members = Object.keys(this.memberVariables).map(name => { + const original = this.memberVariables[name]; if (this.referencedEarly || original.isReassigned) { return `${t}get ${name}${_}()${_}{${_}return ${original.getName()}${ diff --git a/src/ast/variables/ThisVariable.ts b/src/ast/variables/ThisVariable.ts index a469273ffc8..7dc22aa1b46 100644 --- a/src/ast/variables/ThisVariable.ts +++ b/src/ast/variables/ThisVariable.ts @@ -1,13 +1,13 @@ +import { AstContext } from '../../Module'; import CallOptions from '../CallOptions'; import { ExecutionPathOptions } from '../ExecutionPathOptions'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import { EntityPathTracker } from '../utils/EntityPathTracker'; import { LiteralValueOrUnknown, ObjectPath, UNKNOWN_EXPRESSION, UNKNOWN_VALUE } from '../values'; import LocalVariable from './LocalVariable'; export default class ThisVariable extends LocalVariable { - constructor(deoptimizationTracker: EntityPathTracker) { - super('this', null, null, deoptimizationTracker); + constructor(context: AstContext) { + super('this', null, null, context); } getLiteralValueAtPath(): LiteralValueOrUnknown { diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index e4cd90f35e4..2127c0b1282 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -1,3 +1,5 @@ +import ExternalModule from '../../ExternalModule'; +import Module from '../../Module'; import CallOptions from '../CallOptions'; import { DeoptimizableEntity } from '../DeoptimizableEntity'; import { ExecutionPathOptions } from '../ExecutionPathOptions'; @@ -12,6 +14,7 @@ export default class Variable implements ExpressionEntity { isExternal?: boolean; isDefault?: boolean; isNamespace?: boolean; + module: Module | ExternalModule | null; // Not initialised during construction exportName: string | null = null; @@ -40,7 +43,7 @@ export default class Variable implements ExpressionEntity { this.safeName[this.name.length] === '$' && this.safeName[this.name.length + 1] === '$' ) { - this.safeName = undefined; + this.safeName = null; return this.name; } return this.safeName || this.name; diff --git a/src/finalisers/system.ts b/src/finalisers/system.ts index 2ba0b4354c3..859bf69a73a 100644 --- a/src/finalisers/system.ts +++ b/src/finalisers/system.ts @@ -1,9 +1,10 @@ import { Bundle as MagicStringBundle } from 'magic-string'; -import { ModuleDeclarations } from '../Chunk'; +import { ChunkExports, ModuleDeclarations } from '../Chunk'; import { OutputOptions } from '../rollup/types'; +import { MISSING_EXPORT_SHIM_VARIABLE } from '../utils/variableNames'; import { FinaliserOptions } from './index'; -function getStarExcludes({ dependencies, exports }: ModuleDeclarations) { +function getStarExcludes({ dependencies, exports }: ModuleDeclarations): Set { const starExcludes = new Set(exports.map(expt => expt.exported)); if (!starExcludes.has('default')) starExcludes.add('default'); // also include reexport names @@ -17,6 +18,66 @@ function getStarExcludes({ dependencies, exports }: ModuleDeclarations) { return starExcludes; } +const getStarExcludesBlock = ( + starExcludes: Set, + varOrConst: string, + _: string, + t: string, + n: string +): string => + starExcludes + ? `${n}${t}${varOrConst} _starExcludes${_}=${_}{${_}${Array.from(starExcludes).join( + `:${_}1,${_}` + )}${starExcludes.size ? `:${_}1` : ''}${_}};` + : ''; + +const getImportBindingsBlock = ( + importBindings: string[], + _: string, + t: string, + n: string +): string => (importBindings.length ? `${n}${t}var ${importBindings.join(`,${_}`)};` : ''); + +function getExportsBlock( + exports: { name: string; value: string }[], + _: string, + t: string, + n: string +): string { + if (exports.length === 0) { + return ''; + } + if (exports.length === 1) { + return `${t}${t}${t}exports('${exports[0].name}',${_}${exports[0].value});${n}${n}`; + } + return ( + `${t}${t}${t}exports({${n}` + + exports.map(({ name, value }) => `${t}${t}${t}${t}${name}:${_}${value}`).join(`,${n}`) + + `${n}${t}${t}${t}});${n}${n}` + ); +} + +const getHoistedExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => { + return getExportsBlock( + exports + .filter(expt => expt.hoisted || expt.uninitialized) + .map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), + _, + t, + n + ); +}; + +const getMissingExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => + getExportsBlock( + exports + .filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE) + .map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), + _, + t, + n + ); + export default function system( magicString: MagicStringBundle, { @@ -102,69 +163,37 @@ export default function system( setters.push(setter.join(`${n}${t}${t}${t}`)); }); - // function declarations hoist - const hoistedExports: string[] = []; - - const hoistedExportObjs = exports.filter(expt => expt.hoisted || expt.uninitialized); - if (hoistedExportObjs.length === 1) { - const expt = hoistedExportObjs[0]; - hoistedExports.push( - `exports('${expt.exported}',${_}${expt.uninitialized ? 'void 0' : expt.local});` - ); - } else if (hoistedExportObjs.length > 1) { - hoistedExports.push(`exports({`); - for (let i = 0; i < hoistedExportObjs.length; i++) { - const expt = hoistedExportObjs[i]; - hoistedExports.push( - `${t}${expt.exported}:${_}${expt.uninitialized ? 'void 0' : expt.local}${ - i === hoistedExportObjs.length - 1 ? '' : ',' - }` - ); - } - hoistedExports.push(`});`); - } - - const starExcludesSection = !starExcludes - ? '' - : `${n}${t}${varOrConst} _starExcludes${_}=${_}{${_}${Array.from(starExcludes).join( - `:${_}1,${_}` - )}${starExcludes.size ? `:${_}1` : ''}${_}};`; - - const importBindingsSection = importBindings.length - ? `${n}${t}var ${importBindings.join(`,${_}`)};` - : ''; const registeredName = options.name ? `'${options.name}',${_}` : ''; - let wrapperStart = `System.register(${registeredName}[${dependencyIds.join( - `,${_}` - )}],${_}function${_}(exports,${_}module)${_}{${n}`; - wrapperStart += `${t}'use strict';${starExcludesSection}${importBindingsSection}${n}`; - wrapperStart += `${t}return${_}{${ - setters.length - ? `${n}${t}${t}setters:${_}[${setters - .map( - s => - s - ? `function${_}(module)${_}{${n}${t}${t}${t}${s}${n}${t}${t}}` - : `function${_}()${_}{}` - ) - .join(`,${_}`)}],` - : '' - }${n}`; - wrapperStart += `${t}${t}execute:${_}${ - usesTopLevelAwait ? `async${_}` : '' - }function${_}()${_}{${n}${n}`; - if (hoistedExports.length) - wrapperStart += `${t}${t}${t}` + hoistedExports.join(`${n}${t}${t}${t}`) + n + n; + let wrapperStart = + `System.register(${registeredName}[` + + dependencyIds.join(`,${_}`) + + `],${_}function${_}(exports,${_}module)${_}{${n}${t}'use strict';` + + getStarExcludesBlock(starExcludes, varOrConst, _, t, n) + + getImportBindingsBlock(importBindings, _, t, n) + + `${n}${t}return${_}{${ + setters.length + ? `${n}${t}${t}setters:${_}[${setters + .map( + s => + s + ? `function${_}(module)${_}{${n}${t}${t}${t}${s}${n}${t}${t}}` + : `function${_}()${_}{}` + ) + .join(`,${_}`)}],` + : '' + }${n}`; + wrapperStart += + `${t}${t}execute:${_}${usesTopLevelAwait ? `async${_}` : ''}function${_}()${_}{${n}${n}` + + getHoistedExportsBlock(exports, _, t, n); - let wrapperEnd = `${n}${n}${t}${t}}`; - wrapperEnd += `${n}${t}}${options.compact ? '' : ';'}`; - wrapperEnd += `${n}});`; + const wrapperEnd = + `${n}${n}` + + getMissingExportsBlock(exports, _, t, n) + + `${t}${t}}${n}${t}}${options.compact ? '' : ';'}${n}});`; if (intro) magicString.prepend(intro); - if (outro) magicString.append(outro); - return magicString .indent(`${t}${t}${t}`) .append(wrapperEnd) diff --git a/src/rollup/index.ts b/src/rollup/index.ts index ca40b8cae7c..84fb4d31dcf 100644 --- a/src/rollup/index.ts +++ b/src/rollup/index.ts @@ -197,8 +197,7 @@ export default function rollup( graph.build( inputOptions.input, inputOptions.manualChunks, - inputOptions.inlineDynamicImports, - inputOptions.experimentalPreserveModules + inputOptions.inlineDynamicImports ) ) .then( diff --git a/src/utils/variableNames.ts b/src/utils/variableNames.ts new file mode 100644 index 00000000000..a6494c7b25d --- /dev/null +++ b/src/utils/variableNames.ts @@ -0,0 +1 @@ +export const MISSING_EXPORT_SHIM_VARIABLE = '_missingExportShim'; 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 51f1bc17ad8..5b92bf86464 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(['./chunk-264eb6ba.js', './chunk-dcefc23d.js', './chunk-406f6d2a.js'], function (__chunk_2, __chunk_1, __chunk_3) { 'use strict'; +define(['./chunk-dcefc23d.js', './chunk-264eb6ba.js', './chunk-406f6d2a.js'], 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 6c41a6386c6..5b05772f3da 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(['./chunk-264eb6ba.js', './chunk-dcefc23d.js', './chunk-406f6d2a.js'], function (__chunk_2, __chunk_1, __chunk_3) { 'use strict'; +define(['./chunk-dcefc23d.js', './chunk-264eb6ba.js', './chunk-406f6d2a.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js index 0683d5f83c3..261aedc7b77 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js @@ -1,7 +1,7 @@ 'use strict'; -var __chunk_2 = require('./chunk-61a62bc6.js'); require('./chunk-8a340a3c.js'); +var __chunk_2 = require('./chunk-61a62bc6.js'); require('./chunk-4b766e46.js'); console.log(__chunk_2.x + __chunk_2.y); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js index 9a846a1f61a..bffe9665856 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js @@ -1,6 +1,6 @@ 'use strict'; -require('./chunk-61a62bc6.js'); require('./chunk-8a340a3c.js'); +require('./chunk-61a62bc6.js'); require('./chunk-4b766e46.js'); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js index 0af45400320..113cd91f5d0 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js @@ -1,5 +1,5 @@ -import { a as x, b as y } from './chunk-c223c238.js'; import './chunk-91999913.js'; +import { a as x, b as y } from './chunk-c223c238.js'; import './chunk-78fb52ac.js'; console.log(x + y); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js index 19b7d024fcd..3b8e510aea7 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js @@ -1,3 +1,3 @@ -import './chunk-c223c238.js'; import './chunk-91999913.js'; +import './chunk-c223c238.js'; import './chunk-78fb52ac.js'; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js index 504d4177376..938d067a06c 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./chunk-61e8212c.js', './chunk-f874c049.js', './chunk-6e722356.js'], function (exports, module) { +System.register(['./chunk-f874c049.js', './chunk-61e8212c.js', './chunk-6e722356.js'], function (exports, module) { 'use strict'; var x, y; return { - setters: [function (module) { + setters: [function () {}, function (module) { x = module.a; y = module.b; - }, function () {}, function () {}], + }, function () {}], execute: function () { console.log(x + y); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js index bc3b958801b..fe85bc07a1f 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./chunk-61e8212c.js', './chunk-f874c049.js', './chunk-6e722356.js'], function (exports, module) { +System.register(['./chunk-f874c049.js', './chunk-61e8212c.js', './chunk-6e722356.js'], function (exports, module) { 'use strict'; return { setters: [function () {}, function () {}, function () {}], diff --git a/test/chunking-form/samples/chunk-execution-order/_config.js b/test/chunking-form/samples/chunk-execution-order/_config.js new file mode 100644 index 00000000000..74ee8f5f11c --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'maintains execution order ', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'] + } +}; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7754c915.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7754c915.js new file mode 100644 index 00000000000..3e36b05c84b --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7754c915.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + console.log('111'); + +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7d7b15ed.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7d7b15ed.js new file mode 100644 index 00000000000..8f922213b31 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-7d7b15ed.js @@ -0,0 +1,5 @@ +define(['./chunk-7754c915.js', './chunk-bea81d32.js'], function (__chunk_1, __chunk_2) { 'use strict'; + + console.log('11'); + +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-bea81d32.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-bea81d32.js new file mode 100644 index 00000000000..bd54da136b3 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/chunk-bea81d32.js @@ -0,0 +1,8 @@ +define(['exports'], function (exports) { 'use strict'; + + const x = 0; + console.log('112'); + + exports.x = x; + +}); 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 new file mode 100644 index 00000000000..a1676782261 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js @@ -0,0 +1,7 @@ +define(['./chunk-7754c915.js', './chunk-bea81d32.js', './chunk-7d7b15ed.js'], function (__chunk_1, __chunk_2, __chunk_3) { 'use strict'; + + console.log('1'); + + console.log(__chunk_2.x); + +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js new file mode 100644 index 00000000000..44f1c1077fd --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./chunk-7754c915.js', './chunk-bea81d32.js', './chunk-7d7b15ed.js'], 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 new file mode 100644 index 00000000000..9146cb2eef2 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./chunk-7754c915.js'], 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 new file mode 100644 index 00000000000..e356bfc4f3d --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./chunk-bea81d32.js'], function (__chunk_2) { 'use strict'; + + + +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-4b975806.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-4b975806.js new file mode 100644 index 00000000000..ad37af910ed --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-4b975806.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./chunk-631287c1.js'); +require('./chunk-fb49fcb9.js'); + +console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-631287c1.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-631287c1.js new file mode 100644 index 00000000000..bf703b5acf3 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-631287c1.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-fb49fcb9.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-fb49fcb9.js new file mode 100644 index 00000000000..8ddf85976dd --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/chunk-fb49fcb9.js @@ -0,0 +1,6 @@ +'use strict'; + +const x = 0; +console.log('112'); + +exports.x = x; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js new file mode 100644 index 00000000000..13779ab396d --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js @@ -0,0 +1,9 @@ +'use strict'; + +require('./chunk-631287c1.js'); +var __chunk_2 = require('./chunk-fb49fcb9.js'); +require('./chunk-4b975806.js'); + +console.log('1'); + +console.log(__chunk_2.x); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js new file mode 100644 index 00000000000..59f994af60e --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./chunk-631287c1.js'); +require('./chunk-fb49fcb9.js'); +require('./chunk-4b975806.js'); + diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js new file mode 100644 index 00000000000..5c5875e0416 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js @@ -0,0 +1,4 @@ +'use strict'; + +require('./chunk-631287c1.js'); + diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js new file mode 100644 index 00000000000..fe5082d232e --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js @@ -0,0 +1,4 @@ +'use strict'; + +require('./chunk-fb49fcb9.js'); + diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-5c9dd4f3.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-5c9dd4f3.js new file mode 100644 index 00000000000..d014e06029c --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-5c9dd4f3.js @@ -0,0 +1,4 @@ +import './chunk-871160e8.js'; +import './chunk-633ac7f7.js'; + +console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-633ac7f7.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-633ac7f7.js new file mode 100644 index 00000000000..88830d6c71b --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-633ac7f7.js @@ -0,0 +1,4 @@ +const x = 0; +console.log('112'); + +export { x as a }; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-871160e8.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-871160e8.js new file mode 100644 index 00000000000..ab8d7e39114 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/chunk-871160e8.js @@ -0,0 +1 @@ +console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js new file mode 100644 index 00000000000..a449cada867 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js @@ -0,0 +1,7 @@ +import './chunk-871160e8.js'; +import { a as x } from './chunk-633ac7f7.js'; +import './chunk-5c9dd4f3.js'; + +console.log('1'); + +console.log(x); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js new file mode 100644 index 00000000000..dd68d82cea2 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js @@ -0,0 +1,3 @@ +import './chunk-871160e8.js'; +import './chunk-633ac7f7.js'; +import './chunk-5c9dd4f3.js'; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js new file mode 100644 index 00000000000..673a8ccba00 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js @@ -0,0 +1 @@ +import './chunk-871160e8.js'; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js new file mode 100644 index 00000000000..d1b03a94635 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js @@ -0,0 +1 @@ +import './chunk-633ac7f7.js'; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-490a02cf.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-490a02cf.js new file mode 100644 index 00000000000..d63387c147c --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-490a02cf.js @@ -0,0 +1,11 @@ +System.register(['./chunk-7114e829.js', './chunk-acbba8ee.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}, function () {}], + execute: function () { + + console.log('11'); + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-7114e829.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-7114e829.js new file mode 100644 index 00000000000..5f2cd618ed1 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-7114e829.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + console.log('111'); + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-acbba8ee.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-acbba8ee.js new file mode 100644 index 00000000000..19724f3e855 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/chunk-acbba8ee.js @@ -0,0 +1,11 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const x = exports('a', 0); + console.log('112'); + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js new file mode 100644 index 00000000000..90e20786fcf --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./chunk-7114e829.js', './chunk-acbba8ee.js', './chunk-490a02cf.js'], function (exports, module) { + 'use strict'; + var x; + return { + setters: [function () {}, function (module) { + x = module.a; + }, function () {}], + execute: function () { + + console.log('1'); + + console.log(x); + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js new file mode 100644 index 00000000000..f68467bafc0 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js @@ -0,0 +1,11 @@ +System.register(['./chunk-7114e829.js', './chunk-acbba8ee.js', './chunk-490a02cf.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}, function () {}, function () {}], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js new file mode 100644 index 00000000000..f698ad04852 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js @@ -0,0 +1,11 @@ +System.register(['./chunk-7114e829.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js new file mode 100644 index 00000000000..c80333a294b --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js @@ -0,0 +1,11 @@ +System.register(['./chunk-acbba8ee.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/dep1.js b/test/chunking-form/samples/chunk-execution-order/dep1.js new file mode 100644 index 00000000000..50ba98e65d5 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/dep1.js @@ -0,0 +1,2 @@ +export { x } from './dep11.js'; +console.log('1'); diff --git a/test/chunking-form/samples/chunk-execution-order/dep11.js b/test/chunking-form/samples/chunk-execution-order/dep11.js new file mode 100644 index 00000000000..97363e7263a --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/dep11.js @@ -0,0 +1,3 @@ +import './dep111'; +export { x } from './dep112.js'; +console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/dep111.js b/test/chunking-form/samples/chunk-execution-order/dep111.js new file mode 100644 index 00000000000..ab8d7e39114 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/dep111.js @@ -0,0 +1 @@ +console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/dep112.js b/test/chunking-form/samples/chunk-execution-order/dep112.js new file mode 100644 index 00000000000..b1a9e95a5c5 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/dep112.js @@ -0,0 +1,2 @@ +export const x = 0; +console.log('112'); diff --git a/test/chunking-form/samples/chunk-execution-order/main1.js b/test/chunking-form/samples/chunk-execution-order/main1.js new file mode 100644 index 00000000000..32685605c2c --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/main1.js @@ -0,0 +1,3 @@ +import { x } from './dep1.js'; + +console.log(x); diff --git a/test/chunking-form/samples/chunk-execution-order/main2.js b/test/chunking-form/samples/chunk-execution-order/main2.js new file mode 100644 index 00000000000..88134ad4325 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/main2.js @@ -0,0 +1 @@ +import './dep11.js'; diff --git a/test/chunking-form/samples/chunk-execution-order/main3.js b/test/chunking-form/samples/chunk-execution-order/main3.js new file mode 100644 index 00000000000..8deff57f5f0 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/main3.js @@ -0,0 +1 @@ +import './dep111.js'; diff --git a/test/chunking-form/samples/chunk-execution-order/main4.js b/test/chunking-form/samples/chunk-execution-order/main4.js new file mode 100644 index 00000000000..43bd3341ca1 --- /dev/null +++ b/test/chunking-form/samples/chunk-execution-order/main4.js @@ -0,0 +1 @@ +import './dep112.js'; diff --git a/test/chunking-form/samples/chunk-namespace-boundary/cjs.js b/test/chunking-form/samples/chunk-namespace-boundary/cjs.js index 6a627075869..1c100bb30e8 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/cjs.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/cjs.js @@ -4,4 +4,4 @@ commonjsHelpers.commonjsGlobal.fn = d => d + 1; var cjs = commonjsHelpers.commonjsGlobal.fn; export default cjs; -export { cjs as __moduleExports }; \ No newline at end of file +export { cjs as __moduleExports }; diff --git a/test/chunking-form/samples/chunk-namespace-boundary/commonjsHelpers.js b/test/chunking-form/samples/chunk-namespace-boundary/commonjsHelpers.js index 9e9c54aefaa..2ad9d66e22a 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/commonjsHelpers.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/commonjsHelpers.js @@ -10,4 +10,4 @@ export function unwrapExports (x) { export function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; -} \ No newline at end of file +} diff --git a/test/chunking-form/samples/chunk-namespace-boundary/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/main1.js index a33823bfdc6..e1cbe6892e1 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/main1.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/main1.js @@ -1,3 +1,3 @@ import e from './shared'; import fn from './cjs'; -export default e.map(fn); \ No newline at end of file +export default e.map(fn); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/main2.js index 162b6c804ca..22fa96ebc0a 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/main2.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/main2.js @@ -1,2 +1,2 @@ import d from './shared'; -export default d.map(d => d + 2); \ No newline at end of file +export default d.map(d => d + 2); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/shared.js b/test/chunking-form/samples/chunk-namespace-boundary/shared.js index dedd7012f63..b7cb6d21727 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/shared.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/shared.js @@ -4,4 +4,4 @@ commonjsHelpers.commonjsGlobal.data = [4, 5, 6]; var shared = commonjsHelpers.commonjsGlobal.data; export default shared; -export { shared as __moduleExports }; \ No newline at end of file +export { shared as __moduleExports }; 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 d8b98ede13d..7498aaf8d0c 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', './chunk-849a022f.js', 'external'], function (exports, __chunk_1, external) { 'use strict'; +define(['exports', 'external', './chunk-849a022f.js'], 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 d8b98ede13d..7498aaf8d0c 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', './chunk-849a022f.js', 'external'], function (exports, __chunk_1, external) { 'use strict'; +define(['exports', 'external', './chunk-849a022f.js'], function (exports, external, __chunk_1) { 'use strict'; diff --git a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js index a080fea886c..cc014e765c4 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, '__esModule', { value: true }); -require('./chunk-8b8e0de7.js'); var external = require('external'); +require('./chunk-8b8e0de7.js'); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js index a080fea886c..cc014e765c4 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, '__esModule', { value: true }); -require('./chunk-8b8e0de7.js'); var external = require('external'); +require('./chunk-8b8e0de7.js'); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js index ebedcf1b1bb..c3bdb0adb6d 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js @@ -1,2 +1,2 @@ -import './chunk-70b1cf27.js'; export { asdf as dep } from 'external'; +import './chunk-70b1cf27.js'; diff --git a/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js index ebedcf1b1bb..c3bdb0adb6d 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js @@ -1,2 +1,2 @@ -import './chunk-70b1cf27.js'; export { asdf as dep } from 'external'; +import './chunk-70b1cf27.js'; diff --git a/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js index 2d4933e4dc0..bed116a5e4d 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js @@ -1,9 +1,9 @@ -System.register(['./chunk-f2f3db66.js', 'external'], function (exports, module) { +System.register(['external', './chunk-f2f3db66.js'], function (exports, module) { 'use strict'; return { - setters: [function () {}, function (module) { + setters: [function (module) { exports('dep', module.asdf); - }], + }, function () {}], execute: function () { diff --git a/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js index 2d4933e4dc0..bed116a5e4d 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js @@ -1,9 +1,9 @@ -System.register(['./chunk-f2f3db66.js', 'external'], function (exports, module) { +System.register(['external', './chunk-f2f3db66.js'], function (exports, module) { 'use strict'; return { - setters: [function () {}, function (module) { + setters: [function (module) { exports('dep', module.asdf); - }], + }, function () {}], execute: function () { 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 517af19a45d..62e4de1f537 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', './chunk-57fd7dbc.js', 'starexternal2', 'external2'], function (exports, starexternal1, external1, __chunk_1, starexternal2, external2) { 'use strict'; +define(['exports', 'starexternal1', 'external1', 'starexternal2', 'external2', './chunk-57fd7dbc.js'], 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 d1c36b42b82..3252a788208 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,10 +1,10 @@ -define(['exports', './chunk-57fd7dbc.js', 'starexternal2', 'external2'], function (exports, __chunk_1, starexternal2, external2) { 'use strict'; +define(['exports', 'starexternal2', 'external2', './chunk-57fd7dbc.js'], function (exports, starexternal2, external2, __chunk_1) { 'use strict'; var main = '2'; Object.keys(starexternal2).forEach(function (key) { exports[key] = starexternal2[key]; }); - exports.dep = __chunk_1.dep; exports.e = external2.e; + exports.dep = __chunk_1.dep; exports.main = main; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js index ee18f21a777..b3b57866341 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js @@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); var starexternal1 = require('starexternal1'); var external1 = require('external1'); -var __chunk_1 = require('./chunk-8f97d2d9.js'); require('starexternal2'); require('external2'); +var __chunk_1 = require('./chunk-8f97d2d9.js'); var main = '1'; diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js index 8fa1a624486..6ff8494e09e 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js @@ -2,13 +2,13 @@ Object.defineProperty(exports, '__esModule', { value: true }); -var __chunk_1 = require('./chunk-8f97d2d9.js'); var starexternal2 = require('starexternal2'); var external2 = require('external2'); +var __chunk_1 = require('./chunk-8f97d2d9.js'); var main = '2'; Object.keys(starexternal2).forEach(function (key) { exports[key] = starexternal2[key]; }); -exports.dep = __chunk_1.dep; exports.e = external2.e; +exports.dep = __chunk_1.dep; exports.main = main; diff --git a/test/chunking-form/samples/chunking-star-external/_expected/es/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/es/main1.js index 1b3af826ee0..e8fd802f1ae 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/es/main1.js @@ -1,8 +1,8 @@ export * from 'starexternal1'; export { e } from 'external1'; -export { a as dep } from './chunk-01863ad2.js'; import 'starexternal2'; import 'external2'; +export { a as dep } from './chunk-01863ad2.js'; var main = '1'; diff --git a/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js index 5fe80b48c19..b16b0f8fe72 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js @@ -1,6 +1,6 @@ -export { a as dep } from './chunk-01863ad2.js'; export * from 'starexternal2'; export { e } from 'external2'; +export { a as dep } from './chunk-01863ad2.js'; var main = '2'; diff --git a/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js index 9611701cf49..f0802977996 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['starexternal1', 'external1', './chunk-16fda336.js', 'starexternal2', 'external2'], function (exports, module) { +System.register(['starexternal1', 'external1', 'starexternal2', 'external2', './chunk-16fda336.js'], function (exports, module) { 'use strict'; var _starExcludes = { main: 1, default: 1, e: 1, dep: 1 }; return { @@ -10,9 +10,9 @@ System.register(['starexternal1', 'external1', './chunk-16fda336.js', 'starexter exports(_setter); }, function (module) { exports('e', module.e); - }, function (module) { + }, function () {}, function () {}, function (module) { exports('dep', module.a); - }, function () {}, function () {}], + }], execute: function () { var main = exports('main', '1'); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js index 6c91661afb0..d7c7c8ef5d8 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js @@ -1,10 +1,8 @@ -System.register(['./chunk-16fda336.js', 'starexternal2', 'external2'], function (exports, module) { +System.register(['starexternal2', 'external2', './chunk-16fda336.js'], function (exports, module) { 'use strict'; - var _starExcludes = { main: 1, default: 1, dep: 1, e: 1 }; + var _starExcludes = { main: 1, default: 1, e: 1, dep: 1 }; return { setters: [function (module) { - exports('dep', module.a); - }, function (module) { var _setter = {}; for (var _$p in module) { if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; @@ -12,6 +10,8 @@ System.register(['./chunk-16fda336.js', 'starexternal2', 'external2'], function exports(_setter); }, function (module) { exports('e', module.e); + }, function (module) { + exports('dep', module.a); }], execute: function () { diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/chunk-d42319c1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/chunk-d42319c1.js index 7c2370c19a3..73c2459fb48 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/chunk-d42319c1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/chunk-d42319c1.js @@ -7,7 +7,7 @@ define(['exports'], function (exports) { 'use strict'; console.log('dynamic', dep); const dynamic = 'dynamic'; - exports.dep = dep; exports.dynamic = dynamic; + exports.dep = dep; }); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/chunk-57ff6d6d.js b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/chunk-57ff6d6d.js index 210a1e1c5bc..4f1397b1c78 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/chunk-57ff6d6d.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/cjs/chunk-57ff6d6d.js @@ -7,5 +7,5 @@ const dep = 'dep'; console.log('dynamic', dep); const dynamic = 'dynamic'; -exports.dep = dep; exports.dynamic = dynamic; +exports.dep = dep; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-9fd0b968.js b/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-9fd0b968.js index 14faa75894f..39129fa82e3 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-9fd0b968.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-9fd0b968.js @@ -1 +1 @@ -export { b as dynamic } from './chunk-fa3f0c72.js'; +export { a as dynamic } from './chunk-fa3f0c72.js'; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-fa3f0c72.js b/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-fa3f0c72.js index 37053a9255c..4150b42fb24 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-fa3f0c72.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/es/chunk-fa3f0c72.js @@ -5,4 +5,4 @@ const dep = 'dep'; console.log('dynamic', dep); const dynamic = 'dynamic'; -export { dep as a, dynamic as b }; +export { dynamic as a, dep as b }; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/es/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/es/main2.js index 288ebafb02c..87d1ce104f5 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/es/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/es/main2.js @@ -1,3 +1,3 @@ -import { a as dep, b as dynamic } from './chunk-fa3f0c72.js'; +import { a as dynamic, b as dep } from './chunk-fa3f0c72.js'; console.log('main2', dynamic, dep); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-55e635b3.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-22c305f4.js similarity index 68% rename from test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-55e635b3.js rename to test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-22c305f4.js index 0092d9f8101..b5bf05575ae 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-55e635b3.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-22c305f4.js @@ -5,10 +5,10 @@ System.register([], function (exports, module) { console.log('dep'); - const dep = exports('a', 'dep'); + const dep = exports('b', 'dep'); console.log('dynamic', dep); - const dynamic = exports('b', 'dynamic'); + const dynamic = exports('a', 'dynamic'); } }; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-d225f367.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-346290dd.js similarity index 52% rename from test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-d225f367.js rename to test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-346290dd.js index db29f31bc42..dd73e1f2380 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-d225f367.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/chunk-346290dd.js @@ -1,8 +1,8 @@ -System.register(['./chunk-55e635b3.js'], function (exports, module) { +System.register(['./chunk-22c305f4.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { - exports('dynamic', module.b); + exports('dynamic', module.a); }], execute: function () { 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 35f39e567cb..da11ebee6cf 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('./chunk-d225f367.js').then(({dynamic}) => console.log('main1', dynamic)); + module.import('./chunk-346290dd.js').then(({dynamic}) => console.log('main1', dynamic)); } }; diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js index 96e037f1b38..f85591e9b6f 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register(['./chunk-55e635b3.js'], function (exports, module) { +System.register(['./chunk-22c305f4.js'], function (exports, module) { 'use strict'; - var dep, dynamic; + var dynamic, dep; return { setters: [function (module) { - dep = module.a; - dynamic = module.b; + dynamic = module.a; + dep = module.b; }], execute: function () { diff --git a/test/chunking-form/samples/entry-point-without-own-code/_config.js b/test/chunking-form/samples/entry-point-without-own-code/_config.js new file mode 100644 index 00000000000..cdd3035cbc1 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'Handles entry points that contain no own code except imports and exports', + options: { + input: ['main.js', 'm1.js', 'm2.js'] + } +}; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1-0e5663a6.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1-0e5663a6.js new file mode 100644 index 00000000000..122db75ab30 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1-0e5663a6.js @@ -0,0 +1,12 @@ +define(['exports', './m2.js'], function (exports, m2) { 'use strict'; + + + + var ms = /*#__PURE__*/Object.freeze({ + m2: m2 + }); + + exports.m2 = m2.default; + exports.ms = ms; + +}); 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 new file mode 100644 index 00000000000..7683319a6e0 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js @@ -0,0 +1,9 @@ +define(['exports', './m2.js', './m1-0e5663a6.js'], function (exports, m2, m1) { 'use strict'; + + + + exports.m2 = m2.default; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js new file mode 100644 index 00000000000..a0c374fb3a3 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js @@ -0,0 +1,7 @@ +define(function () { 'use strict'; + + var m2 = 'm2'; + + return m2; + +}); 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 new file mode 100644 index 00000000000..93db0446de4 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./m2.js', './m1-0e5663a6.js'], function (m2, m1) { 'use strict'; + + console.log(m1.ms); + +}); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1-31ef6d45.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1-31ef6d45.js new file mode 100644 index 00000000000..901dfa4f519 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1-31ef6d45.js @@ -0,0 +1,12 @@ +'use strict'; + +var m2 = require('./m2.js'); + + + +var ms = /*#__PURE__*/Object.freeze({ + m2: m2 +}); + +exports.m2 = m2.default; +exports.ms = ms; 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 new file mode 100644 index 00000000000..ca3dbd20952 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js @@ -0,0 +1,10 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var m2 = require('./m2.js'); +require('./m1-31ef6d45.js'); + + + +exports.m2 = m2.default; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m2.js new file mode 100644 index 00000000000..c1120eef185 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m2.js @@ -0,0 +1,5 @@ +'use strict'; + +var m2 = 'm2'; + +module.exports = m2; 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 new file mode 100644 index 00000000000..b42537a8c65 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/main.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./m2.js'); +var m1 = require('./m1-31ef6d45.js'); + +console.log(m1.ms); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1-e0f3aef3.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1-e0f3aef3.js new file mode 100644 index 00000000000..489a82e7192 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1-e0f3aef3.js @@ -0,0 +1,10 @@ +import m2 from './m2.js'; +export { default as b } from './m2.js'; + + + +var ms = /*#__PURE__*/Object.freeze({ + m2: m2 +}); + +export { ms as a }; 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 new file mode 100644 index 00000000000..0de7c8ae6ad --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m1.js @@ -0,0 +1,2 @@ +export { default as m2 } from './m2.js'; +import './m1-e0f3aef3.js'; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js new file mode 100644 index 00000000000..ba5d9f8731a --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js @@ -0,0 +1,3 @@ +var m2 = 'm2'; + +export default m2; 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 new file mode 100644 index 00000000000..a338b6e11d3 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/main.js @@ -0,0 +1,4 @@ +import './m2.js'; +import { a as ms } from './m1-e0f3aef3.js'; + +console.log(ms); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1-1f88c681.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1-1f88c681.js new file mode 100644 index 00000000000..80d74a06a2a --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1-1f88c681.js @@ -0,0 +1,20 @@ +System.register(['./m2.js'], function (exports, module) { + 'use strict'; + var m2; + return { + setters: [function (module) { + m2 = module.default; + exports('b', module.default); + }], + execute: function () { + + + + var ms = /*#__PURE__*/Object.freeze({ + m2: m2 + }); + exports('a', ms); + + } + }; +}); 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 new file mode 100644 index 00000000000..3c2ba216f37 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js @@ -0,0 +1,13 @@ +System.register(['./m2.js', './m1-1f88c681.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('m2', module.default); + }, function () {}], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js new file mode 100644 index 00000000000..5f01a36266a --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var m2 = exports('default', 'm2'); + + } + }; +}); 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 new file mode 100644 index 00000000000..65aea4f76b2 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./m2.js', './m1-1f88c681.js'], function (exports, module) { + 'use strict'; + var ms; + return { + setters: [function () {}, function (module) { + ms = module.a; + }], + execute: function () { + + console.log(ms); + + } + }; +}); diff --git a/test/chunking-form/samples/entry-point-without-own-code/m1.js b/test/chunking-form/samples/entry-point-without-own-code/m1.js new file mode 100644 index 00000000000..7f84c7d65f2 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/m1.js @@ -0,0 +1,3 @@ +import m2 from './m2.js'; + +export { m2 }; diff --git a/test/chunking-form/samples/entry-point-without-own-code/m2.js b/test/chunking-form/samples/entry-point-without-own-code/m2.js new file mode 100644 index 00000000000..41ca66f98ed --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/m2.js @@ -0,0 +1 @@ +export default 'm2'; diff --git a/test/chunking-form/samples/entry-point-without-own-code/main.js b/test/chunking-form/samples/entry-point-without-own-code/main.js new file mode 100644 index 00000000000..c7526ddd8b1 --- /dev/null +++ b/test/chunking-form/samples/entry-point-without-own-code/main.js @@ -0,0 +1,3 @@ +import * as ms from './m1.js'; + +console.log(ms); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias-bff49b9a.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias-bff49b9a.js index 4a5858c04a1..a298d6f2a15 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias-bff49b9a.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias-bff49b9a.js @@ -8,7 +8,7 @@ define(['exports'], function (exports) { 'use strict'; } } - exports.dep = dep; exports.log = log; + exports.dep = dep; }); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/cjs/main2alias-4b102ef6.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/cjs/main2alias-4b102ef6.js index 6c9f57c4580..77ebd333ad8 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/cjs/main2alias-4b102ef6.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/cjs/main2alias-4b102ef6.js @@ -8,5 +8,5 @@ function log (x) { } } -exports.dep = dep; exports.log = log; +exports.dep = dep; diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main1alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main1alias.js index 2ad08eee135..e26f8c7bbb0 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main1alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main1alias.js @@ -1,3 +1,3 @@ -import { a as dep, b as log } from './main2alias-e628225d.js'; +import { a as log, b as dep } from './main2alias-e628225d.js'; log(dep); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias-e628225d.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias-e628225d.js index 47f232a6b54..461268e5515 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias-e628225d.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias-e628225d.js @@ -6,4 +6,4 @@ function log (x) { } } -export { dep as a, log as b }; +export { log as a, dep as b }; diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias.js index 78cbc35df20..6532f8e0b30 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/es/main2alias.js @@ -1 +1 @@ -export { b as default } from './main2alias-e628225d.js'; +export { a as default } from './main2alias-e628225d.js'; diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js index 4d76a17df7c..fda047741c7 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js @@ -1,10 +1,10 @@ -System.register(['./main2alias-4b538eea.js'], function (exports, module) { +System.register(['./main2alias-c713bf1b.js'], function (exports, module) { 'use strict'; - var dep, log; + var log, dep; return { setters: [function (module) { - dep = module.a; - log = module.b; + log = module.a; + dep = module.b; }], execute: function () { diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-4b538eea-system.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-c713bf1b.js similarity index 76% rename from test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-4b538eea-system.js rename to test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-c713bf1b.js index 101389000ea..22516b5eba1 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-4b538eea-system.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-c713bf1b.js @@ -3,9 +3,9 @@ System.register([], function (exports, module) { return { execute: function () { - exports('b', log); + exports('a', log); - var dep = exports('a', { x: 42 }); + var dep = exports('b', { x: 42 }); function log (x) { if (dep) { diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js index cfceaba2557..e68a16d17f2 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js @@ -1,8 +1,8 @@ -System.register(['./main2alias-4b538eea.js'], function (exports, module) { +System.register(['./main2alias-c713bf1b.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { - exports('default', module.b); + exports('default', module.a); }], execute: function () { diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2-bff49b9a.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2-bff49b9a.js index 4a5858c04a1..a298d6f2a15 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2-bff49b9a.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2-bff49b9a.js @@ -8,7 +8,7 @@ define(['exports'], function (exports) { 'use strict'; } } - exports.dep = dep; exports.log = log; + exports.dep = dep; }); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2-4b102ef6.js b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2-4b102ef6.js index 6c9f57c4580..77ebd333ad8 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2-4b102ef6.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/cjs/main2-4b102ef6.js @@ -8,5 +8,5 @@ function log (x) { } } -exports.dep = dep; exports.log = log; +exports.dep = dep; 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 97ce6a66ac9..f3443c748ec 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 dep, b as log } from './main2-e628225d.js'; +import { a as log, b as dep } from './main2-e628225d.js'; log(dep); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/es/main2-e628225d.js b/test/chunking-form/samples/entrypoint-facade/_expected/es/main2-e628225d.js index 47f232a6b54..461268e5515 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/es/main2-e628225d.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/es/main2-e628225d.js @@ -6,4 +6,4 @@ function log (x) { } } -export { dep as a, log as b }; +export { log as a, dep as b }; 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 916361ee016..d631583e194 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 { b as default } from './main2-e628225d.js'; +export { a as default } from './main2-e628225d.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 008f4f04336..0d090b72823 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js @@ -1,10 +1,10 @@ -System.register(['./main2-4b538eea.js'], function (exports, module) { +System.register(['./main2-c713bf1b.js'], function (exports, module) { 'use strict'; - var dep, log; + var log, dep; return { setters: [function (module) { - dep = module.a; - log = module.b; + log = module.a; + dep = module.b; }], execute: function () { diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-4b538eea.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2-c713bf1b.js similarity index 76% rename from test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-4b538eea.js rename to test/chunking-form/samples/entrypoint-facade/_expected/system/main2-c713bf1b.js index 101389000ea..22516b5eba1 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias-4b538eea.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2-c713bf1b.js @@ -3,9 +3,9 @@ System.register([], function (exports, module) { return { execute: function () { - exports('b', log); + exports('a', log); - var dep = exports('a', { x: 42 }); + var dep = exports('b', { x: 42 }); function log (x) { if (dep) { 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 163d04b8852..a8daf3c86c2 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js @@ -1,8 +1,8 @@ -System.register(['./main2-4b538eea.js'], function (exports, module) { +System.register(['./main2-c713bf1b.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { - exports('default', module.b); + exports('default', module.a); }], execute: function () { diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-bff49b9a-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-bff49b9a-amd.js index 4a5858c04a1..a298d6f2a15 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-bff49b9a-amd.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-bff49b9a-amd.js @@ -8,7 +8,7 @@ define(['exports'], function (exports) { 'use strict'; } } - exports.dep = dep; exports.log = log; + exports.dep = dep; }); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-4b102ef6-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-4b102ef6-cjs.js index 6c9f57c4580..77ebd333ad8 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-4b102ef6-cjs.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-4b102ef6-cjs.js @@ -8,5 +8,5 @@ function log (x) { } } -exports.dep = dep; exports.log = log; +exports.dep = dep; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-e628225d-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-e628225d-esm.js index 47f232a6b54..461268e5515 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-e628225d-esm.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-e628225d-esm.js @@ -6,4 +6,4 @@ function log (x) { } } -export { dep as a, log as b }; +export { log as a, dep as b }; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-1a6a749d-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-1a6a749d-esm.js index fed82fd5129..50784d8bf82 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-1a6a749d-esm.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-1a6a749d-esm.js @@ -1,3 +1,3 @@ -import { a as dep, b as log } from './chunk-main2-e628225d-esm.js'; +import { a as log, b as dep } from './chunk-main2-e628225d-esm.js'; log(dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-137367cc-esm.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-137367cc-esm.js index b2c1c3a587c..a98c1a031c1 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-137367cc-esm.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-137367cc-esm.js @@ -1 +1 @@ -export { b as default } from './chunk-main2-e628225d-esm.js'; +export { a as default } from './chunk-main2-e628225d-esm.js'; diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2-4b538eea.js b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-c713bf1b-system.js similarity index 76% rename from test/chunking-form/samples/entrypoint-facade/_expected/system/main2-4b538eea.js rename to test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-c713bf1b-system.js index 101389000ea..22516b5eba1 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2-4b538eea.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-c713bf1b-system.js @@ -3,9 +3,9 @@ System.register([], function (exports, module) { return { execute: function () { - exports('b', log); + exports('a', log); - var dep = exports('a', { x: 42 }); + var dep = exports('b', { x: 42 }); function log (x) { if (dep) { diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-d020ac3e-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-ce2d9eaa-system.js similarity index 53% rename from test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-d020ac3e-system.js rename to test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-ce2d9eaa-system.js index d19a470c48d..fee402230a2 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-d020ac3e-system.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-ce2d9eaa-system.js @@ -1,10 +1,10 @@ -System.register(['./chunk-main2-4b538eea-system.js'], function (exports, module) { +System.register(['./chunk-main2-c713bf1b-system.js'], function (exports, module) { 'use strict'; - var dep, log; + var log, dep; return { setters: [function (module) { - dep = module.a; - log = module.b; + log = module.a; + dep = module.b; }], execute: function () { diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-e24445f6-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-07ba2e91-system.js similarity index 55% rename from test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-e24445f6-system.js rename to test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-07ba2e91-system.js index 25ef304e98f..bb9ce345b8d 100644 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-e24445f6-system.js +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-07ba2e91-system.js @@ -1,8 +1,8 @@ -System.register(['./chunk-main2-4b538eea-system.js'], function (exports, module) { +System.register(['./chunk-main2-c713bf1b-system.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { - exports('default', module.b); + exports('default', module.a); }], execute: function () { diff --git a/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js b/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js index bb8c199aa0d..d9e43c99c45 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js @@ -1,3 +1,3 @@ define(['exports'],function(exports){'use strict';var _missingExportShim=void 0;function x () { sideEffect(); -}exports.x=x;exports.missingFn=dep.missingFn;exports.missingExport=dep.missingFn;Object.defineProperty(exports,'__esModule',{value:true});}); \ No newline at end of file +}exports.x=x;exports.missingFn=_missingExportShim;exports.missingExport=_missingExportShim;Object.defineProperty(exports,'__esModule',{value:true});}); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/es/main.js b/test/chunking-form/samples/missing-export-compact/_expected/es/main.js index 640c960463c..ac1e69ef80f 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/es/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/es/main.js @@ -1,2 +1,2 @@ -import {missingFn as _missingExportShim$$1,x}from'./dep.js';_missingExportShim$$1(); -x(_missingExportShim$$1); \ No newline at end of file +import {missingFn as _missingExportShim$1,x}from'./dep.js';_missingExportShim$1(); +x(_missingExportShim$1); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js b/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js index ae03dba5678..68befd459c4 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js @@ -1,3 +1,3 @@ -System.register([],function(exports,module){'use strict';return{execute:function(){exports({x:x,missingFn:dep.missingFn,missingExport:dep.missingFn});var _missingExportShim=void 0;function x () { +System.register([],function(exports,module){'use strict';return{execute:function(){exports('x',x);var _missingExportShim=void 0;function x () { sideEffect(); -}}}}); \ No newline at end of file +}exports({missingFn:_missingExportShim,missingExport:_missingExportShim});}}}); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/system/main.js b/test/chunking-form/samples/missing-export-compact/_expected/system/main.js index ee428dae034..2526542b862 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/system/main.js @@ -1,2 +1,2 @@ -System.register(['./dep.js'],function(exports,module){'use strict';var _missingExportShim$$1,x;return{setters:[function(module){_missingExportShim$$1=module.missingFn;x=module.x;}],execute:function(){_missingExportShim$$1(); -x(_missingExportShim$$1);}}}); \ No newline at end of file +System.register(['./dep.js'],function(exports,module){'use strict';var _missingExportShim$1,x;return{setters:[function(module){_missingExportShim$1=module.missingFn;x=module.x;}],execute:function(){_missingExportShim$1(); +x(_missingExportShim$1);}}}); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/dep.js b/test/chunking-form/samples/missing-export-compact/dep.js index f5db80883b4..3cedc5e4cfe 100644 --- a/test/chunking-form/samples/missing-export-compact/dep.js +++ b/test/chunking-form/samples/missing-export-compact/dep.js @@ -1,3 +1,3 @@ export function x () { sideEffect(); -} \ No newline at end of file +} diff --git a/test/chunking-form/samples/missing-export-compact/main.js b/test/chunking-form/samples/missing-export-compact/main.js index c8e56cf0194..fef6f3b98b4 100644 --- a/test/chunking-form/samples/missing-export-compact/main.js +++ b/test/chunking-form/samples/missing-export-compact/main.js @@ -1,4 +1,4 @@ import { missingExport, missingFn, x } from './dep.js'; missingFn(); -x(missingExport); \ No newline at end of file +x(missingExport); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js index b912eff2d46..03bafc628d6 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js @@ -6,12 +6,12 @@ define(['exports'], function (exports) { 'use strict'; function almostUseUnused(useIt) { if (useIt) { - console.log(__chunk_1.missing1); + console.log(_missingExportShim); } } almostUseUnused(false); - exports.missing1 = __chunk_1.missing1; + exports.missing1 = _missingExportShim; }); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js index 5b86ba50ba5..5ac28b0aebc 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js @@ -1,5 +1,7 @@ define(['exports'], function (exports) { 'use strict'; + var _missingExportShim = void 0; + console.log('This is the output when a missing export is reexported'); var _missingExportShim$1 = void 0; @@ -7,6 +9,6 @@ define(['exports'], function (exports) { 'use strict'; console.log(_missingExportShim$1); exports.previousShimmedExport = _missingExportShim$1; - exports.missing2 = _missingExportShim$1; + exports.missing2 = _missingExportShim; }); 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 66bb6882fd4..771a3512c76 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,5 +1,5 @@ define(['./dep1.js', './dep2.js'], function (__chunk_1, __chunk_2) { 'use strict'; - console.log(__chunk_1.missing1, __chunk_1.missing1); + console.log(__chunk_1.missing1, __chunk_2.missing2, __chunk_2.previousShimmedExport); }); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js index 0b77a4bbf17..e5c185bd324 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js @@ -1,5 +1,7 @@ 'use strict'; +var _missingExportShim = void 0; + console.log('This is the output when a missing export is reexported'); var _missingExportShim$1 = void 0; @@ -7,4 +9,4 @@ var _missingExportShim$1 = void 0; console.log(_missingExportShim$1); exports.previousShimmedExport = _missingExportShim$1; -exports.missing2 = _missingExportShim$1; +exports.missing2 = _missingExportShim; diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/main.js index d97de7c7ac1..cd5ca909182 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/main.js @@ -3,4 +3,4 @@ var __chunk_1 = require('./dep1.js'); var __chunk_2 = require('./dep2.js'); -console.log(__chunk_1.missing1, __chunk_1.missing1); +console.log(__chunk_1.missing1, __chunk_2.missing2, __chunk_2.previousShimmedExport); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep2.js index 44476f4d1ef..f88a7cf2c92 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep2.js @@ -1,7 +1,9 @@ +var _missingExportShim = void 0; + console.log('This is the output when a missing export is reexported'); var _missingExportShim$1 = void 0; console.log(_missingExportShim$1); -export { _missingExportShim$1 as previousShimmedExport, _missingExportShim$1 as missing2 }; +export { _missingExportShim$1 as previousShimmedExport, _missingExportShim as missing2 }; diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/main.js index 6df8ea31d42..92a53c97ac5 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/main.js @@ -1,4 +1,4 @@ -import { missing1 as _missingExportShim$$1 } from './dep1.js'; -import { previousShimmedExport as _missingExportShim$2 } from './dep2.js'; +import { missing1 as _missingExportShim$1 } from './dep1.js'; +import { missing2 as _missingExportShim$2, previousShimmedExport as _missingExportShim$3 } from './dep2.js'; -console.log(_missingExportShim$$1, _missingExportShim$$1); +console.log(_missingExportShim$1, _missingExportShim$2, _missingExportShim$3); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js index fb68752f817..526eda65d35 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js @@ -3,20 +3,20 @@ System.register([], function (exports, module) { return { execute: function () { - exports('missing1', __chunk_1.missing1); - var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { if (useIt) { - console.log(__chunk_1.missing1); + console.log(_missingExportShim); } } almostUseUnused(false); + exports('missing1', _missingExportShim); + } }; }); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js index e85cb9cf9d3..12b4f7bcaba 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js @@ -3,12 +3,16 @@ System.register([], function (exports, module) { return { execute: function () { + var _missingExportShim = void 0; + console.log('This is the output when a missing export is reexported'); - var _missingExportShim$1 = exports('missing2', void 0); + var _missingExportShim$1 = exports('previousShimmedExport', void 0); console.log(_missingExportShim$1); + exports('missing2', _missingExportShim); + } }; }); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js index 87ad7377153..286d38bda38 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js @@ -1,15 +1,16 @@ System.register(['./dep1.js', './dep2.js'], function (exports, module) { 'use strict'; - var _missingExportShim$$1, _missingExportShim$2; + var _missingExportShim$1, _missingExportShim$2, _missingExportShim$3; return { setters: [function (module) { - _missingExportShim$$1 = module.missing1; + _missingExportShim$1 = module.missing1; }, function (module) { - _missingExportShim$2 = module.previousShimmedExport; + _missingExportShim$2 = module.missing2; + _missingExportShim$3 = module.previousShimmedExport; }], execute: function () { - console.log(_missingExportShim$$1, _missingExportShim$$1); + console.log(_missingExportShim$1, _missingExportShim$2, _missingExportShim$3); } }; diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/main.js index ae5374c64b6..167c08b23fc 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/main.js @@ -1,4 +1,4 @@ import { missing1 } from './dep1.js'; -import { missing2 } from './dep2.js'; +import { missing2, previousShimmedExport } from './dep2.js'; -console.log(missing1, missing2); +console.log(missing1, missing2, previousShimmedExport); diff --git a/test/chunking-form/samples/missing-export/_expected/amd/dep.js b/test/chunking-form/samples/missing-export/_expected/amd/dep.js index aa9c06c28c8..a97da9aa379 100644 --- a/test/chunking-form/samples/missing-export/_expected/amd/dep.js +++ b/test/chunking-form/samples/missing-export/_expected/amd/dep.js @@ -7,9 +7,9 @@ define(['exports'], function (exports) { 'use strict'; } exports.x = x; - exports.missingFn = dep.missingFn; - exports.missingExport = dep.missingFn; - exports.default = dep.missingFn; + exports.missingFn = _missingExportShim; + exports.missingExport = _missingExportShim; + exports.default = _missingExportShim; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/test/chunking-form/samples/missing-export/_expected/es/main.js b/test/chunking-form/samples/missing-export/_expected/es/main.js index 14ade90a2b0..f539ec1208a 100644 --- a/test/chunking-form/samples/missing-export/_expected/es/main.js +++ b/test/chunking-form/samples/missing-export/_expected/es/main.js @@ -1,4 +1,4 @@ -import { missingFn as _missingExportShim$$1, x } from './dep.js'; +import { missingFn as _missingExportShim$1, x } from './dep.js'; -_missingExportShim$$1(); -x(_missingExportShim$$1, _missingExportShim$$1); +_missingExportShim$1(); +x(_missingExportShim$1, _missingExportShim$1); diff --git a/test/chunking-form/samples/missing-export/_expected/system/dep.js b/test/chunking-form/samples/missing-export/_expected/system/dep.js index f9cd7badf4d..76ff9f5ba3d 100644 --- a/test/chunking-form/samples/missing-export/_expected/system/dep.js +++ b/test/chunking-form/samples/missing-export/_expected/system/dep.js @@ -3,12 +3,7 @@ System.register([], function (exports, module) { return { execute: function () { - exports({ - x: x, - missingFn: dep.missingFn, - missingExport: dep.missingFn, - default: dep.missingFn - }); + exports('x', x); var _missingExportShim = void 0; @@ -16,6 +11,12 @@ System.register([], function (exports, module) { sideEffect(); } + exports({ + missingFn: _missingExportShim, + missingExport: _missingExportShim, + default: _missingExportShim + }); + } }; }); diff --git a/test/chunking-form/samples/missing-export/_expected/system/main.js b/test/chunking-form/samples/missing-export/_expected/system/main.js index be767e1aa22..77d033e0e64 100644 --- a/test/chunking-form/samples/missing-export/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export/_expected/system/main.js @@ -1,15 +1,15 @@ System.register(['./dep.js'], function (exports, module) { 'use strict'; - var _missingExportShim$$1, x; + var _missingExportShim$1, x; return { setters: [function (module) { - _missingExportShim$$1 = module.missingFn; + _missingExportShim$1 = module.missingFn; x = module.x; }], execute: function () { - _missingExportShim$$1(); - x(_missingExportShim$$1, _missingExportShim$$1); + _missingExportShim$1(); + x(_missingExportShim$1, _missingExportShim$1); } }; diff --git a/test/chunking-form/samples/missing-export/dep.js b/test/chunking-form/samples/missing-export/dep.js index f5db80883b4..3cedc5e4cfe 100644 --- a/test/chunking-form/samples/missing-export/dep.js +++ b/test/chunking-form/samples/missing-export/dep.js @@ -1,3 +1,3 @@ export function x () { sideEffect(); -} \ No newline at end of file +} diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2-3b4df12d.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2-3b4df12d.js index 0fbd5d7082f..f539aafa977 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2-3b4df12d.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2-3b4df12d.js @@ -9,7 +9,7 @@ define(['exports'], function (exports) { 'use strict'; }); exports.a = a; - exports.b = b; exports.main2 = main2; + exports.b = b; }); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2-c3a8a9cf.js b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2-c3a8a9cf.js index ad0cd3ad080..1539f4e14b6 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2-c3a8a9cf.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2-c3a8a9cf.js @@ -9,5 +9,5 @@ var main2 = /*#__PURE__*/Object.freeze({ }); exports.a = a; -exports.b = b; exports.main2 = main2; +exports.b = b; 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 1fc339e9636..f69497839dd 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, c as main2 } from './main2-530714f0.js'; +import { a, b as main2 } from './main2-530714f0.js'; console.log(a); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/es/main2-530714f0.js b/test/chunking-form/samples/namespace-object-import/_expected/es/main2-530714f0.js index 41a8f02f8c1..42c30f97ff6 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/es/main2-530714f0.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/es/main2-530714f0.js @@ -6,4 +6,4 @@ var main2 = /*#__PURE__*/Object.freeze({ b: b }); -export { a, b, main2 as c }; +export { a, main2 as b, b as c }; 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 2799ac2e757..1b3661171f4 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, b } from './main2-530714f0.js'; +export { a, c as b } from './main2-530714f0.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 0431f43f8f9..be56dafa7d2 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,11 +1,10 @@ -System.register(['./main2-0b56937b.js'], function (exports, module) { +System.register(['./main2-fea2fa7a.js'], function (exports, module) { 'use strict'; - var a, b, main2; + var a, main2; return { setters: [function (module) { a = module.a; - b = module.b; - main2 = module.c; + main2 = module.b; }], execute: function () { diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/main2-0b56937b.js b/test/chunking-form/samples/namespace-object-import/_expected/system/main2-fea2fa7a.js similarity index 79% rename from test/chunking-form/samples/namespace-object-import/_expected/system/main2-0b56937b.js rename to test/chunking-form/samples/namespace-object-import/_expected/system/main2-fea2fa7a.js index aab41a5555b..babff4580f7 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/main2-0b56937b.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/main2-fea2fa7a.js @@ -4,13 +4,13 @@ System.register([], function (exports, module) { execute: function () { var a = exports('a', 'a'); - var b = exports('b', 'a'); + var b = exports('c', 'a'); var main2 = /*#__PURE__*/Object.freeze({ a: a, b: b }); - exports('c', main2); + exports('b', main2); } }; 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 b5e78d092e4..bace94a1a68 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,10 +1,10 @@ -System.register(['./main2-0b56937b.js'], function (exports, module) { +System.register(['./main2-fea2fa7a.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { var _setter = {}; _setter.a = module.a; - _setter.b = module.b; + _setter.b = module.c; exports(_setter); }], execute: function () { diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js new file mode 100644 index 00000000000..df7159a507b --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js @@ -0,0 +1,11 @@ +module.exports = { + description: 'renders namespaces with reexports that conflict with existing imports', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + external: ['external'], + output: { + exports: 'named', + chunkFileNames: 'generated-[name].js' + } + } +}; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk.js new file mode 100644 index 00000000000..d0bef9bda22 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + const reexported = 1; + + exports.reexported = reexported; + +}); 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 new file mode 100644 index 00000000000..72fef366cb5 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-chunk2.js @@ -0,0 +1,11 @@ +define(['exports', './generated-chunk.js', 'external'], function (exports, __chunk_1, external) { 'use strict'; + + console.log(external.reexported); + + var lib = /*#__PURE__*/Object.freeze({ + reexported: __chunk_1.reexported + }); + + exports.lib = lib; + +}); 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 new file mode 100644 index 00000000000..3d3a5144d0b --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-chunk.js', 'external', './generated-chunk2.js'], 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 new file mode 100644 index 00000000000..3ed815db8ae --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk.js', 'external', './generated-chunk2.js'], 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 new file mode 100644 index 00000000000..7829aea9079 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-chunk.js'], function (__chunk_1) { 'use strict'; + + + +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk.js new file mode 100644 index 00000000000..a412cfa84df --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk.js @@ -0,0 +1,5 @@ +'use strict'; + +const reexported = 1; + +exports.reexported = reexported; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk2.js new file mode 100644 index 00000000000..efde5396823 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/generated-chunk2.js @@ -0,0 +1,12 @@ +'use strict'; + +var __chunk_1 = require('./generated-chunk.js'); +var external = require('external'); + +console.log(external.reexported); + +var lib = /*#__PURE__*/Object.freeze({ + reexported: __chunk_1.reexported +}); + +exports.lib = lib; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main1.js new file mode 100644 index 00000000000..bcb57971dfe --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main1.js @@ -0,0 +1,7 @@ +'use strict'; + +require('./generated-chunk.js'); +require('external'); +var __chunk_2 = require('./generated-chunk2.js'); + +console.log(__chunk_2.lib); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main2.js new file mode 100644 index 00000000000..0c13973bdd8 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main2.js @@ -0,0 +1,7 @@ +'use strict'; + +var __chunk_1 = require('./generated-chunk.js'); +require('external'); +require('./generated-chunk2.js'); + +console.log(__chunk_1.reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main3.js new file mode 100644 index 00000000000..cd3e1d69188 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/cjs/main3.js @@ -0,0 +1,4 @@ +'use strict'; + +require('./generated-chunk.js'); + diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk.js new file mode 100644 index 00000000000..cad99a517ff --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk.js @@ -0,0 +1,3 @@ +const reexported = 1; + +export { reexported as a }; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk2.js new file mode 100644 index 00000000000..3403eb3dfb2 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/generated-chunk2.js @@ -0,0 +1,10 @@ +import { a as reexported$1 } from './generated-chunk.js'; +import { reexported } from 'external'; + +console.log(reexported); + +var lib = /*#__PURE__*/Object.freeze({ + reexported: reexported$1 +}); + +export { lib as a }; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main1.js new file mode 100644 index 00000000000..2b3f6676e4d --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main1.js @@ -0,0 +1,5 @@ +import './generated-chunk.js'; +import 'external'; +import { a as lib } from './generated-chunk2.js'; + +console.log(lib); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main2.js new file mode 100644 index 00000000000..c6ad92fd6a3 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main2.js @@ -0,0 +1,5 @@ +import { a as reexported } from './generated-chunk.js'; +import 'external'; +import './generated-chunk2.js'; + +console.log(reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main3.js new file mode 100644 index 00000000000..5d03e846db5 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/es/main3.js @@ -0,0 +1 @@ +import './generated-chunk.js'; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk.js new file mode 100644 index 00000000000..244dd349cd6 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk.js @@ -0,0 +1,10 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const reexported = exports('a', 1); + + } + }; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk2.js new file mode 100644 index 00000000000..9434705024a --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-chunk2.js @@ -0,0 +1,21 @@ +System.register(['./generated-chunk.js', 'external'], function (exports, module) { + 'use strict'; + var reexported$1, reexported; + return { + setters: [function (module) { + reexported$1 = module.a; + }, function (module) { + reexported = module.reexported; + }], + execute: function () { + + console.log(reexported); + + var lib = /*#__PURE__*/Object.freeze({ + reexported: reexported$1 + }); + exports('a', lib); + + } + }; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js new file mode 100644 index 00000000000..f90e3992d03 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js', 'external', './generated-chunk2.js'], function (exports, module) { + 'use strict'; + var lib; + return { + setters: [function () {}, function () {}, function (module) { + lib = module.a; + }], + execute: function () { + + console.log(lib); + + } + }; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js new file mode 100644 index 00000000000..49d0f9d44db --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js', 'external', './generated-chunk2.js'], function (exports, module) { + 'use strict'; + var reexported; + return { + setters: [function (module) { + reexported = module.a; + }, function () {}, function () {}], + execute: function () { + + console.log(reexported); + + } + }; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js new file mode 100644 index 00000000000..fd707ad411c --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js @@ -0,0 +1,11 @@ +System.register(['./generated-chunk.js'], function (exports, module) { + 'use strict'; + return { + setters: [function () {}], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/dep.js b/test/chunking-form/samples/namespace-reexport-name-conflict/dep.js new file mode 100644 index 00000000000..e4b3c53b160 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/dep.js @@ -0,0 +1 @@ +export const reexported = 1; diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/index.js b/test/chunking-form/samples/namespace-reexport-name-conflict/index.js new file mode 100644 index 00000000000..4506e18fb15 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/index.js @@ -0,0 +1,4 @@ +export { reexported } from './dep'; +import { reexported } from 'external'; + +console.log(reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/main1.js new file mode 100644 index 00000000000..ad3183d73d5 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/main1.js @@ -0,0 +1,2 @@ +import * as lib from './index'; +console.log(lib); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/main2.js new file mode 100644 index 00000000000..a15ef2d23b9 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/main2.js @@ -0,0 +1,2 @@ +import * as lib from './index'; +console.log(lib.reexported); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/main3.js new file mode 100644 index 00000000000..1f6200b9dd1 --- /dev/null +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/main3.js @@ -0,0 +1 @@ +import './dep'; 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 671d15534e7..96394ddc8ae 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js @@ -1,8 +1,8 @@ -define(['exports', './index-583b88ec.js', './hsl2hsv.js'], function (exports, index, hsl2hsv) { 'use strict'; +define(['exports', './hsl2hsv.js', './index-583b88ec.js'], function (exports, hsl2hsv, index) { 'use strict'; - exports.hsl2hsv = index.hsl2hsv; + exports.hsl2hsv = hsl2hsv.default; Object.defineProperty(exports, '__esModule', { value: true }); 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 ed49bc3efe9..2ddaa5af3e0 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); -var index = require('./index-07661ef3.js'); -require('./hsl2hsv.js'); +var hsl2hsv = require('./hsl2hsv.js'); +require('./index-07661ef3.js'); -exports.hsl2hsv = index.hsl2hsv; +exports.hsl2hsv = hsl2hsv.default; 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 9b940aa30ca..473c7967f79 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 { b as hsl2hsv } from './index-6a71658c.js'; -import './hsl2hsv.js'; +export { default as hsl2hsv } from './hsl2hsv.js'; +import './index-6a71658c.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 82c8974ca04..8912d258a3f 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/main.js @@ -1,4 +1,4 @@ -import hsl2hsv, { p } from './hsl2hsv.js'; +import { p } from './hsl2hsv.js'; import { a as lib } from './index-6a71658c.js'; console.log(p); 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 0a81f1b3234..315d2df424d 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/index.js @@ -1,8 +1,8 @@ -System.register(['./index-51f0f10d.js', './hsl2hsv.js'], function (exports, module) { +System.register(['./hsl2hsv.js', './index-51f0f10d.js'], function (exports, module) { 'use strict'; return { setters: [function (module) { - exports('hsl2hsv', module.b); + exports('hsl2hsv', module.default); }, function () {}], execute: function () { 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 a3b0fe5fe3e..bf159b245f0 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/main.js @@ -1,9 +1,8 @@ System.register(['./hsl2hsv.js', './index-51f0f10d.js'], function (exports, module) { 'use strict'; - var hsl2hsv, p, lib; + var p, lib; return { setters: [function (module) { - hsl2hsv = module.default; p = module.p; }, function (module) { lib = module.a; 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 04b2fbb0eee..f2d73fcdf05 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(['./chunk-71f1648d.js', './chunk-747bf861.js'], function (__chunk_2, __chunk_1) { 'use strict'; +define(['./chunk-747bf861.js', './chunk-71f1648d.js'], 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 78fb80ea671..5a1230b6f2b 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(['./chunk-71f1648d.js', './chunk-67ec8019.js', './chunk-747bf861.js'], function (__chunk_2, __chunk_3, __chunk_1) { 'use strict'; +define(['./chunk-747bf861.js', './chunk-71f1648d.js', './chunk-67ec8019.js'], 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 95cf73710fb..2fe546c8b8f 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(['./chunk-67ec8019.js', './chunk-747bf861.js'], function (__chunk_3, __chunk_1) { 'use strict'; +define(['./chunk-747bf861.js', './chunk-67ec8019.js'], function (__chunk_1, __chunk_3) { 'use strict'; __chunk_3.bar(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-a.js index e0b47475c71..5737d0a587e 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-a.js @@ -1,7 +1,7 @@ 'use strict'; -var __chunk_2 = require('./chunk-3c2b236e.js'); var __chunk_1 = require('./chunk-fb422dac.js'); +var __chunk_2 = require('./chunk-3c2b236e.js'); __chunk_2.foo(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-b.js index 236a8c8c0e4..5e530139282 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-b.js @@ -1,8 +1,8 @@ 'use strict'; +var __chunk_1 = require('./chunk-fb422dac.js'); var __chunk_2 = require('./chunk-3c2b236e.js'); var __chunk_3 = require('./chunk-75d7bcb4.js'); -var __chunk_1 = require('./chunk-fb422dac.js'); __chunk_2.foo(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-c.js index 5e1961107b9..8e825c85123 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/cjs/main-c.js @@ -1,7 +1,7 @@ 'use strict'; -var __chunk_3 = require('./chunk-75d7bcb4.js'); var __chunk_1 = require('./chunk-fb422dac.js'); +var __chunk_3 = require('./chunk-75d7bcb4.js'); __chunk_3.bar(); __chunk_1.broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/es/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/es/main-a.js index 33b592dcf3a..e8d4ab50cf7 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/es/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/es/main-a.js @@ -1,5 +1,5 @@ -import { a as foo } from './chunk-59f2138c.js'; import { a as broken } from './chunk-77a3d20f.js'; +import { a as foo } from './chunk-59f2138c.js'; foo(); broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/es/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/es/main-b.js index def879eabb9..dcdedb5a494 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/es/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/es/main-b.js @@ -1,6 +1,6 @@ +import { a as broken } from './chunk-77a3d20f.js'; import { a as foo } from './chunk-59f2138c.js'; import { a as bar } from './chunk-ef0a1a76.js'; -import { a as broken } from './chunk-77a3d20f.js'; foo(); broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/es/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/es/main-c.js index 6cea14c6fcf..3fada310bb3 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/es/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/es/main-c.js @@ -1,5 +1,5 @@ -import { a as bar } from './chunk-ef0a1a76.js'; import { a as broken } from './chunk-77a3d20f.js'; +import { a as bar } from './chunk-ef0a1a76.js'; bar(); broken(); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js index c2b3bf4c2e8..d1bf86fb5fb 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js @@ -1,11 +1,11 @@ -System.register(['./chunk-daa4308b.js', './chunk-4b433a97.js'], function (exports, module) { +System.register(['./chunk-4b433a97.js', './chunk-daa4308b.js'], function (exports, module) { 'use strict'; - var foo, broken; + var broken, foo; return { setters: [function (module) { - foo = module.a; - }, function (module) { broken = module.a; + }, function (module) { + foo = module.a; }], execute: function () { diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js index dd803616168..b6253ba3e77 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js @@ -1,13 +1,13 @@ -System.register(['./chunk-daa4308b.js', './chunk-adb756c4.js', './chunk-4b433a97.js'], function (exports, module) { +System.register(['./chunk-4b433a97.js', './chunk-daa4308b.js', './chunk-adb756c4.js'], function (exports, module) { 'use strict'; - var foo, bar, broken; + var broken, foo, bar; return { setters: [function (module) { + broken = module.a; + }, function (module) { foo = module.a; }, function (module) { bar = module.a; - }, function (module) { - broken = module.a; }], execute: function () { diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js index 3de570735b8..4af19e03a2c 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js @@ -1,11 +1,11 @@ -System.register(['./chunk-adb756c4.js', './chunk-4b433a97.js'], function (exports, module) { +System.register(['./chunk-4b433a97.js', './chunk-adb756c4.js'], function (exports, module) { 'use strict'; - var bar, broken; + var broken, bar; return { setters: [function (module) { - bar = module.a; - }, function (module) { broken = module.a; + }, function (module) { + bar = module.a; }], execute: function () { diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js new file mode 100644 index 00000000000..5f9018cd1cb --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js @@ -0,0 +1,8 @@ +module.exports = { + // TODO Lukas do not inline execution list for preserve modules + description: 'Preserve modules properly handles internal namespace imports (#2576)', + options: { + input: ['main.js'], + experimentalPreserveModules: true + } +}; 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 new file mode 100644 index 00000000000..0788bf47212 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js @@ -0,0 +1,8 @@ +define(['exports', './m2.js', './m3.js'], function (exports, __chunk_1, __chunk_2) { 'use strict'; + + + + exports.m2 = __chunk_1.default; + exports.m3 = __chunk_2.default; + +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js new file mode 100644 index 00000000000..2ade9265476 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + var m2 = {a:1}; + + exports.default = m2; + +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js new file mode 100644 index 00000000000..7f26f198b02 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js @@ -0,0 +1,7 @@ +define(['exports'], function (exports) { 'use strict'; + + var m3 = {b:2}; + + exports.default = m3; + +}); 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 new file mode 100644 index 00000000000..d2ddab26e51 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./m1.js'], function (__chunk_3) { 'use strict'; + + console.log(__chunk_3); + +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js new file mode 100644 index 00000000000..2d344aba613 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js @@ -0,0 +1,9 @@ +'use strict'; + +var __chunk_1 = require('./m2.js'); +var __chunk_2 = require('./m3.js'); + + + +exports.m2 = __chunk_1.default; +exports.m3 = __chunk_2.default; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m2.js new file mode 100644 index 00000000000..1b68fbf1694 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m2.js @@ -0,0 +1,5 @@ +'use strict'; + +var m2 = {a:1}; + +exports.default = m2; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m3.js new file mode 100644 index 00000000000..8f0d9440c15 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m3.js @@ -0,0 +1,5 @@ +'use strict'; + +var m3 = {b:2}; + +exports.default = m3; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/main.js new file mode 100644 index 00000000000..9cfd124aa66 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var __chunk_3 = require('./m1.js'); + +console.log(__chunk_3); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m1.js new file mode 100644 index 00000000000..86968950d9d --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m1.js @@ -0,0 +1,2 @@ +export { default as m2 } from './m2.js'; +export { default as m3 } from './m3.js'; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js new file mode 100644 index 00000000000..0ee68395af0 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js @@ -0,0 +1,3 @@ +var m2 = {a:1}; + +export default m2; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js new file mode 100644 index 00000000000..0d65aa10bb9 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js @@ -0,0 +1,3 @@ +var m3 = {b:2}; + +export default m3; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/main.js new file mode 100644 index 00000000000..c7526ddd8b1 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/main.js @@ -0,0 +1,3 @@ +import * as ms from './m1.js'; + +console.log(ms); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js new file mode 100644 index 00000000000..734d751633b --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js @@ -0,0 +1,15 @@ +System.register(['./m2.js', './m3.js'], function (exports, module) { + 'use strict'; + return { + setters: [function (module) { + exports('m2', module.default); + }, function (module) { + exports('m3', module.default); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js new file mode 100644 index 00000000000..95b650af9d8 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js @@ -0,0 +1,11 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var m2 = {a:1}; + exports('default', m2); + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js new file mode 100644 index 00000000000..1139d763304 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js @@ -0,0 +1,11 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + var m3 = {b:2}; + exports('default', m3); + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js new file mode 100644 index 00000000000..55d840c5b13 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./m1.js'], function (exports, module) { + 'use strict'; + var ms; + return { + setters: [function (module) { + ms = module; + }], + execute: function () { + + console.log(ms); + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m1.js new file mode 100644 index 00000000000..611f3360f0a --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m1.js @@ -0,0 +1,5 @@ +import m2 from './m2.js'; +import m3 from './m3.js'; + +// console.log('m1'); +export { m2, m3 }; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m2.js new file mode 100644 index 00000000000..040aecae258 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m2.js @@ -0,0 +1,2 @@ +var m2 = {a:1}; +export default m2; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m3.js new file mode 100644 index 00000000000..e58c26e98bd --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/m3.js @@ -0,0 +1,2 @@ +var m3 = {b:2}; +export default m3; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/main.js new file mode 100644 index 00000000000..c7526ddd8b1 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/main.js @@ -0,0 +1,3 @@ +import * as ms from './m1.js'; + +console.log(ms); 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 c5377a64e71..260cfa9dfef 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', './lib/lib2.js'], function (__chunk_1, __chunk_3, __chunk_2) { 'use strict'; +define(['./deps/dep1.js', './deps/dep2.js'], 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 ed6672c67ea..6e00984a2d4 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', './lib/lib2.js', './lib/lib1.js'], function (__chunk_3, __chunk_5, __chunk_2, __chunk_4) { 'use strict'; +define(['./deps/dep2.js', './deps/dep3.js'], function (__chunk_3, __chunk_5) { 'use strict'; class Main2 { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/main1.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/main1.js index 07494d42465..70488dc698a 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/main1.js @@ -2,7 +2,6 @@ var __chunk_1 = require('./deps/dep1.js'); var __chunk_3 = require('./deps/dep2.js'); -require('./lib/lib2.js'); class Main1 { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/main2.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/main2.js index 8d43e3893cc..ca7e906776a 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/main2.js @@ -2,8 +2,6 @@ var __chunk_3 = require('./deps/dep2.js'); var __chunk_5 = require('./deps/dep3.js'); -require('./lib/lib2.js'); -require('./lib/lib1.js'); class Main2 { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/es/main1.js b/test/chunking-form/samples/preserve-modules/_expected/es/main1.js index c8f20a825c3..db71b463402 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/es/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/es/main1.js @@ -1,6 +1,5 @@ import { fn } from './deps/dep1.js'; import { fn as fn$1 } from './deps/dep2.js'; -import './lib/lib2.js'; class Main1 { constructor () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/es/main2.js b/test/chunking-form/samples/preserve-modules/_expected/es/main2.js index 3521d11c39b..a3b4ef89ff7 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/es/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/es/main2.js @@ -1,12 +1,10 @@ -import { fn } from './deps/dep2.js'; -import { fn as fn$1 } from './deps/dep3.js'; -import './lib/lib2.js'; -import './lib/lib1.js'; +import { fn as fn$1 } from './deps/dep2.js'; +import { fn } from './deps/dep3.js'; class Main2 { constructor () { - fn$1(); fn(); + fn$1(); } } diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/main1.js b/test/chunking-form/samples/preserve-modules/_expected/system/main1.js index a4569b16b83..e349ffe8b31 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./deps/dep1.js', './deps/dep2.js', './lib/lib2.js'], function (exports, module) { +System.register(['./deps/dep1.js', './deps/dep2.js'], function (exports, module) { 'use strict'; var fn, fn$1; return { @@ -6,7 +6,7 @@ System.register(['./deps/dep1.js', './deps/dep2.js', './lib/lib2.js'], function fn = module.fn; }, function (module) { fn$1 = module.fn; - }, function () {}], + }], execute: function () { class Main1 { diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/main2.js b/test/chunking-form/samples/preserve-modules/_expected/system/main2.js index ea108695ef3..9aa9cafa71d 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/main2.js @@ -1,18 +1,18 @@ -System.register(['./deps/dep2.js', './deps/dep3.js', './lib/lib2.js', './lib/lib1.js'], function (exports, module) { +System.register(['./deps/dep2.js', './deps/dep3.js'], function (exports, module) { 'use strict'; - var fn, fn$1; + var fn$1, fn; return { setters: [function (module) { - fn = module.fn; - }, function (module) { fn$1 = module.fn; - }, function () {}, function () {}], + }, function (module) { + fn = module.fn; + }], execute: function () { class Main2 { constructor () { - fn$1(); fn(); + fn$1(); } } exports('default', Main2); diff --git a/test/form/samples/export-default-import/_expected/es.js b/test/form/samples/export-default-import/_expected/es.js index 76a9f238ce7..c64c12b0265 100644 --- a/test/form/samples/export-default-import/_expected/es.js +++ b/test/form/samples/export-default-import/_expected/es.js @@ -1,2 +1 @@ -import x from 'x'; export { default as x } from 'x'; diff --git a/test/form/samples/export-default-import/_expected/system.js b/test/form/samples/export-default-import/_expected/system.js index eec667e4a39..05af71e7b19 100644 --- a/test/form/samples/export-default-import/_expected/system.js +++ b/test/form/samples/export-default-import/_expected/system.js @@ -1,9 +1,7 @@ System.register('myBundle', ['x'], function (exports, module) { 'use strict'; - var x; return { setters: [function (module) { - x = module.default; exports('x', module.default); }], execute: function () { diff --git a/test/form/samples/external-imports/_expected/system.js b/test/form/samples/external-imports/_expected/system.js index cf99ce5b225..68fdf332150 100644 --- a/test/form/samples/external-imports/_expected/system.js +++ b/test/form/samples/external-imports/_expected/system.js @@ -1,6 +1,6 @@ System.register(['factory', 'baz', 'shipping-port', 'alphabet'], function (exports, module) { 'use strict'; - var factory, foo, bar, port, forEach, alphabet, a; + var factory, foo, bar, port, forEach, a, alphabet; return { setters: [function (module) { factory = module.default; @@ -11,8 +11,8 @@ System.register(['factory', 'baz', 'shipping-port', 'alphabet'], function (expor port = module.port; forEach = module.forEach; }, function (module) { - alphabet = module.default; a = module.a; + alphabet = module.default; }], execute: function () { diff --git a/test/form/samples/import-external-namespace-and-default/_expected/system.js b/test/form/samples/import-external-namespace-and-default/_expected/system.js index edb17c134e8..08bcb7b5892 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/system.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/system.js @@ -1,10 +1,10 @@ System.register(['foo'], function (exports, module) { 'use strict'; - var foo__default, bar; + var bar, foo__default; return { setters: [function (module) { - foo__default = module.default; bar = module.bar; + foo__default = module.default; }], execute: function () { diff --git a/test/form/samples/namespace-import-reexport/_expected/system.js b/test/form/samples/namespace-import-reexport/_expected/system.js index db43ddaf421..15b63f0fd51 100644 --- a/test/form/samples/namespace-import-reexport/_expected/system.js +++ b/test/form/samples/namespace-import-reexport/_expected/system.js @@ -1,9 +1,7 @@ System.register('iife', ['external-package'], function (exports, module) { 'use strict'; - var externalPackage; return { setters: [function (module) { - externalPackage = module; exports('ext', module); }], execute: function () {