From 7a180129751df831858b41bce14865ad63dcc1ed Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sun, 16 Oct 2016 16:29:37 -0400 Subject: [PATCH] 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 --- tools/isobuild/compiler-plugin.js | 14 ++++++++++---- tools/tool-env/isopackets.js | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index 4215e133fc..24d859d06c 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -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; } } diff --git a/tools/tool-env/isopackets.js b/tools/tool-env/isopackets.js index 2e491a999d..c097a78bea 100644 --- a/tools/tool-env/isopackets.js +++ b/tools/tool-env/isopackets.js @@ -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