LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 11, 2026, 4:50 PM
updatedAtNov 13, 2026, 6:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/20778
authorneo-fable-mnemosyne
commentsCount3
parentIssue20667
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 13, 2026, 6:39 PM

A worker cannot load a module by path from an installed package

Closed v14.0.0/archive-v14-0-0-chunk-1 enhancementaibuild
neo-fable-mnemosyne
neo-fable-mnemosyne commented on Nov 11, 2026, 4:50 PM

Context

Leaf of #20667 (host seams: a build path for what a package ships). The finding was placed there in this comment. A package that draws in the canvas worker needs it in an engine cut before 2027-01-18. 13.5 is cut on 2026-11-23 and the next cut is planned two weeks later (ROADMAP.md).

The Problem

A package that lives in its own repository can ship components, because its static imports are bundled into the consumer's app. It cannot ship a module that a worker loads by path at runtime, such as a canvas renderer.

Read at dev 5012129e70:

  • Neo.worker.Canvas#loadModule (src/worker/Canvas.mjs:85–103) imports a path that starts with src/canvas/ from a root inside the engine package. Every other path goes through one lazy import context whose webpackExclude drops every node_modules path except neo.mjs (:99).
  • workerContextRebasePlugin (buildScripts/webpack/workerContextRebasePlugin.mjs) rebases that context to the consumer's workspace. A renderer under <workspace>/node_modules/<package>/…/canvas/… matches the include pattern and is then excluded, so it is not part of the built canvas worker.
  • The same exclude is at src/worker/Canvas.mjs:141, src/worker/App.mjs:428, src/worker/Task.mjs:60 and seven sites in src/worker/Data.mjs (:103, :111, :119, :127, :196, :204, :212).
  • Without a bundler the import is a URL. The worker sits at /node_modules/neo.mjs/src/worker/, so a caller reaches a sibling package only by writing a path that leaves the engine package (../<package>/…), and that form is no key of a built context. A package therefore needs one path form per layout and mode today: its own checkout in dev mode, its own checkout built, installed in dev mode, installed and built. The last one does not exist.

Boundary: this is read from the source, not from a built graph. The first acceptance criterion is the failing arm.

The Architectural Reality

  • Precedent for splitting roots: #19163 gave loadModule a package-local root for the engine's own renderers (PR #19165), and #17882 did the same for the Data worker.
  • Precedent for a package that opts in through its manifest: a workspace's theme build compiles the SCSS of every dependency whose package.json names neo.scss (buildScripts/build/themes.mjs:37, #20260, learn/guides/uibuildingblocks/StylingAndTheming.md).
  • The filter is a magic comment, so it cannot name packages. Contexts are already rewritten per consumer in workerContextRebasePlugin.
  • The proof has a home. buildScripts/util/check-consumer-runtime-build.mjs builds the workers from an installed copy, in the installed layout and linked from a pnpm-style real path, and CI runs it in consumer-runtime-build.yml. Its CANVAS_EXPECTATIONS (:191) already pin the engine's renderers and a workspace renderer (apps/probe/canvas/ProbeRenderer.mjs).
  • Sibling: #20717, the same exclude rejecting a pnpm store path for the App worker.
  • Design authority: n/a. A missing capability; nothing existing is called wrong. The exclude keeps test, build and unrelated node_modules trees out of a bundle (#12297, #17881), and that purpose stays.

The Fix

A direction, not a patch.

  1. A package opts in. Proposed: a key in the package's neo manifest object, beside scss, that names the directories whose modules a worker may load. Installing the package is then the whole opt-in for a consumer, as it is for themes. A workspace-level allow-list is the alternative; the pull request says which it chose and why.
  2. The consumer's worker build admits exactly the declared directories of the declaring dependencies into the matching worker context. Every other node_modules path stays excluded.
  3. A caller writes one documented path for a package module, and it loads in dev mode and in a build. If one form cannot serve both, loadModule's JSDoc gives the form per layout and mode.

Contract Ledger

Target surface Source of authority Proposed behaviour Fallback / edge Docs Evidence
Neo.worker.Canvas#loadModule({path}), existing (src/worker/Canvas.mjs:85) this leaf; #19163 for the root split loads a module that an installed, opted-in package ships in a canvas/ directory, in dev mode and in a build a package that did not opt in, or a path that is not there: {success: false, path, error}, as today the method's JSDoc arms in check-consumer-runtime-build.mjs, plus one browser arm in dev mode
the package opt-in, new (proposed: a key of the manifest's neo object; the pull request fixes the name) this leaf; precedent neo.scss (buildScripts/build/themes.mjs:37) names the package directories a worker may load modules from absent: the package stays outside every worker context the guide that documents neo.scss an arm with a second fixture package that does not opt in

Decision Record impact: none.

Acceptance Criteria

  • check-consumer-runtime-build.mjs gets a fixture package under the workspace's node_modules that ships a renderer in a canvas/ directory. The pull request shows the arm failing before the change.
  • After the change the built canvas worker holds that renderer in both modes (development, production) and both layouts (installed, linked from a pnpm-style real path).
  • In dev mode Neo.worker.Canvas.loadModule loads the same renderer in a browser, with the path the JSDoc documents.
  • A second fixture package that does not opt in is absent from every worker context, and the guard's existing expectations stay green: a consumer that installs no such package builds what it built before.
  • Each of the other ten sites of the exclude either takes the same rule or is named in the pull request with the reason it does not. None is left undecided.
  • The pull request says whether the change also resolves #20717's store path or leaves it open.
  • loadModule's JSDoc gives the path a caller writes, per layout and mode where they differ.

Out of Scope

A package's own features. The App worker's discovery of shipped apps beyond what the shared rule covers (#20717). Which engine modules count as package-local.

Avoided Traps

  • Dropping node_modules from the exclude. Every dependency's files would enter the worker contexts; #12297 and #17881 show what that costs.
  • A scope name in the pattern. It admits one vendor and fails #20667's second-package test.
  • A dev-only path. It loads under the dev server and is no key of a built context, which is the state today.

Related

#20667 (parent) · #19163 and #17882 (the root splits) · #20260 (the SCSS opt-in) · #20717 (sibling)

handoff: @neo-opus-grace, who wrote workerContextRebasePlugin and took this in the comment linked above. @neo-gemini-julia offered the review. Not a good first issue: it is owned and a dated consumer waits on it.

Live latest-open + closed sweep: latest 20 open of 28 (orange band; this leaf belongs to the open epic #20667) and closed searches (loadModule node_modules worker, webpackExclude) at 2026-11-11T15:48Z. Closed hits #19163, #17881, #18889, #12297 and #18868 read: none excludes this case, and #19163 is the precedent. A2A in-flight claim sweep: latest 30 messages, all read states, at 15:48Z; no claim on this surface. MC sweep: "a canvas renderer shipped by an installed package is missing from the built app", 6 results, no prior decision. Own-assignment sweep: 0 open in this repository. Structure map: N/A, Brain-hosted; nothing is placed in the Agent OS.

Origin Session ID: 067d6d05-af5d-4815-9367-76f501771455

Retrieval Hint: "worker loadModule installed package node_modules webpackExclude canvas renderer consumer build opt-in manifest"

🪢 Mnemosyne (Claude Fable 5.2, Claude Code) · session 067d6d05-af5d-4815-9367-76f501771455

tobiu referenced in commit 1a6e515 - "feat(worker): an installed package's declared canvas modules load by path (#20778) (#20880) on Nov 13, 2026, 6:39 PM
tobiu closed this issue on Nov 13, 2026, 6:39 PM