Plugin modules with the same name cause unexpected GET-request if several plugins use same module name #1656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tmpl!foo/bar
xhtml!foo/bar
And both plugins uses method fromText() for evaluation. For example:
define('tmpl', ['text'], function(text) {
return {
load: function(name, require, load, conf) {
try {
var onLoad = function(data) {
load.fromText(data);
};
onLoad.error = function(e) {
load.error(e);
};
text.load(name + '.tmpl', require, onLoad, conf);
} catch (e) {
load.error(e);
}
}
};
});
The module with plugin defined like this:
define('tmpl!foo/bar', function () {
return function foo_bar_tmpl () {};
});
In that case async calls with various plugins works almost fine - evaluated code receives in callback successfully:
require(['tmpl!foo/bar'], function (bar) {
console.log(bar)
});
setTimeout(function() {
require(['xhtml!foo/bar'], function (bar) {
console.log(bar)
});
}, 1000);
But second call for 'xhtml!foo/bar' cause an unexpected GET request to foo/bar.js.
That's happened because module 'foo/bar' has in 'defined' since first call. But re-created not initialized in 'registry' in second call.