We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
loaderContext.importModule
System: OS: macOS 14.6.1 CPU: (12) arm64 Apple M2 Max Memory: 12.00 GB / 96.00 GB Shell: 3.7.1 - /opt/homebrew/bin/fish Binaries: Node: 20.17.0 - ~/.local/state/fnm_multishells/51660_1732612003106/bin/node npm: 10.8.2 - ~/.local/state/fnm_multishells/51660_1732612003106/bin/npm pnpm: 9.14.2 - ~/.local/state/fnm_multishells/51660_1732612003106/bin/pnpm Browsers: Chrome: 131.0.6778.86 Safari: 17.6 npmPackages: @rsbuild/core: ^1.0.19 => 1.1.5 @rsbuild/plugin-sass: ^1.1.1 => 1.1.1 @rsbuild/plugin-webpack-swc: ^1.0.8 => 1.0.8 @rsbuild/webpack: ^1.1.3 => 1.1.3
When using rspack.CssExtractRspackPlugin, the error message is weird:
rspack.CssExtractRspackPlugin
File: /rsbuild-project/src/index.scss:1:1 × Module build failed: ╰─▶ × TypeError: Cannot read properties of undefined (reading '__esModule') │ at handleExports (/rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/cssExtractLoader.js:169:40) │ at /rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/cssExtractLoader.js:263:7 │ at /rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/index.js:6274:13 @ ./src/index.js
After debugging into the source code, I found that Rspack did not return the error in the callback of importModule:
error
importModule
rspack/packages/rspack/src/builtin-plugin/css-extract/loader.ts
Lines 268 to 284 in c1e8f11
Thus, an undefined is resolved and caused the TypeError: Cannot read properties of undefined (reading '__esModule') error.
undefined
TypeError: Cannot read properties of undefined (reading '__esModule')
https://github.com/colinaaa-reproductions/rspack-repro-sass-error
Run Rspack:
pnpm install
pnpm run build
Errors occurs:
error Compile error: Failed to compile, check the errors for troubleshooting. File: /rsbuild-project/src/index.scss:1:1 × Module build failed: ╰─▶ × TypeError: Cannot read properties of undefined (reading '__esModule') │ at handleExports (/rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/cssExtractLoader.js:169:40) │ at /rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/cssExtractLoader.js:263:7 │ at /rsbuild-project/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rspack/core/dist/index.js:6274:13 @ ./src/index.js File: /Users/colin/rsbuild-project/src/index.scss:1:1 × Module build failed: ╰─▶ × Expected identifier. │ ╷ │ 8 │ ..content { │ │ ^ │ ╵ │ /rsbuild-project/src/index.scss 8:2 root stylesheet error Failed to build. error Rspack build failed!
Comparing with Webpack:
USE_WEBPACK=1 npm run build
error Compile error: Failed to compile, check the errors for troubleshooting. File: /Users/colin/rsbuild-project/src/index.scss:1:1 Module build failed (from ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rsbuild/plugin-sass/compiled/sass-loader/index.js): Expected identifier. ╷ 8 │ ..content { │ ^ ╵ /Users/colin/rsbuild-project/src/index.scss 8:2 root stylesheet @ ./src/index.scss @ ./src/index.js File: /Users/colin/rsbuild-project/src/index.scss:1:1 Module build failed (from ./node_modules/.pnpm/[email protected][email protected]/node_modules/mini-css-extract-plugin/dist/loader.js): HookWebpackError: Module build failed (from ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@rsbuild/plugin-sass/compiled/sass-loader/index.js): Expected identifier. ╷ 8 │ ..content { │ ^ ╵ /Users/colin/rsbuild-project/src/index.scss 8:2 root stylesheet at tryRunOrWebpackError (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/HookWebpackError.js:86:9) at __webpack_require_module__ (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compilation.js:5299:12) at __webpack_require__ (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compilation.js:5256:18) at /Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compilation.js:5328:20 at symbolIterator (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3485:9) at done (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3527:9) at Hook.eval [as callAsync] (eval at create (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at /Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compilation.js:5234:43 at symbolIterator (/Users/colin/rsbuild-project/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3482:9) error Failed to build. error Webpack build failed!
The text was updated successfully, but these errors were encountered:
JSerFeng
Successfully merging a pull request may close this issue.
System Info
Details
When using
rspack.CssExtractRspackPlugin
, the error message is weird:After debugging into the source code, I found that Rspack did not return the
error
in the callback ofimportModule
:rspack/packages/rspack/src/builtin-plugin/css-extract/loader.ts
Lines 268 to 284 in c1e8f11
Thus, an
undefined
is resolved and caused theTypeError: Cannot read properties of undefined (reading '__esModule')
error.Reproduce link
https://github.com/colinaaa-reproductions/rspack-repro-sass-error
Reproduce Steps
Run Rspack:
pnpm install
pnpm run build
Errors occurs:
Comparing with Webpack:
USE_WEBPACK=1 npm run build
The text was updated successfully, but these errors were encountered: