-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Prototype ESM-only package workaround for unbundled back end #14833
Comments
I was able to get the browser version of the Theia back end to load correctly using the flag |
The flag above is available in node versions >= 22. Since electron brings it's own node version, we would have to update electron to a version that uses nodejs >= 22. Such a version is not available right now (https://www.electronjs.org/docs/latest/tutorial/electron-timelines), but the next version (35) should include node 22. |
I also tried to use fix-esm. For this, we need to do `require('fix-esm').register() early in the lifecyle, for example in main.js. We could add code to does this dependending on a flag. |
Earlier, I prototyped using babel-register with https://babeljs.io/docs/babel-plugin-transform-modules-commonjs in order to make our unit tests run when consuming Monaco as ESM modules and this worked, so it should also work with an unbundled back end. |
By that I mean I had to change the import
to
|
@tsmaeder FYI the flag could be whether the |
babel/babel#14579 seems to indicate that the "babel on the fly" thing will not work, and indeed I still get ERR_REQUIRE_ESM even with requiring |
The last idea I have is this: we could use the async |
Sure, I believe that should work well. However, this would only be a temporary solution, right? |
An alternative is to document the Once we switch to ESM modules the issue will be "fixed" without this adopter need |
From this cursory investigation, I would propose the following action items:
|
Feature Description:
There seem to be some workarounds for making
require()
of ESM-only modules work in pre-node-22 versions (fix-esm
comes to mind immediately). Alternatively, we might see what the experimental flag does (https://nodejs.org/api/cli.html#--experimental-require-module)The text was updated successfully, but these errors were encountered: