From a5df709bc34383d8aad2c4dae7fb2e8bc8255214 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Sat, 17 Mar 2018 14:01:26 -0700 Subject: [PATCH] Lazy-load @babel/core's dependencies to decrease up-front load times. --- .babelrc.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.babelrc.js b/.babelrc.js index 9a6311a2c5..4a6d9dc764 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -46,7 +46,9 @@ module.exports = function(api) { "@babel/proposal-export-namespace-from", "@babel/proposal-numeric-separator", ["@babel/proposal-object-rest-spread", { useBuiltIns: true }], - convertESM ? "@babel/transform-modules-commonjs" : null, + + // Explicitly use the lazy version of CommonJS modules. + convertESM ? ["@babel/transform-modules-commonjs", { lazy: true }] : null, ].filter(Boolean), overrides: [ { @@ -56,6 +58,15 @@ module.exports = function(api) { ["@babel/transform-for-of", { assumeArray: true }], ], }, + { + test: "./packages/babel-register", + plugins: [ + // Override the root options to disable lazy imports for babel-register + // because otherwise the require hook will try to lazy-import things + // leading to dependency cycles. + convertESM ? "@babel/transform-modules-commonjs" : null, + ].filter(Boolean), + }, ], };