Align regenerator-transform import with native ESM (#13086)
* Align `regenerator-transform` import with native ESM * Add `regenerator` test to `@babel/standalone`
This commit is contained in:
parent
42e630e8a2
commit
6d89daf064
@ -475,15 +475,14 @@ function pluginNodeImportInteropBabel({ template }) {
|
||||
}
|
||||
|
||||
function pluginNodeImportInteropRollup({ types: t }) {
|
||||
const depsUsing__esModuleAndDefaultExport = [
|
||||
src => src.startsWith("babel-plugin-polyfill-"),
|
||||
];
|
||||
const depsUsing__esModuleAndDefaultExport = src =>
|
||||
src.startsWith("babel-plugin-polyfill-") || src === "regenerator-transform";
|
||||
|
||||
return {
|
||||
visitor: {
|
||||
ImportDeclaration(path) {
|
||||
const { value: source } = path.node.source;
|
||||
if (depsUsing__esModuleAndDefaultExport.every(test => !test(source))) {
|
||||
if (!depsUsing__esModuleAndDefaultExport(source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1 +1,2 @@
|
||||
export { default } from "regenerator-transform";
|
||||
import regeneratorTransform from "regenerator-transform";
|
||||
export default regeneratorTransform.default;
|
||||
|
||||
@ -181,6 +181,16 @@ const require = createRequire(import.meta.url);
|
||||
[].includes(2);"
|
||||
`);
|
||||
});
|
||||
|
||||
it("regenerator works", () => {
|
||||
const output = Babel.transform("function* fn() {}", {
|
||||
sourceType: "module",
|
||||
targets: { ie: 11 },
|
||||
presets: ["env"],
|
||||
}).code;
|
||||
|
||||
expect(output).toMatch("regeneratorRuntime.mark(fn)");
|
||||
});
|
||||
});
|
||||
|
||||
describe("custom plugins and presets", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user