diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index 22a2852cd6..3f368886c9 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -1072,10 +1072,7 @@ export class PackageSourceBatch { // depends on something). self.importedSymbolToPackageName = {}; // map from symbol to supplying package name - - // List of packages (including weak) that need to load before - // this unibuild - self.orderedDeps = new Set(); + self.deps = []; } async init() { @@ -1098,26 +1095,17 @@ export class PackageSourceBatch { skipDebugOnly: true, skipProdOnly: true, skipTestOnly: true, - }, (depUnibuild) => { + }, (depUnibuild, { weak, unordered }) => { let packageName = depUnibuild.pkg.name; - self.orderedDeps.add(packageName); - _.each(depUnibuild.declaredExports, function (symbol) { // Slightly hacky implementation of test-only exports. if (! symbol.testOnly || self.unibuild.pkg.isTest) { self.importedSymbolToPackageName[symbol.name] = packageName; } }); - }); - // At this point we can't easily know all weak dependencies - // that are actually used to pass them to eachUsedUnibuild. - // So instead we loop over the packages again to add them. - self.unibuild.uses.forEach(uses => { - if (uses.weak) { - self.orderedDeps.add(uses.package); - } + self.deps.push({ package: packageName, weak, unordered }); }); self.useMeteorInstall = @@ -1712,7 +1700,7 @@ export class PackageSourceBatch { imports: self.importedSymbolToPackageName, // XXX report an error if there is a package called global-imports includeSourceMapInstructions: isWeb, - orderedDeps: Array.from(self.orderedDeps) + deps: self.deps }; const fileHashes = []; diff --git a/tools/isobuild/linker.js b/tools/isobuild/linker.js index 984ac94e9a..31d6ed990e 100644 --- a/tools/isobuild/linker.js +++ b/tools/isobuild/linker.js @@ -941,8 +941,12 @@ var getHeader = function (options) { var isApp = options.name === null; var chunks = []; - let orderedDeps = options.orderedDeps.map(packageName => { - return JSON.stringify(packageName); + let orderedDeps = []; + + options.deps.forEach(dep => { + if (!dep.unordered) { + orderedDeps.push(JSON.stringify(dep.package)) + } }); chunks.push( @@ -1136,9 +1140,9 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, { // how to use them in a browser. includeSourceMapInstructions, - // List of packages this bundle directly uses that need to load - // first. Includes weak dependencies. - orderedDeps + // List of packages this bundle directly uses, or is implied by the packages + // it uses + deps }) { buildmessage.assertInJob(); @@ -1155,7 +1159,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, { // we can be sure the runtime will be available // The main situations it is not available is the core-runtime // package itself, or any build plugins with no dependencies - let hasRuntime = orderedDeps.length > 0; + let hasRuntime = deps.some(entry => entry.unordered !== true); _.each(inputFiles, file => module.addFile(file)); @@ -1190,7 +1194,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, { imports, packageVariables: [], hasRuntime, - orderedDeps + deps }); let footer = getFooter({ name: null, @@ -1251,7 +1255,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, { imports, packageVariables: _.union(assignedVariables, declaredExports), hasRuntime, - orderedDeps + deps }); var footer = getFooter({