-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Remove --experimental-loader ExperimentalWarning as the option doesn't exist anymore / is no longer experimental #51196
Comments
#30213 is about On the other hand, |
While #30213 was opened for experimental modules it seems it became inclusive of experimental loaders midway through, but can understand that sentiment has shifted since then. I'd defend not removing the Instead, as |
What about the flag suggested in the warning though, the one you pasted above? It should be a drop-in replacement. |
@aduh95, can you please elaborate on how to apply suggested solution? I do not understand where I should put these line. |
As the warning suggests, you should replace the |
The implementation suggested in the warning is more than just a flag, it's an entire inline script:
This is unergonomic and reduces the readability of package scripts by pulling implementation details into what should be a high-level orchestration of commands. The alternative of moving the inline script into an actual file indeed improves the readability of package scripts, at the expense of creating an unnecessary boilerplate file which will likely be duplicated across many projects. Several issues have been opened related to this matter, and the typical suggestion of stabilizing the |
If you want to make a stronger case, I'd suggest linking to those issues.
I think the idea is that most packages that want to hook into the module resolution would probably need communication with the main thread – and so, it would not be an "unnecessary boilerplate file", but a file containing the main thread logic as well as the actual |
Update:Just use
Old answer:
if you want to add into VSCODE's
|
The NODE_OPTIONS="--experimental-loader ts-node/esm" npx webpack configtest offers a solution
To make the command more ergonomic, create a file that registers module resolution hooks. Let’s name the file import { register } from 'node:module';
import { pathToFileURL } from 'node:url';
register('ts-node/esm', pathToFileURL('./')); Then use the NODE_OPTIONS="--import=./register.js" npx webpack configtest Node.js v20.9, v20.10, v20.11 (LTS: Iron). |
I'd like to mention here that the "getting started" documentation page Node.js with Typescript simply says:
No mention of this being experimental or planned for removal. So it doesn't seem quite the case as @aduh95 was saying earlier in the thread:
Is this just a documentation bug that should be fixed? |
I also see the |
Yes, the documentation should be using
Technically it exists, even though it was created by accident. I still think we’re likely to remove it in the future, but until we do, |
One thing I ran into was that you can't use quotes if you set the node-options=--import data:text/javascript,import%20%7B%20register%20%7D%20from%20%22node%3Amodule%22%3Bimport%20%7B%20pathToFileURL%20%7D%20from%20%22node%3Aurl%22%3Bregister%28%22ts-node%2Fesm%22%2C%20pathToFileURL%28%22.%2F%22%29%29%3B |
if this benefits others, i advise to try |
Thank you for sharing, let me know there is a better tsx |
For anyone using node with Typescript, I used this solution in your
with @edukisto 's solution above for This will launch your app with nodemon and watch for changes to your src folder. |
This is what worked for me:
|
Why do you need NODE_OPTIONS here? Can't it be rewritten as: {
"dev": "cross-env NODE_ENV=development node --import=./register-ts-node.js --experimental-specifier-resolution=node server.ts"
} |
Hey y'all, I'd like to remind you that this issue is closed. If you still need support for setting up loaders, please visit nodejs/help. |
Version
21.4.0
Platform
MacOS Sonoma
Subsystem
No response
What steps will reproduce the bug?
Using
--loader
(not--experimental-loader
)How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
This feature is clearly no longer experimental (ESM has been out for years, is the default for many new projects, and the option is no longer
--experimental-loader
but--loader
). Since it generates anExperimentalWarning
and specifically logs--experimental-loader
I'm almost certain this is just an oversight.What do you see instead?
Additional information
Was previously discussed in #30213 and there were plans to merge a fix for this in 2019, but seems the discussion was closed and died out. Opening a new issue for visibility (and also since the error/basis is slightly different).
The text was updated successfully, but these errors were encountered: