[loader] Bootstrap renderer host import maps #216

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

Problem

Browser and Electron-renderer ESM plugin module graphs need host API imports such as obsidian and selected @lapis-notes/* exports to resolve before plugin modules are imported.

Goal

Expose stable host APIs to renderer ESM plugins through an app-owned import map generated from the shared host-module catalogue.

Scope

  • Generate or maintain wrapper modules under the workspace plugin-host area.
  • Generate host import map JSON from the shared catalogue.
  • Add workspace Vite or HTML transform logic that injects the import map before app and plugin module scripts.
  • Support both dev and production URLs.
  • Ensure production entries point at emitted assets.
  • Keep import maps host-owned and do not merge plugin-supplied maps in v1.

Non-goals

  • Do not allow arbitrary plugin-defined import maps.
  • Do not implement plugin asset serving in this issue.
  • Do not expose every workspace dependency as a public host module.

Acceptance Criteria

  • Test modules can import obsidian and selected host modules through the map.
  • Import map loading is early enough for plugin ESM imports.
  • Production build tests verify import map targets exist.
  • Web and Electron renderer receive the same host module policy.

Implementation Notes

  • Wrapper modules should import from stable package exports instead of arbitrary internal bundle chunks.
  • Import map injection must happen before dynamic ESM plugin imports.
  • Vite dev and production paths may differ, but the generated catalogue should remain the source of truth.

Suggested Files or Specs To Inspect

  • spec/src/30-cross-package-contracts/plugin-runtime.md
  • spec/src/20-packages/workspace/index.md
  • packages/workspace/vite.config.ts
  • packages/workspace/vite-plugin-lapis-plugin-host-import-map.ts
  • packages/web/vite.config.ts
  • packages/desktop-electron/vite.config.ts

Validation Commands

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

Follow-up Tasks

Implementation Summary

Bootstrapped renderer host import maps by generating shared-module wrappers/import-map JSON and injecting the import map in workspace, web, and desktop Vite entry HTML before app scripts execute.

## Problem Browser and Electron-renderer ESM plugin module graphs need host API imports such as `obsidian` and selected `@lapis-notes/*` exports to resolve before plugin modules are imported. ## Goal Expose stable host APIs to renderer ESM plugins through an app-owned import map generated from the shared host-module catalogue. ## Scope - Generate or maintain wrapper modules under the workspace plugin-host area. - Generate host import map JSON from the shared catalogue. - Add workspace Vite or HTML transform logic that injects the import map before app and plugin module scripts. - Support both dev and production URLs. - Ensure production entries point at emitted assets. - Keep import maps host-owned and do not merge plugin-supplied maps in v1. ## Non-goals - Do not allow arbitrary plugin-defined import maps. - Do not implement plugin asset serving in this issue. - Do not expose every workspace dependency as a public host module. ## Acceptance Criteria - Test modules can import `obsidian` and selected host modules through the map. - Import map loading is early enough for plugin ESM imports. - Production build tests verify import map targets exist. - Web and Electron renderer receive the same host module policy. ## Implementation Notes - Wrapper modules should import from stable package exports instead of arbitrary internal bundle chunks. - Import map injection must happen before dynamic ESM plugin imports. - Vite dev and production paths may differ, but the generated catalogue should remain the source of truth. ## Suggested Files or Specs To Inspect - `spec/src/30-cross-package-contracts/plugin-runtime.md` - `spec/src/20-packages/workspace/index.md` - `packages/workspace/vite.config.ts` - `packages/workspace/vite-plugin-lapis-plugin-host-import-map.ts` - `packages/web/vite.config.ts` - `packages/desktop-electron/vite.config.ts` ## Validation Commands - `pnpm plugin-host:check` - `pnpm --filter @lapis-notes/workspace check:all` - `pnpm --filter @lapis-notes/web check:all` - `pnpm --filter @lapis-notes/desktop-electron check:all` - `pnpm check:all` ## Related Issues ## Follow-up Tasks ## Implementation Summary Bootstrapped renderer host import maps by generating shared-module wrappers/import-map JSON and injecting the import map in workspace, web, and desktop Vite entry HTML before app scripts execute. <!-- backlog:task_id=TASK-PLUGIN-LOADER-004 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#216
No description provided.