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

Commit 351b4dc

Browse files
author
Wenjie Xia
committed
chore(compiler): update build and benchmark script
1 parent 52b9aec commit 351b4dc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

compiler/benchmark.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { compile, CompileOptions } from 'https://deno.land/x/[email protected]/tsc/compile.ts';
2-
import { colors, path, Sha1, walk } from '../deps.ts';
3-
import { initWasm, transpileSync } from './mod.ts';
1+
import { compile, CompileOptions } from 'https://deno.land/x/[email protected]/tsc/compile.ts'
2+
import { colors, path, Sha1, walk } from '../deps.ts'
3+
import { initWasm, transpileSync } from './mod.ts'
44

55
const hashShort = 9
66
const reHttp = /^https?:\/\//i
@@ -39,6 +39,8 @@ async function benchmark(sourceFiles: Array<{ code: string, filename: string }>,
3939
console.log(`[benchmark] ${sourceFiles.length} files ${isDev ? '(development mode)' : ''}`)
4040

4141
const d1 = { d: 0, min: 0, max: 0, }
42+
const d2 = { d: 0, min: 0, max: 0, }
43+
4244
for (const { code, filename } of sourceFiles) {
4345
const t = performance.now()
4446
for (let i = 0; i < 5; i++) {
@@ -53,8 +55,6 @@ async function benchmark(sourceFiles: Array<{ code: string, filename: string }>,
5355
}
5456
d1.d += d
5557
}
56-
57-
const d2 = { d: 0, min: 0, max: 0, }
5858
for (const { code, filename } of sourceFiles) {
5959
const t = performance.now()
6060
for (let i = 0; i < 5; i++) {
@@ -83,6 +83,7 @@ if (import.meta.main) {
8383
stderr: 'null'
8484
})
8585
await initWasm((new TextDecoder).decode(await p.output()).split('"')[1])
86+
p.close()
8687

8788
const sourceFiles: Array<{ code: string, filename: string }> = []
8889
const walkOptions = { includeDirs: false, exts: ['.tsx'], skip: [/[\._]test\.tsx?$/i] }

compiler/build.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { base64, brotli, Sha1 } from '../deps.ts'
1+
import { base64, brotli, ensureDir, Sha1 } from '../deps.ts'
22

33
if (import.meta.main) {
44
const p = Deno.run({
@@ -8,21 +8,23 @@ if (import.meta.main) {
88
})
99
await p.status()
1010
p.close()
11+
1112
const wasmData = await Deno.readFile('./pkg/aleph_compiler_bg.wasm')
1213
const data = brotli.compress(wasmData)
1314
const data64 = base64.encode(data)
1415
const hash = (new Sha1).update(data).hex()
16+
await ensureDir('./dist')
1517
await Deno.writeTextFile(
16-
'./wasm.js',
18+
'./dist/wasm.js',
1719
[
18-
`import { base64, brotli } from "../deps.ts";`,
20+
`import { base64, brotli } from "../../deps.ts";`,
1921
`const dataRaw = "${data64}";`,
2022
`export default () => brotli.decompress(base64.decode(dataRaw))`
2123
].join('\n')
2224
)
2325
await Deno.writeTextFile(
24-
'./wasm-checksum.js',
26+
'./dist/wasm-checksum.js',
2527
`export const checksum = ${JSON.stringify(hash)}`
2628
)
27-
await Deno.copyFile('./pkg/aleph_compiler.js', './wasm-pack.js')
29+
await Deno.copyFile('./pkg/aleph_compiler.js', './dist/wasm-pack.js')
2830
}

0 commit comments

Comments
 (0)