Skip to content

Commit

Permalink
Do not transpile typeof helper with itself in babel/runtime (#10788)
Browse files Browse the repository at this point in the history
* Do not transpile typeof helper with itself in babel/runtime

* Nits

* Remove console.log
  • Loading branch information
nicolo-ribaudo committed Dec 4, 2019
1 parent d18afbd commit 3d0c5d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/babel-plugin-transform-runtime/package.json
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
20 changes: 18 additions & 2 deletions packages/babel-plugin-transform-runtime/scripts/build-dist.js
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 @@ -151,15 +152,30 @@ function buildHelper(
tree.body.push(...helper.nodes);

return babel.transformFromAst(tree, null, {
presets: [[require("@babel/preset-env"), { modules: false }]],
filename: helperFilename,
presets: [
[
"@babel/preset-env",
{ modules: false, exclude: ["@babel/plugin-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 3d0c5d2

Please sign in to comment.