Architecture - Thoughts on require implementation

38 views
Skip to first unread message

Tom Ortega II

unread,
Nov 21, 2012, 9:59:31 AM11/21/12
to mont...@googlegroups.com
I think we already covered this with https://github.com/montagejs/montage/issues/1039 and in the irc channel, but just wanted to make sure.

Isn't it dangerous to assume that there are no other instances of require, exports or module in the global scope? I've already seen how trying to use the Aloha editor by including their require will confuse line 60 of montage.js because require is defined byt exports and module are not. Sadly, the require that is defined is not the one you think you created.

Kris Kowal

unread,
Nov 26, 2012, 12:59:11 PM11/26/12
to mont...@googlegroups.com
Yeah. I’m going to fix this. Montage will drop `montageRequire` and `montageApplicationRequire` onto the global for use in the debugger only.

Internally, we should use require.getPackage({name}) to get the require function of any loaded package. I’ll consider injecting an "application" alias into the named package memo so we can use require.getPackage({name: "application"}) instead of window.require, though I think we should just remove all usage of "window.require" outright. We should *never* use a default "require" because eventually the scenario change and working code will break.

Kris Kowal
Reply all
Reply to author
Forward
0 new messages