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

Plugin modules with the same name cause unexpected GET-request if several plugins use same module name #1656

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aleksey-a-maltsev
Copy link

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.

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.
@aleksey-a-maltsev aleksey-a-maltsev changed the title Several plugins use same module name. For example: Plugin modules with the same name cause unexpected GET-request if several plugins use same module name. Apr 12, 2017
@aleksey-a-maltsev aleksey-a-maltsev changed the title Plugin modules with the same name cause unexpected GET-request if several plugins use same module name. Plugin modules with the same name cause unexpected GET-request if several plugins use same module name Apr 12, 2017
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

Successfully merging this pull request may close these issues.

None yet

1 participant