ID:WORK-094Status:ready
Create @refrakt-md/vite plugin — Level 1 static transform
Build the core Vite plugin that intercepts .md files and emits JS modules with rendered HTML, frontmatter, SEO data, and serialized tree. This is the Level 1 (static, per-file) integration — no cross-page awareness.
Priority:highComplexity:moderateMilestone:v1.0.0Source:SPEC-031
Acceptance Criteria
- New package
packages/vite/withpackage.json,tsconfig.json, build config - Plugin entry (
src/index.ts) exportsrefrakt()function returning a Vite plugin - Config accepts
packages,theme,extensions,injectCSS,level,contentDir - Per-file transform pipeline: Markdoc parse → rune schema transforms → serialize → identity transform → renderToHtml
- Each
.mdfile emits a JS module exportinghtml,tree,frontmatter,seo,meta seoexport includesjsonLdarray andogobject viaextractSeo()from@refrakt-md/runesmetaexport includesrunes(list of rune names used) andpackages(list of package names)- Community packages loaded via
loadRunePackage()and merged viamergePackages() - Runes requiring Level 2 (breadcrumb, nav, glossary auto-linking) render as static content with build warning
- Plugin sets
ssr.noExternalfor refrakt packages (sameCORE_NO_EXTERNALpattern as sveltekit) viteis a peer dependency (^5.0.0 || ^6.0.0)- Package builds successfully in monorepo dependency order
- Basic integration test: transform a
.mdfile with runes, verify module exports
Approach
- Scaffold
packages/vite/— package.json, tsconfig extending root, tsup build config - Implement config parsing and validation in
src/index.ts - Implement per-file transform in
src/transform.ts— reusesMarkdoc.parse(), rune schemas from@refrakt-md/runes,serialize()from@refrakt-md/transform(requires WORK-088),createTransform(), andrenderToHtml() - Wire up Vite's
transformhook to intercept configured extensions - Emit JS module string with named exports
- Add
resolveId/loadhooks for virtual module support (used by WORK-095)
Dependencies
- Extract shared utilities from @refrakt-md/svelte to @refrakt-md/transform —
serialize()must be available from@refrakt-md/transform
References
- Vite Plugin — Framework-Agnostic Rune Integration (Architecture, Configuration, Level 1 sections)
packages/sveltekit/src/plugin.ts— existing Vite plugin to referencepackages/transform/src/engine.ts— identity transformpackages/transform/src/html.ts—renderToHtml()
Relationships
Dependency of
ID:WORK-098Status:ready0/6
Vite plugin — behavior init helper export
Priority:lowComplexity:trivialMilestone:v1.0.0
ID:WORK-095Status:ready0/9
Vite plugin — virtual CSS module and tree-shaking
Priority:highComplexity:simpleMilestone:v1.0.0
ID:WORK-096Status:ready0/6
Vite plugin — dev server HMR
Priority:mediumComplexity:simpleMilestone:v1.0.0
ID:WORK-097Status:ready0/11
Vite plugin — Level 2 cross-page pipeline
Priority:mediumComplexity:moderateMilestone:v1.0.0