question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to have @angular/core as small as 75kB in the bundle?

See original GitHub issue

Please provide us with the following information:

OS?

Windows 10.

Versions.

angular-cli: local (v1.0.0-beta.26, branch: beta26) node: 6.5.0 os: win32 x64 @angular/common: 2.4.4 @angular/compiler: 2.4.4 @angular/core: 2.4.4 @angular/forms: 2.4.4 @angular/http: 2.4.4 @angular/platform-browser: 2.4.4 @angular/platform-browser-dynamic: 2.4.4 @angular/router: 3.4.4 @angular/compiler-cli: 2.4.4

Repro steps.

A) for angular-cli generated app: A.1) ng new some-app A.2) cd some-app && ng build --prod --aot --sm (the sourcemap is for later steps) A.3) npm i source-map-explorer -g A.4) cd dist && source-map-explorer vendor.[hash].bundle.js

B) for toh: B.1) git clone https://github.com/johnpapa/angular2-tour-of-heroes.git toh B.2) cd toh (add the missing bit as following) B.3) edit tsconfig-aot.json, insert "lib": [ "es2015", "dom" ], after "target": "es5", B.4) edit package.json, insert "aot-gzip": "npm run aot && npm run rollup && gulp copy-aot-gzip" after "start-aot": ... B.5) npm run aot-gzip B.6) cd dist && source-map-explorer build.js

The log given by the failure.

No error.

Mention any other details that might be useful.

After repro A), I have this breakdown, with @angular/core size at 135kB. After repro B), the breakdown and @angular/core size at 72.3kB.

repro B is a full toh app while repor A is only hello-world, we may expect a larger @angular/core from repro B, but the result is the opposite. Obviously, repro B uses rollup. I’m not sure if that’s the main reason for the size difference. I searched for ways to combine the benefits of webpack and rollup and found ‘https://github.com/egoist/rollup-loader’. But I have no idea how to inject this into angular-cli. Is it possible to do something like loader: 'rollup-loader!webpackLoader'? Thanks.


Thanks! We’ll be in touch soon.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
filipesilvacommented, Jan 23, 2017

I think part of it is the webpack helpers, but also https://github.com/webpack/webpack/issues/2899.

I haven’t looked into the rollup-loader yet but it was on my list. Let me see what can be done.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimize Angular bundle size in 4 steps | by Siyang Kern Zhao
Step 1: Know your Bundle Size ... It's hard to deny that initial page loading time is tightly connected with your Angular app...
Read more >
Reduce the Bundle Size of Your Angular App | Pluralsight
In this guide, you will learn how to reduce the production bundle size of your Angular app. Angular is a very opinionated and...
Read more >
How to decrease prod bundle size? - angular - Stack Overflow
Another option is to use module chunking/lazy loading to better split your application into smaller chunks; Ivy rendering engine comes by ...
Read more >
Angular - How to improve bundle size? - Daniel Kreider
Is your Angular application slow? Here are 5 ways you can reduce the bundle size. And make it load faster. ⚡️. Want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found