-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
misc: migrate all packages to ESM-only #5816
Conversation
great 👍 isn't the problem in |
Man, it's far more than that😅 If it's just With ESM:
These are to make the behavior exactly like the browser behavior. There's a node flag |
ed443f0
to
e022e38
Compare
It's almost working! Currently blocked by |
FYI we'd also need to require Node >= 14.14, not just >= 14 https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
When I check for features it doesn't seem 14.5 and 14.18 have a big difference besides some class fields stuff... I guess that Sindre Sorhus gist was just playing it safe by recommending the last minor version (while 14.14 is not the last minor version now)? 12.20 is also in the list, so I guess it would be fine. We have CI checks anyways |
CI checks are "14", I suspect it's different than "14.0". We'll figure out later what min version to recommend ;) |
@slorber what do we use |
|
I see... I saw somewhere that a common practice is to add unique query strings to each |
Yes, the former cached modules will likely stay in the cache forever. Isn't it possible to keep using importFresh and mixing ESM with some CJS here and there? Or will we have to ask our users to convert their config/sidebars to ESM too? |
The interoperability of CJS and ESM is like:
Config files can stay as CJS as long as they don't try to |
There's an interesting suggestion of using worker threads to import fresh modules by killing the worker thread👀 I think workers can offer a new perspective of how Docusaurus works, but not sure if we want such architectural changes. |
@@ -1,17 +1,19 @@ | |||
#!/usr/bin/env node | |||
#!/usr/bin/env node --experimental-specifier-resolution=node |
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.
Some day, this flag is may be removed or renamed and completely break everything. I feel like it's not a good idea to hard-code it.
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.
Yes, this is just to make sure things work. Soon after things start working we will try to explicitly specify file names & extensions (especially when TS 4.6 has better support for this)
I like the direction this is going in, but I really don't think ESM is near ready enough. |
Well we gotta make this move. MDX v2 is ESM-only, so we either have to build it as CJS and re-publish it, or we stay on v1 forever. A lot of remark/rehype plugins are ESM only as well, and ESM cascades down the |
Closing because of too many conflicts. We will revisit this in the future, and probably do it progressively (e.g. migrating tests first, then core, then plugins, then utils) |
Breaking changes
Motivation
Resolve #5379. Since we are now Node 14+, we can work on migrating our packages to ESM to be in sync with the JS community, especially Remark/Rehype.
The current TS tranpilation is not good enough so E2E tests are failing. From the release notes of TS 4.5, there would be prioritized support for ESM, so we can wait to upgrade TS.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
E2E tests, local dev preview