Skip to content

fix: import node:path in the generated Node prerender runner - #289

Merged
Brooooooklyn merged 1 commit into
mainfrom
07-29-fix_import_node_path_in_the_generated_node_prerender_runner
Jul 29, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
07-29-fix_import_node_path_in_the_generated_node_prerender_runner

Conversation

@shulaoda

Copy link
Copy Markdown
Member

Fixes #285. Third task of #287.

Problem

runNodePrerenderRunner() writes .void/prerender-runner.mjs into the consumer app and executes it as a separate Node process. The generated file imported the path library as a bare specifier:

import { join, dirname } from "pathslash"; // previously "pathe"

Bare specifiers in <app>/.void/ resolve from the application, not from the installed void package. Under strict pnpm, any target: "node" + output: "static" app that doesn't install the path library directly fails:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'pathslash' imported from <app>/.void/prerender-runner.mjs

The pathe → pathslash swap (#288) did not fix this — it only changed the name of the missing package.

Fix

The runner only handles local filesystem paths, so it now imports from the Node built-in:

import { dirname, join } from "node:path";

Why CI never caught this

playground/node-static declared the path library (pathe, then pathslash) as its own devDependency — the exact workaround reported in #285, baked into the test fixture. The runner's bare import always resolved inside the monorepo, so node-static.test.ts stayed green while every real strict-pnpm consumer broke.

This PR removes that dependency so the playground resolves modules like a real consumer app, turning the existing integration test into a genuine regression test for #285. The only in-playground user of pathslash was the dev-convenience scripts/serve-static.mjs, which now uses node:path (with an oxlint exemption documenting why this playground must not depend on pathslash) — it only builds local fs paths, so no slash normalization is needed.

Verification

Runner import Playground pathslash dep node-static.test.ts
pathslash (no fix) present (old state) green — bug masked
pathslash (no fix) removed red — ERR_MODULE_NOT_FOUND for the runner
node:path (this PR) removed green — 13/13 pass

Also verified: vp lint passes, serve:static smoke-tested (serves pages, path-traversal guard intact), void package typecheck passes. The lockfile change is only the dependency removal.

@Brooooooklyn
Brooooooklyn merged commit f243900 into main Jul 29, 2026
8 checks passed
@Brooooooklyn
Brooooooklyn deleted the 07-29-fix_import_node_path_in_the_generated_node_prerender_runner branch July 29, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node static prerender runner cannot resolve pathe with strict pnpm

2 participants