-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathindex.ts
27 lines (25 loc) · 2.21 KB
/
index.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
import type { QuickJSAsyncVariant } from "@jitl/quickjs-ffi-types"
/**
* ### @jitl/quickjs-singlefile-mjs-release-asyncify
*
* [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-mjs-release-asyncify/README.md) |
* Variant with the WASM data embedded into a NodeJS ESModule.
*
* | Variable | Setting | Description |
* | -- | -- | -- |
* | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
* | releaseMode | release | Optimized for performance; use when building/deploying your application. |
* | syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. |
* | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
* | exports | import | Has these package.json export conditions |
*
*/
const variant: QuickJSAsyncVariant = {
type: "async",
importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSAsyncFFI),
importModuleLoader: () =>
import("@jitl/quickjs-singlefile-mjs-release-asyncify/emscripten-module").then(
(mod) => mod.default,
),
} as const
export default variant