rspack icon indicating copy to clipboard operation
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.

Open 1yasa opened this issue 1 year ago • 7 comments

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: 截屏2024-07-11 18 17 46

location for error code: 截屏2024-07-11 18 17 58

class dependencie [LexicalNode] defind in the last bottom: 截屏2024-07-11 18 18 52

rollup build output [LexicalNode] in the top(before used): 截屏2024-07-11 18 19 54

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

1yasa avatar Jul 11 '24 10:07 1yasa