question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Injection (Component, Token) fails during building (3.0.0-rc.3, also ^2.0.0) in Angular 6.0

See original GitHub issue

Type 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:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, May 22, 2018

//cc @dherges to see when this can get merged

1reaction
abbazabactocommented, May 22, 2018

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

BUILD ERROR
Cannot read property 'isSkipSelf' of null
TypeError: Cannot read property 'isSkipSelf' of null

Made it very hard to find the origin, had to just remove dependencies to see which one caused the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular versioning and releases
We update peer dependencies in minor versions by expanding the supported versions, but we do not require projects to update these dependencies. Patch...
Read more >
"Unexpected token: punc ())" when building for production
After upgrading to angular 8 during production build, I was getting "Error in common-es2015.xxx.js from Terser Unexpected token: Punc(;) ...
Read more >
cannot find module '@angular/core/testing' from ... - You.com
After these steps we're getting the next error while trying to do a node test of the ... from 'node_modules/jest-preset-angular/build/config/setup-jest.js'.
Read more >
Open source licenses for Code42 platform version 6.0
Component, License. "Java Concurrency in Practice" book annotations1.0. Creative Commons Attribution 2.5. 1to21.0.0. MIT License. abab1.0.3.
Read more >
Testing Guide - OWASP Foundation
About the OWASP Testing Guide Project. About The Open Web Application Security Project. 3 - 4. 5 - 6. Testing Guide Foreword -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found