Consult babel-runtime package when discarding helper modules.

The most fool-proof way to tell if a module is provided by babel-runtime
is to load babel-runtime as an isopacket and ask it.

This should fix any remaining issues like this one:
https://github.com/meteor/meteor/pull/7668#pullrequestreview-4379559
This commit is contained in:
Ben Newman
2016-10-16 16:29:37 -04:00
parent dfa8c343ce
commit 7a18012975
2 changed files with 12 additions and 5 deletions

View File

@@ -771,6 +771,15 @@ class ResourceSlot {
}
}
let babelRuntime;
function checkBabelRuntimeHelper(id) {
if (! babelRuntime) {
babelRuntime = require("../tool-env/isopackets.js")
.load("runtime")["babel-runtime"];
}
return babelRuntime.checkHelper(id);
}
export class PackageSourceBatch {
constructor(unibuild, processor, {
sourceRoot,
@@ -1112,10 +1121,7 @@ export class PackageSourceBatch {
// relying on programs/server/npm/node_modules/babel-runtime,
// but on the web these bundled files are all we have, so we'd
// better not remove them.
if (parts[0] === "node_modules" &&
parts[1] === "babel-runtime" &&
(parts[2] === "helpers" ||
parts[2].startsWith("regenerator"))) {
if (checkBabelRuntimeHelper(file.installPath)) {
return;
}
}

View File

@@ -56,7 +56,8 @@ export const ISOPACKETS = {
'constraint-solver': ['constraint-solver'],
'cordova-support': ['boilerplate-generator', 'logging', 'webapp-hashing',
'xmlbuilder'],
'logging': ['logging']
'logging': ['logging'],
'runtime': ['babel-runtime'],
};
// Caches isopackets in memory (each isopacket only needs to be loaded