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

@babel/traverse 7.17.10 变更导致的问题 #1000

Open
1 of 2 tasks
SoloJiang opened this issue May 10, 2022 · 1 comment
Open
1 of 2 tasks

@babel/traverse 7.17.10 变更导致的问题 #1000

SoloJiang opened this issue May 10, 2022 · 1 comment

Comments

@SoloJiang
Copy link
Contributor

SoloJiang commented May 10, 2022

背景

@babel/traverse v7.17.10 之后的版本如果和 babel-plugin-minify-dead-code-elimination v0.3.0 同时使用时,会导致 var _this = this 语句被移除,babel 官方的解决方案是在 babel-plugin-minify-dead-code-elimination v0.5.2 版本修复这个问题,也就是说,为了解决这个问题,框架必须把 babel-plugin-minify-dead-code-elimination 从 0.3.0 升级到 v0.5.2

但是,babel-plugin-minify-dead-code-elimination 插件升级之后会导致多端代码移除能力受到严重影响 babel/minify#1035

解决方案

如果需要真正解决问题,需要 babel 官方提供方案,潜在的解法:
方案 1: revert @babel/traverse v7.17.10 的代码
方案 2: babel-plugin-minify-dead-code-elimination 给 0.3.x 发版本解决 this 移除的问题以及 babel/minify#981 这个问题
方案 3:fork 0.3.x 的版本,修复 this 移除的的问题(目前这个方案改动最小)

框架临时的解决方案

目前已经给 cnpm 合入 bug version 把 @babel/traverse v7.17.10 标记错误版本,但是一旦 @babel/traverse 再发版,又会有问题。

@builder/pack 在官方解决问题之前不能升级 babel 相关依赖

rax-app v3.8.x 以上版本

#999 变更 revert (目前已经修改了 latest tag)

rax-app v3.8.x 以下版本

#998 变更 revert,同时给 rax-webpack-config 2.x 发版,将 babel-loader 替换为 @builder/pack 内置的 babel-loader

编译时小程序

babel 相关能力全部改用 @builder/pack 内置的版本

rax 组件工程 (build-plugin-rax-component & build-plugin-component)

babel 相关能力全部改用 @builder/pack 内置的版本

@SoloJiang
Copy link
Contributor Author

目前选择了方案 3: fork 0.3.x 的版本,修复 this 移除的的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant