AhsanAyaz / ngx-device-detector

An Angular v7+ library to detect the device, OS, and browser details.
https://ahsanayaz.github.io/ngx-device-detector
MIT License
517 stars 101 forks source link

Angular 18 is released #289

Closed forrestlin2020 closed 2 months ago

forrestlin2020 commented 3 months ago

Angular 18 is released. It doesn't work with Angular 18. Can you update it to work with Angular 18?

Rambou commented 3 months ago

It works fine with v18. The problem during npm install is the peerDependency to v17. Could you change the peer dependency to >=17.0.0 instead of caret usage?

forrestlin2020 commented 3 months ago

@Rambou Thank you for your answer. How to change the peer dependency to >=17.0.0?

Regards

Forrest

isoroka-plana commented 3 months ago

@Rambou what do you mean when you say it works fine? It doesn't work for me. It doesn't work with serve on Vite. When running serve there's an error:

Failed to resolve dependency: ngx-device-detector, present in 'optimizedDeps.include'

UPD: Actually, it seems the issue I mentioned is rather related to the fact that I am using NX with npm workspaces and ngx-device-detector was installed only in one of the apps and since it relied on a different version of angular it was installed into apps/projectname/node_modules and not into the root one. Probably Angular with Vite cannot get the deps from non-root node_modules, idk. But I resolved it by moving ngx-device-detector to the root package.json. And then I finally ran into the problem with the peerDependencies. Btw, @forrestlin2020 it can be bypassed using overrides in your package.json:

"overrides": {
    "ngx-device-detector": {
      "@angular/core": "$@angular/core",
      "@angular/common": "$@angular/common",
    }
  }

It works, but would be great to have the package updated too.

forrestlin2020 commented 3 months ago

@isoroka-plana

Thank you!

JaxonWright commented 3 months ago

I tried making a PR to add Angular 18 support but couldn't get past the problem of the outer package.json having the library itself as a dependency.

For now, you can add the following to your project's package.json as the current version does still work with ng18:

  "overrides": {
    "ngx-device-detector": {
        "@angular/common": "$@angular/common",
        "@angular/core": "$@angular/core"
    }
  }
ivanpopovicib commented 3 months ago

+1

AhsanAyaz commented 2 months ago

A new release (8.0.0) has been published now 🚀

clark-stevenson commented 2 months ago

Thanks @AhsanAyaz ! 😊

forrestlin2020 commented 2 months ago

@AhsanAyaz

Thanks!