Closed Bug 1558940 Opened 6 years ago Closed 3 years ago

Worker requires should support relative paths

Categories

(Toolkit :: General, task, P5)

task

Tracking

()

RESOLVED FIXED
108 Branch
Tracking Status
firefox108 --- fixed

People

(Reporter: jlast, Assigned: ochameau)

References

Details

Attachments

(1 file)

Currently, worker requires support absolute resource paths

importScripts("resource://gre/modules/workers/require.js");
const { createTask } = require("resource://devtools/shared/worker/helper.js");

It would be great if we could add a builder pattern similar to DevTools Browser loader that lets us specify a baseUri.

const { require } = BrowserLoader({
    baseURI: "resource://devtools/client/debugger",
    window
});
require('./src/main') ;

This is particularly useful now because the Debugger's workers are currently using commonjs requires and are being bundled via webpack source-map.js

Bugbug thinks this bug is a enhancement, but please change it back in case of error.

Type: defect → enhancement
Type: enhancement → task
Priority: -- → P5

We're moving to ES6 modules, and away from require, so this issue seems obsolete.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WONTFIX

Actually, this would be trivial to implement and would help me land an incremental steps toward ES6 modules in devtools.

In the debugger, we are currently using webpack to craft bundles as it is too complex to use commonjs in workers because of this limitation.
Using commonjs (like all other code in devtools) instead of webpack bundles is actually going to help move all devtools codebase from commonjs to ESM.

So I'm willing to add this feature. It will also help wait for ESM support in workers. We can keep using commonjs until this is implemented.

Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Severity: normal → S3
Assignee: nobody → poirot.alex
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a1410df016b8 [devtools] Support relative require path in worker commonjs loader. r=arai
Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: