Skip to content

Commit

Permalink
[regenerator] Support respecting moduleName option (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored Mar 8, 2024
1 parent 444a3b7 commit 2dfab44
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/babel-plugin-polyfill-regenerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";

type Options = {
"#__secret_key__@babel/runtime__compatibility": void | {
useBabelRuntime: string;
useBabelRuntime: boolean;
moduleName: string;
};
};

Expand All @@ -19,7 +20,9 @@ export default defineProvider<Options>(({ debug, targets, babel }, options) => {
);
}

const { [runtimeCompat]: { useBabelRuntime = false } = {} } = options;
const {
[runtimeCompat]: { moduleName = null, useBabelRuntime = false } = {},
} = options;

return {
name: "regenerator",
Expand All @@ -37,9 +40,11 @@ export default defineProvider<Options>(({ debug, targets, babel }, options) => {
let pureName = "regenerator-runtime";
if (useBabelRuntime) {
const runtimeName =
moduleName ??
((path.hub as any).file as PluginPass).get(
"runtimeHelpersModuleName",
) ?? "@babel/runtime";
) ??
"@babel/runtime";
pureName = `${runtimeName}/regenerator`;
}

Expand Down

0 comments on commit 2dfab44

Please sign in to comment.