Filter out node_modules/babel-runtime/* when Meteor provides babel-runtime.

Should fix #7872 and others (e.g. #7833).
This commit is contained in:
Ben Newman
2016-10-13 18:33:36 -04:00
parent 5de9070c9c
commit 56c041c858

View File

@@ -1088,14 +1088,38 @@ export class PackageSourceBatch {
this._warnAboutMissingModules(allMissingNodeModules);
const meteorProvidesBabelRuntime = map.has("babel-runtime");
scannerMap.forEach((scanner, name) => {
const isApp = ! name;
const isWeb = scanner.isWeb();
const outputFiles = scanner.getOutputFiles();
if (isApp) {
const appFilesWithoutNodeModules = [];
scanner.getOutputFiles().forEach(file => {
outputFiles.forEach(file => {
const parts = file.installPath.split("/");
if (meteorProvidesBabelRuntime || ! isWeb) {
// If the Meteor babel-runtime package is installed, it will
// provide implementations for babel-runtime/helpers/* and
// babel-runtime/regenerator at runtime, so we should filter
// out any node_modules/babel-runtime/* modules from the app.
// If the Meteor babel-runtime package is not installed, then
// we should rely on node_modules/babel-runtime/* instead. On
// the server that still means removing bundled files here and
// 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" &&
// Can't just be node_modules/babel-runtime.
parts.length > 2) {
return;
}
}
const nodeModulesIndex = parts.indexOf("node_modules");
if (nodeModulesIndex === -1 || (nodeModulesIndex === 0 &&
@@ -1118,7 +1142,7 @@ export class PackageSourceBatch {
map.get(null).files = appFilesWithoutNodeModules;
} else {
map.get(name).files = scanner.getOutputFiles();
map.get(name).files = outputFiles;
}
});