Angular with Ivy + webpack - bundles larger than before

1k Views Asked by At

I've upgraded to Angular 8.0 while opting in to "Ivy". Everything is compiling OK but results have been disappointing in terms of bundle sizes. Actually, my vendor bundle with Angular has increased in size vs ng7.

Not configured right?

  • I'm using Node 12
  • @angular 8.0 with @ngtool 8.01

tsconfig

{
  "compileOnSave": false,
    "compilerOptions": {
        "baseUrl": ".",
        "noImplicitAny": false,
        "noEmitOnError": true,
        "sourceMap": false,
        "inlineSourceMap": false,
        "target": "es5",
        "module": "es2015",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": false,
        "allowJs": false,
        "noStrictGenericChecks": true,
        "noEmit": false,
        "lib": [ "es6", "dom" ],
    },
 "angularCompilerOptions": {
    "skipMetadataEmit": true,
    "enableIvy": "ngtsc",
    "allowEmptyCodegenFiles": true
  }
}

enter image description here

1

There are 1 best solutions below

2
On

Angular's new compiler (Ivy) is only experimental for now and not even fully stable.

You can try it out if you're running Angular 8 by passing a flag enableIvy as you've done. But it's not the default value (now) for a good reason. You shouldn't use that in prod (yet).

You'll not get anything beneficial by activating Ivy right now. They've changed the way the compiler does work and one of the reasons is to get better tree shaking. But the tooling around that hasn't been updated yet (which in my opinion will probably only come in v9).

For now, it's fine to use Ivy as a beta tester and report any issue you might encounter with it to the team. You'll also encounter issues with libraries that haven't been updated yet to support it. So I wouldn't recommend to use it in prod.

PS:

I've also talked about that in this thread https://github.com/angular/angular/issues/13721#issuecomment-498989717 (I'm explaining things about Ivy but also giving an answer to someone insulting maintainers so don't bother with that part...)