Closed Bug 1773603 Opened 2 years ago Closed 2 years ago

Cover *.js and *.jsm.js in the shim for ESM-ified module

Categories

(Core :: XPConnect, task, P1)

task

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

As pointed out in bug 1609269 comment #8, non-*.jsm files are also referred from out-of-tree.
That means:

  • we should keep the *.js extension
  • we should cover *.js case with the shim
  • we should directly migrate from *.js to .sys.mjs

also we need to cover .jsm.js

Summary: Cover *.js in the shim for ESM-ified module → Cover *.js and *.jsm.js in the shim for ESM-ified module
Attachment #9280607 - Attachment description: Bug 1773603 - Support resource URI with *.js extension in ESM shim. r?jonco! → Bug 1773603 - Support resource URI with *.js and *.jsm.js extension in ESM shim. r?jonco!
Summary: Cover *.js and *.jsm.js in the shim for ESM-ified module → Cover *.js in the shim for ESM-ified module
Summary: Cover *.js in the shim for ESM-ified module → Cover *.js and *.jsm.js in the shim for ESM-ified module

This patch adds the support for the following 2 cases, in addition to *.jsm to *.sys.mjs:

  • JSM file with *.js extension is converted to ESM with *.sys.mjs
    • e.g. services/sync/modules/main.js to services/sync/modules/main.sys.mjs
  • JSM file with *.jsm.js extension is converted to ESM with *.sys.mjs
    • e.g. devtools/client/performance-new/popup/background.jsm.js to devtools/client/performance-new/popup/background.sys.mjs

So, consumers that imports those modules with the current URL keeps working even if those files are renamed.
This should cover in-tree consumers (to make the migration easier, by making it smaller chunk), and out-of-tree consumers (extensions, etc).

Is there any other cases that I missed here, e.g. in devtools, newtab, remote, sync? also, is there any issue with the above?

Flags: needinfo?(sdowne)
Flags: needinfo?(poirot.alex)
Flags: needinfo?(markh)
Flags: needinfo?(jdescottes)

AFAIK, there is no official addon/code running in firefox that is hosted out of the tree for DevTools.
We have the "adp helper addon", but it doesn't run any JS and only distributes executables.

I think that the profiler no longer involves an addon and the profiler icon is now always managed by some in-tree code?

Otherwise, DevTools isn't using any special extension names and sticks to .jsm (for jsm) or .js (for common js modules).
Except in performance-new folder, where there is this .jsm.js trick for typescript.

Flags: needinfo?(poirot.alex) → needinfo?(felash)

Nothing to add on top of what Alex said for DevTools.
For remote/ I also don't think we have any out-of-tree consumer for any of our JSMs. Pinging :whimboo in case I am missing something.

Flags: needinfo?(jdescottes) → needinfo?(hskupin)

Yeah, we don't use any addon in the profiler / performance-new code now. The files *.jsm.js are jsm, the js suffix is to trick typescript to look at these files, as we can't otherwise instruct typescript to look at specific suffixes.

Flags: needinfo?(felash)

I'm not aware that there is any code outside of our tree that actually uses our JSM files under /remote.

Flags: needinfo?(hskupin)

I was wrong, there wasn't non-*.jsm file in newtab component.

Flags: needinfo?(sdowne)

That plan sounds great to me for the services/* modules, thanks.

Flags: needinfo?(markh)

Thank you all!
looks like this will cover most of the cases and we can go with it.

If there's any other issue (such as, .sys.mjs cannot be used for some reason), we can still keep the compatibility by making a thin wrapper with existing jsm filename, that exposes new ESM file's symbols.

Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/fe7b745e73f1
Support resource URI with *.js and *.jsm.js extension in ESM shim. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: