joanllenas / ngx-date-fns

⏳ date-fns pipes for Angular
163 stars 14 forks source link

Support date-fns-tz #331

Closed vhdirk closed 2 years ago

vhdirk commented 4 years ago

It'd be cool if you could also format timezone-aware dates. For that you need the format function from date-fns-tz.

I'm willing to create a PR, but I wanted to check if/how you'd integrate a feature like that.

joanllenas commented 4 years ago

Hi @vhdirk, thanks for your suggestion. What bothers me is adding another mandatory dependency to the library. I'm not 100% sure about this, but let me take a look first, I haven't used this library myself.

LayZeeDK commented 3 years ago

What bothers me is adding another mandatory dependency to the library. I'm not 100% sure about this, but let me take a look first, I haven't used this library myself.

You could add a sub-module in a sub-folder by adding a package.json file like this one:

{
  "name": "ngx-date-fns/tz",
  "private": true,
  "ngPackage": {
    "lib": {
      "entryFile": "./src/public-api.ts"
    }
  },
  "peerDependencies": {
    "@angular/common": ">=8",
    "@angular/core": ">=8",
    "date-fns": ">=2",
    "date-fns-tz": ">=2"
  }
}
joanllenas commented 3 years ago

Thank's @LayZeeDK, I had no idea this could be done. Researching right know 👍

LayZeeDK commented 3 years ago

Example here: https://github.com/ng-packagr/ng-packagr/blob/master/integration/samples/secondary/sub-module/package.json

LayZeeDK commented 3 years ago

Docs here: https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md

joanllenas commented 3 years ago

I also found this very detailed article: https://medium.com/tunaiku-tech/creating-secondary-entry-points-for-your-angular-library-1d5c0e95600a I will look into all of this more thoroughly next weekend.

joanllenas commented 2 years ago

Hey, It's been a long time since this was posted and there hasn't been much interest in this. I'm closing the issue. Thanks!

LayZeeDK commented 2 years ago

As it turns out, having dependencies in a secondary entry point isn't supported by any package managers so it wouldn't have made a difference. There are ways to mark peer dependencies as optional in the primary entry point's package.json file though.