Merge remote-tracking branch 'origin/fix/core-runtime-weak-deps' into release-3.0

# Conflicts:
#	tools/isobuild/linker.js
This commit is contained in:
Gabriel Grubba
2023-02-28 15:04:36 -03:00
2 changed files with 24 additions and 16 deletions

View File

@@ -1072,7 +1072,10 @@ export class PackageSourceBatch {
// depends on something).
self.importedSymbolToPackageName = {}; // map from symbol to supplying package name
self.deps = [];
// List of packages (including weak) that need to load before
// this unibuild
self.orderedDeps = new Set();
}
async init() {
@@ -1095,17 +1098,26 @@ export class PackageSourceBatch {
skipDebugOnly: true,
skipProdOnly: true,
skipTestOnly: true,
}, (depUnibuild, { weak, unordered }) => {
}, (depUnibuild) => {
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;
}
});
});
self.deps.push({ package: packageName, weak, unordered });
// 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.useMeteorInstall =
@@ -1700,7 +1712,7 @@ export class PackageSourceBatch {
imports: self.importedSymbolToPackageName,
// XXX report an error if there is a package called global-imports
includeSourceMapInstructions: isWeb,
deps: self.deps
orderedDeps: Array.from(self.orderedDeps)
};
const fileHashes = [];

View File

@@ -941,12 +941,8 @@ var getHeader = function (options) {
var isApp = options.name === null;
var chunks = [];
let orderedDeps = [];
options.deps.forEach(dep => {
if (!dep.unordered) {
orderedDeps.push(JSON.stringify(dep.package))
}
let orderedDeps = options.orderedDeps.map(packageName => {
return JSON.stringify(packageName);
});
chunks.push(
@@ -1140,9 +1136,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, or is implied by the packages
// it uses
deps
// List of packages this bundle directly uses that need to load
// first. Includes weak dependencies.
orderedDeps
}) {
buildmessage.assertInJob();
@@ -1159,7 +1155,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 = deps.some(entry => entry.unordered !== true);
let hasRuntime = orderedDeps.length > 0;
_.each(inputFiles, file => module.addFile(file));
@@ -1194,7 +1190,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, {
imports,
packageVariables: [],
hasRuntime,
deps
orderedDeps
});
let footer = getFooter({
name: null,
@@ -1255,7 +1251,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, {
imports,
packageVariables: _.union(assignedVariables, declaredExports),
hasRuntime,
deps
orderedDeps
});
var footer = getFooter({