-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature/fix async transformer syntax #60
Feature/fix async transformer syntax #60
Conversation
read options from third argument
I have no idea what changed here with all the formatting changes, so lgtm me I guess? |
I guess the changes can be seen in the second commit in this PR |
after applying this fix, I am getting following error
Here's sandbox where you can see it happening. |
export default createTransformer; | ||
export default { | ||
processAsync | ||
} |
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.
Needs to probably change to export default processAsync
@sebastianrothe? I haven't read the new transformer docs so I'll touch back on this when I have time unless it's solved earlier.
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.
I have only found these references:
- https://github.com/sodatea/vite-jest/blob/main/packages/vite-jest/index.js
- https://github.com/axe-me/vite-jest/blob/main/src/transformer.ts
- https://github.com/bitttttten/jest-transformer-mdx/blob/da6eae4b9fe089643636092eeed7dc5f1a370673/mdx-options.cjs
Most of the transformers (like vue-jest, esbuild-jest) still use the old syntax and/or no ESM.
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.
The thing is, there is no documentation about asyncTransformers :( https://jestjs.io/docs/code-transformation#writing-custom-transformers
Yeah, I don't know why the old code was not formatted? |
For the new code to work, you need to enabled ESM support in Jest. Which means ALL steps described here https://jestjs.io/docs/ecmascript-modules Maybe we need to split the releases. See #61 |
Yep... After juggling through myriad of configuration I could finally make it work. This was a fun little exercise. Here's the sandbox that can be used as a reference for anyone stuck with planning to port svelte, jest and typescript to ESM. |
I feel you. And this is supposed to be the future... :D |
I've tried with my current project and that is the way it works for me.
Should fix #59
Jest's support for ESM is still experimental and some stuff still doesn't work. (see jestjs/jest#9430 and https://jestjs.io/docs/ecmascript-modules)