web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API πŸ¦€οΈ
https://rspack.dev
MIT License
9.83k stars 568 forks source link

[Bug]: `Module not found: Can't resolve <entry_path>` in Docker #8433

Open mxmason opened 1 day ago

mxmason commented 1 day ago

System Info

System: OS: macOS 15.1 CPU: (8) arm64 Apple M1 Pro Memory: 262.28 MB / 32.00 GB Shell: 5.9 - /opt/homebrew/opt/zsh/bin/zsh Binaries: Node: 20.11.0 - ~/.local/state/fnm_multishells/44569_1731538780778/bin/node npm: 10.2.4 - ~/.local/state/fnm_multishells/44569_1731538780778/bin/npm Browsers: Chrome: 130.0.6723.117 Safari: 18.1 npmPackages: @rspack/cli: 1.1.1 => 1.1.1 @rspack/core: 1.1.1 => 1.1.1

Details

As of v1.1.1, rspack does not successfully build in Docker containers. This bug is not present in rspack v1.1.0, or when installing directly on the host machine.

Reproduce link

https://github.com/mxmason/rspack-repro-docker

Reproduce Steps

  1. Clone the example repo
  2. Start a docker daemon
  3. docker build . -f Dockerfile-rspack -t rspack-image
  4. Observe the error below
ERROR in Γ— Module not found: Can't resolve './src/index' in '/app'
help: Found module './src/index.js'. However, it's not possible to request this module without the extension
      if its extension was not listed in the `resolve.extensions`. Here're some possible solutions:

      1. add the extension `".js"` to `resolve.extensions` in your rspack configuration
      2. use './src/index.js' instead of './src/index'

ERROR in Γ—   Error: Child compilation failed:
β”‚     Γ— Module not found: Can't resolve '/app/node_modules/html-webpack-plugin/def  ault_index.ejs' in '/app'
β”‚
β”‚   - child-compiler.js:211
β”‚     [app]/[html-webpack-plugin]/lib/child-compiler.js:211:18
β”‚
β”‚   - index.js:13364 finalCallback
β”‚     [app]/[@rspack]/core/dist/index.js:13364:9
β”‚
β”‚   - index.js:13386
β”‚     [app]/[@rspack]/core/dist/index.js:13386:14
β”‚
β”‚   - index.js:13488
β”‚     [app]/[@rspack]/core/dist/index.js:13488:18
β”‚
β”‚   - index.js:473 done
β”‚     [app]/[@rspack]/lite-tapable/dist/index.js:473:13
β”‚
β”‚   - index.js:480 AsyncSeriesHook.callAsyncStageRange
β”‚     [app]/[@rspack]/lite-tapable/dist/index.js:480:20
β”‚
β”‚   - index.js:82 AsyncSeriesHook.callAsync
β”‚     [app]/[@rspack]/lite-tapable/dist/index.js:82:21
β”‚
β”‚   - index.js:13484
β”‚     [app]/[@rspack]/core/dist/index.js:13484:33
β”‚
β”‚   - index.js:13528
β”‚     [app]/[@rspack]/core/dist/index.js:13528:37

Compare to building directly on the host machine, which works fine:

npm ci
npm run build:rspack

Builds in Docker also work in v1.1.0. To demonstrate, downgrade the rspack binaries and try to build the Docker image again:

npm i -DE @rspack/cli@1.1.0 @rspack/core@1.1.0
docker build . -f Dockerfile-rspack -t rspack-image
Robot-Inventor commented 22 hours ago

The same issue is occurring on Cloudflare Pages. Although I haven’t changed the code, after updating rspack from v1.1.0 to v1.1.1, a "module not found" error started appearing. Building locally works without any issues.

zMcKracken commented 18 hours ago

We have a similar issue with @rsbuild/core: 1.1.1 also, probably related? Rolling back to @rsbuild/core: 1.0.19 that uses @rspack/core: 1.0.14 fixes the issue