Skip to content

Commit 6d7f4ee

Browse files
committed
expose onLoadPageFile
1 parent 28050f4 commit 6d7f4ee

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

build.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ export async function build({
1414
minify = Bun.env.NODE_ENV === "production",
1515
define,
1616
plugins,
17+
onLoadPageFile = async ({ path, loader }) => {
18+
const contents = await Bun.file(path).text();
19+
return {
20+
contents: contents.replaceAll(
21+
/\/\/\s*@server-side[^\n\S]*\n[^\n]+\n/g,
22+
""
23+
),
24+
loader,
25+
};
26+
},
1727
}: {
1828
baseDir: string;
1929
buildDir?: string;
@@ -23,6 +33,7 @@ export async function build({
2333
minify?: boolean;
2434
define?: Record<string, string>;
2535
plugins?: import("bun").BunPlugin[];
36+
onLoadPageFile?: import("bun").OnLoadCallback;
2637
}) {
2738
const entrypoints = [join(baseDir, hydrate)];
2839
const absPageDir = join(baseDir, pageDir);
@@ -81,16 +92,7 @@ export async function build({
8192
);
8293
build.onLoad(
8394
{ namespace: "client", filter: /\.ts[x]$/ },
84-
async ({ path, loader }) => {
85-
const contents = await Bun.file(path).text();
86-
return {
87-
contents: contents.replaceAll(
88-
/\/\/\s*@server-side[^\n\S]*\n[^\n]+\n/g,
89-
""
90-
),
91-
loader,
92-
};
93-
}
95+
onLoadPageFile
9496
);
9597
},
9698
},

0 commit comments

Comments
 (0)