Skip to content

Commit

Permalink
Always load the CJS helpers when using require (#12865)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 23, 2021
1 parent f47737c commit a2114d4
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 253 deletions.
26 changes: 16 additions & 10 deletions packages/babel-plugin-transform-runtime/scripts/build-dist.js
Expand Up @@ -139,17 +139,23 @@ function writeHelpers(runtimeName, { corejs } = {}) {
for (const helperName of helpers.list) {
const helperPath = path.join("helpers", helperName);
helperSubExports[`./${helperPath}`] = {
module: writeHelperFile(runtimeName, pkgDirname, helperPath, helperName, {
esm: true,
corejs,
}),
node: writeHelperFile(runtimeName, pkgDirname, helperPath, helperName, {
esm: false,
corejs,
}),
get default() {
return this.module;
get node() {
return this.require;
},
require: writeHelperFile(
runtimeName,
pkgDirname,
helperPath,
helperName,
{ esm: false, corejs }
),
default: writeHelperFile(
runtimeName,
pkgDirname,
helperPath,
helperName,
{ esm: true, corejs }
),
};
writeHelperLegacyESMFile(pkgDirname, helperName);
}
Expand Down

0 comments on commit a2114d4

Please sign in to comment.