dmtrKovalenko / date-io

Abstraction over common javascript date management libraries
MIT License
715 stars 92 forks source link

Missing tslib dependency? #248

Closed vinsonchuong closed 1 year ago

vinsonchuong commented 4 years ago

Hello! I'm currently using @date-io/dayjs@2.0.1 and I'm getting the following error:

Error: Cannot resolve dependency 'tslib'

I see the import in the compiled files build/index.esm.js and build/index.js, but there's no runtime dependency specified in package.json

favna commented 4 years ago

tslib is a dependency that comes standard with TypeScript and gets used in the build when the tsconfig has the option importHelpers set to true. The easiest solution is for you to npm install tslib / yarn add tslib (or write your app in TypeScript, which is better than regular JS anyway)

HeVictor commented 1 year ago

It appears this issue may still be occurring and is breaking this CodeSandbox demo that does not have a tslib dependency in itself. Is it still possible to consider adding a runtime dependency for tslib in the package.json within @date-io?

dmtrKovalenko commented 1 year ago

@HeVictor feel free to open a PR with the correct tslib version. I can quicly publish a new version if it will be ok to merge

LukasTy commented 1 year ago

@dmtrKovalenko I was also looking into possible solutions to https://github.com/mui/mui-x/issues/8205 I see two possible courses of action:

  1. add tslib as a dependency or a peer dependency to the hijri and jalaali packages
  2. bump target of the transpiled TS code to ES6 in order to reap the benefit of native support for class extending

  1. This is easiest to do, but I'm not a fan of this approach due to the need for users to have an additional dependency even though they might technically not need it.
  2. This would be the best but raises a question of minimum system support. Is there an explicit or preferred system support for @date-io libraries? I couldn't find one... Raising target to ES6 would no longer support IE11 and Opera Mini.
dmtrKovalenko commented 1 year ago

I think the minimum supported browsers should match latest http://mui.com (https://mui.com/material-ui/getting-started/supported-platforms/#browser) which explicitly declares that date picker can not support IE11 so I would probably bump a target.

But wait, why we need to add dependency only for 2 packages?

LukasTy commented 1 year ago

I think the minimum supported browsers should match latest http://mui.com

Well, that's a good point, but on the page you linked there is a link to browserlistrc file and specifies op_mini all as supported version and that is either an issue on MUI side (because it has even worse feature support than IE11) or we can't bump the target. 🤔

But wait, why we need to add dependency only for 2 packages?

Well, they are the only ones that have tslib import in their production (built) code (because they are extending base adapter classes): hijri & jalaali. Whereas other packages like dayjs do not have this dependency.

dmtrKovalenko commented 1 year ago

Ok clear so I think either option is ok.

HeVictor commented 1 year ago

Have updated my PR in #643 to go with option 1 for the time being

LukasTy commented 1 year ago

I've opened a PR changing the target of the built code to ES6.