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.
The Angular build process uses webpack behind the scenes to transpile TypeScript to JavaScript, transform Sass files to CSS, and many other tasks. To understand the importance of this build tool, it helps to understand why it exists.
Ivy Compiler is the latest compiler for Angular application released by Angular Team. Currently, Angular is using View Engine compiler to compile Angular application. In general, Angular compiler has two options to compile an application.
I updated to Angular 12 yesterday which uses Webpack 5. The release notes blog says: In the v11 update we added experimental support for Webpack 5. Today, we're happy to announce that we're releasing a production ready version of Webpack 5 support in Angular.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With