Closed Bug 1548308 Opened 6 years ago Closed 3 years ago

Remove modules.json in favor of explicit import with ChromeUtils.import

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement, P3)

enhancement

Tracking

(firefox102 fixed)

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: mossop, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In bug 1312355 we wanted to help eslint identify the variables generated by a Cu.import call. Part of that involved adding an export lookup (modules.json) for cases where the import wasn't just a single variable named from the module name. I did this partly because when parsing a given js file identifying the source for the jsm it imports is v. hard and even if we knew where it was, parsing it to find the exports would also add to the time to lint.

But that file is generally not kept up to date, lots of people don't know about it.

It occurs to me that we do already parse jsm files when linting them, we could write a plugin that when linting a jsm file it verifies that the EXPORTED_SYMBOLS matches the modules.json entry and throw a descriptive error if not.

With the recent ChromeUtils.import changes, the need for modules.json has largely gone away. I think there's another couple of follow-ups that we could do to remove it completely (xref https://phabricator.services.mozilla.com/D16745#429110 and the comments below that).

I have recently noticed that there's eslint-plugin-import available, but that is only going to work with es6 modules, unless we fork it, or complete the switch to es6.

In some ways I don't really want to have an additional file for developers to update even if it is automatically checked. Maybe we could investigate switching to a fork of import or at least seeing how they determine it (and how expensive it would be to do time-wise).

Blocks: 1548309
Type: defect → enhancement
Priority: -- → P3

Bug 1765167 will deprecate Cu.import after rewriting all consumers, and then we can remove modules.json.

See Also: → 1765167

Also bug 1758481 that removes the consumer of 2nd parameter of ChromeUtils.import

See Also: → 1758481
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Summary: Verify that EXPORTED_SYMBOLS matches modules.json → Remove modules.json in favor of explicit import with ChromeUtils.import

Unfortunately worker's importScripts still requires modules.json, or a simple map from resource:// to actual path.

Depends on: 1766099

Now that importScripts consumers are gone, modules.json can be removed once in-tree Cu.import are removed

Depends on: 1765167, 1765156
See Also: 1765167
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: