Primeng: Make @angular/cdk a peer dependency

Created on 13 Dec 2018  路  20Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
compilation error in production build with AOT:
ERROR in primeng\components\multiselect\multiselect.ts(782,41): Error during template compile of 'MultiSelectModule'
Could not resolve @angular/cdk/scrolling relative to [object Object]..

Expected behavior
Successful compilation

Minimal reproduction of the problem with instructions

  • install PrimeNg 7.0.1
  • run ng build --prod

What is the motivation / use case for changing the behavior?
I am unable to build and deploy application

Please tell us about your environment:
Windows 10,
npm

  • Angular version: 7.1.3

  • PrimeNG version: 7.0.1

  • Browser: Irrelevant

  • Language: TypeScript 3.1.6

  • Node (for AoT issues): node --version =
    v10.13.0

Most helpful comment

have you installed @angular/cdk ? i simply npm install @angular/cdk and it worked

All 20 comments

Same with 7.0.0 and angular 7.1.2
Looks like @angular/cdk no longer compatible with version PrimeNG uses

are you sure this is the same reason?
PrimeNg 7.0.0 works fine with Angular 7.1.3 for me

same problem

7.0.0 build
7.0.1 don't build

ERROR in ../primeng/components/multiselect/multiselect.ts(782,41): Error during template compile of 'MultiSelectModule'
Could not resolve @angular/cdk/scrolling relative to [object Object]..

show https://github.com/primefaces/primeng/issues/3952

have you installed @angular/cdk ? i simply npm install @angular/cdk and it worked

thx is working with @angular/cdk ;)

@huineng @angular/cdk is the Material library, I don't think it should be necessary to install one component library to use another.

Well it has been added to prime ?

import { ScrollingModule } from '@angular/cdk/scrolling';

and it's in prime's package json as a dev dependency

@huineng Yes, but a devDependency should be only for development/build, not to be used directly on the source code.

On that case, it should be a peerDependency, but again, I find it awkward to install 2 component libraries. Maybe it's just me, thought.

@huineng Yes, but a devDependency should be only for development/build, not to be used directly on the source code.

On that case, it should be a peerDependency, but again, I find it awkward to install 2 component libraries. Maybe it's just me, thought.

Totally agree, it is a peerDependency.
Anyway they are very dependent on VirtualScroller from @angular/cdk
https://github.com/primefaces/primeng/commit/e8d30f6e614692c1fa8c11ed5a80f8c2a9eef98a

MultiSelect Virtual Scrolling and p-VirtualScroller depends on @angular/cdk so it is not set to peerDependency to avoid issues like this.

Need to think more, only two components use it but when added a peer dependency, npm says cdk is required. Maybe we can just document it.

Why not add @angular/cdk as a normal dependency ?
If it's required by primeng, just using npm i primeng should install all the necessary dependencies, no ?

(btw, using @angular/cdk is a good idea and should be extended to others component, like Dialog for example)

@mselerin As a normal dependency, if the user's project already has a dependency to another version of @angular/cdk, it would end up with 2 installations of the same library.

As a peerDependency, that doesn't happen. Npm will give a warning if the dependency is not installed, thought.

Commented here:
03e6546

This is still an issue.

Same here 馃殌

I ran into this issue on 7.0.5

So adding the @angular/cdk inside devDependencies and peerDependencies should fix the problem, isn't it ?

@mselerin A devDependency wouldn't make a difference, except for those developing primeng. Only as a peerDependency would be the right call.

@tiagodws That's why I suggest both : as a devDependency for the developers/contributors of primeng and as a peer for the consumers.

Solved with npm install --save @angular/cdk

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyberrranger picture cyberrranger  路  3Comments

watalberto picture watalberto  路  3Comments

SchneMa picture SchneMa  路  3Comments

Faigjaz picture Faigjaz  路  3Comments

mitosandov picture mitosandov  路  3Comments