-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
Description
问题
比如
包含代码,
export function getNodeRequire() {
return typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
}其中 __webpack_require__ 会被认定为特殊语法,然后报错。
解法
排除 typeof 的场景。
新增一个 visitor,在遇到 __webpack_require__ 等 webpack 特有语法时,转换为 typeof undefined。
比如:
- return typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
+ return typeof undefined === 'function' ? __non_webpack_require__ : require;这个一直修修补补,感觉需要一个更彻底的解,比如通过配置提供一个 webpack 常用 runtime 层的兼容补丁。
Reactions are currently unavailable