-
Notifications
You must be signed in to change notification settings - Fork 499
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
Multiple plugins applied to a dependency #9
Comments
It is Option C, because the resourceId (IDs are If that makes sense, I can add that to the API page, and send a note the amd-implement list about the update. |
Just confirming that curl.js operates like RequireJS: option C. IIRC, dojo On Tue, Feb 19, 2013 at 10:42 PM, James Burke [email protected]:
|
Cool, that seems quite sensible. Thank you for the clarification! |
Confirmed.
|
In the Loader Plugins spec, I would find it useful to spell out what
happens when multiple plugins are chained.
For example, consider a dependency of the form,
My first question is, is this allowed?
If it is allowed, what order should the plugin load() and normalize()
methods be called and what should be given as the resource id in each
invocation? It seems to me that there are a few possibilities:
Option A, plugins are applied from right-to-left and the normalized
dependency name is passed to the next plugin:
bar.normalize('../resources/thing', fn);
bar.load('/root/resources/thing', require, load);
foo.normalize('bar!/root/resources/thing', fn);
foo.load('bar!/root/resources/thing', require, load);
Option B, plugins are applied from right-to-left and each plugin gets
the original resource id:
bar.normalize('../resources/thing', fn);
bar.load('/root/resources/thing', require, load);
foo.normalize('../resources/thing', fn);
foo.load('/root/resources/thing', require, load);
Option C, the leftmost plugin is applied and is responsible for
interpreting the other plugin applications:
foo.normalize('bar!../resources/thing', fn);
foo.load('bar!/root/resources/thing', require, load);
In my personal option Option A is the way to go. I think that Option
B does not make much sense and that Option C, while providing the most
flexibility, pushes unnecessary work onto plugin implementations.
There is a complication with Option A though, which is that the Plugins
API does not appear to allow a loaded dependency to be passed from
plugin to plugin - only the dependency name can be forwarded. That
could make it difficult to implement a dynamic, chainable plugin.
Is there precedent for one of these options in the RequireJS
implementation?
The text was updated successfully, but these errors were encountered: