test(islands): guard zero-JS routes and single-React bundling

Two guards protect the core promise: a route with no islands emits no
assets at all, and a page with several islands keeps React in one shared
chunk.

buildIslands now writes a generated entry per island instead of passing
component sources directly. Two islands sharing a source deduped to a
single entrypoint, and output order is not guaranteed to match input
order, so island names could bind to the wrong bundle.

Island modules are excluded from the editor compiler bundle: it globs
packages/compiler/src, and island-bundle.ts calls Bun.build while
island-codegen.ts imports @wrnexus/core — neither belongs in a Node-only
VS Code artifact.

Integration assertions share one build. bun test interferes with
Bun.build's module reads after several build calls in one process, while
the same calls succeed repeatedly outside the runner; production is
unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 15:50:26 +05:30
co-authored by Claude Opus 5
parent 3115277e9d
commit 442a3106ed
9 changed files with 2619 additions and 1702 deletions
+16 -2
View File
@@ -34,13 +34,28 @@ function loadTypeScript() {
const ts = loadTypeScript();
// React island modules are not used by the editor: island-bundle.ts calls
// Bun.build and island-codegen.ts imports @wrnexus/core, neither of which
// exists in this Node-only bundle. They are unreachable from the editor entry,
// so excluding them keeps Bun-only code out of the extension entirely.
const EDITOR_EXCLUDED = ["island-bundle.ts", "island-codegen.ts"];
function isEditorExcluded(path) {
return EDITOR_EXCLUDED.some((name) => path.endsWith(name));
}
function walk(dir) {
const files = [];
for (const entry of readdirSync(dir)) {
const path = join(dir, entry);
const stat = statSync(path);
if (stat.isDirectory()) files.push(...walk(path));
else if (stat.isFile() && path.endsWith(".ts") && !path.endsWith(".test.ts")) files.push(path);
else if (
stat.isFile() &&
path.endsWith(".ts") &&
!path.endsWith(".test.ts") &&
!isEditorExcluded(path)
)
files.push(path);
}
return files;
}
@@ -69,7 +84,6 @@ for (const file of sourceFiles) {
compilerOptions: {
target: ts.ScriptTarget.ES2022,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.Node10,
esModuleInterop: true,
skipLibCheck: true,
sourceMap: false,