Closed Bug 1612572 Opened 5 years ago Closed 2 years ago

Write a script to convert an already-ready JSM to ESM

Categories

(Core :: XPConnect, task, P3)

task

Tracking

()

RESOLVED FIXED

People

(Reporter: zbraniecki, Unassigned)

References

(Blocks 1 open bug)

Details

Once we have the JSM ready to be converted to ESM, we need a script to do that.

P3

Is this an XPConnect bug? kmag says yes. He will probably be the person to fix it when the time comes.

Priority: -- → P3

(In reply to Chris Peterson [:cpeterson] from comment #1)

P3

Is this an XPConnect bug? kmag says yes. He will probably be the person to fix it when the time comes.

I'm not sure exactly what the right component is, since this is about mass-changing JSM files across the entire tree. But if kmag thinks it's in the right place then happy to leave it here :).

We've been working on a few AST rewrites for other bugs at https://github.com/bgrins/jsm-rewrites and I believe we could automate the rewriting of exports to ESM format using something similar (that, or maybe eslint --fix and a custom rule) once a module is ready to be converted (fixed up with all the issues identified blocking bug 1308512), and we have initial support for ESM loading (bug 1432901).

Here's WIP scripts and rules https://github.com/arai-a/jsm-to-esm
for:

  • EXPORTED_SYMBOLS to export declarations
  • ChromeUtils.import to ChromeUtils.importESM
  • XPCOMUtils.defineLazyModuleGetters to ChromeUtils.defineESMGetters
  • top-level ChromeUtils.import to import declaration
  • rename file and modify moz.build etc

things not covered are:

  • process/window actors API call

process/window actors API call is also supported in https://github.com/arai-a/jsm-to-esm

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.