Context
My boundary review on #20863 (comment 6880574910) named this from reading the code, and promised an artifact probe. This is the probe: dev 3c9ef1039f's own transforms and identity guard, run over the real src/worker/Canvas.mjs in a workspace whose dist/esm exists:
emitted package branch: `../../../${path.slice(13)}.mjs` (unchanged by the transform)
loadModule({path: 'node_modules/widget/canvas/Renderer'}) requests: dist/widget/canvas/Renderer.mjs (exists: false)
emitted package copy: dist/esm/node_modules/widget/canvas/Renderer.mjs (exists: false)
findUnresolvableImports on that branch: no verdictPositive control: in the same run, the guard reports the stub tree's absent siblings and computed-root ../canvas/${path.slice(11)}.mjs. The package branch's root resolves to dist/, which every dist/esm build has, so it passes.
The Problem
Canvas#loadModule's node_modules/ branch climbs three levels from the worker file. From an installed engine's node_modules/neo.mjs/src/worker/, that lands in node_modules/. From dist/esm/src/worker/, it lands in dist/, outside both trees. Main has a layout switch for the same request; the Canvas worker has none.
The build never emits neo.canvasModules roots either. So even a corrected path would find no emitted copy, and loading the source copy would bring the source Engine into the Canvas worker. Neither the build nor its identity guard reports any of this.
The Architectural Reality
src/worker/Canvas.mjs loadModule(): src/canvas/ → ../canvas/…; node_modules/ → ../../../${path.slice(13)}.mjs; anything else → ../../${path}.mjs.
src/Main.mjs importAddonModule(): the Main thread's switch for package addons. Inside an installed engine (import.meta.url holds /node_modules/neo.mjs/) it imports ../../${modulePath}.mjs, from any other tree ../node_modules/${modulePath}.mjs. Both specifiers stay literal, so webpack resolves each as a context of its own.
buildScripts/build/esmodules.mjs admits declared neo.mainAddons roots only. buildScripts/util/declaredPackageRoots.mjs reads neo.canvasModules too, but nothing in the ESM build consumes it.
findUnresolvableImports() passes a computed specifier whose root directory exists. dist/ always exists.
- After #20956:
createEsmBuildPlan() and esmDestination() own every admission's destination.
- Design authority: n/a: the probe above shows a request for a file no build emits.
The Fix
- Give the Canvas worker's
node_modules/ branch the layout switch Main uses: in dist/esm it resolves under the emitted tree's node_modules/.
- Emit declared
neo.canvasModules roots through #20956's plan (esmDestination()), with their Engine edges rebased the way Main roots are.
Fail the build for a computed specifier whose root leaves dist/esm, instead of passing it because the directory exists. An absent root inside the tree keeps its current warning. Retired at intake, below.
Decision Record impact: none.
Intake — 14 November 2026, after #20956 and #20973
Drift probe fired: buildScripts/build/esmodules.mjs, buildScripts/util/esmBuildGraph.mjs and buildScripts/util/esmDistTransforms.mjs changed (#20956's plan, #20973's Main helper check). The premise holds at dev d6e427e7a7: the Canvas branch still climbs ../../../, and the build still hands the plan mainAddonPackageRoots() only.
Prescription, sharpened:
- The emitted Canvas worker's package root follows Main's emitted one.
rewriteEsmImports() already rewrites the emitted Main.mjs's computed package roots onto dist/esm/node_modules; it now rewrites Canvas.mjs's ../../../ root the same way. The source file needs no runtime switch: Main's exists for the engine repository's own layout, which installs no Canvas packages (canvasModuleContextPlugin). Webpack builds are untouched, and check-consumer-runtime-build.mjs's declared-canvas expectation stays their witness. Corrected during implementation: the first version of this intake named a runtime switch.
- The ESM build's declared roots become
neo.mainAddons plus neo.canvasModules, each entry tagged with its manifest key. The plan copies both, rewriteEsmImports() rebases both onto the emitted Engine, and #20973's outside-root helper check covers Canvas roots too, naming the declaring key in its remedy.
- AC-3 is retired. A computed root that leaves
dist/esm is exactly the dormant installed-layout branch that Main carries, and that the Canvas worker carries after fix 1. The identity guard cannot tell a switch's dormant branch from a live one, so failing such a root would fail every build. After fix 1, no live branch leaves the tree.
Prescription checked: src/worker/Canvas.mjs owns the runtime path; buildScripts/build/esmodules.mjs with buildScripts/util/esmBuildGraph.mjs own admission. Sophie owns the plan and Main admission (#20821, #20956); the fork is with her.
Contract Ledger
| Target surface |
Source of authority |
Proposed behaviour |
Fallback / edge |
Docs |
Evidence |
Neo.worker.Canvas#loadModule, node_modules/ paths (existing) |
rewriteEsmImports()' rewrite of the emitted Main roots |
In dist/esm, the emitted worker resolves a package under the emitted tree's node_modules/; source and webpack builds are unchanged |
Unknown paths fail as today |
rewriteEsmImports JSDoc |
Unit (real build: the emitted worker loads the emitted copy) |
ESM build, neo.canvasModules roots (new admission) |
declaredPackageRoots.mjs |
Copied into dist/esm/node_modules/<package>/…, Engine edges rebased onto the emitted Engine, outside-root helpers checked as Main roots are |
An undeclared package stays unadmitted |
learn/guides/advanced/CanvasArchitecture.md |
Unit (real build, identity read) |
| ESM build's outside-root helper refusal (#20973) |
esmBuildGraph.mjs |
The remedy names the declaring key (neo.mainAddons or neo.canvasModules) |
— |
MainThreadAddons.md |
Unit |
Acceptance Criteria
Out of Scope
Main addons (#20963); the App static graph (#20863); the runtime URL redesign (Discussion #17886).
Related
#20863 / #20956 (the plan this reuses) · #20778 (the runtime package paths, my seam) · #20963 (the Main-root twin) · #20821 · #20667 (parent)
Ownership: self-assigned (Grace, owner of #20778's runtime path). Blocked by #20863.
Live latest-open + closed sweep: checked latest 20 open (50 open, orange band) + closed search ("Canvas loadModule dist/esm package canvasModules": no hits) and open search ("canvasModules dist/esm", "Canvas dist/esm": #20863, #20963, both read) at 2026-11-14T19:15Z; A2A last 15 messages: no overlapping claim; Memory Core problem-noun search: only my own #20778 work; own assignments (#20952, #20911, #20884, #20790) do not overlap. No equivalent found.
Retrieval Hint: "dist/esm Canvas worker loadModule package path outside emitted tree canvasModules"
Context
My boundary review on #20863 (comment 6880574910) named this from reading the code, and promised an artifact probe. This is the probe:
dev3c9ef1039f's own transforms and identity guard, run over the realsrc/worker/Canvas.mjsin a workspace whosedist/esmexists:emitted package branch: `../../../${path.slice(13)}.mjs` (unchanged by the transform) loadModule({path: 'node_modules/widget/canvas/Renderer'}) requests: dist/widget/canvas/Renderer.mjs (exists: false) emitted package copy: dist/esm/node_modules/widget/canvas/Renderer.mjs (exists: false) findUnresolvableImports on that branch: no verdictPositive control: in the same run, the guard reports the stub tree's absent siblings and
computed-root ../canvas/${path.slice(11)}.mjs. The package branch's root resolves todist/, which everydist/esmbuild has, so it passes.The Problem
Canvas#loadModule'snode_modules/branch climbs three levels from the worker file. From an installed engine'snode_modules/neo.mjs/src/worker/, that lands innode_modules/. Fromdist/esm/src/worker/, it lands indist/, outside both trees. Main has a layout switch for the same request; the Canvas worker has none.The build never emits
neo.canvasModulesroots either. So even a corrected path would find no emitted copy, and loading the source copy would bring the source Engine into the Canvas worker. Neither the build nor its identity guard reports any of this.The Architectural Reality
src/worker/Canvas.mjsloadModule():src/canvas/→../canvas/…;node_modules/→../../../${path.slice(13)}.mjs; anything else →../../${path}.mjs.src/Main.mjsimportAddonModule(): the Main thread's switch for package addons. Inside an installed engine (import.meta.urlholds/node_modules/neo.mjs/) it imports../../${modulePath}.mjs, from any other tree../node_modules/${modulePath}.mjs. Both specifiers stay literal, so webpack resolves each as a context of its own.buildScripts/build/esmodules.mjsadmits declaredneo.mainAddonsroots only.buildScripts/util/declaredPackageRoots.mjsreadsneo.canvasModulestoo, but nothing in the ESM build consumes it.findUnresolvableImports()passes a computed specifier whose root directory exists.dist/always exists.createEsmBuildPlan()andesmDestination()own every admission's destination.The Fix
node_modules/branch the layout switch Main uses: indist/esmit resolves under the emitted tree'snode_modules/.neo.canvasModulesroots through #20956's plan (esmDestination()), with their Engine edges rebased the way Main roots are.Fail the build for a computed specifier whose root leavesRetired at intake, below.dist/esm, instead of passing it because the directory exists. An absent root inside the tree keeps its current warning.Decision Record impact: none.
Intake — 14 November 2026, after #20956 and #20973
Drift probe fired:
buildScripts/build/esmodules.mjs,buildScripts/util/esmBuildGraph.mjsandbuildScripts/util/esmDistTransforms.mjschanged (#20956's plan, #20973's Main helper check). The premise holds atdevd6e427e7a7: the Canvas branch still climbs../../../, and the build still hands the planmainAddonPackageRoots()only.Prescription, sharpened:
rewriteEsmImports()already rewrites the emittedMain.mjs's computed package roots ontodist/esm/node_modules; it now rewritesCanvas.mjs's../../../root the same way. The source file needs no runtime switch: Main's exists for the engine repository's own layout, which installs no Canvas packages (canvasModuleContextPlugin). Webpack builds are untouched, andcheck-consumer-runtime-build.mjs's declared-canvas expectation stays their witness. Corrected during implementation: the first version of this intake named a runtime switch.neo.mainAddonsplusneo.canvasModules, each entry tagged with its manifest key. The plan copies both,rewriteEsmImports()rebases both onto the emitted Engine, and #20973's outside-root helper check covers Canvas roots too, naming the declaring key in its remedy.dist/esmis exactly the dormant installed-layout branch that Main carries, and that the Canvas worker carries after fix 1. The identity guard cannot tell a switch's dormant branch from a live one, so failing such a root would fail every build. After fix 1, no live branch leaves the tree.Prescription checked:
src/worker/Canvas.mjsowns the runtime path;buildScripts/build/esmodules.mjswithbuildScripts/util/esmBuildGraph.mjsown admission. Sophie owns the plan and Main admission (#20821, #20956); the fork is with her.Contract Ledger
Neo.worker.Canvas#loadModule,node_modules/paths (existing)rewriteEsmImports()' rewrite of the emitted Main rootsdist/esm, the emitted worker resolves a package under the emitted tree'snode_modules/; source and webpack builds are unchangedrewriteEsmImportsJSDocneo.canvasModulesroots (new admission)declaredPackageRoots.mjsdist/esm/node_modules/<package>/…, Engine edges rebased onto the emitted Engine, outside-root helpers checked as Main roots arelearn/guides/advanced/CanvasArchitecture.mdesmBuildGraph.mjsneo.mainAddonsorneo.canvasModules)MainThreadAddons.mdAcceptance Criteria
neo.canvasModulesbuilds todist/esm. The emitted Canvas worker loads the package module fromdist/esm/node_modules/<package>/…, and that module reaches the emitted CoreBase: an identity read, not a mount.node_modules/<package>/….A computed specifier whose root leavesRetired at intake (see Intake, point 3).dist/esmfails the build, naming the importer. An absent root insidedist/esmstays a warning.Out of Scope
Main addons (#20963); the App static graph (#20863); the runtime URL redesign (Discussion #17886).
Related
#20863 / #20956 (the plan this reuses) · #20778 (the runtime package paths, my seam) · #20963 (the Main-root twin) · #20821 · #20667 (parent)
Ownership: self-assigned (Grace, owner of #20778's runtime path). Blocked by #20863.
Live latest-open + closed sweep: checked latest 20 open (50 open, orange band) + closed search ("Canvas loadModule dist/esm package canvasModules": no hits) and open search ("canvasModules dist/esm", "Canvas dist/esm": #20863, #20963, both read) at 2026-11-14T19:15Z; A2A last 15 messages: no overlapping claim; Memory Core problem-noun search: only my own #20778 work; own assignments (#20952, #20911, #20884, #20790) do not overlap. No equivalent found.
Retrieval Hint: "dist/esm Canvas worker loadModule package path outside emitted tree canvasModules"