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

fix: babel-loader work incorrectly with .babelrc #392

Merged
merged 1 commit into from
May 7, 2021
Merged

Conversation

myl0204
Copy link
Contributor

@myl0204 myl0204 commented May 7, 2021

fix #384

问题产生原因是3.5.0中引用了copy-text-to-clipboard,问题代码在31行,catch块没有携带参数。

这种写法是es2019的提案,babel7已经支持@babel/plugin-proposal-optional-catch-binding

在相对老的项目中,比如vue-cli2生成的项目,其中的babel还处在babel6,遇到这种代码便会报错。

根据官网所说,@babel/preset-env已经预置了@babel/plugin-proposal-optional-catch-binding插件

本项目使用的也是babel7+@babel/preset-env,但是编译出来的代码却还是

try {} catch {}

最重搜索得知babel-loader好像并不是默认加载.babelrc中的配置,issue1issue2

@tencent-adm
Copy link
Member

tencent-adm commented May 7, 2021

CLA assistant check
All committers have signed the CLA.

@Maizify
Copy link
Collaborator

Maizify commented May 7, 2021

赞~
额外探讨下,31行中,为 catch 加上参数,是更方便快速的 fix 办法吧?

@myl0204
Copy link
Contributor Author

myl0204 commented May 7, 2021

赞~
额外探讨下,31行中,为 catch 加上参数,是更方便快速的 fix 办法吧?

确实如此,源头来自那边。但是31行的写法严格来说好像并没有错?只是写法比较先进,潜在对babel的要求限制在了7+。我不确定这种情况下是否应该向copy-text-to-clipboard提起一个pr。

同时本项目的babel配置 好像确实没起作用啊。。

@Maizify
Copy link
Collaborator

Maizify commented May 7, 2021

确实如此,源头来自那边。但是31行的写法严格来说好像并没有错?只是写法比较先进,潜在对babel的要求限制在了7+。我不确定这种情况下是否应该向copy-text-to-clipboard提起一个pr。

同时本项目的babel配置 好像确实没起作用啊。。

OK,我们作为引用方,只能去兼容到这种写法了。感谢贡献~

@Maizify Maizify merged commit 95b4338 into Tencent:dev May 7, 2021
Maizify added a commit that referenced this pull request May 7, 2021
* chore: update plugins list

* fix:  Fix fetch lose `Status, Time` in Network && Fix fetch error for text reponse.

* feat: copy log

* chore: remove transitionEnd

* docs: update changelog

* chore: update NPM dependencies

* docs: update doc

* fix(log): do not sort array's keys

* chore: update syntax

* fix(network): Fix `disableLogScrolling` not working in Network panel. (issue #282, #379)

* chore: add .npmignore

* Perf(System): Rename "System" field to "Client", and add `MacOS` version.

* style(log): fix copy style

* perf(log): use localeCompare to sort keys

* docs: update changelog

* fixed: change variable type (#388)

* fix: babel-loader work incorrectly with .babelrc (#392)

* chore: npm audit

* feat: v3.5.1

Co-authored-by: 王鑫凯 <[email protected]>
Co-authored-by: zimv <[email protected]>
Co-authored-by: akai <[email protected]>
Co-authored-by: Sanapoint 曾几何 <[email protected]>
Co-authored-by: claude <[email protected]>
@myl0204
Copy link
Contributor Author

myl0204 commented May 8, 2021

更新一下:

又研究了一下,比较优雅的方式应该是把.babelrc文件重命名为babel.config.json

细节可以看Babel文档

简单来说就是babel.config.json对应项目级别的配置;.babelrc对应文件级别,且需要配置filename才能起作用

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

Successfully merging this pull request may close these issues.

vue安装v3.5.0,本地dev时报错
3 participants