Skip to content

[Bug]: compilation causes function variables to be replaced by import variables #7886

@xierenyuan

Description

@xierenyuan

System Info

System:
OS: macOS 13.4
CPU: (12) arm64 Apple M2 Pro
Memory: 94.25 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.2/bin/yarn
npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm
pnpm: 8.15.8 - ~/Library/pnpm/pnpm
bun: 1.0.25 - ~/.bun/bin/bun
Watchman: 2023.08.28.00 - /opt/homebrew/bin/watchman
Browsers:
Safari: 16.5

Details

rt
内部有一个三方包 import react 变量是 e 和 n 同时文件内还有一个函数 get extension 定义了变量 e 和 n 编译后 extension 函数内的变量被替换成 import 变量的 e 和 n (Internally, there is a tripartite package import react with variables e and n. There is also a function get extension in the file that defines the variables e and n. After compilation, the variables in the extension function are replaced by the e and n of the import variables)
image
image
编译后代码 (compiled code)
image
webpack 是正常的 仅 rspack 出现问题 (The webpack is working fine, only the rspack is having problems)

Reproduce link

No response

Reproduce Steps

rsbuild-fangzhou-bug.zip
pnpm install
pnpm dev

image
  1. 浏览器打开 三方 vendors (browser opens) static/js/vendors-node_modules_pnpm_object-assign_4_1_1_node_modules_object-assign_index_js-packages_sp-869e56.js
  2. 点击格式化
  3. 搜索关键词 get extension
  4. 预期 get extension 值应该使用当前作用域的

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpending triageThe issue/PR is currently untouched.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions