-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for ./webpack.config.ts #2916
Comments
Repro and output ( |
It was answered here #2458 (comment), we can't fix it on our side |
Can you catch the error and display a possible solution? |
Maybe wrong link? |
Correct link, I was showing what a good error looks like, which this isn't:
I wish tools caught these errors and suggested solutions instead of sending them on Google trips. |
But we showed the real error and why it happens, nothing to say more here, it should be improved on |
Here right solution:
|
Only one thing valid here, we can add this to docs |
/cc @snitin315 @anshumanv We should improve our docs for ECMA modules (i.e.
|
I will document it 👍🏻 |
I like the second one, without |
Added to docs |
Cannot be easily done in tools and build systems like Nx. |
It seems that loaders are being deprecated or something: ❯ NODE_OPTIONS="--loader ts-node/esm" npx webpack
(node:28958) ExperimentalWarning: `--experimental-loader` may be removed
in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; im
port { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFil
eURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created) To get rid of the ugly output, you must use this asinine env: NODE_OPTIONS="--import \"data:text/javascript,import { register } from 'node:module'; import { pathToFileURL } from 'node:url'; register('ts-node/esm', pathToFileURL('./'));\"" npx webpack It is annoying to penalized this much for using ESM. I would just recommend using // @ts-check
/** @type {import('webpack').Configuration} */
export const config = {
// ... stuff
};
export default config; You can then avoid the |
Describe the bug
Webpack is unable to read Webpack’s config file in TypeScript if
type
ismodule
. This is basically a duplicate ofwhich reportedly has been fixed by
but it fails with the exact test config included in that PR.
What is the current behavior?
To Reproduce
Steps to reproduce the behavior:
If you drop
type:module
it reverts to the regularUnexpected token 'export'
error.Please paste the results of
npx webpack-cli info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: