[3.0.0-next.50 / next] SSR build: the $$moduleUrl export added to a Worker main module stops workerd from starting
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend, build-system
Direzione di ricerca
The export is appended by injectSsrModuleId in src/index.ts, which currently adds it to every SSR module outside node_modules. Start there and check the condition that decides which modules get $$moduleUrl, then run vite build and inspect the last line of dist/server/server.js for the example worker. Done means a server entry keeps only its original exports while lazy()-reached modules still receive the export, and the worker still starts under vite preview.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
In SSR builds, the plugin appends export const $$moduleUrl = "<path>" to project modules. Since #407 (3.0.0-next.49) it does so for plain .ts/.js modules too; .tsx modules already had it. When the module that gets it is a server entry, the export becomes part of the entry's public surface.
With @cloudflare/vite-plugin, which the README names as a host the plugin composes with, the Worker's main module is re-exported as a whole by the Worker entry (export * from "<main>"). workerd accepts only handlers and entrypoint classes as named exports of a Worker. So the production Worker can't start:
Uncaught TypeError: Incorrect type for map entry '$$moduleUrl': the provided value is not of type 'function or ExportedHandler'.
vite dev is not affected. Expected: a server entry keeps only the exports it was written with.
Reproduction
Versions:
@solidjs/vite-plugin3.0.0-next.48 / 49 / 50, withstart: true, ssr: true;@cloudflare/vite-plugin1.64.0 andwrangler4.151.0;- Vite 8.3.4;
solid-js/@solidjs/web2.0.0-rc.15;- Node 24.21.0, Linux.
// vite.config.ts
import { cloudflare } from "@cloudflare/vite-plugin";
import solid from "@solidjs/vite-plugin";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [cloudflare({ viteEnvironment: { name: "ssr" } }), solid({ start: true, ssr: true })],
server: { host: "127.0.0.1", port: 5391, strictPort: true },
});
// wrangler.jsonc
{
"name": "module-url-probe",
"main": "src/worker.ts",
"compatibility_date": "2026-09-19",
"compatibility_flags": ["nodejs_compat"]
}
// src/worker.ts
export { default } from "virtual:solid-ssr-handler";
// src/App.tsx
export default function App() {
return <p>Hello</p>;
}
Run vite build, then vite preview --port 5391, then curl http://127.0.0.1:5391/. The second column is the last line of dist/server/server.js.
@solidjs/vite-plugin |
main |
dist/server/server.js exports |
vite preview |
|---|---|---|---|
| 3.0.0-next.48 | src/worker.ts |
export { worker_entry_default as default } |
starts, HTTP 200 |
| 3.0.0-next.48 | src/worker.tsx (same content) |
export { $$moduleUrl, worker_entry_default as default } |
workerd fails to start (error above) |
| 3.0.0-next.49 | src/worker.ts |
export { $$moduleUrl, worker_entry_default as default } |
workerd fails to start |
| 3.0.0-next.49 | src/worker.tsx |
same | workerd fails to start |
| 3.0.0-next.50 | src/worker.ts |
same | workerd fails to start |
| 3.0.0-next.50 | src/worker.tsx |
same | workerd fails to start |
With 3.0.0-next.50, vite dev renders the page (<p _hk=10>Hello</p>).
Cause
injectSsrModuleId in src/index.ts; the code is unchanged on next. It appends the export to every SSR module outside node_modules:
function injectSsrModuleId(code, id, isSsr) {
if (!isSsr || /node_modules/.test(id) || code.includes('$$moduleUrl')) return code;
// ...
return code + `\nexport const $$moduleUrl = ${JSON.stringify(relativeId)};\n`;
}
#407 also runs it on non-JSX modules, which is why a .ts Worker main breaks from next.49 on.
@cloudflare/vite-plugin's Worker entry module (virtual:cloudflare/worker-entry) re-exports the user's main:
import * as mod from "virtual:cloudflare/user-entry";
export * from "virtual:cloudflare/user-entry";
export default mod.default ?? {};
That way, Durable Object classes and other entrypoints written in main reach the Worker. In the build output, the added $$moduleUrl comes along as a named export of the Worker. workerd rejects it, because it is neither a handler nor an entrypoint class.
The only reader of $$moduleUrl is server-side lazy(). It reads it off a module that it resolved through import(), when its callsite has no static module URL (cur.mod?.$$moduleUrl in solid-js's server build). A Worker's main module is never such a target. So the export there serves no purpose, and it changes the entry's public surface.
Expected
A server entry module, and anything a host re-exports from it, keeps only the exports it was written with. $$moduleUrl is only needed on modules that lazy() reaches through import(). Related: #406 / #407 (where .ts/.js modules started getting the export).
(submitted by Claude Opus 5.5 on behalf of rvlzzr)
- Lingua principale
- TypeScript
- Stelle
- 522
- Fork
- 73
- Merge medio
- 1g 4h
- PR unite (30g)
- 35
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid-vite-plugin
-
Test environment detection doesn't consider Vitest workspacesForse già presa @carloitaben l’ha presa 55 giorni fa. Aperta1.x
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
solidjs/solid-vite-plugin#205 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Dev: a stylesheet shared by the entry and a lazy component moves after the lazy component's stylesAperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 62/100
solidjs/solid-vite-plugin#425 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
solidjs/solid-vite-plugin#419 ·
I maintainer di solito rispondono entro 1 giorno
-
start.node: node.js imports node:http before start.instrument runs, so HTTP instrumentation misses the serverForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 30/100
solidjs/solid-vite-plugin#418 ·
I maintainer di solito rispondono entro 1 giorno
-
Dev manifest bridge keeps stale CSS after an editForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 34/100
solidjs/solid-vite-plugin#415 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid-vite-plugin
Issue simili
-
Endpoint links in the tag operations list are below the 24px target sizeForse già presa @AdzerKI l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa bug Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
linagora/twake-tasks#435 ·
I maintainer di solito rispondono entro 1 giorno
-
bug domain: database priority: p1 Stellar Wave
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
StellarState/SS-backend#632 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
A2A audit timestamps end in +00:00Z (invalid ISO 8601)Forse già presa @O1sumitkumar l’ha presa oggi. Apertabug good first issue help wanted python
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`cf complete zsh >> .zshrc` fails on vanilla zshForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cloudflare/cf#340 ·
I maintainer di solito rispondono entro 1 giorno