Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TypeError: Cannot read properties of undefined (reading 'set') #6372

Closed
wengjiacheng opened this issue Apr 26, 2024 · 9 comments
Closed
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.

Comments

@wengjiacheng
Copy link

System Info

System:
OS: macOS 13.3.1
CPU: 2.5 GHz Intel Core i7
Memory: 16 GB 2133 MHz LPDDR3
Browsers:
Chrome: 120.0.6099.109
npmPackages:
"@rsbuild/core": "^0.6.1",
"@rsbuild/plugin-vue2": "^0.6.1",

Details

插件在webpack中可以使用,在rspack中报错TypeError: Cannot read properties of undefined (reading 'set')

Reproduce link

https://github.com/wengjiacheng/rspack-repro

Reproduce Steps

npm run dev:webapck
npm run dev:rspack 会报错

@wengjiacheng wengjiacheng added bug Something isn't working pending triage The issue/PR is currently untouched. labels Apr 26, 2024
@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 26, 2024

这是因为 skin-utils/src/index.js 中使用到了 webpack.DefinePlugin:

https://github.com/wengjiacheng/rspack-repro/blob/c1241d12557ff16e6785f12a2e3a9f8a4fe2d751/skin-utils/src/index.js#L24-L26

替换成 new compiler.webpack.DefinePlugin({ .. }) 就可以兼容 webpack 和 rspack 了

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 26, 2024

如果还有其他问题欢迎重开 issue~

@h-a-n-a h-a-n-a closed this as completed Apr 26, 2024
@wengjiacheng
Copy link
Author

@h-a-n-a
我更改成new compiler.webpack.DefinePlugin不报错了,当时编译好像没生效
33333
我在插件中设置了一个值
在webpack中是可以编译的
12233
但是在rspack中没有编译
22222111
并且在控制台有报错信息
1221111

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 26, 2024

@h-a-n-a 我更改成new compiler.webpack.DefinePlugin不报错了,当时编译好像没生效 33333 我在插件中设置了一个值 在webpack中是可以编译的 12233 但是在rspack中没有编译 22222111 并且在控制台有报错信息 1221111

可以看下产物中的结果吗?上述截图是否是根据 source-map 还原的代码片段?

@wengjiacheng
Copy link
Author

上面代码我没有开启source-map
https://github.com/wengjiacheng/rspack-repro 这有个demo,这个可以吗 ?
npm run dev:webpack
npm run dev:rspack

@wengjiacheng
Copy link
Author

@h-a-n-a 你好,编译好像没生效问题,找到问题了吗?

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 28, 2024

@h-a-n-a 你好,编译好像没生效问题,找到问题了吗?

@wengjiacheng 能否根据产物结果确认一下 DefinePlugin 是否生效?

@wengjiacheng
Copy link
Author

@h-a-n-a 打包测试了,产物里是编译的了的
123
这个是rspack的
456
这个是webpack

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 28, 2024

@h-a-n-a 打包测试了,产物里是编译的了的 123 这个是rspack的 456 这个是webpack

@wengjiachengDefinePlugin 这部分就没有问题了,可以看看其他方面是不是有不符合预期的部分。如果有其他关于 rspack 的问题可以开新的 issue 处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants