-
Notifications
You must be signed in to change notification settings - Fork 295
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InjectionToken not included in metadata #317
Comments
I don’t see the token being included in any typescript decorator in your library. I believe the decorators are the source of that metadata. This looks like an incomplete use of the injection token in your library. |
In my library the InjectionToken is only used in the following method in dialog.service.ts. This is the same way that angular material handles dialogs and in that library the InjectionToken is included in the metadata. https://github.com/angular/material2/tree/master/src/lib/dialog
|
What I meant, is that you didn't include the token in a module's providers like angular material does. Your module setup is missing the injection token. Thus, it will not be part of the metadata. Please add your token to the providers array and report back on if the problem is solved. |
I see, however if you look in the material file you linked there is also an InjectionToken called MAT_DIALOG_DATA and that is not included in the modules provider from what I can see. |
Good point. I just cloned your library and built it, then linked it, then built the demo app with the linked library with the compiler commands you provided and it failed with a completely different error than what you've reported. |
Specifically, it's having trouble with this:
|
Hi all, what is the current status here? The error |
It appears I'm having the same issue. My use case is that I have a library that exports injection tokens, as an alternative to Steps to reproduce:
Observed error:
|
A bit more insight, and a workaround from #720 as applied to my case: Apparently the issue is that - for whatever reason - the first entry point must be a direct reference to the barrel file, rather than the directory it lives in. This cascades - so if your The workaround for this issue is: Always refer barrel files directly, don't use directory resolution. |
This workaround saved my life. |
This issue has been automatically locked due to inactivity. |
Type of Issue
Description
I am exporting the following InjectionToken
export const SX_NGX_FABRIC_DIALOG_DATA = new InjectionToken<any>('SxNgxFabricDialogData');
When I run ng-packagr, the InjectionToken is not included in the metadata.json file which resulted in the following error
Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler
when building with the following flagsng build --prod --aot --sourcemaps --build-optimizer --named-chunks --stats-json
How To Reproduce
Add an InjectionToken in you library, run ng-packagr and try to use that injection token in the app that refereneces the library. Project can be found here: https://github.com/Abrissirba/sx-ngx-fabric
Expected Behaviour
The injection token should be included in the metadata.json
Version Information
The text was updated successfully, but these errors were encountered: