-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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: Explicit --import support for Node ESM #5002
Comments
Not sure if this is related, but I am able to use "--loader" with node v18 and v20. Specifically:
However, mocha appears to be calling node with the "experimental-loader" flag, resulting in a warning:
Is "--loader" supported or not? |
👋 thanks for the great details! Although this was filed as a bug, it seems like more of a docs/feature request to me. As in, you're asking for support of ESM loaders in Node, right @GianlucaGuarini? @drernie is right: Mocha actually does "support" ESM loaders! It's just coincidental and not documented (🙃). You can see ESM support in action in the Which leads me to think that this is issue is really two requests:
...and any In more detail: Mocha forwards unrecognized args to its child
:
|
Since --loader flag was deprecated in node it doesn't make sense to further discuss about this issue. For all the others having a similar issue I recommend to register the loaders using explicitly the register hook https://nodejs.org/api/module.html#customization-hooks |
So that we can use tsx with official --import rather than requiring (old-style) which doesn't work with string-sameness esm for some reason mochajs/mocha#5002 mochajs/mocha-examples#76
Prerequisites
faq
labelnode_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
Node versions >=16 allow the use of the
--loader
flag. Custom Loaders should be supported by mocha since the flag is a Node native option.Steps to Reproduce
Expected behavior: [What you expect to happen]
Mocha should work without the use of NODE_OPTIONS workaround
Actual behavior: [What actually happens]
Reproduces how often: [What percentage of the time does it reproduce?]
Always
Versions
mocha --version
andnode_modules/.bin/mocha --version
: 10.2.0node --version
: v18.14.0Additional Information
Thank you for your hard work ❤️
The text was updated successfully, but these errors were encountered: