Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile a library without Ivy?

I'm publishing a library and when I cd to dist/my-library I get the message:

ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed. Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.

How do we rebuild without Ivy?

like image 417
Ole Avatar asked Nov 30 '19 03:11

Ole


People also ask

How do you disable ivy?

To disable Ivy:json set "aot": false; in tsconfig. app. json remove the angularCompilerOptions option or set "enableIvy": false.

What is Ivy library?

The code generation step really needs to be done in the application's Angular version. So Ivy library compilation concept is a set of mechanism for running only the code generation step rapidly after library installation and mechanism for finishing the analysis step before NPM release.

What is Ivy partial compilation mode?

"Partial" is short for "partially compiled", meaning that the compiler has only half-compiled the library code, and held off on generating the full Ivy instructions for the library.

What is Ivy rendering?

Ivy is the code name for Angular's next-generation compilation and rendering pipeline. With the version 9 release of Angular, the new compiler and runtime instructions are used by default instead of the older compiler and runtime, known as View Engine.


3 Answers

Within the library project there is a tsconfig.lib.json file. Here's my Angular compiler configuration:

  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "enableResourceInlining": true,
    "enableIvy": false
  },

like image 131
Ole Avatar answered Nov 19 '22 13:11

Ole


Fix for angular 9.x.x

If you migrated your app to angular 9 and you see this kind of error, make sure to build your library with --prod option it will not build with IVY

ng build yourLibraryName --prod

When you will pass --prod it will build without the ivy option and it will be allowed to be published.

As part of the migration, angular CLI create tsconfig.lib.prod.json and configure to not use IVY and you are all set

like image 45
Aniruddha Das Avatar answered Nov 19 '22 14:11

Aniruddha Das


To Fix this warning:

Try to disable Ivy in tsconfig.lib.json by adding below line to "angularCompilerOptions" :-

"enableIvy": false

Or

build with --prod

example: ng build your-package-name --prod

like image 5
innovThemes Avatar answered Nov 19 '22 14:11

innovThemes