Open sholladay opened 9 years ago
I am thinking that r.js is doing a little too much work here automatically. While a config option could be added that disables this bad behavior, I think it makes more sense to push responsibility of this setup code to the user (via something akin to wrap
), if they are going to use a namespace. Then we don't have to hack around various assumptions like this. To make it easier, there could simply be a default for the wrap
-like option that does exactly what the existing code does.
Problem
My application (we'll call it
banana
, for sake of discussion), lives on a namespace.window.banana
, for example. Yet, that namespace is not fully under my control, due to the 3rd-party nature ofbanana
.When using the r.js optimizer with the
namespace: 'banana'
setting, andinclude
ing Alameda as I do here, the optimized file ends up having this at the top ...This is problematic for me, because
banana
already being defined as a truthy value (but without arequirejs
property) is the normal state of affairs for where my application will be loaded.Therefor, the
require = banana
code path is taken, and Alameda proceeds to treatrequire
(akabanana
) as its own configuration, since it was already defined as a truthy value.In other words, if left unaddressed, this is going to lead to my customers being able to control my Alameda config, when I don't want them to be able to do so.
Use Case
See my use case in #842 for more info.