Repository navigation
Description
🐞 bug report
Affected Package
mydatepicker https://github.com/kekeh/mydatepicker
Is this a regression?
Angular 8.2.6 works
Angular 9.0.0-next.5 fails
Description
Everything works as expected with 8.2.6
Upgrading to 9.0.0-next.5 fails to build (Ivy disabled, aot enabled)
🔬 Minimal Reproduction
https://github.com/whyboris/angular-ivy-problem
I created a new app (npm install -g @angular/cli@latest & ng new angular-ivy-problem)
The repository contains that code (no changes) along with two branches:
branch 1 named ERROR follows the minimal requirements to get mydatepicker working. The code change is in this PR: https://github.com/whyboris/angular-ivy-problem/pull/1
branch 2 named no-error which simply downgrades the angular & cli versions to latest version 8 is in this PR: https://github.com/whyboris/angular-ivy-problem/pull/2/files (note it's a PR against ERROR
🔥 Exception or Error
ERROR in node_modules/mydatepicker/dist/my-date-picker.module.d.ts:1:22 - error TS-996002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
1 export declare class MyDatePickerModule {
~~~~~~~~~~~~~~~~~~
src/app/app.component.html:5:3 - error TS8001: 'my-date-picker' is not a valid HTML element.
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
src/app/app.component.html:5:33 - error TS8002: 'options' is not a valid property of .
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
src/app/app.component.html:5:65 - error TS8002: 'ngModel' is not a valid property of .
5
~~~~~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
src/app/app.component.html:8:1 - error TS8001: 'router-outlet' is not a valid HTML element.
8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.0-next.4
Node: 12.10.0
OS: darwin x64
Angular: 9.0.0-next.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-next.4
@angular-devkit/build-angular 0.900.0-next.4
@angular-devkit/build-optimizer 0.900.0-next.4
@angular-devkit/build-webpack 0.900.0-next.4
@angular-devkit/core 9.0.0-next.4
@angular-devkit/schematics 9.0.0-next.4
@angular/cli 9.0.0-next.4
@ngtools/webpack 9.0.0-next.4
@schematics/angular 9.0.0-next.4
@schematics/update 0.900.0-next.4
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.3
Anything else relevant?
Also very related to errors encountered in #32466
Activity
compeek commentedon Sep 17, 2019
I had a lot of these kinds of errors trying to get my project working with Angular 9 and Ivy. I could not pinpoint the exact cause, the the combination of these two things seemed to resolved them for the most part:
"allowEmptyCodegenFiles": trueto the"angularCompilerOptions"block intsconfig.json"postinstall": "ivy-ngcc"topackage.jsonand then deletenode_modulescompletely and rerunnpm install(which will run thepostinstallscript automatically)I would recommend you try each of those and see if it gives you any better results.
I'm not using mydatepicker, but I suspect your problems aren't specific to mydatepicker. My experience with Ivy so far in the last few days unfortunately has been that it's still very finicky, especially with third party libraries and/or lazy loaded modules (not sure which is the exact cause).
In particular with suggestion 2 above, even though the compiler automatically runs the ngcc compiler now (from what I gather, anyway), it doesn't seem to do it properly because I get better results running it manually first with that npm script.
whyboris commentedon Sep 18, 2019
Thank you @compeek -- I added
allowEmptyCodeGenFiles,postinstall, removednode_modulesand rannpm installagain. Unfortunately in my case I still get the above errors.I suspect what you recommend makes a difference, but perhaps I should just move on from
mydatepicker(latest versions2.6.6, last updated 1 year ago) toangular-mydatepicker, its successor 🤷♂Either way it may be worth for the Angular team to investigate why a simple version upgrade breaks things (even without turning Ivy on) 😕
whyboris commentedon Sep 18, 2019
For reference, I created a branch
new-datepickerusingangular-mydatepickerlibrary instead ofmydatepicker-- the PR for it: https://github.com/whyboris/angular-ivy-problem/pull/3It works with Angular 9 (current latest
9.0.0-next.5) 🎉 even with Ivy enabled 🎉 🎉JoostK commentedon Sep 26, 2019
Finally found some time to look into this. The
mydatepickerlib is not processed by itself as its library structure follows an unusual layout, whereindex.js/index.d.tsfiles are at the root, but Angular's metadata file is stored atdist/index.metadata.json. ngcc needs some hint to know this is indeed an Angular package that needs to be processed, which can be accomplished by creating angcc.config.js(that's.js, not.json!) file in the root of the project (next to the rootpackage.json):This is enough to teach ngcc that
mydatepickerneeds to be processed as an Angular library. With this config, the library is processed correctly and the app compiles successfully.Unfortunately, the app will fail at runtime:
The
RendererAPI has been deprecated a long time ago and is no longer available in Ivy, so the library is just no longer compatible.The error that is being reported is less than ideal, as it doesn't really tell why it's failing nor what can be done to rectify the issue. If you have suggestions for improving the situation, please let us know.
Regarding this particular issue, I don't see how it's actionable at this moment so I will go ahead and close it for now.
whyboris commentedon Sep 28, 2019
Thank you @JoostK -- hope the time you spent looking into this issue wasn't a waste. I think it's very sensible for Angular to allow for some outdated versions of libraries to not be compatible with new versions of Angular 👌
For anyone coming across similar problems upgrading to Angular 9, the best recommendation is:
mydatepickerto its successorangular-mydatepickerThis is a sensible solution because
mydatepickerhasn't been updated in 1 year: https://www.npmjs.com/package/mydatepicker?activeTab=versionsAnd its official repository (https://github.com/kekeh/mydatepicker) recommends you upgrade to the successor (https://github.com/kekeh/angular-mydatepicker), also written by the same author. This new version was released as recently as 2 months ago: https://www.npmjs.com/package/angular-mydatepicker
👏 keep 👏 dependencies 👏 up 👏 to 👏 date 👏
Cheers ❤️
angular-automatic-lock-bot commentedon Oct 29, 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.