-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to use any other date library #333
Comments
The previous implementation was very vague and implicit, so it could very well be that the author of #329 didn't know other date back-ends like // app/app.js
import { setDateUtils } from 'ember-power-calendar';
import { dateUtils } from 'ember-power-calendar-date-fns';
setDateUtils(dateUtils); This way:
|
we can add also ember-power-calendar-date-fns in the switch case, but this package is very old and outdated... and must get an update, becaus it is using old dependency like ember-auto-import... I will try to make a PR in thr next days here and in ember-power-calendar-date-fns |
I would still consider using an API to set the date utils, compared to hardcoding another addon in the switch. The current setup forces people to use one of the hardcoded addons and disallows them from using any other Date library. What if, at some point, someone wants to create a fork and publish |
Maybe a completely explicit function is a good way to let the user choose its date adapter but a kind of automatic assignment when there is an imported date adapter is still a nice thing to have. Chartjs seems to have a good implementation for date libraries (I'm sure they support luxon and date-fns, didn't check for others) and they have a documented interface to make your own if you want to. Maybe their API interface for external date adapters can be a good starting point to define the interface for date adapters in this project. |
Yes API is a possible option, if it is embroider safe and addon v2 compatibile. The only problem is, that we never know which meta packages exists and if they are working after changes in this repo |
@ErikPelli could you provide any link? |
https://github.com/chartjs/Chart.js, It's vanilla JavaScript though Adapters:
Internally they call an explicit set function on chartjs |
maybe we can use initializer to register the external package, so the consumer app doesn't need to make any setup in app.js... |
Yep, since this is an ember-specific addon, it makes completely sense to use the available features instead of standard js like they do |
This isn't any different from not knowing which apps are using this addon, and if those apps still work after changes to this addon. That's why SemVer exists, to correctly communicate changes to the public API towards consumers (both apps and addons). Also, initializers are not really a recommended feature anymore. |
Is there really necessary to use ember-load-initializers? My plan was to use application initializer, which provides ember ot of the box. https://api.emberjs.com/ember/5.2/classes/Application/methods/initializer?anchor=initializer |
Initializers only run automatically because apps have |
@bertdeblock Okay thanks, is there any RFC, which tells us, that initializers are outdated and not anymore recommanded? I'm not really happy that app comsumers must do always manually steps to get run the addons, but if this is the new, recommanded way to go we can also change it. |
@bertdeblock created a PR, like you described (without initializer). import { registerDateLibrary } from 'ember-power-calendar';
import DateUtils from 'ember-power-calendar-moment';
registerDateLibrary(DateUtils); |
Just chiming in to say I've also hit this issue when updating to 0.20.2, I use the date-fns addon as well. |
PR for so we have known meta packages ready for realese. |
Recent update to ember-power-calendar version
0.20.0
merged the pull request #329 that in fact prevent the usage of any library different fromember-power-calendar-moment
andember-power-calendar-luxon
.Code extracted from the new
addon/utils.js
file:Actually the projects that I maintain rely on ember-power-calendar-date-fns adapter and the reason is simple: we migrated away from Moment a few months ago because they consider themself a legacy project now and
date-fns
is actually well maintained and fits our needs.I don't think that break the compatibility with external date libraries is a good solution, especially if one of the two available adapters is for a library that's no longer supported. In #300 someone mentioned also an usage with
dayjs
for example.Maybe the old
ember-power-calendar-utils
handling was really ancient and its removal is good, I don't know the reason of the removal, but create a new interface to use other adapters should be considered important now, and I hope to not be obliged to be stuck with0.19.0
forever because of the compatibility with date-fns.The text was updated successfully, but these errors were encountered: