Skip to content

Commit 5b8ad19

Browse files
authored
chore: make use of NAPI_CPP_CUSTOM_NAMESPACE (#25)
Use the feature added in nodejs/node-addon-api@5b51864 to avoid namespace conflicts between different addons in the future.
1 parent b5d1822 commit 5b8ad19

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/native-addons.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable dot-notation */
2+
import { randomBytes } from 'crypto';
23
import { promises as fs } from 'fs';
34
import { parse } from 'gyp-parser';
45
import path from 'path';
@@ -61,7 +62,8 @@ function turnIntoStaticLibrary (config: GypConfig, addonId: string): AddonResult
6162
for (const want of [
6263
'BUILDING_BOXEDNODE_EXTENSION',
6364
`BOXEDNODE_REGISTER_FUNCTION=${registerFunction}`,
64-
`BOXEDNODE_MODULE_NAME=${linkedModuleName}`
65+
`BOXEDNODE_MODULE_NAME=${linkedModuleName}`,
66+
`NAPI_CPP_CUSTOM_NAMESPACE=i${randomBytes(12).toString('hex')}`
6567
]) {
6668
negDefines.delete(want);
6769
posDefines.add(want);

0 commit comments

Comments
 (0)