-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Plugin requires as strings #2899
Comments
I think that also most (all) of plugins should define AFAIR there was a ticket for that in main repo. |
Does this issue could solve this: https://github.com/ckeditor/ckeditor5-image/issues/255? From @Reinmar's insights on why not including
would IMO allow to provide different implementation of |
|
Forget about the
I'd see this as "soft" dependency as opposite to "hard" (class taken from import). |
Confirmed and added to the next iteration. Since we rely right now in some places on these "loosen" dependencies, let's have better error reporting for them. |
Maybe I'm wrong here, but the Taking that code:
You'd have to load the
Maybe this is the place that can be changed to achieve a similar effect? We can provide a method that may throw if the plugin isn't defined yet. |
I think that it's good if it fails early, and |
One thing to remember is that plugins from |
BTW, this will not be that trivial to implement. The plugin which is required by its name may be a 3rd dependency in a chain of some other plugin deps, so basically, before loading anything, we need to scan the entire tree of dependencies and store those plugins in a map. I'm not sure whether we're doing this already so this feature may require a bit more refactoring. |
To my surprise this has limited support right now. What we lack is the human readable error - right now generic load error is thrown. What I think we lack right now is:
Do we need harder checking of dependencies? Like building dependency tree before instantiating editor? One plus would be such that before instantiating plugins we could load all required and then check if all are available so one could not worry about order of defining dependencies (by string) as such might be loaded by Class by other plugin later.
For starters I'd go with human-friendly errors and I'd refactor features "soft" dependencies so they would be in the The I'd go with loading plugins in two-step process (as describe earlier):
ps.: I might rethink it so I don't propose it as final |
Below is current state of dependencies:
From above I can see some inconsistencies or possible bugs:
As for refactoring:
Sorry for lengthy post :) @pjasiun & @oleq what do you think on the above? Also what should be the rule for requires? This look logical for me. Also I'd update this guide with what we agree on. (also the feature split part is obsolete now AFAIR). |
First of all, thanks for the great research! Second: my original post was not about making any big changes in the way the current dependencies works now, more about introducing new feature which might be useful in some cases. This is why I think that:
However, when it comes to the idea of having |
This boils down to how to deal with situations like this for which Also such constructs: Should it be enclosed in I would review current state and add such checks for plugins that are not needed. Also this ticket is about adding string requires (look your first post ;) ). The Adding those not needed plugins to the Anyway I would add them as "string" dependency to
|
We talked F2F with @jodator and agreed that it will be better if |
ps.: The below construct is valid in current code: static get requires() {
return [ 'Plugin' ];
} |
Other: Throw `editor.plugins.get()` error when the plugin is not loaded. Closes #148. BREAKING CHANGE: The `editor.plugins.get()` will now throw an error if the plugin is not loaded. Use `editor.plugins.has()` to check if plugin is available.
It's actually not. You cannot require a plugin by a string. It must be a function. |
Finally, I proposed to get rid of the concept of soft requirements as we don't use it frequently enough to make a difference: https://github.com/ckeditor/ckeditor5-core/issues/193. |
But you can: It will work as long as the required plugin is loaded. |
Sometimes we want to add a plugin to the editor which is already built. In such a case, we can not import requirements. We expect that they are already loaded.
However since
this.editor.plugins.get( 'Plugin' );
will returnundefined
if thePlugin
is not loaded, there will be no human-friendly error what is going on.This is why I think we should introduce strings in
requires()
function:Should enable
Plugin
if it is avaialbe or show a human-friendly error, if not.The text was updated successfully, but these errors were encountered: