angular/ngcc-validation

How do I add my project to the list?

eestein opened this issue · 10 comments

I followed the instructions but when I tried to push a new branch with my project it didn't work (403).
Apparently, I need this validation in order to allow my lib to work with stackblitz. Until then I keep getting an error.

@eestein, you cannot push directly to repositories that you don't have write access to. You need to fork this repository, create a new branch with your work (e.g. adding your library) and then create a pull request on this repo.

Let us know if you run into any problems.

Also, not sure what validation you are referring to or what this has to do with your library working with StackBlitz.

I am closing this issues, since it is not actionable on our part, but feel free to continue the discussion below.

@gkalpak thanks.

Whenever I try to use my library on stackblitz I get an error after they run ngcc on it. After much research and not finding the problem (the library runs fine on 2 angular 9 projects running in production - it also worked fine on stackblitz while on angular 8) I read this article https://indepth.dev/the-angular-ivy-guide-for-library-authors/ which mentioned this:

The Angular compatibility compiler can require some changes to our libraries. If we want to verify that our library works with ngcc, we should at it to the Angular Ivy library compatibility validation project by the Angular team.

Hence why I'm here. Is this not the case? Isn't the problem my library not being added to this repo?

Thank you

As mentioned by the article, adding the library to this project can be done to verify that it works with ngcc (or rather that it continues to work as we release new versions). But in no way is this mandatory for the library to work with ngcc.

This repo is just a giant Angular CLI workspace with hundreds of apps that are processed by ngcc (via ng build among other methods) to verify that ngcc (the Angular Compatibility Compiler) does not unexpectedly breaks an library.

If you want to make your library work with ngcc (and thus with Ivy), you don't need this repo. You can just create a simple Angular CLI app that uses your library, attempt to build that app (which will run ngcc implicitly), see what breaks and fix it.

That's the thing... I did that and it works nicely with the apps I created. No errors. I pulled the ngcc-validation project, added my lib and it's working there as well. Maybe you can shed some light here?

To confirm, as I mentioned, I pulled the project, added my lib and ran ng build mylib and it built:
Screen Shot 2020-06-25 at 11 04 30
Screen Shot 2020-06-25 at 11 03 51

There were some errors, but only on a @alfresco lib:
Screen Shot 2020-06-25 at 11 05 17

Do you think maybe you could point me in the right direction here? This project was the closest I got to "understanding" the problem.

Thanks.

Can you show an example of it failing on StackBlitz? Maybe it is a StackBlitz issue.

@gkalpak sure, if you click here http://sdk.uniodigital.com.br/#/components/notification/examples and click on the first StackBlitz button you'll see what I mean. It works nicely on the page above, if you click on "Notificar" button, but if you try to open it on StackBlitz, then you get the error:

ERROR
Error: No component factory found for NotificationContainerComponent. Did you add it to @NgModule.entryComponents?

Which is not required anymore for v9. And, again, it works :/

Thanks for the help.

Well, entryComponents are still required in ViewEngine apps. They are not required in Ivy apps. The default engine for v9 is Ivy and your apps at http://sdk.uniodigital.com.br is indeed an Ivy app (hence it doesn't indeed require entryComponents).

I don't know how you create the StackBlitz project (maybe through their API?), but it seems to create a ViewEngine app, which requires entryComponents. StackBlitz has a checkbox in the "Settings" panel, where you can turn Ivy on. When I turned Ivy on in StackBlitz, I got the error: ngcc failed to run on @unio/components@0.5.48.

So, this seems to be somehow related to StackBlitz's setup. Maybe this is due to the format that StackBlitz uses. IIRC, it tries to use CommonJS/UMD (i.e. the main property in each dependency's package.json). By default, Angular CLI apps use es2015. So, maybe ngcc can successfully process our library's es2015 format, but not its main format.

You can try running the following command locally and see if you get any errors:

./node_modules/.bin/ngcc --create-ivy-entry-points --first-only --properties main module --target @unio/components

@gkalpak thank you for your time, I appreciate it! I'll dig further into StackBlitz' setup, but regarding the command, no errors:

Screen Shot 2020-06-25 at 16 55 56

EDIT: Also, I forgot to tell you, if you go to here http://sdk.uniodigital.com.br/#/components/button/examples and click on the first StackBlitz again it's going to work. It is the same library, but now it's not using a dynamically created component. From your explanation, since it didn't throw any errors using that command, it seems to be a problem on StackBlitz, right?

Yeah, it sounds like a StackBlitz-specific problem. Maybe you could report it to them.

Ok, I'll forward it to them. Thank you very much for your help :)