-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: add support for async transform #76
Conversation
const supportsEsm = 'Module' in vm | ||
|
||
function createTransformer(swcTransformOpts?: Options) { | ||
function createTransformer(swcTransformOpts?: Options): Transformer { |
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.
mostly to type jestOptions
correctly
Can you rebase? |
ba0cd00
to
c841e23
Compare
Done 🙂 |
eeaf892
to
044b0a0
Compare
...computedSwcOptions, | ||
module: { | ||
...computedSwcOptions.module, | ||
type: jestOptions.supportsStaticESM ? 'es6' : 'commonjs' |
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.
since we now also do async transformation, it's not safe to mutate the shared option as there might be concurrency issues
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.
LGTM.
Thank you!
Thanks! Feel free to ping me if any issues crop up (I don't personally use this module, just noticed the needless complexity when browsing the code. I did verify it works for native ESM, though 🙂) |
set(computedSwcOptions, 'module.type', isEsm(filename, jestOptions) ? 'es6' : 'commonjs') | ||
} | ||
process(src, filename, jestOptions) { | ||
set(computedSwcOptions, 'module.type', jestOptions.supportsStaticESM ? 'es6' : 'commonjs') |
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.
oops, should have deleted this
Jest has supported async code transformation since v27, so why not support it.
And there's no need for this transformer to attempt to detect ESM support - Jest provides the necessary options (specifically
supportsStaticESM
) as of v25.3.0.I can split this up into two PRs if you want