Injection (Component, Token) fails during building (3.0.0-rc.3, also ^2.0.0) in Angular 6.0
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
While upgrading my UI library to Angular 6 I encountered a problem with Injection during the build with ng-packagr (Error Message in appended and inside the minimal example)
Here is the most minimal example I was able to create. https://github.com/georgiee/ng-packagr-inject (I tried to use stackblitz so you can quickly take a look- but it’s just not made for CLI stuff)
The weird thing is: Injection of the Token and the Component Reference happens in two different places. But once I remove either of them the problem goes away.
I can imagine that this is a ngc problem as it fails during the step Compiling TypeScript sources through ngc
inside the file ng-packagr/lib/ngc/compile-source-files.js
but I’m unsure so that I rather open this issue.
I don’t know if this is related:
https://github.com/angular/angular/issues/23734
A quick @Injectable({providedIn: 'root'})
did not help in my example.
How To Reproduce
Just build the library in the example project. I also wanted to try a raw ngc example but I have no real clue where to begin. I want to drop this issue here instead in case you see what’s going on.
Expected Behaviour
The build should be fine in this easy scenario.
Version Information
ng-packagr: 3.0.0-rc.3
@angular/compiler: 6.0.0
rollup: 0.58.2
tsickle: 0.27.5
typescript: 2.7.2
Here the error details:
Warning: Can’t resolve all parameters for FooClass in ng-packagr-bug-inject/projects/library/foo/public-api.ts: (?). This will become an error in Angular v6.x
BUILD ERROR
projects/dist/library/bar/public-api.d.ts(1,31): error TS2307: Cannot find module '@my/library/some-component'.
: Can't resolve all parameters for BarDirective inng-packagr-bug-inject/projects/dist/library/bar/my-library-bar.d.ts: (?).
Error: projects/dist/library/bar/public-api.d.ts(1,31): error TS2307: Cannot find module '@my/library/some-component'.
: Can't resolve all parameters for BarDirective in ng-packagr-bug-inject/projects/dist/library/bar/my-library-bar.d.ts: (?).
at Object.<anonymous> (ng-packagr-bug-inject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:62:68)
at Generator.next (<anonymous>)
atng-packagr-bug-inject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (ng-packagr-bug-inject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (ng-packagr-bug-inject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:21:12)
at Object.<anonymous> (ng-packagr-bug-inject/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:42:34)
at Generator.next (<anonymous>)
atng-packagr-bug-inject/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
//cc @dherges to see when this can get merged
Wanted to file a bug about this until I came across this. Already made a small repo where the same issue is demonstrated, will drop it here anyway: https://github.com/abbazabacto/ngpackagr-issue
@alan-agius4 I built your branch
feature/fix-issue-852
locally and the issues disappears like snow for the sun. Any idea when a new RC will be released with this patch?FYI In my real (private) package the original compiler warning was swallowed by the following error
Made it very hard to find the origin, had to just remove dependencies to see which one caused the issue.