Allow namespacing the loader #78
Comments
What do you think, @ipeychev? |
We could go with a |
@yuchi You mean
@jbalsas Was that "namespace" reassignment proposed by a real client? I'm trying to figure out what would be the benefits for a company, let's say Google, to have |
Hey @ipeychev, I was just trying to expose it in a general way. The real client in this case is Liferay Portal. As hard as we (specially you) tried (and suceeded) to create a fully compliant amd loader, the problem is that a lot of the existing web is not 😢 . We are having a lot of problems with clients upgrading and seeing their old code behave in unexpected ways in the presence of our loader. For this reason, our general plan could be summarized as:
I want to keep the default standard behaviour. Expose Does it make sense? PS: I don't think the |
@ipeychev it would re-assign the previous values and return a |
We currently expose three things: a Maybe what @jbalsas proposes would be the best one - a
Any additional comments, arguments agains this or some other proposals? Thanks, |
Hey @ipeychev, this sounds good to me, I was actually going to ask that namespace be an array, so we could pass everything in just one setting, but your proposal sounds even better. If I understand it correctly: // Default behaviour
console.log(window.Loader, window.define, window.require); // Loader, function, function __CONFIG__.namespace = "Liferay";
// exposeGlobal = true should be the default
// __CONFIG__.exposeGlobal = true;
console.log(window.Liferay.Loader, window.Liferay.define, window.Liferay.require); // Loader, function, function
console.log(window.Loader, window.define, window.require); // [undefined|Loader]?, function, function __CONFIG__.namespace = "Liferay";
__CONFIG__.exposeGlobal = false;
console.log(window.Liferay.Loader, window.Liferay.define, window.Liferay.require); // Loader, function, function
console.log(window.Loader, window.define, window.require); // undefined, undefined, undefined The only thing unclear to me is wether we should expose as global the PS: One other thing I don't like about the |
The code you wrote is correct. The argument against For backward compatibility, we should expose Thanks, |
You're right, and we're actually using it to manually configure some additional modules via |
Okay then. @yuchi, do you have something else to add before we go with this approach? |
Okay then, all clear. So, some volunteer to write this small piece of code and to see his name written with golden letters in the history of the mankind or I shall do it? Thanks, |
Hahaha... I can take care of this and send it your way, unless @yuchi wants to become a contributor 😉 |
I’m just a bystanding stalker, don’t worry about me. |
Hey @jbalsas, May I ask if you are going to send the PR? Otherwise I will do it. Thanks, |
Hey @ipeychev, @brunobasto was going to take over this since I got pulled to other stuff, but he also got re-prioritized 😢 I'll try to get it done right now, and otherwise let you know so you can work on it. Thanks! |
Hey @ipeychev, I look briefly into it today, and I'm not sure I'll get it right without messing up the templates. I'd appreciate if you could work on this and I'll "just" deal with the integration 😢 |
Fixed in v1.5.5 |
Thanks so much!!!! |
So a question about this fix--if I am merely interested in kicking the custom AMD loader out of the global namespace, and don't really need/want to use the custom module environment it provides, how would you recommend that I set the "CONFIG.exposeGlobal" (presumably in a standard portlet?) |
Hey @mfreeman-xtivia, I actually didn't see this... is this answered by #79 (comment)? |
yes thanks |
Currently, the loader always exposes a global
require
anddefine
methods. This causes some not-so-unexpected interoperability problems with other libraries that either present an anonymous umd wrapper or contain their own loader implementation (see Dojo).To solve this issues, it would be nice to be able to configure the namespace where the loader methods are exposed.
With this option, the loader can be exposed globally by default and hidden behind a namespace if a specific project requires it.
The text was updated successfully, but these errors were encountered: