LearnNewsExamplesServices
Frontmatter
id8859
titleEnforce ESM Worker Instantiation Globally
stateClosed
labels
bugaicore
assigneestobiu
createdAtJan 22, 2026, 12:48 AM
updatedAtJan 22, 2026, 12:54 AM
githubUrlhttps://github.com/neomjs/neo/issues/8859
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 22, 2026, 12:54 AM

Enforce ESM Worker Instantiation Globally

Closed v11.23.1 bugaicore
tobiu
tobiu commented on Jan 22, 2026, 12:48 AM

The hasJsModules check in src/worker/Manager.mjs and src/main/addon/ServiceWorker.mjs incorrectly assumes that dist/development and dist/production do not support ES modules. This causes blank pages as the new webpack builds output ESM bundles.

Changes:

  1. Update src/worker/Manager.mjs to always instantiate workers with {type: 'module'}.
  2. Refactor hasJsModules logic to primarily control file extensions (.mjs vs .js) and pathing, rather than module capability.
  3. Update src/main/addon/ServiceWorker.mjs similarly.
  4. Review src/remotes/Api.mjs to ensure path resolution logic remains correct under the new environment assumptions.
tobiu added the bug label on Jan 22, 2026, 12:48 AM
tobiu added the ai label on Jan 22, 2026, 12:48 AM
tobiu added the core label on Jan 22, 2026, 12:48 AM
tobiu referenced in commit 72bdde6 - "fix: Enforce ESM worker instantiation for all environments (#8859)" on Jan 22, 2026, 12:54 AM
tobiu assigned to @tobiu on Jan 22, 2026, 12:54 AM
tobiu
tobiu Jan 22, 2026, 12:54 AM

Input from Gemini 3 Pro:

✦ I have refactored src/worker/Manager.mjs, src/main/addon/ServiceWorker.mjs, and src/remotes/Api.mjs to enforce ESM worker instantiation across all environments.

Changes:

  1. Renamed hasJsModules to useMjsFiles to correctly reflect its purpose (file extension/path selection vs. module capability).
  2. Updated src/worker/Manager.mjs to always use {type: 'module'} when creating workers.
  3. Updated src/main/addon/ServiceWorker.mjs to always use {type: 'module'} when registering the service worker.
  4. Updated src/remotes/Api.mjs to use the renamed variable for consistency in path resolution.

This ensures that dist/development and dist/production builds, which are now ESM, are loaded correctly.

tobiu closed this issue on Jan 22, 2026, 12:54 AM