You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up until Node 18, I could use a --loader node flag to pick a custom TypeScript loader, but in Node 20 this no longer appears to work.
NODE_OPTIONS="--loader tsx" npx webpack
What is the current behavior?
It can't load my .ts config.
(node:84039) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[webpack-cli] Unable load './webpack.config.ts'
[webpack-cli] Unable to use specified module loaders for ".ts".
[webpack-cli] Cannot find module 'ts-node/register' from '.'
[webpack-cli] Cannot find module 'sucrase/register/ts' from '.'
[webpack-cli] Cannot find module '@babel/register' from '.'
[webpack-cli] Cannot find module 'esbuild-register/dist/node' from '.'
[webpack-cli] Cannot find module '@swc/register' from '.'
[webpack-cli] Please install one of them
Webpack uses the tsx loader to load the .ts configuration. This is the output on Node 18:
(node:84137) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:84137) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:84137) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:84137) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
assets by status 99 bytes [cached] 1 asset
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ETC..
ETC..
ETC..
Please paste the results of npx webpack-cli info here, and mention other relevant information
My guess is that interpret or rechoir are suddenly exiting early even if Node "natively" supports .ts files (via global --loader). Until Node 18, they probably let the .ts extension through.
Describe the bug
Up until Node 18, I could use a
--loader
node flag to pick a custom TypeScript loader, but in Node 20 this no longer appears to work.What is the current behavior?
It can't load my .ts config.
To Reproduce
Expected behavior
Webpack uses the
tsx
loader to load the.ts
configuration. This is the output on Node 18:Please paste the results of
npx webpack-cli info
here, and mention other relevant informationAdditional context
Also reported in the loader’s repo, but I don’t think this can be fixed there:
ts-node
also has issues on Node 20:The text was updated successfully, but these errors were encountered: