RxJS 6和Webpack4。生产包的奇怪内容

时间:2018-07-17 13:27:22

标签: webpack rxjs

试图获得更小的捆绑包,我已经将项目中的所有rxjs导入更改为新的推荐语法。我直接从searchText包中导入了诸如interval等静态方法,并从int solution(N) { int num = N, currentLongest=0, lastLongest=0, start=0; while(num>0){ int rem = num%2; num = num/2; if(rem == 1){ if(lastLongest < currentLongest){ lastLongest = currentLongest; } currentLongest = 0; start = true; }else{ if(start) ++currentLongest; } } return lastLongest; } 中引入了可管道运算符。

我遵循official instruction,并在我的webpack配置中包括了路径映射和启用的模块串联。

尽管如此,我仍未发现捆绑包大小有明显变化。 rxjs给出以下图片:

Contents of the bundle

在左侧,确实在我的项目中导入了模块。但是,右边那个运算符是什么?它的大小与单独模块的大小相同。看起来它复制了这些模块,但是是串联的。

这对我的捆绑包有必要吗?如果没有,如何将其删除?

1 个答案:

答案 0 :(得分:0)

For me the issue was that I was using commonjs modules when webpack needs es6 modules in order to do tree shaking. I detailed the solution in a related issue here: https://stackoverflow.com/a/53850079/628418