Skip to content

Commit cafd29b

Browse files
committed
feat: add required config hint in package entry
1 parent fd7a83f commit cafd29b

2 files changed

Lines changed: 54 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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,45 @@ 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+
ALLOW_TABLE_GROWTH: '1',
38+
MIN_CHROME_VERSION: '85',
39+
EXPORTED_RUNTIME_METHODS: [
40+
'emnapiInit',
41+
],
42+
EXPORTED_FUNCTIONS: [
43+
'_malloc',
44+
'_free',
45+
'_napi_register_wasm_v1',
46+
'_node_api_module_get_api_version_v1',
47+
'_emnapi_create_env',
48+
'_emnapi_delete_env',
49+
],
50+
},
51+
},
52+
clang: {
53+
target: 'wasm32-wasip1-threads',
54+
cflags: ['-matomics', '-mbulk-memory'],
55+
ldflags: ['-mexec-model=reactor'],
56+
wasmld: [
57+
'--import-memory',
58+
'--shared-memory',
59+
'--export-table',
60+
'--growable-table',
61+
'--export=malloc',
62+
'--export=free',
63+
'--export=napi_register_wasm_v1',
64+
'--export-if-defined=node_api_module_get_api_version_v1',
65+
'--export=emnapi_thread_crashed',
66+
'--export-if-defined=emnapi_async_worker_create',
67+
'--export-if-defined=emnapi_async_worker_init',
68+
'--export=emnapi_create_env',
69+
'--export=emnapi_delete_env',
70+
],
71+
},
72+
}

0 commit comments

Comments
 (0)