[loader] Generate shared host module catalogue #214

Closed
opened 2026-06-02 09:43:25 +00:00 by steve · 0 comments
Owner

Problem

The renderer dependency exposure is manually maintained in packages/workspace/src/lib/deps.ts, while ESM import maps, CommonJS compatibility, registry validation, and plugin builds all need the same host-module policy.

Goal

Replace hand-maintained dependency exposure with a generated, allowlisted host-module catalogue that drives ESM import maps, CommonJS providers, shared externals, registry validation metadata, and developer diagnostics.

Scope

  • Add scripts/plugin-host-modules.config.json as the source of truth.
  • Add scripts/generate-plugin-host-modules.mjs.
  • Generate workspace host module metadata, import map JSON, CommonJS providers, shared externals, and API-side schema metadata.
  • Generate Electron sidecar host module metadata for the smaller sidecar dependency surface.
  • Add plugin-host:generate and plugin-host:check scripts.
  • Add tests that prove generation is deterministic and rejects invalid config.

Non-goals

  • Do not expose arbitrary app dependencies as public plugin APIs.
  • Do not delete deps.ts in this issue.
  • Do not implement plugin ESM execution yet.

Acceptance Criteria

  • Adding a public host module requires one config edit plus regeneration.
  • Generated outputs are deterministic.
  • Invalid exports, duplicate mappings, unsupported platforms, and accidental wildcard exposure fail generation.
  • The catalogue preserves essential current compatibility dependencies while marking private or deprecated surfaces explicitly.

Implementation Notes

  • Treat the config as an allowlist.
  • Generate package-export subpaths only for packages explicitly listed in config.
  • Include public, deprecated, platforms, replacement, and reason metadata where applicable.

Suggested Files or Specs To Inspect

  • spec/src/30-cross-package-contracts/plugin-runtime.md
  • spec/src/30-cross-package-contracts/plugin-registry.md
  • packages/workspace/src/lib/deps.ts
  • packages/workspace/src/lib/deps-shims.d.ts
  • packages/desktop-electron/src-electron/plugin-sidecar-child.ts
  • scripts/

Validation Commands

  • pnpm plugin-host:check
  • pnpm --filter @lapis-notes/api check:all
  • pnpm --filter @lapis-notes/workspace check:all
  • pnpm --filter @lapis-notes/desktop-electron check:all
  • pnpm check:all

Follow-up Tasks

Implementation Summary

Added the generated plugin host module catalogue, schema export, wrapper generation, shared externals, sidecar module list, and plugin-host check script from the shared config.

## Problem The renderer dependency exposure is manually maintained in `packages/workspace/src/lib/deps.ts`, while ESM import maps, CommonJS compatibility, registry validation, and plugin builds all need the same host-module policy. ## Goal Replace hand-maintained dependency exposure with a generated, allowlisted host-module catalogue that drives ESM import maps, CommonJS providers, shared externals, registry validation metadata, and developer diagnostics. ## Scope - Add `scripts/plugin-host-modules.config.json` as the source of truth. - Add `scripts/generate-plugin-host-modules.mjs`. - Generate workspace host module metadata, import map JSON, CommonJS providers, shared externals, and API-side schema metadata. - Generate Electron sidecar host module metadata for the smaller sidecar dependency surface. - Add `plugin-host:generate` and `plugin-host:check` scripts. - Add tests that prove generation is deterministic and rejects invalid config. ## Non-goals - Do not expose arbitrary app dependencies as public plugin APIs. - Do not delete `deps.ts` in this issue. - Do not implement plugin ESM execution yet. ## Acceptance Criteria - Adding a public host module requires one config edit plus regeneration. - Generated outputs are deterministic. - Invalid exports, duplicate mappings, unsupported platforms, and accidental wildcard exposure fail generation. - The catalogue preserves essential current compatibility dependencies while marking private or deprecated surfaces explicitly. ## Implementation Notes - Treat the config as an allowlist. - Generate package-export subpaths only for packages explicitly listed in config. - Include `public`, `deprecated`, `platforms`, `replacement`, and `reason` metadata where applicable. ## Suggested Files or Specs To Inspect - `spec/src/30-cross-package-contracts/plugin-runtime.md` - `spec/src/30-cross-package-contracts/plugin-registry.md` - `packages/workspace/src/lib/deps.ts` - `packages/workspace/src/lib/deps-shims.d.ts` - `packages/desktop-electron/src-electron/plugin-sidecar-child.ts` - `scripts/` ## Validation Commands - `pnpm plugin-host:check` - `pnpm --filter @lapis-notes/api check:all` - `pnpm --filter @lapis-notes/workspace check:all` - `pnpm --filter @lapis-notes/desktop-electron check:all` - `pnpm check:all` ## Related Issues ## Follow-up Tasks ## Implementation Summary Added the generated plugin host module catalogue, schema export, wrapper generation, shared externals, sidecar module list, and plugin-host check script from the shared config. <!-- backlog:task_id=TASK-PLUGIN-LOADER-002 source_spec=spec/src/30-cross-package-contracts/plugin-runtime.md -->
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lapis-notes/lapis#214
No description provided.