Rollup bundle is way too big
$ bazel build src:bundle
$ ls -alH dist/bin/src/bundle.min.js
-r-xr-xr-x 1 alexeagle eng 928105 Jan 19 16:34 dist/bin/src/bundle.min.js
A hello world app should be a lot smaller. First problem is it brings in rxjs from npm (using commonjs)
/cc @robwormald who helped me debug it
Maybe it makes sense to include a simple plugin to resolve to rxjs esm I have something here:
https://github.com/thelgevold/angular-2-samples/blob/master/rollup/resolve-esm.js
This removes the need for the commonjs plugin (for rxjs). Unless you plan to use it for other libraries later...
When I check the produced bundle for my app using the rollup_bundle rule, there were 21 separate definitions of Observable (Observable through Observable$20.) It looks like the library may be included a large number of times.
Potentially related: when I first set up my rollup_bundle target, in the places of my code where I import rxjs/Observable, Rollup complained about not knowing where to find Observable, so it treated it as a global (even though it still defined several local Observable$N local variables inside of the IIFE.) My app wouldn't work until I added node_modules/rxjs/** back into my //:node_modules filegroup.
https://github.com/bazelbuild/rules_nodejs/commit/50160838918fb381ad2691d4ddbd62e4eac17bee should fix this issue with rxjs - we should depend on the files built by bazel, not the rxjs distribution.
Misko found today that we are also missing the Angular Build Optimizer in this path, which does things like these /* @__PURE__ */ annotations that tell uglify that some code can be removed, I'll wire that up next.
We built it again today and it's under 350,000 bytes uncompressed. We are in the ballpark. Working on hooking up @angular-devkit/build-optimizer, maybe need @igorminar to help next week.
i tried to serve example on my mac and I think this issue is related, when ibazel run src:devserver i get this
@istiti I don't see how that's related to this issue?
Isn't that just ibazel waiting for you to make the next source file change? I don't think there's a slow process there
On Mon, Jan 29, 2018 at 12:56 PM Begović [email protected] wrote:
😕 Apologises me if not, i thought long process was due to rollup
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/alexeagle/angular-bazel-example/issues/62#issuecomment-361383413, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC5I1gXkUL3pzCgqdePWleuJ6BDDtACks5tPjBlgaJpZM4RlOgU .
Improved
but still needs work
Not doing more work on this - new rollup_bundle rule does the same thing you would do outside Bazel so it's not a problem in our scope