Ole
Ole

Reputation: 47080

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?

Upvotes: 12

Views: 13796

Answers (3)

innovThemes
innovThemes

Reputation: 171

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

Upvotes: 5

Aniruddha Das
Aniruddha Das

Reputation: 21698

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

Upvotes: 12

Ole
Ole

Reputation: 47080

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
  },

Upvotes: 11

Related Questions