This document summarizes the migration work, regressions found, fixes applied, and investigation outcomes while moving @fresh/plugin-vite from Vite 7/Rollup behavior to Vite 8/Rolldown behavior.
deno test -A packages/plugin-vite/tests/build_test.ts- ✅ 30 passed / 0 failed
- Previously failing areas during migration:
- Bare/JSR island resolution (
@marvinh-test/fresh-island) .cjsparsing failures in SSR build- CSS Modules not applied for island/imported chunks
- Bare/JSR island resolution (
Symptoms
- Build error:
Could not load @marvinh-test/fresh-island - No such file or directory (os error 2)
Causes
resolveIdresult shape assumptions from previous behavior no longer held.- Returned string IDs were not always sufficient in this path.
resolveIdmetadata assumptions (resolvedBy) were invalid with current typings/runtime surface.resolveIdoptions import attributes (options.attributes) are not available in current Rolldown integration (see linked Rolldown issue below).
Fixes
- Return object from resolver for deno namespaced IDs:
return { id: toDenoSpecifier(...) }
- Removed usage of unsupported resolver provenance metadata (
resolvedBy). - Stopped relying on unavailable import-attributes options in resolver:
- Fallback to default type handling in plugin path.
- Result: remote island resolution now works again.
Symptoms
- SSR build errors such as:
Cannot use export statement outside a moduleCannot use import statement outside a module
- Reported on transformed
.cjsfiles (e.g. demo fixtures).
Cause
fresh:patchesincludescjsPlugin, which rewrites CommonJS patterns to ESM-style syntax.- Under Vite 8 / Rolldown / OXC strictness,
.cjsis still interpreted as CommonJS by extension semantics. - Result: transformed ESM syntax in
.cjsbecame invalid for parser expectations.
Fix
- SSR workaround in
packages/plugin-vite/src/mod.ts:- Mark
.cjsas external inrolldownOptions.external.
- Mark
- This bypasses problematic bundling/parsing path for
.cjsin SSR.
Notes
- This is a practical compatibility workaround.
- Long-term ideal is upstream/toolchain alignment of module-kind and transformed output.
Symptoms
vite build - css modulestest failed (computed styles were incorrect).- Island route rendered, but expected island CSS was missing in output.
Cause
- Island CSS collection logic relied on manifest assumptions that did not consistently hold after migration.
- Shared/imported chunk CSS was not always associated with island entries.
- Manifest lookup by a single key strategy was insufficient with current output shape.
Fix
- In
server_snapshot.ts, switched to robust CSS collection:- Build helper to resolve manifest chunk by reference (supports key/file matching).
- Recursively walk
importsgraph. - Aggregate all reachable CSS into island entry CSS list.
- Result: CSS modules tests passed.
- Updated resolver behavior for Rolldown compatibility:
- Return object form for deno specifier IDs.
- Removed unsupported assumptions:
- No
resolvedBychecks. - No direct
options.attributesusage (unavailable in current environment).
- No
- Preserved plugin-chain interoperability while keeping deno-first resolution intent.
- Added SSR Rolldown external rule:
- Externalize
.cjsto avoid parser/module-kind mismatch in bundle phase.
- Externalize
- Reworked island CSS gathering:
- Added manifest reference resolution helper.
- Added recursive import-graph CSS collection.
- Ensured island registry receives full CSS set including transitive imports.
- Rolldown import attributes support gap:
- Potentially related CSS/chunk behavior class:
- Do not rely on non-standard resolver metadata unless guaranteed by current types/runtime.
- Treat
.cjscarefully under stricter parser semantics; avoid producing ESM syntax in.cjsbundle path. - Assume manifest shape variance across bundlers; use resilient chunk resolution and import-graph traversal.
- Prefer behavior-based guards (e.g.,
external, virtual IDs, imports graph) over provenance-based assumptions.
- Revisit
.cjsexternal workaround when upstream parser/module-kind behavior improves. - Consider narrowing
cjsPluginapplication scope to avoid.cjstransformation hazards. - Add targeted regression tests around:
- manifest key/file reference differences
- transitive island CSS inclusion
- deno resolver fallback behavior under Rolldown.