From e3aa0e5f8ac3fcfb78f67c3089a352e87623fa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 24 Jan 2022 15:36:52 -0500 Subject: [PATCH] disable output.interop for packages not in this repo --- Gulpfile.mjs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index acdc9c990a70..800384d2d68b 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -405,6 +405,26 @@ function buildRollup(packages, targetBrowsers) { name, sourcemap: sourcemap, exports: "named", + interop(id) { + // We have manually applied commonjs-esm interop to the source + // for library not in this monorepo + // https://github.com/babel/babel/pull/12795 + if (id.startsWith("@babel/")) { + // Some syntax plugins have been archived + if (id.includes("plugin-syntax")) { + const srcPath = id.replace("@babel/", "babel-"); + if ( + !fs.existsSync( + new URL("./packages/" + srcPath, import.meta.url) + ) + ) { + return false; + } + } + return true; + } + return false; + }, }); // Only minify @babel/standalone @@ -487,8 +507,15 @@ function* libBundlesIterator() { dir === "babel-standalone" || // todo: Rollup hangs on allowHashBang: true with babel-cli/src/babel/index.ts hashbang dir === "babel-cli" || - // todo: Rollup bundles only the browser entry of babel-register - dir === "babel-register" + // todo: @rollup/node-resolve 'browsers' option does not work when package.json contains `exports` + // https://github.com/rollup/plugins/tree/master/packages/node-resolve#browser + dir === "babel-register" || + dir === "babel-core" || + dir === "babel-plugin-transform-runtime" || + // @babel/node invokes internal lib/_babel-node.js + dir === "babel-node" || + // todo: test/helpers/define-helper requires internal lib/helpers access + dir === "babel-helpers" ) { continue; }