tiny-invariant.js怎么会这么大呢?

3

我正在尝试优化我的react应用程序块的大小。 我使用以下命令进行了分析:

source-map-explorer 'build/static/js/*.js

结果如下图所示,显示tiny-invariant.js占用774KB的空间。 这对我来说没有意义。 一个12.2kB解压缩的库怎么可能会占用774KB的空间呢?

可能出了什么问题? 是source-map-explorer有bug吗? 目前这是我主要的解释。

Output of source-map-explorer


1
是的,我有完全相同的问题。 - Alecu Marian Alexandru
1个回答

1

我认为在这种情况下,source-map-explorer 是不正确的。

我的解决方案是将 source-map-explorer 的结果与 webpack-bundle-analyzer 的结果进行比较:

> npm run build -- --stats
> npx webpack-bundle-analyzer ./build/bundle-stats.json

(该功能目前未记录在文档中(文档已被删除),因为 CRA 团队发现 webpack-bundle-analyzer 的标签误导了用户,请参见:https://github.com/facebook/create-react-app/issues/4563

webpack-bundle-analyzer 的结果中,我发现相同的大小实际上来自于:

  • moment-timezone/data/packed/latest.json

我猜测 source-map-explorer 无法很好地处理 json 文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接