Incoming JS module (JSM) / component loader changes
kmaglione at mozilla.com
Thu Aug 31 18:14:34 UTC 2017
A quick heads-up on some incoming changes to the JS component loader
that may affect some existing JSM or JS component code:
1) As of bug 1394556, all JS module and component scripts are
automatically compiled in strict mode. While I fixed all of the
resulting issues that showed up in automated tests, new issues may turn
up in code with incomplete test coverage. Please be on the lookout for
errors like "TypeError: this is null", "TypeError: setting a property
that has only a getter", and "ReferenceError: assignment to undeclared
variable", and if you see any, file bugs blocking bug 1394556.
2) Andrew McCreight has been working on changing the component loader to
load most modules and components into a single global, with each
module still getting its own top-level variable scope (similar to a
with() block). Most of the blockers for this have been resolved, and it
should hopefully be ready to land within the next week.
This change will significantly reduce the memory overhead of JS modules,
along with the performance overhead of creating dozens module globals at
startup, and of creating thousands of cross-compartment object wrappers
But it does so at the cost of decreased isolation among module scripts.
All (non-add-on) modules will now share prototypes for built-in objects.
It will be possible to define objects on the shared global that affect
all modules. getGlobalForObject will no longer return the root scope for
a module. In short, it's possible we will see subtle issues as a
result of this change (as we often saw on b2g, which its module loader
differed from the desktop module loader), so please be on the look-out
over the next few weeks.
More information about the firefox-dev