Skip to content
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

jest.mock of ESM should fail, and it's correct #5205

Closed
kdy1 opened this issue Jul 14, 2022 · 2 comments
Closed

jest.mock of ESM should fail, and it's correct #5205

kdy1 opened this issue Jul 14, 2022 · 2 comments

Comments

@kdy1
Copy link
Member

kdy1 commented Jul 14, 2022

This is not an issue, because the input was already wrong.

If you really want to workaround this, see #5151 (comment)
Note that this is not an official one, and it will break frequently.


jest not working with ESM is not an issue of swc. See jestjs/jest#9430

common js vs ESM behavior

Technically this can be workarounded by SWC by compiling in a wrong way.

But ESM is an established standard, and swc follows the specification. If you use ESM as input, swc will compile the code to behave in a way defined by the specification.

You may claim the official typescript compiler does not follow specification if module type is common js, but it's a bug of tsc. If you want behavior of common js, you can write a common js module instead.


Discussions

Issues

@kwonoj
Copy link
Member

kwonoj commented Jul 14, 2022

For the opinions / suggestions, please use general discussions #5151.

For the workaround, please refer #5151 (comment) .

This issue itself is an announcement, will be locked to avoid diverging comments between existing discussions.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 14, 2022
@kdy1
Copy link
Member Author

kdy1 commented May 23, 2023

Closing in favor of #7435

@kdy1 kdy1 closed this as completed May 23, 2023
@kdy1 kdy1 unpinned this issue May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants