Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit effe913

Browse files
committed
Clean up
1 parent 1db885d commit effe913

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

server/build.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ const supportedPlatforms: Record<BuildPlatform, string> = {
2828

2929
/**
3030
* Build the app into a worker for serverless platform. Functions include:
31-
* - import routes modules (since deno deploy/clouflare don't support dynamic import)
31+
* - import routes modules (since deno-deploy/cloudflare don't support dynamic import)
32+
* - apply module loaders
33+
* - pre-compile/bundle client modules
3234
* - resolve import maps
33-
* - pre-compile client modules
34-
* - bundle client modules
35+
*
36+
* after build, you need to bootstrap the server from `./dist/server.js`
3537
*/
3638
export async function build(serverEntry?: string) {
3739
const workingDir = Deno.cwd();
@@ -276,7 +278,7 @@ export async function build(serverEntry?: string) {
276278
tasks.push(`${alephPkgUri}/framework/core/nomodule.ts`);
277279

278280
const entryModules = new Map(tasks.map((task) => [task, 0]));
279-
const tracing = new Set<string>();
281+
const allClientModules = new Set<string>();
280282

281283
// transform client modules
282284
const serverHandler: FetchHandler | undefined = Reflect.get(globalThis, "__ALEPH_SERVER")?.handler;
@@ -313,14 +315,16 @@ export async function build(serverEntry?: string) {
313315
} else if (url.searchParams.has("module")) {
314316
deps.add(`${alephPkgUri}/framework/core/style.ts`);
315317
}
316-
tracing.add(specifier);
318+
allClientModules.add(specifier);
317319
}));
318-
tasks = Array.from(deps).filter((specifier) => !tracing.has(specifier));
320+
tasks = Array.from(deps).filter((specifier) => !allClientModules.has(specifier));
319321
}
320322
}
321323

322-
// count client module refs
324+
const clientModules = new Map(entryModules);
323325
const refs = new Map<string, Set<string>>();
326+
327+
// count client module refs
324328
for (const [name] of entryModules) {
325329
clientDependencyGraph?.walk(name, ({ specifier }, importer) => {
326330
if (importer) {
@@ -334,8 +338,6 @@ export async function build(serverEntry?: string) {
334338
});
335339
}
336340

337-
const clientModules = new Map(entryModules);
338-
339341
// find shared modules
340342
for (const [specifier, counter] of refs) {
341343
if (counter.size > 1) {
@@ -428,6 +430,7 @@ export async function build(serverEntry?: string) {
428430
);
429431

430432
// clean up then exit
433+
// todo: remove dead client modules
431434
if (jsxShimFile) {
432435
await Deno.remove(jsxShimFile);
433436
}

server/bundle_css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type BundleCSSResult = {
1919
};
2020

2121
/**
22-
* bundle css with `parcel-css`.
22+
* Bundle the css using `parcel-css` with `nesting` and `customMedia` draft support.
2323
*
2424
* https://github.com/parcel-bundler/parcel-css
2525
*/

0 commit comments

Comments
 (0)