Skip to content

Commit

Permalink
Do not transpile typeof helper with itself in babel/runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 2, 2019
1 parent 26c0a32 commit faafeba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/babel-plugin-transform-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@babel/core": "^7.7.4",
"@babel/helper-plugin-test-runner": "^7.7.4",
"@babel/helpers": "^7.7.4",
"@babel/plugin-transform-typeof-symbol": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/runtime": "^7.7.4",
"@babel/template": "^7.7.4",
Expand Down
23 changes: 21 additions & 2 deletions packages/babel-plugin-transform-runtime/scripts/build-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = require("@babel/types");

const transformRuntime = require("../");

const runtimeVersion = require("@babel/runtime/package.json").version;
const corejs2Definitions = require("../lib/runtime-corejs2-definitions").default();
const corejs3Definitions = require("../lib/runtime-corejs3-definitions").default();

Expand Down Expand Up @@ -150,16 +151,34 @@ function buildHelper(
);
tree.body.push(...helper.nodes);

console.log(helperFilename);

return babel.transformFromAst(tree, null, {
presets: [[require("@babel/preset-env"), { modules: false }]],
filename: helperFilename,
presets: [
[
"@babel/preset-env",
{ modules: false, exclude: ["transform-typeof-symbol"] },
],
],
plugins: [
[transformRuntime, { corejs, useESModules: esm }],
[
transformRuntime,
{ corejs, useESModules: esm, version: runtimeVersion },
],
buildRuntimeRewritePlugin(
runtimeName,
path.relative(path.dirname(helperFilename), pkgDirname),
helperName
),
],
overrides: [
{
exclude: /typeof/,
plugins: ["@babel/plugin-transform-typeof-symbol"],
},
{},
],
}).code;
}

Expand Down

0 comments on commit faafeba

Please sign in to comment.