web-infra-dev / rspack

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

Error: Missing field `options` #4958

Closed f0reclone closed 6 months ago

f0reclone commented 7 months ago

System Info

System: OS: macOS 13.3.1 CPU: (10) arm64 Apple M1 Pro Memory: 57.95 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm pnpm: 8.6.5 - ~/.nvm/versions/node/v18.13.0/bin/pnpm Browsers: Brave Browser: 106.1.44.101 Chrome: 120.0.6099.71 Edge: 120.0.2210.61 Safari: 16.4 npmPackages: @rspack/cli: 0.4.1 => 0.4.1 @rspack/core: 0.4.1 => 0.4.1

Details

Error: Missing field `options`
    at Compiler._Compiler_getInstance (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Compiler.js:516:55)
    at Compiler.build (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Compiler.js:380:87)
    at /Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Watching.js:269:27
    at Hook.eval [as callAsync] (eval at create (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/tapable/lib/Hook.js:18:14)
    at Watching._Watching_go (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Watching.js:253:34)
    at Watching._Watching_invalidate (/Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Watching.js:217:74)
    at /Users/andreas.neufeld/Code/aboutyou-panel-application/node_modules/@rspack/cli/node_modules/@rspack/core/dist/Watching.js:51:94
    at processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'InvalidArg'
}

For some reason it works only again if the node_modules folder is deleted and then reverted to 0.4.0. Using bun 1.0.15 as a package manager.

Reproduce link

No response

Reproduce Steps

  1. Upgrade from 0.3.14 to 0.4.x
  2. npx rspack serve
  3. Error is shown
lovetingyuan commented 6 months ago

same issue +1 I use unplugin to create a rspack plugin The error occurs on using it.

github-actions[bot] commented 6 months ago

Hello @f0reclone, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction will be closed if no activities in 14 days.

hardfist commented 6 months ago

check whether @rspack/binding and @rspack/core are same version in your node_modules

lovetingyuan commented 6 months ago

check whether @rspack/binding and @rspack/core are same version in your node_modules

--node_modules --playground --node_modules --rspack-project

the first node_modules contains @rspack/core and binding, both version is 0.4.2 the inner node_modules(beside rspack-project) also contains @rspack/core and binding, both version is 0.4.0 I delete the inner node_modules/@rspack/core(binding), rspack works well.

I am not sure why there are two node_modules. (I am using npm workspace).

"workspaces": [
    ".",
    "playground/*"
  ],
hardfist commented 6 months ago

seems your issue is resolved

lovetingyuan commented 6 months ago

seems your issue is resolved

What? I had to manually delete the problem to get rid of it, at least I think rspack's case support for monorepo is problematic.

f0reclone commented 6 months ago

I think this is related to bun.

Steps to reproduce:

  1. Install bun: curl -fsSL https://bun.sh/install | bash

  2. clone rspack repro git clone git@github.com:web-infra-dev/rspack-repro.git

  3. cd rspack-dist

  4. Run bun run dev:rspack

Working example:

  1. Install pnpm
  2. clone rspack repro
  3. cd rspack-dist
  4. Run pnpm run dev:rspack
hardfist commented 6 months ago

@f0reclone I can't reproduce following your step, you can commit the node_modules so we can investigate

hardfist commented 6 months ago

@lovetingyuan please provide repro