Skip to content

Commit ce4523d

Browse files
authored
Remove ts_morph dep (#19)
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
1 parent 7f3b88e commit ce4523d

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/build/kv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toSnapshotJSON } from "../dev/build.ts";
1+
import { toSnapshotJSON } from "../dev/snapshot.ts";
22
import { getFile, housekeep, isSupported, saveFile } from "./kvfs.ts";
33
import { BuildSnapshot, BuildSnapshotJson } from "./mod.ts";
44

src/dev/snapshot.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* This file was intentionally duplicated to remove the dev/deps.ts dependency to avoid including `ts_morph` dep.
3+
* This is necessary because we do build the islands and save them on KV instead of in memory and those dependencies are used for ahead-of-time build.
4+
*/
5+
import { BuildSnapshot, BuildSnapshotJson } from "../build/mod.ts";
6+
import { BUILD_ID } from "../server/build_id.ts";
7+
8+
export const toSnapshotJSON = async (snapshot: BuildSnapshot) => {
9+
// Write dependency snapshot file to disk
10+
const jsonSnapshot: BuildSnapshotJson = {
11+
build_id: BUILD_ID,
12+
files: {},
13+
};
14+
15+
for (const filePath of await snapshot.paths) {
16+
const dependencies = await snapshot.dependencies(filePath);
17+
jsonSnapshot.files[filePath] = dependencies;
18+
}
19+
20+
return jsonSnapshot;
21+
};

0 commit comments

Comments
 (0)