From aef1d05a409de8ef35d44d2cf6a1f6c7fd91bd99 Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Mon, 2 May 2022 11:00:44 -0400 Subject: [PATCH 1/7] Initial exploration of startService API --- src/Graph.ts | 15 ++++++++-- src/ModuleLoader.ts | 1 + src/browser-entry.ts | 2 +- src/node-entry.ts | 2 +- src/rollup/rollup.ts | 65 +++++++++++++++++++++++++++++++++++++++++-- src/rollup/types.d.ts | 13 +++++++++ 6 files changed, 91 insertions(+), 7 deletions(-) diff --git a/src/Graph.ts b/src/Graph.ts index 2bc50b79764..15aed08457a 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -166,9 +166,20 @@ export default class Graph { throw new Error('You must supply options.input to rollup'); } for (const module of this.modulesById.values()) { - if (module instanceof Module) { + this.ensureModule(module); + } + } + + ensureModule(module: Module | ExternalModule) { + // Make sure that the same module / external module can only be added to the + // graph once since it may be requested multiple times over the life of a + // service. + if (module instanceof Module) { + if (this.modules.indexOf(module) === -1) { this.modules.push(module); - } else { + } + } else { + if (this.externalModules.indexOf(module) === -1) { this.externalModules.push(module); } } diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index 729afd56185..aa66f7c766d 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -40,6 +40,7 @@ import transform from './utils/transform'; export interface UnresolvedModule { fileName: string | null; id: string; + implicitlyLoadedAfter?: string[]; importer: string | undefined; name: string | null; } diff --git a/src/browser-entry.ts b/src/browser-entry.ts index 8f03c2d6209..ada21e75244 100644 --- a/src/browser-entry.ts +++ b/src/browser-entry.ts @@ -1,2 +1,2 @@ -export { default as rollup, defineConfig } from './rollup/rollup'; +export { default as rollup, defineConfig, startService } from './rollup/rollup'; export { version as VERSION } from 'package.json'; diff --git a/src/node-entry.ts b/src/node-entry.ts index d2a08e5f631..4a2ff631270 100644 --- a/src/node-entry.ts +++ b/src/node-entry.ts @@ -1,3 +1,3 @@ -export { default as rollup, defineConfig } from './rollup/rollup'; +export { default as rollup, defineConfig, startService } from './rollup/rollup'; export { default as watch } from './watch/watch-proxy'; export { version as VERSION } from 'package.json'; diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index f1981f7f1d5..f529fa76e78 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -23,6 +23,7 @@ import type { RollupBuild, RollupOptions, RollupOutput, + RollupService, RollupWatcher } from './types'; @@ -30,15 +31,54 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise { +): Promise { + const { graph, inputOptions } = await graphSetup(rawInputOptions, watcher); + + const service: RollupService = { + async close(err?: any) { + if (service.closed) return; + + service.closed = true; + + if (err) { + const watchFiles = Object.keys(graph.watchFiles); + if (watchFiles.length > 0) { + err.watchFiles = watchFiles; + } + } + + await graph.pluginDriver.hookParallel('buildEnd', err ? [err] : []); + await graph.pluginDriver.hookParallel('closeBundle', []); + }, + closed: false, + resolve(source: string, importer?: string | undefined) { + return graph.moduleLoader.resolveId(source, importer, undefined, false); + }, + load(id: string) { + return graph.moduleLoader.preloadModule({ id, resolveDependencies: true }); + } + }; + + await catchUnfinishedHookActions(graph.pluginDriver, async () => { + try { + await graph.pluginDriver.hookParallel('buildStart', [inputOptions]); + } catch (err: any) { + await service.close(err); + throw err; + } + }); + + return service; +} + +async function graphSetup(rawInputOptions: GenericConfigObject, watcher: RollupWatcher | null) { const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions( rawInputOptions, watcher !== null ); - initialiseTimers(inputOptions); const graph = new Graph(inputOptions, watcher); @@ -47,6 +87,25 @@ export async function rollupInternal( delete inputOptions.cache; delete rawInputOptions.cache; + return { + graph, + inputOptions, + unsetInputOptions, + useCache + }; +} + +export async function rollupInternal( + rawInputOptions: GenericConfigObject, + watcher: RollupWatcher | null +): Promise { + const { graph, inputOptions, unsetInputOptions, useCache } = await graphSetup( + rawInputOptions, + watcher + ); + + initialiseTimers(inputOptions); + timeStart('BUILD', 1); await catchUnfinishedHookActions(graph.pluginDriver, async () => { diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index b4c4673212b..afdf8144eb4 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -830,6 +830,17 @@ export interface RollupBuild { write: (options: OutputOptions) => Promise; } +export interface RollupService { + close: (err?: any) => Promise; + closed: boolean; + load(id: string): Promise; + resolve( + source: string, + importer?: string, + options?: { custom?: CustomPluginOptions; isEntry?: boolean } + ): Promise; +} + export interface RollupOptions extends InputOptions { // This is included for compatibility with config files but ignored by rollup.rollup output?: OutputOptions | OutputOptions[]; @@ -841,6 +852,8 @@ export interface MergedRollupOptions extends InputOptions { export function rollup(options: RollupOptions): Promise; +export function startService(options: RollupOptions): Promise; + export interface ChokidarOptions { alwaysStat?: boolean; atomic?: boolean | number; From 450b9ab875d48bfcd244810d07211223bc959eee Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Mon, 2 May 2022 17:49:28 -0400 Subject: [PATCH 2/7] Add more plugin-context APIs --- src/Graph.ts | 30 +++++++++++++++--------------- src/ModuleLoader.ts | 7 +++++-- src/rollup/rollup.ts | 9 +++++---- src/rollup/types.d.ts | 6 +++++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/Graph.ts b/src/Graph.ts index 15aed08457a..7710ab8f585 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -135,6 +135,21 @@ export default class Graph { return ast; } + ensureModule(module: Module | ExternalModule) { + // Make sure that the same module / external module can only be added to the + // graph once since it may be requested multiple times over the life of a + // service. + if (module instanceof Module) { + if (this.modules.indexOf(module) === -1) { + this.modules.push(module); + } + } else { + if (this.externalModules.indexOf(module) === -1) { + this.externalModules.push(module); + } + } + } + getCache(): RollupCache { // handle plugin cache eviction for (const name in this.pluginCache) { @@ -170,21 +185,6 @@ export default class Graph { } } - ensureModule(module: Module | ExternalModule) { - // Make sure that the same module / external module can only be added to the - // graph once since it may be requested multiple times over the life of a - // service. - if (module instanceof Module) { - if (this.modules.indexOf(module) === -1) { - this.modules.push(module); - } - } else { - if (this.externalModules.indexOf(module) === -1) { - this.externalModules.push(module); - } - } - } - private includeStatements(): void { for (const module of [...this.entryModules, ...this.implicitEntryModules]) { markModuleAndImpureDependenciesAsExecuted(module); diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index aa66f7c766d..8a5fc27a85b 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -177,12 +177,15 @@ export class ModuleLoader { } public async preloadModule( - resolvedId: { id: string; resolveDependencies?: boolean } & Partial> + resolvedId: { id: string; isEntry?: boolean; resolveDependencies?: boolean } & Partial< + PartialNull + > ): Promise { + const isEntry = resolvedId.isEntry !== false; const module = await this.fetchModule( this.getResolvedIdWithDefaults(resolvedId)!, undefined, - false, + isEntry, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true ); return module.info; diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index f529fa76e78..aab57ab826c 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -54,11 +54,12 @@ export async function startService( await graph.pluginDriver.hookParallel('closeBundle', []); }, closed: false, - resolve(source: string, importer?: string | undefined) { - return graph.moduleLoader.resolveId(source, importer, undefined, false); + getModuleInfo: graph.getModuleInfo, + load(id, options) { + return graph.moduleLoader.preloadModule({ ...options, id }); }, - load(id: string) { - return graph.moduleLoader.preloadModule({ id, resolveDependencies: true }); + resolve(source, importer, options) { + return graph.moduleLoader.resolveId(source, importer, options, false); } }; diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index afdf8144eb4..a9b607845a3 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -833,7 +833,11 @@ export interface RollupBuild { export interface RollupService { close: (err?: any) => Promise; closed: boolean; - load(id: string): Promise; + load: ( + source: string, + options?: { resolveDependencies?: boolean } & Partial> + ) => Promise; + getModuleInfo: GetModuleInfo; resolve( source: string, importer?: string, From 9a5012af52c429c5f52753e61634004de2d101e7 Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Thu, 5 May 2022 11:47:01 -0400 Subject: [PATCH 3/7] Explore partial graph build function --- src/rollup/rollup.ts | 80 ++++++++++++++++++++++++++++++++++++++++++- src/rollup/types.d.ts | 12 +++++-- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index aab57ab826c..eceb6621189 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -26,18 +26,96 @@ import type { RollupService, RollupWatcher } from './types'; +import type Module from '../Module'; export default function rollup(rawInputOptions: GenericConfigObject): Promise { return rollupInternal(rawInputOptions, null); } export async function startService( - rawInputOptions: GenericConfigObject, + { input, ...rawInputOptions }: GenericConfigObject, watcher: RollupWatcher | null ): Promise { + if (input) { + throw new Error( + `The 'input' option must not be specified when starting Rollup in service mode.` + ); + } + const { graph, inputOptions } = await graphSetup(rawInputOptions, watcher); const service: RollupService = { + async build(input, options) { + const normalizedInput = input == null ? [] : typeof input === 'string' ? [input] : input; + const seen: Set = new Set(); + const entrypoints = Array.isArray(normalizedInput) + ? [...normalizedInput] + : Object.values(normalizedInput); + + const modules: Module[] = []; + + const entrypointIdPromises = entrypoints.map(async source => { + const resolvedId = await graph.moduleLoader.resolveId(source, undefined, {}, true); + + if (!resolvedId) { + throw new Error(`Failed to resolve the entrypoint ${source}`); + } + + if (resolvedId.external) { + throw new Error(`An entrypoint cannot be marked as external ${source}`); + } + + return resolvedId.id; + }); + + const queue = await Promise.all(entrypointIdPromises); + + while (queue.length && options.signal?.aborted !== true) { + const moduleId = queue.shift()!; + + if (seen.has(moduleId)) { + continue; + } + seen.add(moduleId); + + console.log('preloading', moduleId); + + const moduleInfo = await graph.moduleLoader.preloadModule({ + id: moduleId, + isEntry: false, + resolveDependencies: true + }); + + const module = graph.modulesById.get(moduleInfo.id)! as Module; + + modules.push(module); + + for (const [source, resolvedDependencyId] of Object.entries(module.resolvedIds)) { + const shouldIncludeInBundleFn = options.shouldIncludeInBundle; + + // If `source` is nullish, this means it came from a plugin. We want synthetic files + // to be included. + if ( + shouldIncludeInBundleFn && + source != null && + !resolvedDependencyId.id.startsWith('\0') + ) { + if (!shouldIncludeInBundleFn(resolvedDependencyId, source, module.id)) { + continue; + } + } + + queue.push(resolvedDependencyId.id); + } + } + + console.log( + 'finished traversing', + modules.map(m => m.info.id) + ); + + return {} as any; + }, async close(err?: any) { if (service.closed) return; diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index a9b607845a3..fc37d95c1c5 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -830,7 +830,15 @@ export interface RollupBuild { write: (options: OutputOptions) => Promise; } +export interface BuildOptions { + signal?: { + aborted: boolean; + }; + shouldIncludeInBundle?: (resolvedId: ResolvedId, source: string, fromId: string) => boolean; +} + export interface RollupService { + build: (input: InputOption, options: BuildOptions) => Promise; close: (err?: any) => Promise; closed: boolean; load: ( @@ -838,11 +846,11 @@ export interface RollupService { options?: { resolveDependencies?: boolean } & Partial> ) => Promise; getModuleInfo: GetModuleInfo; - resolve( + resolve: ( source: string, importer?: string, options?: { custom?: CustomPluginOptions; isEntry?: boolean } - ): Promise; + ) => Promise; } export interface RollupOptions extends InputOptions { From 11cea36e4e6749ac360ac911bb25744948b382de Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Fri, 6 May 2022 09:02:57 -0400 Subject: [PATCH 4/7] Use static bundle factory --- src/Bundle.ts | 48 +++++++++++++++++++++++++------- src/rollup/rollup.ts | 64 +++++++++++++++++++++++++++++++++++-------- src/rollup/types.d.ts | 4 +-- 3 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/Bundle.ts b/src/Bundle.ts index 53b1f2b87f4..290dc6b7315 100644 --- a/src/Bundle.ts +++ b/src/Bundle.ts @@ -41,7 +41,29 @@ export default class Bundle { private readonly graph: Graph ) {} + static async fromModules( + outputOptions: NormalizedOutputOptions, + unsetOptions: ReadonlySet, + inputOptions: NormalizedInputOptions, + pluginDriver: PluginDriver, + graph: Graph, + entryModules: Module[], + modulesById: Map + ) { + const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, pluginDriver, graph); + + return bundle.generateInternal(false, entryModules, modulesById); + } + async generate(isWrite: boolean): Promise { + return this.generateInternal(isWrite); + } + + async generateInternal( + isWrite: boolean, + entryModules = this.graph.entryModules, + modulesById = this.graph.modulesById + ) { timeStart('GENERATE', 1); const outputBundle: OutputBundleWithPlaceholders = Object.create(null); this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions, this.facadeChunkByModule); @@ -49,7 +71,7 @@ export default class Bundle { await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]); timeStart('generate chunks', 2); - const chunks = await this.generateChunks(); + const chunks = await this.generateChunks(entryModules, modulesById); if (chunks.length > 1) { validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn); } @@ -155,13 +177,16 @@ export default class Bundle { } } - private assignManualChunks(getManualChunk: GetManualChunk): Map { + private assignManualChunks( + getManualChunk: GetManualChunk, + modulesById: Map + ): Map { const manualChunkAliasesWithEntry: [alias: string, module: Module][] = []; const manualChunksApi = { - getModuleIds: () => this.graph.modulesById.keys(), + getModuleIds: () => modulesById.keys(), getModuleInfo: this.graph.getModuleInfo }; - for (const module of this.graph.modulesById.values()) { + for (const module of modulesById.values()) { if (module instanceof Module) { const manualChunkAlias = getManualChunk(module.id, manualChunksApi); if (typeof manualChunkAlias === 'string') { @@ -203,22 +228,25 @@ export default class Bundle { this.pluginDriver.finaliseAssets(); } - private async generateChunks(): Promise { + private async generateChunks( + entryModules = this.graph.entryModules, + modulesById = this.graph.modulesById + ): Promise { const { manualChunks } = this.outputOptions; const manualChunkAliasByEntry = typeof manualChunks === 'object' ? await this.addManualChunks(manualChunks) - : this.assignManualChunks(manualChunks); + : this.assignManualChunks(manualChunks, modulesById); const chunks: Chunk[] = []; const chunkByModule = new Map(); for (const { alias, modules } of this.outputOptions.inlineDynamicImports - ? [{ alias: null, modules: getIncludedModules(this.graph.modulesById) }] + ? [{ alias: null, modules: getIncludedModules(modulesById) }] : this.outputOptions.preserveModules - ? getIncludedModules(this.graph.modulesById).map(module => ({ + ? getIncludedModules(modulesById).map(module => ({ alias: null, modules: [module] })) - : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) { + : getChunkAssignments(entryModules, manualChunkAliasByEntry)) { sortByExecutionOrder(modules); const chunk = new Chunk( modules, @@ -226,7 +254,7 @@ export default class Bundle { this.outputOptions, this.unsetOptions, this.pluginDriver, - this.graph.modulesById, + modulesById, chunkByModule, this.facadeChunkByModule, this.includedNamespaces, diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index eceb6621189..0a94308026a 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -26,7 +26,7 @@ import type { RollupService, RollupWatcher } from './types'; -import type Module from '../Module'; +import Module from '../Module'; export default function rollup(rawInputOptions: GenericConfigObject): Promise { return rollupInternal(rawInputOptions, null); @@ -42,17 +42,21 @@ export async function startService( ); } - const { graph, inputOptions } = await graphSetup(rawInputOptions, watcher); + const { graph, inputOptions, unsetInputOptions } = await graphSetup(rawInputOptions, watcher); const service: RollupService = { - async build(input, options) { + async build( + input, + { signal, shouldIncludeInBundle: shouldIncludeInBundleFn, ...rawOutputOptions } + ) { const normalizedInput = input == null ? [] : typeof input === 'string' ? [input] : input; const seen: Set = new Set(); const entrypoints = Array.isArray(normalizedInput) ? [...normalizedInput] : Object.values(normalizedInput); - const modules: Module[] = []; + const modulesById: Map = new Map(); + const entryModules: Module[] = []; const entrypointIdPromises = entrypoints.map(async source => { const resolvedId = await graph.moduleLoader.resolveId(source, undefined, {}, true); @@ -68,9 +72,10 @@ export async function startService( return resolvedId.id; }); - const queue = await Promise.all(entrypointIdPromises); + const entrypointIds = new Set(await Promise.all(entrypointIdPromises)); + const queue = [...entrypointIds]; - while (queue.length && options.signal?.aborted !== true) { + while (queue.length && signal?.aborted !== true) { const moduleId = queue.shift()!; if (seen.has(moduleId)) { @@ -86,13 +91,19 @@ export async function startService( resolveDependencies: true }); - const module = graph.modulesById.get(moduleInfo.id)! as Module; + const module = graph.modulesById.get(moduleInfo.id)!; + + if (!(module instanceof Module)) { + continue; + } - modules.push(module); + modulesById.set(module.id, module); - for (const [source, resolvedDependencyId] of Object.entries(module.resolvedIds)) { - const shouldIncludeInBundleFn = options.shouldIncludeInBundle; + if (entrypointIds.has(moduleId)) { + entryModules.push(module); + } + for (const [source, resolvedDependencyId] of Object.entries(module.resolvedIds)) { // If `source` is nullish, this means it came from a plugin. We want synthetic files // to be included. if ( @@ -111,10 +122,39 @@ export async function startService( console.log( 'finished traversing', - modules.map(m => m.info.id) + Array.from(modulesById.values()).map(m => m.info.id) + ); + + for (const module of modulesById.values()) { + graph.ensureModule(module); + } + + // for (const module of modulesById.values()) { + // module.bindReferences(); + // } + + const { + options: outputOptions, + outputPluginDriver, + unsetOptions + } = getOutputOptionsAndPluginDriver( + rawOutputOptions as GenericConfigObject, + graph.pluginDriver, + inputOptions, + unsetInputOptions + ); + + const outputBundle = await Bundle.fromModules( + outputOptions, + unsetOptions, + inputOptions, + outputPluginDriver, + graph, + entryModules, + modulesById ); - return {} as any; + return createOutput(outputBundle); }, async close(err?: any) { if (service.closed) return; diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index fc37d95c1c5..5b00f588ec3 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -830,7 +830,7 @@ export interface RollupBuild { write: (options: OutputOptions) => Promise; } -export interface BuildOptions { +export interface BuildOptions extends OutputOptions { signal?: { aborted: boolean; }; @@ -838,7 +838,7 @@ export interface BuildOptions { } export interface RollupService { - build: (input: InputOption, options: BuildOptions) => Promise; + build: (input: InputOption, options: BuildOptions) => Promise; close: (err?: any) => Promise; closed: boolean; load: ( From dcf60bc25e626e7322db0b6a2f7a9cc9508b15ad Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Tue, 17 May 2022 11:31:36 -0400 Subject: [PATCH 5/7] Tweak style for ensureModules --- src/Graph.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Graph.ts b/src/Graph.ts index 7710ab8f585..a5369d7dae6 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -139,14 +139,11 @@ export default class Graph { // Make sure that the same module / external module can only be added to the // graph once since it may be requested multiple times over the life of a // service. - if (module instanceof Module) { - if (this.modules.indexOf(module) === -1) { - this.modules.push(module); - } - } else { - if (this.externalModules.indexOf(module) === -1) { - this.externalModules.push(module); - } + const modules: Array = + module instanceof Module ? this.modules : this.externalModules; + + if (!modules.includes(module)) { + modules.push(module); } } From 649d40075082d4d01f07ee84418000b28105410e Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Thu, 19 May 2022 16:19:54 -0400 Subject: [PATCH 6/7] Create ephemeral ExternalModule instances --- src/Module.ts | 13 +++++++++---- src/rollup/rollup.ts | 8 +++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Module.ts b/src/Module.ts index 1e7c4ada2ba..db20d447b64 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -676,12 +676,16 @@ export default class Module { this.addModulesToImportDescriptions(this.reexportDescriptions); const externalExportAllModules: ExternalModule[] = []; for (const source of this.exportAllSources) { - const module = this.graph.modulesById.get(this.resolvedIds[source].id)!; + const module = this.graph.modulesById.get(this.resolvedIds[source].id); if (module instanceof ExternalModule) { externalExportAllModules.push(module); - continue; + } else if (module instanceof Module) { + this.exportAllModules.push(module); + } else { + this.exportAllModules.push( + new ExternalModule(this.options, this.resolvedIds[source].id, true, {}, true) + ); } - this.exportAllModules.push(module); } this.exportAllModules.push(...externalExportAllModules); } @@ -1019,7 +1023,8 @@ export default class Module { ): void { for (const specifier of importDescription.values()) { const { id } = this.resolvedIds[specifier.source]; - specifier.module = this.graph.modulesById.get(id)!; + specifier.module = + this.graph.modulesById.get(id) ?? new ExternalModule(this.options, id, true, {}, true); } } diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index 0a94308026a..5da0feddb76 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -129,9 +129,11 @@ export async function startService( graph.ensureModule(module); } - // for (const module of modulesById.values()) { - // module.bindReferences(); - // } + for (const module of modulesById.values()) { + module.linkImports(); + module.bindReferences(); + module.includeAllInBundle(); + } const { options: outputOptions, From ce7d45a1453f13ac074b5a6fdbfb4975071813cb Mon Sep 17 00:00:00 2001 From: Geoff Goodman Date: Thu, 19 May 2022 16:22:26 -0400 Subject: [PATCH 7/7] Better match export all ordering --- src/Module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module.ts b/src/Module.ts index db20d447b64..df7aa00f6d9 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -682,7 +682,7 @@ export default class Module { } else if (module instanceof Module) { this.exportAllModules.push(module); } else { - this.exportAllModules.push( + externalExportAllModules.push( new ExternalModule(this.options, this.resolvedIds[source].id, true, {}, true) ); }