Follow firefox ESMify for Bug 1308512
Firefox is currently working through converting its JSM modules to ESM
- Meta bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1308512
- Progress in mozilla-central: https://spidermonkey.dev/areweesmifiedyet/
- Documents: https://docs.google.com/document/d/1cpzIK-BdP7u6RJSar-Z955GV--2Rj8V4x2vl34m36Go/edit#
- Matrix channel for questions: #esmification:mozilla.org
According to the docs under "Compatibility Layer":
we’ve made it possible to only convert a JSM to ESM, without converting its consumers. Concretely, you can convert a file from a JSM to an ESM, without touching any of its consumers. In this case,
ChromeUtils.import
for*.jsm
or*.js
or*.jsm.js
URI is automatically redirected toChromeUtils.importESModule
for*.sys.mjs
, and the conversion of the importers can happen later.[...]
This compatibility layer will be kept until all in-tree and out-of-tree code is migrated to new APIs.
So we should be ok with changes from upstream :) for the time being.
There's also a new tool ./mach esmify
(under "JSM-to-ESM conversion Walkthrough" in the docs) which we might be able to use on our own files. Although I know thunderbird had to adapt it so we may have to do a similar thing https://bugzilla.mozilla.org/show_bug.cgi?id=1779047