Skip to content
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

Error with ESLint v9, config ESM: SyntaxError: Cannot use import statement outside a module #230

Open
lelelethu opened this issue Dec 26, 2024 · 0 comments

Comments

@lelelethu
Copy link

lelelethu commented Dec 26, 2024

Bug report

I setting ESLint v9 ESM.
Trong webpack, sử dụng 'thread-loader', but raise errror: SyntaxError: Cannot use import statement outside a module

Actual Behavior

webpack.config.mjs
use: [ 'thread-loader', { loader: 'babel-loader', options: { cacheDirectory: true, babelrc: false, }, }, ]

Error:
`ERROR in ./src/index.tsx
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
\node_modules\thread-loader\dist\cjs.js:3
import index from './index.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module`

Expected Behavior

Can support ESM

How Do We Reproduce?

Please paste the results of npx webpack-cli info here, and mention other relevant information

`
ERROR in ./src/index.tsx
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
xxx\node_modules\thread-loader\dist\cjs.js:3
import index from './index.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at loadLoader (xxx\node_modules\loader-runner\lib\loadLoader.js:19:17)
at iteratePitchingLoaders (xxx\node_modules\loader-runner\lib\LoaderRunner.js:182:2)

webpack 5.97.1 compiled with 1 error in 5170 m`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant