fix: convert island filePath to valid variable name (#2984)

I only added a unit test, but maybe it's testing internals too much?
Should I add a more E2E test in `tests/` with real files?


Closes #2971
This commit is contained in:
Christian Svensson
2025-05-21 11:06:16 +02:00
committed by GitHub
parent b6c02b0668
commit bc8cdb9c7b
4 changed files with 66 additions and 4 deletions
+2 -3
View File
@@ -1,4 +1,3 @@
import * as path from "@std/path";
import { type ComponentType, h } from "preact";
import { renderToString } from "preact-render-to-string";
import { trace } from "@opentelemetry/api";
@@ -17,7 +16,7 @@ import { type BuildCache, ProdBuildCache } from "./build_cache.ts";
import type { ServerIslandRegistry } from "./context.ts";
import { FinishSetup, ForgotBuild } from "./finish_setup.tsx";
import { HttpError } from "./error.ts";
import { mergePaths } from "./utils.ts";
import { mergePaths, pathToExportName } from "./utils.ts";
// TODO: Completed type clashes in older Deno versions
// deno-lint-ignore no-explicit-any
@@ -159,7 +158,7 @@ export class App<State> {
// Create unique island name
let name = exportName === "default"
? path.basename(filePath, path.extname(filePath))
? pathToExportName(filePath)
: exportName;
if (this.#islandNames.has(name)) {
let i = 0;