Closed Bug 1778042 Opened 2 years ago Closed 2 years ago

Investigate static list for JSM-to-ESM redirect

Categories

(Core :: XPConnect, task, P3)

task

Tracking

()

RESOLVED WONTFIX

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

The shim introduced by bug 1766761 redirects a load for .jsm to .sys.mjs if the .jsm file is not found.
This requires extra load, and also suppressing the error handling in network code (bug 1777641).

Given most of the migrations are going to be handled by ./mach esmify command (bug 1776870), we could have a static list of migrated JSMs.

In ./mach esmify command, what the command receives is the path to the file, and what needs to be in the static list is the URLs.
The command uses a map from URI to file path, that can be used to reverse-map from path to URI, and add the corresponding URI to the static list when migrating JSM files.

The problems are the following:

  • the map is incomplete
    • the list contains 1271 files, and 133 files aren't covered. either the URL is unknown, or not used with URI (testcase etc).
  • the map can be outdated
    • the map is hand-generated
Attached file testing patch (deleted) —

This patch implements a static list for known-to-be-ESMified files, and use it for redirecting.
(still uses retry-after-failure way for fallback)

It uses a plain text file for listing known URLs.
not yet integrated with ./mach esmify to update it automatically.

the other option is to generate the URL from EXTRA_JS_MODULES in moz.build and jar.mn files in the script, that is also useful in other purposes as well (linting, searchfox link, etc),
but I think it's overkill for this purpose, because of the complexity.

Now checking if I can generate the list of URIs from moz.build and jar.mn.
the issue here is that the set of URIs depends on configuration and also the prefix in resource URI (either gre or not) seems to depend on the application, and it's hard to check which URI is correct one.

Given bug 1777641 lands, this is no longer requirement.
We can revisit this if any performance issue arises.

Severity: -- → N/A
Priority: -- → P3

There is an issue with alias with chrome registration for jar file:

https://searchfox.org/mozilla-central/rev/287583a4a605eee8cd2d41381ffaea7a93d7b987/toolkit/components/formautofill/jar.mn#5-6

toolkit.jar:
% resource autofill %res/autofill/

https://searchfox.org/mozilla-central/rev/287583a4a605eee8cd2d41381ffaea7a93d7b987/layout/style/jar.mn#5,29

toolkit.jar:
...
% resource gre-resources %res/

The following URLs return the same file, and the latter is actually used, but there's no information which is expected.

  • resource://gre-resources/autofill/phonenumberutils/PhoneNumber.jsm
  • resource://autofill/phonenumberutils/PhoneNumber.jsm

So, having a list of URLs is almost impossible without extra data source.

prototype patch in bug 1776870 has a code that maps URI to file, that works for all JSMs.
https://bug1776870.bmoattachments.org/attachment.cgi?id=9284165

but it's only "URI => file path" direction.
"file path => URI" cannot be automated. we could choose shortest one, but there's no guarantee that shortest one is always used.

given above, closing for now.

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

Attachment

General

Created:
Updated:
Size: