Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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