diff --git a/build.ts b/build.ts index 1c6c41f..8d1ea64 100644 --- a/build.ts +++ b/build.ts @@ -1,5 +1,6 @@ import { Glob, Transpiler, fileURLToPath, pathToFileURL } from "bun"; -import { basename, join, relative } from "node:path"; +import { basename, join, parse, relative } from "node:path"; +import { hashremap } from "./hash"; function escapeRegExp(string: string) { return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string @@ -105,8 +106,12 @@ export async function build({ const path = relative(outdir, output.path); if (output.kind === "entry-point" && output.hash) { hashed[`/${path}`] = output.hash; + const imports = transpiler.scanImports(await output.text()); + dependencies[`/${hashremap(path, output.hash)}`] = imports + .filter((x) => x.kind === "import-statement") + .map((x) => "/" + join(path, "..", x.path)); } - if (output.kind === "entry-point" || output.kind === "chunk") { + if (output.kind === "chunk") { const imports = transpiler.scanImports(await output.text()); dependencies[`/${path}`] = imports .filter((x) => x.kind === "import-statement") diff --git a/bun.lockb b/bun.lockb index de5d793..09c4faa 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/example/pages/users/[id].tsx b/example/pages/users/[id].tsx index da919e8..ac2a0ed 100644 --- a/example/pages/users/[id].tsx +++ b/example/pages/users/[id].tsx @@ -1,8 +1,11 @@ +import { Clock } from "../../components/Clock"; + export default function User(props: any) { return (