Fix handling implied packages in linker

This commit is contained in:
zodern
2023-01-27 17:07:03 -06:00
parent a593ad95ef
commit f60663ca12
2 changed files with 21 additions and 13 deletions

View File

@@ -1071,6 +1071,8 @@ export class PackageSourceBatch {
// decision of whether or not an unrelated package in the target
// depends on something).
self.importedSymbolToPackageName = {}; // map from symbol to supplying package name
self.deps = [];
}
async init() {
@@ -1093,13 +1095,17 @@ export class PackageSourceBatch {
skipDebugOnly: true,
skipProdOnly: true,
skipTestOnly: true,
}, depUnibuild => {
}, (depUnibuild, { weak, unordered }) => {
let packageName = depUnibuild.pkg.name;
_.each(depUnibuild.declaredExports, function (symbol) {
// Slightly hacky implementation of test-only exports.
if (! symbol.testOnly || self.unibuild.pkg.isTest) {
self.importedSymbolToPackageName[symbol.name] = depUnibuild.pkg.name;
self.importedSymbolToPackageName[symbol.name] = packageName;
}
});
self.deps.push({ package: packageName, weak, unordered });
});
self.useMeteorInstall =
@@ -1694,7 +1700,7 @@ export class PackageSourceBatch {
imports: self.importedSymbolToPackageName,
// XXX report an error if there is a package called global-imports
includeSourceMapInstructions: isWeb,
uses: self.unibuild.uses
deps: self.deps
};
const fileHashes = [];

View File

@@ -941,16 +941,17 @@ var getHeader = function (options) {
var isApp = options.name === null;
var chunks = [];
let deps = [];
options.uses.forEach(uses => {
if (!uses.unordered) {
deps.push(JSON.stringify(uses.package))
let orderedDeps = [];
options.deps.forEach(dep => {
if (!dep.unordered) {
orderedDeps.push(JSON.stringify(dep.package))
}
});
chunks.push(
`Package["core-runtime"].queue("${options.name}", [`,
deps.join(', '),
orderedDeps.join(', '),
'], function () {'
);
@@ -1139,8 +1140,9 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, {
// how to use them in a browser.
includeSourceMapInstructions,
// List of packages this bundle uses
uses
// List of packages this bundle directly uses, or is implied by the packages
// it uses
deps
}) {
buildmessage.assertInJob();
@@ -1157,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 = uses.some(entry => entry.unordered !== true);
let hasRuntime = deps.some(entry => entry.unordered !== true);
_.each(inputFiles, file => module.addFile(file));
@@ -1192,7 +1194,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, {
imports,
packageVariables: [],
hasRuntime,
uses
deps
});
let footer = getFooter({
name: null,
@@ -1253,7 +1255,7 @@ export var fullLink = Profile("linker.fullLink", async function (inputFiles, {
imports,
packageVariables: _.union(assignedVariables, declaredExports),
hasRuntime,
uses
deps
});
var footer = getFooter({