-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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引用flv.js,webpack打包之后包含ES6语法,并且未被压缩 #232
Comments
|
webpack 2+ 会优先使用 pkg.module 入口,你可能需要在 babel-loader 的配置里加上: {
...
include: [
// more accurate regex: /(node_modules\/[^\/]+)(?:.(?!node_modules))*$/
require.resolve('flv.js').replace(/(node_modules\/[^\/]+).*/, '$1'),
],
} 其实比较建议 |
看来是我搞错了,但是我提这个issue的目的也是想让,import引用的内容默认是ES5的代码,换句话说我也希望pkg.module 指向半编译后的模块,要不还会有别人踩到坑。 |
被坑了,估计都会被摆一道。建议遵循一般的依赖引入的内容构建 |
被坑了+1 建议issue置顶 |
Should be fixed in new version v1.6.0 |
1.6.0 没有修复。 在升级 webpack5 的时候需要额外配置 文档 |
@tommytroylin 感谢指正,稍等 |
因为WebPack中babel-loader一般的配置是不将/node_modules中的代码进行ES6->ES5转码,
而flv.js的package中"main": "./dist/flv.js",这个文件中包含ES6语法,
这就导致了项目转码之后仍然后ES6语法,并在之后的压缩过程中抛出“语法不支持”的异常,
其最终结果就是打包之后的vendor.js中既包含ES6语法的代码,而且没有进行压缩。
于是我将引用的方式由import flvjs from 'flv.js'变为 import flvjs from 'flv.js/dist/flv.min',这个问题就解决了。
The text was updated successfully, but these errors were encountered: