Meteor bundle visualizer 将动态导入添加到初始客户端包
Meteor bundle visualizer add dynamic imports to the initial client bundle
我目前正在使用 Meteor bundle-visualizer
包来检查初始包大小。
我已经以某种方式编写了我的程序包,它使用 dynamic-import
并且它们在开发模式下按预期工作。
但是,当我 运行 bundle-visualizer
通过
meteor --production --extra-packages bundle-visualizer
我得到了包含所有模块的完整包大小。经过短暂的研究,我发现 this paragraph in the documentation:
This visualization can uncover details about which files or packages are occupying space within the initial client bundle. This can be useful in determining which imports might be candidates for being converted to dynamic import() statements (which are excluded from the initial client bundle), or for identifying packages which have been inadvertently included in a project.
我特别想知道的地方是
(which are excluded from the initial client bundle)
,因为这会阻止我在使用动态导入转换后获得实际的包大小。因此我无法验证我的包是否小于某个 KB 大小。
有没有人找到 运行 bundle-visualizer
并为初始客户端包启用 dynamic-import
的方法?
我偶然发现了解决方案。最初,我试过
meteor --production --extra-packages bundle-visualizer dynamic-import
或
meteor --production --extra-packages bundle-visualizer --extra-packages dynamic-import
两者都导致了错误,我认为这是不可能的。
但是,如果我将 dynamic-import
添加到 --extra-packages
的列表中但不添加 space 并用逗号分隔,例如
meteor --production --extra-packages bundle-visualizer,dynamic-import
它将 运行 bundle-visualizer
动态导入,显示优化后的 "new" 大小。
我目前正在使用 Meteor bundle-visualizer
包来检查初始包大小。
我已经以某种方式编写了我的程序包,它使用 dynamic-import
并且它们在开发模式下按预期工作。
但是,当我 运行 bundle-visualizer
通过
meteor --production --extra-packages bundle-visualizer
我得到了包含所有模块的完整包大小。经过短暂的研究,我发现 this paragraph in the documentation:
This visualization can uncover details about which files or packages are occupying space within the initial client bundle. This can be useful in determining which imports might be candidates for being converted to dynamic import() statements (which are excluded from the initial client bundle), or for identifying packages which have been inadvertently included in a project.
我特别想知道的地方是
(which are excluded from the initial client bundle)
,因为这会阻止我在使用动态导入转换后获得实际的包大小。因此我无法验证我的包是否小于某个 KB 大小。
有没有人找到 运行 bundle-visualizer
并为初始客户端包启用 dynamic-import
的方法?
我偶然发现了解决方案。最初,我试过
meteor --production --extra-packages bundle-visualizer dynamic-import
或
meteor --production --extra-packages bundle-visualizer --extra-packages dynamic-import
两者都导致了错误,我认为这是不可能的。
但是,如果我将 dynamic-import
添加到 --extra-packages
的列表中但不添加 space 并用逗号分隔,例如
meteor --production --extra-packages bundle-visualizer,dynamic-import
它将 运行 bundle-visualizer
动态导入,显示优化后的 "new" 大小。