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

npm run dist 失败,ci 失败 #1360

Closed
silentcloud opened this issue May 23, 2017 · 14 comments
Closed

npm run dist 失败,ci 失败 #1360

silentcloud opened this issue May 23, 2017 · 14 comments
Assignees
Labels

Comments

@silentcloud
Copy link
Contributor

silentcloud commented May 23, 2017

排查了哈原因:大概是因为 uglifyjs-webpack-plugin 目前不支持 es 的压缩,

webpack-contrib/uglifyjs-webpack-plugin#33

https://github.com/mishoo/UglifyJS2/tree/harmony

@paranoidjk
Copy link
Contributor

es下的文件没经过babel转码?

@paranoidjk
Copy link
Contributor

我以为es和lib的目录只是使用 es6 module 而已,语法还是编译过后的 es5?

@paranoidjk paranoidjk added the bug label May 23, 2017
@silentcloud
Copy link
Contributor Author

@paranoidjk 我看编译后貌似不是 es5了,会有 import export 等

我尝试了在自定义 webpack.config 里覆盖 UglifyJsPlugin 也没能搞定,囧

@paranoidjk
Copy link
Contributor

只有 import 和 export 这个 module syntax, 其他 es6 语法还是转了的
https://unpkg.com/antd-mobile@1.1.4-beta.1/es/button/index.web.js

另外,es 目录下的不是不经过 uglify 吗?

@silentcloud
Copy link
Contributor Author

@paranoidjk dist 是打包 antd-mobile.min.js

@paranoidjk
Copy link
Contributor

打 antd-mobile.min.js umd bundle 的时候不应该牵扯 es 吧?保持原来的逻辑就好了,src -> babel -> lib -> webpack + uglify > min.js

@silentcloud
Copy link
Contributor Author

@paranoidjk 现在的貌似是走的 src -> babel -> es -> webpack + uglify > min.js

@paranoidjk
Copy link
Contributor

paranoidjk commented May 24, 2017

@yiminghe

@paranoidjk
Copy link
Contributor

去掉uglify plugin之后build success, 但是 bundle 并不是有效的 umd,还是一堆 import '../components/xx'

@paranoidjk
Copy link
Contributor

这个 close. @warmhug 应该已经 fix 了,记得来这里把原因写下。

@squallvince
Copy link

本地运行“npm run dist”会报错,“Failed at the antd-mobile@1.1.4-beta.4 dist script 'BABEL_ENV=dist antd -tools run dist'.”

@paranoidjk
Copy link
Contributor

@saiyagg rm -rf node_modules && npm i 重装依赖,如果使用 yarn 则 yarn upgrade, 这个问题已经在新版的 antd-tools 修复了,确保你升级到最新版。

@squallvince
Copy link

删除BABEL_ENV=dist后,脚本执行正确。

@warmhug
Copy link
Contributor

warmhug commented Jun 1, 2017

@squallvince 看下 node npm 版本是否太老了。


原来报错原因主要有两点:

  1. .babelrc 文件里的 react-native presets 优先级最高,覆盖了 antd-tools 里提供的 presets .
  2. antd-tools 生成 es 目录、支持保留源码里的 import .. from ..export default ..,但对这些语句 UglifyJsPlugin 压缩出错。

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

No branches or pull requests

5 participants