Skip to content

Commit

Permalink
feat(ses): support async generators in Hermes transform for CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
leotm committed Dec 3, 2024
1 parent 1b0ff6e commit 1e6e6df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ses/scripts/hermes-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ const asyncArrowEliminator = {
},
};

const destroyAsyncGenerators = path => {
if (path.node.async && path.node.generator) {
path.replaceWith(t.identifier('undefined'));
}
};

const asyncGeneratorDestroyer = {
FunctionExpression: destroyAsyncGenerators,
FunctionDeclaration: destroyAsyncGenerators,
};

export const hermesTransforms = {
mjs: async (
sourceBytes,
Expand All @@ -60,6 +71,7 @@ export const hermesTransforms = {
) => {
const transforms = {
...asyncArrowEliminator,
...asyncGeneratorDestroyer,
// Some transforms might be added based on the specifier later
};

Expand Down

0 comments on commit 1e6e6df

Please sign in to comment.