Closed ef4 closed 9 months ago
IIRC, optional peer dependencies has been something a lot of people has been waiting for ages.
What would that registerDateLibrary
do?
// addon/index.js
let dateLib;
export function registerDateLibrary(d) {
dateLib = d;
}
export function formatDate(d) {
if (!dateLib) {
throw new Error('ember-power-calendar needs ember-power-calendar-moment or ember-power-calendar-luxon');
}
return dateLib.formatDate(d);
}
// addon/helpers/power-calendar-format-date.js
-import { formatDate } from 'ember-power-calendar-utils';
+import { formatDate } from '..';
With the latest version (0.21.0) we have done change that the addon is fully embroider safe. The plan is also to bring this addon to a v2, when we have ember basic dropdown... ready for that
Opening this as a followup discussion to https://github.com/embroider-build/embroider/issues/134
I think the simplest path is to make the internal protocol between ember-power-calendar and its helper addons explicit.
For example, in ember-power-calendar-moment, we could have:
There is a fancier possible solution that uses
@embroider/macros
and would eliminate the need for separateember-power-calendar-luxon
andember-power-calendar-moment
packages, but I realized that it would need a thing from NPM that doesn't exist: optional peer dependencies. I'm hesitant to open that can of worms right now.