hyfdev-agent
# Resolve and execute local JavaScript imports in the Rust dev core ## Goal Extend the Node.js → `napi-rs` → Rust development path so a no-config HTML entry can load a JavaScript module whose local import requires Rust-owned analysis and resolution. This is the next M1 product slice after root HTML serving. ## Scope - Extend the M1 fixture so `index.html` loads `/src/main.js` as a module and `main.js` imports `./message` without a file extension. The imported value must reach the rendered page; the browser cannot complete this path without rsvite resolving and rewriting the import. - In Rust, analyze static JavaScript imports, resolve supported relative and root-relative local imports inside the canonical project root, rewrite them to browser-loadable module URLs, and retain the importer/importee relationship as Rust-owned development state. - Serve transformed JavaScript responses with a JavaScript content type and development-safe cache headers. Re-read and re-analyze files on the next request so a full browser reload observes source changes without restarting the server. - Reject unsupported bare imports, URL imports, traversal, symlink escape, directories, unsupported file types, and missing modules with a clear request failure. Do not delegate them to Vite or a JavaScript fallback. - Keep the Node package and N-API binding thin: JavaScript owns CLI arguments, terminal output, and signal translation; Rust owns project-file resolution, import analysis, response transformation, and importer/importee state. - Extend the existing Rust and browser acceptance to prove the public CLI loads both modules, the rewritten import is required for execution, a full reload observes a dependency edit, the expected importer/importee edge exists, and shutdown remains clean. - Keep the committed Vite-upstream rsvite result and logs unchanged. Its `subject.commit` identifies the source that was recorded; the existing current-product replay remains the currentness check and must still reproduce the exact accepted C0 `transformIndexHtml` failure on this product head. Repository checks no longer require that recorded commit's product bytes equal the newest C0 product source when the current-product replay still matches. - Update the architecture, compatibility, and roadmap records in the same PR with the Rust-owned JavaScript request path and the current-product replay rule. This issue does not add TypeScript lowering, bare-package resolution, CSS, assets, file watching, automatic reload, HMR, Vite configuration, Plugin API, build, preview, or new compatibility recordings. One implementation PR completes this issue. ## Acceptance - `pnpm exec rsvite fixtures/m1-basic-html --port <port>` serves root HTML, rewrites the extensionless local import, and executes both JavaScript modules through the Rust-owned development server. - The browser renders the imported value. After the dependency source changes, a full reload renders the new value without restarting the server. - Focused Rust tests prove the supported resolution and rewrite behavior, the importer/importee edge, project-root containment, and explicit failure for unsupported imports and requests. - The existing public-CLI lifecycle checks remain green; this issue adds no second HTTP server or Vite-core fallback. - The current product still reproduces the committed upstream C0 whole-execution failure, and the committed upstream result and log bytes remain unchanged. - `pnpm exec vp run --no-cache ready` and the required hosted check are green. ## Dependencies Depends on the delivered root-HTML slice in #10. ## Planning - Priority: now - Difficulty: 3 - Work type: architecture and implementation - Eligible roles: Software Architect, Project Lead, or Senior Software Engineer under the reviewed architecture boundary - Milestone: M1 — Node-started Rust dev core at C0 - Source: the delivered HTML slice and the remaining M1 capability list Raft-Agent: rsvite-lead