Skip to content

Commit b6b4a63

Browse files
committed
feat: add required config hint in package entry
1 parent 5e3e8a9 commit b6b4a63

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

packages/emnapi/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,15 @@ export const include: string
22
export const include_dir: string
33
export const js_library: string
44
export const sources: string[]
5+
export const targets: string
6+
export const requiredConfig: {
7+
emscripten: {
8+
settings: Record<string, string | string[]>
9+
}
10+
clang: {
11+
target: string
12+
cflags: string[]
13+
ldflags: string[]
14+
wasmld: string[]
15+
}
16+
}

packages/emnapi/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,39 @@ exports.include_dir = includeDir
2828
exports.js_library = jsLibrary
2929
exports.sources = sources
3030
exports.targets = targets
31+
32+
exports.requiredConfig = {
33+
emscripten: {
34+
settings: {
35+
WASM_BIGINT: '1',
36+
ALLOW_MEMORY_GROWTH: '1',
37+
MIN_CHROME_VERSION: '85',
38+
EXPORTED_RUNTIME_METHODS: [
39+
'emnapiInit'
40+
],
41+
EXPORTED_FUNCTIONS: [
42+
'_malloc',
43+
'_free',
44+
'_napi_register_wasm_v1',
45+
'_node_api_module_get_api_version_v1'
46+
]
47+
}
48+
},
49+
clang: {
50+
target: 'wasm32-wasip1-threads',
51+
cflags: ['-matomics', '-mbulk-memory'],
52+
ldflags: ['-mexec-model=reactor'],
53+
wasmld: [
54+
'--import-memory',
55+
'--shared-memory',
56+
'--export-table',
57+
'--export=malloc',
58+
'--export=free',
59+
'--export=napi_register_wasm_v1',
60+
'--export-if-defined=node_api_module_get_api_version_v1',
61+
'--export=emnapi_thread_crashed',
62+
'--export-if-defined=emnapi_async_worker_create',
63+
'--export-if-defined=emnapi_async_worker_init'
64+
]
65+
}
66+
}

0 commit comments

Comments
 (0)