-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mod.ts
29 lines (27 loc) · 1.11 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export * from "./src/oak.ts";
export * from "./src/file_server.ts";
export * from "./utils/transpile.ts";
import { MediaType, transpile } from "./utils/transpile.ts";
/**
* Calling this function will load the wasm file used in the deno_emit of the dependency.
* Even if you don't call this function, if you call the transpile function, the wasm file will be read automatically at that timing.
* However, performance can be an issue on the server as loading the wasm file takes time.
* In that case, calling this function in advance can speed up later calls to the transpile function.
*
* ```ts ignore
* import { serveDirWithTs, forceInstantiateWasm } from "@ayame113/ts-serve";
*
* // load the wasm file in the background when the server starts.
* forceInstantiateWasm();
* Deno.serve((request) => serveDirWithTs(request));
* ```
*/
export async function forceInstantiateWasm() {
try {
await transpile("", new URL("file:///src"), MediaType.TypeScript);
} catch (_) { /* ignore error*/ }
}
/**
* @deprecated Use `forceInstantiateWasm` instead. (typo)
*/
export const fourceInstantiateWasm = forceInstantiateWasm;