New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular language service doesn't see components from library built with Ivy. #645
Comments
Update. Ivy compiler doesn't create file |
+1 I have the same issue |
Post version 9, we are going to switch the language service internals to use the Ivy compiler. Until then, the language service would need to rely on |
Yes this is the issue. To resolve for the time being, you will need to build the prod version of your library which has ie But you also need to make sure to All this information is not easily found between the vs-code plugin and angular itself. Just a heads up for anyone else experiencing this same issue. My assumption that |
@jiverson regarding your workaround |
Any updates on this? We have our own libraries developed and published in ivy even in prod. |
Work is underway to move the language service to an Ivy backend! |
I can confirm that if you do:
the error(s) of the type "'xyz' is not a known element" will be gone from the library's parent project. As I understood it this is because Now, one would expect that if I However, this is not working as expected and I can see the same error in a project that has Would this be the same bug as in this issue or a different bug? Or is there some other (or additional) magical combination of keys to press or commands to give to the language server so it processes |
It appears that the new way Ivy is working is to rely on metadata from .d.ts files and no longer from metadat.json files. The only reason why a --prod build is working is because your tsconfig is setting enableIvy to false (as recommended by angular for npm published libraries). This is a language service issue and not an angular cli issue, as the build will work just fine with or without Ivy for an application using the published library. The issue is two-fold:
Why is this a very annoying issue?
|
In order to avoid the complexity related to yarn/npm link and unlink of publishable libs built as npm package, we add path mappings to the tsconfig to pull the imports out of the repo source files. Publishable libraries used as peer dependencies in other libraries will still need to be installed from the npm repo as normal dependencies in package.json. Independently of that, imports in the workspace will still be taken from the source modules and will be built as part of the apps without any restriction on the use of Ivy or not. angular/vscode-ng-language-service#665 angular/vscode-ng-language-service#645 angular/vscode-ng-language-service#827
Here is what I ended up doing to work around this issue, which may be acceptable to some people under the same circumstances. It won't help people who want to use their publishable libraries under the same conditions as a user of such libraries (i.e. from the published npm package): Assuming you are using a monorepo or similar structure where the source code of the publishable library is accessible in a consistent manner to the application using it. Let's assume the package is called 'happy-library'...
"paths": {
"happy-library": ["libs/happy-library/src/index.ts"]
} It's not perfect, but at least I can use my own library in an end-to-end Ivy application, also made by me, without the errors in vscode, while still sharing the love and publishing it to NPM for other users, and I don't have to constantly yarn/npm link and debug why ALS is not working. Interested in feedback if I may have missed something... PS: fully working repo with this method at https://github.com/abdes/happy-coding |
Has any progress been made on this. |
Seems this will be available for beta-testing on Angular 11 scheduled for November. See #335 (comment) |
I'm running on Angular 11 in my project (library built as well with Angular 11, with the --prod flag), and I have the issue decribed by @nprasovict . I published my library on Gitlab packages, and when I install it in our project with I think I'll just end up removing the VSCode extension for now, but I'll be loosing a powerful development just because of this... |
@JonWallsten Thanks, so it will be released soon if I understand well |
This has been fixed by the new Ivy-native language service, released in v11.1.0. |
Awesome work, @kyliau! |
@kyliau Hmmmm... that's weird. I was having the very same problem with a directive declared in a library and I solved it by following the suggestion of building the library with the --prod switch. The thing is that I am already on ALS 11.1.1, so theoretically this would not have to be an issue anymore, right? |
I have the same issue. I build my lib with the The component gets displayed, but still getting this error in vscode. tested versions: 11.1.3 |
I agree, this probably shouldn't be closed @kyliau... I have a minimal reproducible example that I made for another problem that might serve to demonstrate this one as well. Have a look at this: https://github.com/vicatcu/monorepo-example-error (originally posted in connecction with this SO post) |
I'll go a step further, if I add the |
Just to clarify, being on If after verifying all of the above and the extension is still not working as expected, please open a new issue to help us triage and reduce noise. Thank you very much! |
@kyliau thanks I, for one, had certainly missed that. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
馃悶 bug report
Affected Package
The issue is caused by package @angular/language-service
Description
Angular language service doesn't see components from library built with Ivy.
Application is built correctly.
Error
Environment
The text was updated successfully, but these errors were encountered: