angularwebpackangular-builderangular-ivy

Angular Ivy compiler and webpack


We would like to use the new Angular 8 Ivy compiler with webpack. We don't use Angular CLI. Is this possible? How can this be done? I can't seem to find information regarding this requirement.


Solution

  • To learn what to do you have to dig into Angular CLI code and see where exactly they use enableIvy flag.

    I haven't seen your Webpack config but I guess you're using AngularCompilerPlugin.
    If this is the case then you have to provide it with enableIvy in compilerOptions.

    For more details look here (where the flag is defined), here (where the plugin options are defined) and here (where plugin's compilerOptions are initialized).

    The plugin configuration will probably look like this:

    ... // The rest of your webpack config
    plugins: [
      new AngularCompilerPlugin({
        compilerOptions: {
          enableIvy: true,
          ...// the rest of compiler options
        }
        ...// The rest of options you provide to AngularCompilerPlugin
      })
      ...// The rest of your plugins 
    ]
    
    

    I'm not sure if they are using this flag in other places but this place is a must and it will probably give you what you want.

    In any case if you want to save yourself a headache I'd recommend you to stick with Angular CLI.
    Otherwise you'll have to visit their code base quite often.

    If you're using Webpack then most probably it is possible to do what you need with Angular CLI and Custom Webpack Builder.
    If you're having a hard time configuring the builder you're more than welcome to visit Angular Builders Slack channel.