iamkun / iamkun/dayjs

Plugins dependency

Open
#456 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to create a new plugin to retrieve how many weeks has an specific year.

The algorithm relies on methods that are already created in others plugins (`daysInYear`, `isLeapYear`, `dayOfYear`). How we should treat this dependency?

I see various options

1. The dependant plugin (`weeksInYear` in this case) also includes the other plugins. The worst case scenario would be that some plugins are loaded twice. If this would be the case, a warning message could be shown in the console saying something like `The plugin .... has been loaded twice`.
2. If the others plugins aren't loaded, do not load this one, and show an error message through console saying something like `This plugins .... must be included in order to this plugin works`
3. Duplicate the functionality of the plugins inside the dependant. This would make the plugin agnostic to other plugins, but the amount of code would increase, I think, needlessly.

Since the main goal of this lib is to remain small, my preferred option is the 1st one. Any thoughts?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.