为何RSPack未替换变量名?出现'module'标识符重复声明语法错误
用RSPack替换React-scripts后出现变量冲突报错:Identifier 'module' has already been declared
我正尝试用RSPack替换旧版React-scripts构建流程,目前已完成配置并可执行构建,但在浏览器中出现变量冲突问题——推测和代码拆分有关,变量未被正确重命名,导致多处const module声明冲突,具体报错为:Uncaught SyntaxError: Identifier 'module' has already been declared
相关截图说明:
- 控制台报错截图:显示上述语法错误信息
- 代码行截图:可见多处重复的
const module声明语句
当前使用的rsbuild.config.ts配置如下:
import { defineConfig, loadEnv } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; import { pluginEslint } from '@rsbuild/plugin-eslint'; const { publicVars, rawPublicVars } = loadEnv({ prefixes: ['REACT_APP_'] }); export default defineConfig({ plugins: [pluginReact()], html: { template: './public/index.html', }, output: { distPath: { root: 'build', }, polyfill: 'usage', }, source: { define: { ...publicVars, 'process.env': JSON.stringify(rawPublicVars) }, }, });
内容的提问来源于stack exchange,提问作者beek
相关产品推荐
相关产品推荐

