Do not transpile typeof helper with itself in babel/runtime (#10788)

* Do not transpile typeof helper with itself in babel/runtime

* Nits

* Remove console.log
This commit is contained in:
Nicolò Ribaudo 2019-12-04 01:09:14 +01:00 committed by GitHub
parent d18afbd7c3
commit 3d0c5d2afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -24,6 +24,7 @@
"@babel/core": "^7.7.4", "@babel/core": "^7.7.4",
"@babel/helper-plugin-test-runner": "^7.7.4", "@babel/helper-plugin-test-runner": "^7.7.4",
"@babel/helpers": "^7.7.4", "@babel/helpers": "^7.7.4",
"@babel/plugin-transform-typeof-symbol": "^7.7.4",
"@babel/preset-env": "^7.7.4", "@babel/preset-env": "^7.7.4",
"@babel/runtime": "^7.7.4", "@babel/runtime": "^7.7.4",
"@babel/template": "^7.7.4", "@babel/template": "^7.7.4",

View File

@ -9,6 +9,7 @@ const t = require("@babel/types");
const transformRuntime = require("../"); const transformRuntime = require("../");
const runtimeVersion = require("@babel/runtime/package.json").version;
const corejs2Definitions = require("../lib/runtime-corejs2-definitions").default(); const corejs2Definitions = require("../lib/runtime-corejs2-definitions").default();
const corejs3Definitions = require("../lib/runtime-corejs3-definitions").default(); const corejs3Definitions = require("../lib/runtime-corejs3-definitions").default();
@ -151,15 +152,30 @@ function buildHelper(
tree.body.push(...helper.nodes); tree.body.push(...helper.nodes);
return babel.transformFromAst(tree, null, { 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: [ plugins: [
[transformRuntime, { corejs, useESModules: esm }], [
transformRuntime,
{ corejs, useESModules: esm, version: runtimeVersion },
],
buildRuntimeRewritePlugin( buildRuntimeRewritePlugin(
runtimeName, runtimeName,
path.relative(path.dirname(helperFilename), pkgDirname), path.relative(path.dirname(helperFilename), pkgDirname),
helperName helperName
), ),
], ],
overrides: [
{
exclude: /typeof/,
plugins: ["@babel/plugin-transform-typeof-symbol"],
},
],
}).code; }).code;
} }