summaryrefslogtreecommitdiff
path: root/std/hash/_wasm/build.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-02-02 19:05:46 +0800
committerGitHub <noreply@github.com>2021-02-02 12:05:46 +0100
commit6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch)
treefd94c013a19fcb38954844085821ec1601c20e18 /std/hash/_wasm/build.ts
parenta2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff)
chore: remove std directory (#9361)
This removes the std folder from the tree. Various parts of the tests are pretty tightly dependent on std (47 direct imports and 75 indirect imports, not counting the cli tests that use them as fixtures) so I've added std as a submodule for now.
Diffstat (limited to 'std/hash/_wasm/build.ts')
-rw-r--r--std/hash/_wasm/build.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/std/hash/_wasm/build.ts b/std/hash/_wasm/build.ts
deleted file mode 100644
index a328c2615..000000000
--- a/std/hash/_wasm/build.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-import { encode as base64Encode } from "../../encoding/base64.ts";
-
-// 1. build wasm
-async function buildWasm(path: string): Promise<void> {
- const cmd = [
- "wasm-pack",
- "build",
- "--target",
- "web",
- "--release",
- "-d",
- path,
- ];
- const builder = Deno.run({ cmd });
- const status = await builder.status();
-
- if (!status.success) {
- console.error(`Failed to build wasm: ${status.code}`);
- Deno.exit(1);
- }
-}
-
-// 2. encode wasm
-async function encodeWasm(wasmPath: string): Promise<string> {
- const wasm = await Deno.readFile(`${wasmPath}/deno_hash_bg.wasm`);
- return base64Encode(wasm);
-}
-
-// 3. generate script
-async function generate(wasm: string, output: string): Promise<void> {
- const initScript = await Deno.readTextFile(`${output}/deno_hash.js`);
- const denoHashScript =
- "// deno-lint-ignore-file\n" +
- "//deno-fmt-ignore-file\n" +
- "//deno-lint-ignore-file\n" +
- `import * as base64 from "../../encoding/base64.ts";` +
- `export const source = base64.decode("${wasm}");` +
- initScript;
-
- await Deno.writeFile("wasm.js", new TextEncoder().encode(denoHashScript));
-}
-
-const OUTPUT_DIR = "./out";
-
-await buildWasm(OUTPUT_DIR);
-const wasm = await encodeWasm(OUTPUT_DIR);
-await generate(wasm, OUTPUT_DIR);