NAPI Config
The config schema of NAPI-RS.
💡
All the fields in
napi
is optional.Schema
{
napi?: {
binaryName?: string
targets?: string[],
packageName?: string,
npmClient?: string
constEnum?: boolean
dtsHeader?: string
dtsHeaderFile?: string
wasm?: {
initialMemory?: number
maximumMemory?: number
browser?: {
fs?: boolean
asyncInit?: boolean
}
}
}
}
Field | Default | Description |
---|---|---|
binaryName | index | The binary file name of generated .node file. Eg [NAME].[TRIPLE?].node becomes index.win32-x64-msvc.node |
targets | [] | Targets you want to build. Target triples could be found in the output of rustup target list command. |
packageName | undefined | Override the name field in package.json . See Build#js-package-name for usage. |
npmClient | npm | Specify a different NPM client for usage when executing NPM actions such as publishing. |
constEnum | false | Whether to generate const enum for the generated index.d.ts file. |
dtsHeader | undefined | Header string that prepend to the generated index.d.ts file. |
dtsHeaderFile | undefined | File path that contains the header string that prepend to the generated index.d.ts file. If both dtsHeader and dtsHeaderFile are provided, dtsHeaderFile will be used |
wasm.initialMemory | 4000 (256mb) | Initial memory size for the generated WebAssembly module. See WebAssembly.Memory (opens in a new tab) for more details. |
wasm.maximumMemory | 65536 (4GiB) | Maximum memory size for the generated WebAssembly module. See WebAssembly.Memory (opens in a new tab) for more details. |
wasm.browser.fs | false | Whether to enable the node:fs module polyfill for the generated WebAssembly module. |
wasm.browser.asyncInit | false | Whether to enable the async initialization for the generated WebAssembly module. |
What is target triple
See rustc/platform-support (opens in a new tab) and LLVM/CrossCompilation (opens in a new tab)
Targets are identified by their "target triple" which is the string to inform the compiler what kind of output that should be produced.
The triple has the general format
<arch><sub>-<vendor>-<sys>-<abi>
, where:
arch
=x86_64
,i386
,arm
,thumb
,mips
, etc.sub
= for ex. on ARM:v5
,v6m
,v7a
,v7m
, etc.vendor
=pc
,apple
,nvidia
,ibm
, etc.sys
=none
,linux
,win32
,darwin
,cuda
, etc.abi
=eabi
,gnu
,android
,macho
,elf
, etc.