[loader] Baseline tests and runtime selector #213

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

Problem

The dual ESM/CommonJS loader work changes plugin runtime selection and diagnostics. Current CommonJS behavior needs baseline coverage before loader semantics move, and runtime entry selection needs one shared selector instead of being spread across PluginManager.

Goal

Lock current CommonJS behavior, extend Lapis runtime metadata with structured entries, and centralize runtime entry selection without enabling ESM execution yet.

Scope

  • Add or extend tests for renderer CommonJS loading, local CommonJS module graphs, sidecar facade behavior, missing dependency diagnostics, and current runtime selection.
  • Extend LapisExtensionManifest.runtime with structured entries while preserving legacy workspace, desktop, and trustedDesktop string fields.
  • Add selectPluginRuntimeEntry() and route existing plugin-manager runtime selection through it.
  • Add diagnostics for selected host, selected format, entry path, fallback path, and shared dependencies.

Non-goals

  • Do not add browser ESM execution in this issue.
  • Do not remove Obsidian-compatible main.js behavior.
  • Do not shrink the existing workspace dependency bag yet.

Acceptance Criteria

  • Existing Obsidian/CommonJS plugins still load unchanged.
  • Structured runtime entry metadata validates and appears in diagnostics.
  • Selector tests cover workspace, Electron renderer, Electron sidecar, legacy runtime fields, Obsidian main.js, and explicit fallback behavior.
  • Loader behavior has safety coverage before ESM execution is introduced.

Implementation Notes

  • Preserve backward compatibility with manifest-only Lapis extensions.
  • Keep the selector in @lapis-notes/api so registry, loader, diagnostics, and future hosts share the same rules.
  • Treat invalid runtime paths and unsupported formats as actionable diagnostics.

Suggested Files or Specs To Inspect

  • spec/src/30-cross-package-contracts/plugin-runtime.md
  • spec/src/30-cross-package-contracts/plugin-host-boundary.md
  • packages/api/src/lib/lapis-extension.ts
  • packages/api/src/lib/plugin-manager.ts
  • packages/api/src/lib/__tests__/plugin-manager.test.ts

Validation Commands

  • pnpm --filter @lapis-notes/api check:all
  • pnpm check:all

Follow-up Tasks

Implementation Summary

Added baseline runtime-entry selection coverage and manager preflight diagnostics for structured Lapis runtime entries, legacy runtime strings, Obsidian main.js fallback, and manifest-only extensions.

## Problem The dual ESM/CommonJS loader work changes plugin runtime selection and diagnostics. Current CommonJS behavior needs baseline coverage before loader semantics move, and runtime entry selection needs one shared selector instead of being spread across `PluginManager`. ## Goal Lock current CommonJS behavior, extend Lapis runtime metadata with structured entries, and centralize runtime entry selection without enabling ESM execution yet. ## Scope - Add or extend tests for renderer CommonJS loading, local CommonJS module graphs, sidecar facade behavior, missing dependency diagnostics, and current runtime selection. - Extend `LapisExtensionManifest.runtime` with structured `entries` while preserving legacy `workspace`, `desktop`, and `trustedDesktop` string fields. - Add `selectPluginRuntimeEntry()` and route existing plugin-manager runtime selection through it. - Add diagnostics for selected host, selected format, entry path, fallback path, and shared dependencies. ## Non-goals - Do not add browser ESM execution in this issue. - Do not remove Obsidian-compatible `main.js` behavior. - Do not shrink the existing workspace dependency bag yet. ## Acceptance Criteria - Existing Obsidian/CommonJS plugins still load unchanged. - Structured runtime entry metadata validates and appears in diagnostics. - Selector tests cover workspace, Electron renderer, Electron sidecar, legacy runtime fields, Obsidian `main.js`, and explicit fallback behavior. - Loader behavior has safety coverage before ESM execution is introduced. ## Implementation Notes - Preserve backward compatibility with manifest-only Lapis extensions. - Keep the selector in `@lapis-notes/api` so registry, loader, diagnostics, and future hosts share the same rules. - Treat invalid runtime paths and unsupported formats as actionable diagnostics. ## Suggested Files or Specs To Inspect - `spec/src/30-cross-package-contracts/plugin-runtime.md` - `spec/src/30-cross-package-contracts/plugin-host-boundary.md` - `packages/api/src/lib/lapis-extension.ts` - `packages/api/src/lib/plugin-manager.ts` - `packages/api/src/lib/__tests__/plugin-manager.test.ts` ## Validation Commands - `pnpm --filter @lapis-notes/api check:all` - `pnpm check:all` ## Related Issues ## Follow-up Tasks ## Implementation Summary Added baseline runtime-entry selection coverage and manager preflight diagnostics for structured Lapis runtime entries, legacy runtime strings, Obsidian main.js fallback, and manifest-only extensions. <!-- backlog:task_id=TASK-PLUGIN-LOADER-001 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#213
No description provided.