You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
angular 10 library publish error “Trying to publish a package that has been compiled by Ivy” #37973
The issue is caused by package @angular-devkit/build-angular:browser
Is this a regression?
No. In version 9 it is expected behavior. But suppose it should not happen in angular V10
Description
I have created project and generate library with angular 10. But I can't set enableIvy to "true" build and publish my package. It throw error:
my-lib@0.0.1 prepublishOnly .
node --eval "console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\nPlease delete and rebuild the package, without compiling with Ivy, before attempting to publish.\n')" && exit 1
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.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-lib@0.0.1 prepublishOnly: node --eval "console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\nPlease delete and rebuild the package, without compiling with Ivy, before attempting to publish.\n')" && exit 1
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-lib@0.0.1 prepublishOnly script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/aa/.npm/_logs/2020-07-08T13_03_35_422Z-debug.log
When you are preparing a library for publishing to npm you should use ng build --prod which will ensure it is built in ViewEngine mode, rather than Ivy.
@petebacondarwin am I right that the main reason for that is backward compatibility? If so why it is limited for private projects as well. I was hoping that in Angular 10 I will be able to build both internal library and internal project on Ivy while they are both on Angular 10.
The reason is actually forward compatibility. If we allow ivy compiled libraries to be published right now, then we lock ourselves into a very specific use of the ivy instruction set and data structures. This would affect us from being able to make implementation changes that would fix bugs, improvement performance, reduce code size etc. By keeping the ivy internals private we can be more agile going forward.
The current way to achieve this is by requiring ViewEngine compiled code (since this leaves the decorator information in place), which ngcc is able to convert to ivy code at library installation/ application build time. Going forward we are looking into a partially compiled library format that will have the best of both worlds: not requiring a lengthy ngcc build step, but also not exposing the internals of the ivy runtime.
Reacted by Aly Ahmed, Ivan Yudee, Indraraj and Ben Sorohan
That being said, if you are in control of your private libraries and will recompile them whenever you update your version of Angular framework, there is no reason why you could not share them internally in ivy compiled form. But then I would not expect you to be publishing them to npm, which is what this check is designed to prevent.
The reason why I see this error is that I'm using npm publish with custom URL via --registry param. Is it intentionally blocked too? Maybe I should use some other way or publishing to the private registry?
Activity
petebacondarwin commentedon Jul 8, 2020
When you are preparing a library for publishing to npm you should use
ng build --prodwhich will ensure it is built in ViewEngine mode, rather than Ivy.This is working as expected.
Sikatrih commentedon Jul 8, 2020
My library is private and needs to be compiled with Ivy.
According to this table https://gist.github.com/LayZeeDK/61caba93df1ec1a0788c94a973c8dfac
angular 10 should have ability to build library with Ivy. Or this table is not correct?
The same discussion was in this issue ng-packagr/ng-packagr#1467
petebacondarwin commentedon Jul 8, 2020
That table is not correct. Libraries that are published to npm must be built using ViewEngine.
toxity commentedon Jul 9, 2020
@petebacondarwin am I right that the main reason for that is backward compatibility? If so why it is limited for private projects as well. I was hoping that in Angular 10 I will be able to build both internal library and internal project on Ivy while they are both on Angular 10.
petebacondarwin commentedon Jul 9, 2020
The reason is actually forward compatibility. If we allow ivy compiled libraries to be published right now, then we lock ourselves into a very specific use of the ivy instruction set and data structures. This would affect us from being able to make implementation changes that would fix bugs, improvement performance, reduce code size etc. By keeping the ivy internals private we can be more agile going forward.
The current way to achieve this is by requiring ViewEngine compiled code (since this leaves the decorator information in place), which ngcc is able to convert to ivy code at library installation/ application build time. Going forward we are looking into a partially compiled library format that will have the best of both worlds: not requiring a lengthy ngcc build step, but also not exposing the internals of the ivy runtime.
petebacondarwin commentedon Jul 9, 2020
That being said, if you are in control of your private libraries and will recompile them whenever you update your version of Angular framework, there is no reason why you could not share them internally in ivy compiled form. But then I would not expect you to be publishing them to npm, which is what this check is designed to prevent.
toxity commentedon Jul 9, 2020
The reason why I see this error is that I'm using
npm publishwith custom URL via--registryparam. Is it intentionally blocked too? Maybe I should use some other way or publishing to the private registry?petebacondarwin commentedon Jul 9, 2020
In that case the simple workaround is to remove the
prepublishOnlyproperty from the library'spackage.jsonbefore publishing.angular-automatic-lock-bot commentedon Aug 20, 2020
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.