Once again, there have been discussions on the feasibility of adding
static analysis to our JS code, possibly as part of MozReview. As usual,
one of the main problems is that we are not using standard JS, so we
pretty much cannot use standard tools.

One of the main differences between mozilla-central JS and standard JS
is our module system. We use `Components.utils.import`, while the rest
of the world is using `require`-style modules. If we could get rid of
`Cu.import`, we would be a very large step closer towards standard JS.

Which begs the question: what's the point of `Cu.import` these days?

Yes, I'm aware that it isolates code in separate compartments, and that
there is a benefit to isolating add-on code from platform code. However,
it is pretty unclear to me that there is any benefit in separating
compartments inside mozilla-central, rather than, say, relying upon
static analysis and/or reviews to ensure that nobody modifies
`Object.prototype` in funky ways.

If we decide to abandon the guarantees provided by compartments to
isolate mozilla-central modules from each other, it's not hard to imagine:
- semi-automated rewrites that could convert mozilla-central code to
RequireJS-style modules, all sharing a single compartment (per process);
- a backwards compatible, compartment-isolating implementation of
`Cu.import` for the sake of add-ons.

There would also be side-benefits in terms of memory usage, which is
always good to have.

So, can anybody think of good reason to not do this?

Cheers,
 David
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to