Large Bundle? #1863
Replies: 2 comments
-
Thanks for writing the long post.
This needs to be fixed.
The only purpose is not needing to write
Many of the plugins are community-made, the core team has no relations to 'em.
I suggest you send a PR that makes that an option.
Documentation should be updated, but this happens because we don't know all watched paths. In the default config we assume user has his stuff in |
Beta Was this translation helpful? Give feedback.
-
Glad I was able to find and document a real bug 😄
I'll do some more experimentation and see if a new issue should be created. When I used
I'll reach out to
To clarify, does this mean that I can get the behavior I expect by making two changes to the config: one to set the Would it make sense as an improvement to automatically strip the path if there's only one folder in the Alternatively, instead of doing this with It just seems overly-complicated to do a simple task like "change the name of the folder". That feels like the kind of thing one should be able to accomplish with one line of config. |
Beta Was this translation helpful? Give feedback.
-
Nevermind
See "actual behavior" - I discovered the issue that was leading to such large builds in Brunch (or rather, such small builds in WebPack). Although the "additional rants" is still applicable, I plan on making separate issues for each of those.
DescriptionA relatively simple VueJS application built with Brunch is over twice the size of the same application built with WebPackExpected behaviorAll of the Brunch documentation, blog posts about Brunch, and Brunch tutorials suggest that Brunch produces smaller Bundles than WebPack. Even if larger, I wouldn't expect more than a 5-10% increase.Actual behaviorThe final size in WebPack was a 304kmain.js
file while Brunch provided me with a 660kvendor.js
file and a 131kapp.js
file. That's a total of 791k -- 2.6x the sizeI'm working on uploading these two repos to github. Will update the issue once I'm done.Update: I was cleaning up the two github repos to ensure 100% feature parity between them and no extraneous code or unused NPM modules. It was during this cleanup that I noticed a minor difference in the
.babelrc
files. WebPack was passingmodules: false
tobabel-preset-env
. Removing this line increased the WebPack output from 304k to 788k. Still smaller than Brunch, but only 0.4% now instead of 160%It looks like I never noticed this transform wasn't taking place because all testing was done in browsers that support ES6 modules: https://caniuse.com/#feat=es6-module
EnvironmentBrunch: 2.10.17Node.js: v10.4.1NPM: 6.3.0Operating system: Ubuntu 18.04Code editor: NVIM 0.3.0-devpackage.json
contentsbrunch config contentsOther useful files, when present (log,bower.json
etc.).babelrcAdditional Ranting (still valid)
I have a VueJS project that was originally being built by WebPack and I decided to give Brunch a try. In terms of getting up and running, it was fantastically superior. My old build config was 249 lines, and it didn't even work right (source maps were jacked up in production, static assets didn't always load in development, etc) - and that's after spending around 20 hours debugging the build scripts and eventually giving up. Meanwhile I installed Brunch, grabbed the proper plugins, and with very little effort I was able to get everything up and running.
Since then I've just been experimenting with various Brunch plugins, trying out different features, testing different ways to organize my code, and comparing the speed and final bundle size. This is when I started running into a hell of a lot of issues.
As I get time throughout the next couple of days I'll try to properly document and create issues in either Brunch or the appropriate plugins for all of the problems I've been having, but here's a short list of what kept me up late last night:
appcache-brunch
with any plugin that produces hashed filenames likedigest-brunch
orfingerprint-brunch
) cause Brunch to return status code 1 (error) without dumping any errors to console and without giving any meaningful feedback. When this happens there's about a 50% chance that everything build perfectly and the error was superfluous, and a 50% chance that some files are missingextractCSS
didn't seem to do anything when paired withvue-brunch
,manifest
didn't seem to do anything when paired withdigest-brunch
, andignored
didn't seem to do anything when paired withuglifyjs-brunch
)entryPoints
config options is confusing and seems almost useless. I would expect providing an entryPoint to my app would save me the trouble of writing<script>require("index");</script>
(since the entry point is known) and would lead to smaller bundles (thanks to not including every module and possibly thanks to tree-shaking, if that's a feature provided by Brunch). Instead the bundles ended up larger (789kvendor.js
) and didn't even work (the contents of thevendor
directory were not included in the global scope as expected, but instead only modules directly imported were seen)groundskeeper-brunch
simply didn't work. It threw a meaningless error about needing to provide a version (which seems to be related to source maps?) and no output was producedvue-brunch
forces hot module reloading (presumably becausevueify
forces it) which breaks source maps in development. This means when a bug is thrown I'm forced to guess-and-check debug it instead of looking at the actual line that failedpaths.watched
configuration option changes module names. I had a working application and I wanted to renameapp
towwwsrc
so it was more apparent that this was the source code for the front-end of my service, not the back-end. I addedexports.paths.watched = ["wwwsrc"]
to my brunch config and suddenly<script>require("index");</script>
stopped working. Looking at the file produced, it looks like the new invocation is<script>require("wwwsrc/index");</script>
-- why would this happen if there's only oneindex
module and it resides in the only watched directory?Beta Was this translation helpful? Give feedback.
All reactions