Skip to content
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

Plugins dependency #456

Open
naulacambra opened this issue Jan 16, 2019 · 6 comments
Open

Plugins dependency #456

naulacambra opened this issue Jan 16, 2019 · 6 comments

Comments

@naulacambra
Copy link
Contributor

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?

@iamkun
Copy link
Owner

iamkun commented Jan 16, 2019

Maybe we could add a subfolder common under plugins.

And import the duplicated functions from this folder.

Like isLeapYear function could be used in plugin isLeapYear and DaysInYear

1st one is also reasonable.

@naulacambra
Copy link
Contributor Author

Maybe we could add a subfolder common under plugins.

It's fine for me. I'll try this, and if there are any changes, I'll change my PR

@iamkun
Copy link
Owner

iamkun commented Jan 16, 2019

How about deal with #364 together.

So that we could change the plugin folder at the same time.

Any thoughts?

also there's #418 as a reference, not sure if I should merge this pr.

@naulacambra
Copy link
Contributor Author

Sorry, but I don't see why grouping shared methods along some plugins, might affect theirs typescript definiton.

I mean, what I've understood is, under the plugin folder will be a common folder, with methods that will be used by more than one plugin.

plugins
└── advancedFormat
└── buddhistEra
....
└── common
         └── isLeapYear.js
         └── daysInYear.js
          ....

But they won't be exported as a plugin, but used by the plugins that will be exported.

Am I misunderstanding or missing something?

@iamkun
Copy link
Owner

iamkun commented Jan 16, 2019

No, you are correct.

What I really mean is as we are updating plugin's folder design, why not just consider the related issue that need change folder as well. Maybe we can fix both.

@naulacambra
Copy link
Contributor Author

What I really mean is as we are updating plugin's folder design, why not just consider the related issue that need change folder as well. Maybe we can fix both.

Ok, makes sense.

I'll mention this on the other issue and see what comes out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants