-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Implement new transform-runtime protocol for runtime package name #160
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import defineProvider from "@babel/helper-define-polyfill-provider"; | |
import type { NodePath } from "@babel/traverse"; | ||
import { types as t } from "@babel/core"; | ||
|
||
const BABEL_RUNTIME = "@babel/runtime-corejs2"; | ||
|
||
const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility"; | ||
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility"; | ||
|
||
|
@@ -22,7 +24,7 @@ type Options = { | |
entryInjectRegenerator: boolean; | ||
}; | ||
"#__secret_key__@babel/runtime__compatibility": void | { | ||
useBabelRuntime: string; | ||
useBabelRuntime: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a breaking change? If so this PR should be landed in a new major. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but these packages are still at 0.x (so breaking changes are in minor releases) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, 0.x -> 0.x+1 is what I mean for a new major. |
||
runtimeVersion: string; | ||
ext: string; | ||
}; | ||
|
@@ -34,10 +36,11 @@ export default defineProvider<Options>(function ( | |
[presetEnvCompat]: { entryInjectRegenerator } = { | ||
entryInjectRegenerator: false, | ||
}, | ||
[runtimeCompat]: { useBabelRuntime, runtimeVersion, ext = ".js" } = { | ||
useBabelRuntime: "", | ||
runtimeVersion: "", | ||
}, | ||
[runtimeCompat]: { | ||
useBabelRuntime = false, | ||
runtimeVersion = "", | ||
ext = ".js", | ||
} = {}, | ||
}, | ||
) { | ||
const resolve = api.createMetaResolver({ | ||
|
@@ -55,7 +58,7 @@ export default defineProvider<Options>(function ( | |
); | ||
|
||
const coreJSBase = useBabelRuntime | ||
? `${useBabelRuntime}/core-js` | ||
? `${BABEL_RUNTIME}/core-js` | ||
: method === "usage-pure" | ||
? "core-js/library/fn" | ||
: "core-js/modules"; | ||
|
@@ -94,6 +97,8 @@ export default defineProvider<Options>(function ( | |
return { | ||
name: "corejs2", | ||
|
||
runtimeName: BABEL_RUNTIME, | ||
|
||
polyfills, | ||
|
||
entryGlobal(meta, utils, path) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
runtimeHelpersModuleName
also record who defined it? So we can simply say that the current providerbabel-plugin-polyfill-foo
conflicts with another providerbabel-plugin-polyfill-bar
, please remove one of them. Otherwise users have to dive into the implementation detail and dig about who definedruntimeHelpersModuleName
, which could be very frustrating.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!