web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
8.23k stars 488 forks source link

[Bug]: undefined factory 19218 #7031

Open mrceperka opened 1 week ago

mrceperka commented 1 week ago

System Info

  System:
    OS: Linux 6.5 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 9.16 GB / 23.13 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 18.12.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/local/bin/npm
  npmPackages:
    @rspack/cli: ^1.0.0-alpha.0 => 1.0.0-alpha.0 
    @rspack/core: ^1.0.0-alpha.0 => 1.0.0-alpha.0 
    @rspack/plugin-react-refresh: ^1.0.0-alpha.0 => 1.0.0-alpha.0

Details

When running in dev mode (rspack dev) optimization.moduleIds="deterministic" causes errors like undefined factory 19218
I have had hmr and hot mode also enabled.

When changed to moduleIds: isDev ? "named" : "deterministic" it works.

Reproduce link

No response

Reproduce Steps

  1. set optimization.moduleIds="deterministic
  2. rspack dev with hmr
JSerFeng commented 1 week ago

Can you try to create a minimum repro repo

mrceperka commented 1 week ago

@JSerFeng I am not at the moment. I've tried with the repro repo but it was working as expected. But I haven't installed all the plugins and dependencies my original repo has.

Is there some command that could help you debug? I think I could run that in private repo and give you output.

colinaaa commented 6 days ago

Same issue here. I can provide an internal repro. It works when using Rspack 1.0.0-alpha.0 but does not work when using Rspack 1.0.0-alpha.1.

JSerFeng commented 3 days ago

try 1.0.0-alpha.2

mrceperka commented 3 days ago

@JSerFeng it won't even start now :(

NODE_ENV=development HMR=1 rspack dev -c webpack/rspack.app.config.js
/var/docker/frontend_v2/node_modules/cliui/build/index.cjs:291
const stringWidth = require('string-width');
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /var/docker/frontend_v2/node_modules/string-width/index.js from /var/docker/frontend_v2/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /var/docker/frontend_v2/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/cliui/build/index.cjs:291:21)
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/yargs/build/index.cjs:1:60039)
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/yargs/index.cjs:5:30)
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/@rspack/cli/dist/cli.js:35:33)
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/@rspack/cli/dist/bootstrap.js:4:15)
    at Object.<anonymous> (/var/docker/frontend_v2/node_modules/@rspack/cli/bin/rspack:2:16) {
  code: 'ERR_REQUIRE_ESM'

Same problem for alpha.1 as well. Only alpha.0 works for me right now.

JSerFeng commented 3 days ago

Error [ERR_REQUIRE_ESM]: require() of ES Module

This is not issue with rspack, can you solve it and then continue trying 1.0.0-alpha.2

mrceperka commented 3 days ago

@JSerFeng maybe it's not directly, but why 1.0.0-alpha.0 works and 1.0.0-aplha.2 not? It looks like some rspack dependencies were updated and now the build is broken. When I downgrade to alpha.0 its able to run.

JSerFeng commented 2 days ago

I think it's because some dependencies are unexpectedly hoist, can you try using pnpm

mrceperka commented 2 days ago

@JSerFeng thanks for the tip. Will try. I am using yarn v1 and it was working so far (I mean with alpha.0)