I’m using the command
meteor --extra-packages bundle-visualizer --production to measure bundle size. When I take a look at the results it looks like there are several npm packages where the non-minified js is used to calculate the size. Is that to be expected?
I thought the minified version would be used for all npm packages when calculating the bundle size with the
My app uses the standard minifier
Can you elaborate on how you identified that the non-minified files are used to calculate the size?
As an example, one npm package I’m using is
sanitize-html. When I look at the chart created by
bundle-visualizer it appears to be using the file from
/node_modules/sanitize_html/dist/sanitize-html.js rather than
sanitize-html.min.js which is available in the same
Have a look in your actual build files, nothing in mine is minified at all but when I check what is actually served it is minified. I make double sure as a full proof measure I also minify everything at nameserver level also. I’ve never figured out why it builds with full files, I also think it should all be minified at build - then the tarball package would be smaller then also, mines is now around 30mb. Quite big for a web app source really
Meteor combines all JS code into one file and minifies everything. It does not have any knowledge of “minified” versions of packages if not explicitly imported to your code
Got it. Is it fair to say that the results provided by
bundle-visualizer which is a readout of the data in
.meteor/local/build/programs/web.browser/*stats.json is directionally correct but will likely show results that are a little larger than what’s actually shipped to production?
I’m not familiar on what will be the source of difference.
Build your app with
meteor build ../build --architecture os.linux.x86_64
Then you will get a tar ball in the build directory, untar that and take a look. I was intrigued by your request so I looked in my deployed app build and found many source maps although the node modules themself were not minified. What a server to my users is minified because I have ensured to do so on the server level and wasn’t expecting meteor to take care of this (I guess I’m just old school and that’s just the way we’ve always dealed with this over the years from apache to lighttpd and now nginx)
Take a look and see what you find in the build, also view the source the browser loads with developer tools and you will be able to see also when its on the server. Do a test on your staging / dev server if you need.
Hope that helps