-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: esm output's extension to .mjs #1343
base: main
Are you sure you want to change the base?
fix: esm output's extension to .mjs #1343
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 631747f:
|
I don't know why formatting failed in workflow. In local, It passed. And Changes is not related to formatting. |
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.
Why:
More Information: kentcdodds/kcd-scripts#244
It's not clear from this issue why we need to do this. Do you have a minimal repro highlighting what this fixes?
Using .mjs instead of .js is not trivial since older build setups may stop recognizing these files as JS so there should be a justification for making that change.
To be honest, I can't logically explain why it's an issue. I just found out that if you have a .mjs extension or a package.json with type:module, this will fix it. I checked by modifying node_modules myself, so I don't know how to share repro. Should I give it to you as a compressed file? |
ReproProjectArchive.zip testing library attached debug log@testing-library.zip |
And more detail. @eps1lon Testing-library/user-event in ESM format was fetching testing-library/dom in CJS format. But testing-library/react before the extension changed was getting testing-library/dom in ESM format. I'm not sure why you're looking for testing-library/dom in CJS format, but I think the current implementation is meaningful in unifying the different ways of working between the two libraries. I would like to think that this is a matter of node. |
Can we check it? @eps1lon @MatanBobi |
Hi @eps1lon! I believe there could be an issue with how the modules are being loaded based on ESM vs. CJS semantics. As mentioned in #1338 using latest Vitest, RTL, and userEvent together is "broken" and displaying errors in the console. We believe this is due to the userEvent APIs not being patched by RTL at runtime. When we debug this we find that identical esm/cjs modules are loaded and the incorrect one is monkey patched by RTL and this is why we see "not wrapped in act()" warnings. I'm not exactly sure why @syi0808's change seems to fix this but if I had to guess it's the way that modules are loaded in node/vitest vs jest and this change makes things less ambiguous for non-jest runners. 🤷♂️ |
What:
Why:
More Information: kentcdodds/kcd-scripts#244
How:
Change module field extension to
.mjs
and upgradekcd-scripts
after pr released.screenshots
after this pr build output is below.
before change dist file and package.json
after change dist file and package.json
Checklist:
Additional
I think according to https://github.com/kentcdodds/kcd-scripts/releases. We can skip breaking changes from 14, 15 versions. (v14 breaking change is about preact, v15 breaking change is about node v14)
Resolves: #1338 testing-library/user-event#1213