rspack
rspack copied to clipboard
[Bug]: Cannot access '[class x]' before initialization. when rspack handles class dependencies, the scope elevation does not take effect for the class.
System Info
System: OS: macOS 14.4 CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900KF Memory: 12.73 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 21.6.1 - /usr/local/bin/node npm: 10.2.4 - /usr/local/bin/npm pnpm: 9.4.0 - /usr/local/bin/pnpm Watchman: 2024.06.10.00 - /usr/local/bin/watchman
Details
rspack build output used in app error:
location for error code:
class dependencie [LexicalNode] defind in the last bottom:
rollup build output [LexicalNode] in the top(before used):
I tried all possible configurations of swc and rspack, and finally concluded that this issue might be due to the omission of some scenarios of class scope hoisting.
It could also be a circular dependency causing the scope to be hoisted incorrectly.
Reproduce link
https://github.com/openages/lexical
Reproduce Steps
pnpm run rspack for rspack build output.
pnpm run build for rollup build output.
use "lexical":"workspace:*" in the monorepo/packages/app.
https://lexical.dev/docs/getting-started/quick-start