I was reading through this thread: https://github.com/montagejs/montage/issues/1039 and I had a few questions:
Will the function require eventually be replace by mr?
If yes, is there a branch of montage that I can use that currently does this?
And... will we now be able to use Mr with RequireJS?
Thanks in advance,
Indeed, it is our intention to use the variable name
mr instead of
require for the global application module loader in the next release of MontageJS. This should make it possible to use RequireJS alongside MontageJS without interference. Stand-alone Mr (without Montage) does not create a global variable and can already be used multiple times on a single page without interfering with other instances of itself or other module loaders.
To make this possible, we need to merge pull request https://github.com/montagejs/montage/pull/1482 and make a new release. That pull request was waiting for work in the
montage-testing package which has now been merged. I will try to land that now, and Benoît intends to help merge the latest Mr and vet the new master so we can get this onto npm soon.
Thank you for the fast response! I see the changes in GitHub; are more changes pending? Or is it safe to now use RequireJS with Mr? I guess I'm a little confused because in some places you are still using the variable name require and in some places you are using mr?
In a CommonJS module,
require is a local variable injected by the module system, distinct from the global
require used by RequireJS. The two can be safely used together. To access the global require within a module, you must explicitly reference
window.require for RequireJS and
window.mr for MontageJS.