Jankapunkt
Jankapunkt

Reputation: 8423

Meteor bundle visualizer add dynamic imports to the initial client bundle

I am currently using the Meteor bundle-visualizer package to check the initial package size.

I have already written my package in a way, that it uses dynamic-import and they work as expected in development mode.

However, when I run the bundle-visualizer via

meteor --production --extra-packages bundle-visualizer

I get the full package size to be displayed with all modules included. After a short research I found 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.

Where I am especially wondering about is the part

(which are excluded from the initial client bundle)

,because this prevents me from getting the actual bundle size after converting it using dynamic imports. Thus I can't verify, if my package is below a certain KB in size.

Has anyone found a way to run bundle-visualizer with enabled dynamic-import for the initial client package?

Upvotes: 2

Views: 331

Answers (1)

Jankapunkt
Jankapunkt

Reputation: 8423

Just by accident I found the solution. Initially, I tried

meteor --production --extra-packages bundle-visualizer dynamic-import

or

meteor --production --extra-packages bundle-visualizer --extra-packages  dynamic-import

which both have resulted in errors and I thought, that this was just not possible.

However, if I add dynamic-import to the list of --extra-packages but without space and separated by a comma like

meteor --production --extra-packages bundle-visualizer,dynamic-import

it will run the bundle-visualizer with dynamic imports, revealing the "new" size after optimizations.

Upvotes: 2

Related Questions