fix(islands): rebuild on .tsx edits and support islands inside components
Three bugs found by driving the dev server rather than reading code: 1. An island used inside a .wrn component still emitted a component mount — only the page and nested-page render paths were covered. 2. Editing an island .tsx never rebuilt in dev. The bundle cache was keyed on source path alone, and page modules are cached after the first request so no compile runs to notice the change. The cache key now includes mtime, and the file watcher rebuilds islands whose .tsx changed. 3. A .wrn cache hit skipped island building entirely, so after a restart with a warm cache no island bundle was ever produced. Island inputs are now persisted beside the other artifacts and rebuilt on a cache hit. The islands manifest is deliberately excluded from the artifact completeness check: only the async compile path writes it, so requiring it made the sync path miss the cache on every call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
||||
loadWrnServerModule,
|
||||
setCompileCacheDir,
|
||||
setCompileImportOptions,
|
||||
rebuildChangedIslands,
|
||||
setDevCompilerPipeline,
|
||||
wrnBrowserArtifactUrlAsync,
|
||||
} from "./pipeline.ts";
|
||||
@@ -685,6 +686,18 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
||||
|
||||
console.log(`[wrnexus] hot update — ${files.join(", ")}`);
|
||||
await pluginRunner.hook("hmrUpdate", files);
|
||||
// Island .tsx sources are not .wrn files, so nothing below would rebuild
|
||||
// them; page modules are cached, so no compile runs on the next request.
|
||||
const islandFiles = files
|
||||
.map((changed) => (isAbsolute(changed) ? changed : resolve(appDir, changed)))
|
||||
.filter((changed) => changed.endsWith(".tsx"));
|
||||
if (islandFiles.length > 0) {
|
||||
try {
|
||||
await rebuildChangedIslands(islandFiles);
|
||||
} catch (error) {
|
||||
console.warn("[wrnexus] island rebuild failed", error);
|
||||
}
|
||||
}
|
||||
const storeUpdates: Array<{ name: string; url: string; kind: string }> = [];
|
||||
for (const changed of files) {
|
||||
const absolute = isAbsolute(changed) ? changed : resolve(appDir, changed);
|
||||
|
||||
Reference in New Issue
Block a user