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.

Angular 8 + ivy + ng build library usage error

See original GitHub issue

🐞 bug report

Affected Package

Maybe a cli or ng-packagr or ivy issue.

Is this a regression?

kinda : works with enableIvy: false, fails with enableIvy: true

Description

Using angular/*@8.0.0-rc.2, and ng new --enable-ivy fresh projects : in a testlib new project, building a mylib library with ng g library and ng build, only adding a ngIf & CommonModule to default lib files produces a bundle that cannot be consumed from a testclient :

core.js:7182 ERROR Error: Template error: Can't bind to 'ngIf' since it isn't a known property of 'p'.

🔬 Minimal Reproduction

  • use ng cli 8.0.0-rc.2

  • create a lib using ng cli (ng8 rc2, enableIvy=true)

    • ng new testlib --enable-ivy (no router, use css)
    • ng g library mylib
    • add CommonModule to mylib.module imports
    • add an *ngIf to mylib.component
    • build the lib using ng build
  • use it in another project (ng8 rc2, enableIvy=true)

    • ng new testclient --enable-ivy (no router, use css)
    • add this library (copy to node_modules / use yalc / publish to npm…)
    • use it : add MylibModule to app.module
    • add lib-mylib component to app.component.html
    • ng serve … boom

this fails with enableIvy=true, works with enableIvy=false in testclient

I’ve setup a little repo with minimal reproduction

https://github.com/jmbarbier/ng8-ivy-library-issue

the compiled repro lib is available at https://github.com/jmbarbier/ng8-ivy-library-issue/raw/master/mylib.tar.gz

🔥 Exception or Error


core.js:7182 ERROR Error: Template error: Can't bind to 'ngIf' since it isn't a known property of 'p'.
    at createUnknownPropertyError (core.js:12560)
    at elementPropertyInternal (core.js:12426)
    at Module.ɵɵproperty (core.js:16519)
    at MylibComponent_Template (mylib.js:24)
    at executeTemplate (core.js:11998)
    at checkView (core.js:13349)
    at componentRefresh (core.js:13113)
    at refreshChildComponents (core.js:11701)
    at refreshDescendantViews (core.js:11607)
    at checkView (core.js:13350)

🌍 Your Environment

Angular Version:


Angular CLI: 8.0.0-rc.2
Node: 10.15.3
OS: linux x64
Angular: 8.0.0-rc.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.0-rc.2
@angular-devkit/build-angular      0.800.0-rc.2
@angular-devkit/build-ng-packagr   0.800.0-rc.2
@angular-devkit/build-optimizer    0.800.0-rc.2
@angular-devkit/build-webpack      0.800.0-rc.2
@angular-devkit/core               8.0.0-rc.2
@angular-devkit/schematics         8.0.0-rc.2
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.0-rc.2
@schematics/angular                8.0.0-rc.2
@schematics/update                 0.800.0-rc.2
ng-packagr                         5.1.0
rxjs                               6.4.0
typescript                         3.4.5
webpack                            4.30.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jmbarbiercommented, May 25, 2019

Closing this issue as i was able to make it work (with rc.5).

  1. don’t use enableIvy=true on library side - no error, the component is not displayed
  2. always clean everything (node_modules, package-lock.json, .yalc …) between changes
0reactions
angular-automatic-lock-bot[bot]commented, Sep 19, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular enable Ivy cause problem building library
I have created a angular workplace which contain one application and a library. After I enable IVY, I got an error while building...
Read more >
Creating libraries - Angular
Angular CLI uses a tool called ng-packagr to create packages from your compiled code that can be published to npm. See Building libraries...
Read more >
All About Angular Engine Ivy in 5 mins
IVY is a rendering architecture that was first introduced with Version 8. In this article, we are sharing some insights on the features...
Read more >
Improving Build Speed & Bundle Size with Angular Ivy | #ngconf
Join GrapeCity & ng -conf for this webinar on all the benefits that come with using the Ivy compiler. Walk away knowing how...
Read more >
Newest 'angular-ivy' Questions - Stack Overflow
I cannot use component inside the same library in Angular. I'm using angular 13 and I ... angular 13 ng build library fails...
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