@across-protocol/sdk 4.1.24 → 4.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Script for bigint-buffer Native Module
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* This script handles the native compilation of the bigint-buffer module, which provides
|
|
6
|
+
* high-performance BigInt <-> Buffer conversions using native C++ code.
|
|
7
|
+
*
|
|
8
|
+
* Why JavaScript and not TypeScript or an embedded shell script:
|
|
9
|
+
* 1. This is a build script that runs during package installation (postinstall)
|
|
10
|
+
* 2. Using TypeScript would require the TypeScript compiler or ts-node to be available during installation
|
|
11
|
+
* 3. Plain JavaScript ensures this script can run immediately without compilation
|
|
12
|
+
* 4. This script is operating system agnostic, so it can be run on any platform that supports Node.js
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const { execSync } = require('child_process');
|
|
16
|
+
const { existsSync } = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Check if the bigint-buffer module exists in node_modules
|
|
21
|
+
// Using path.join for cross-platform compatibility (Windows/Unix)
|
|
22
|
+
const bigintBufferPath = path.join(process.cwd(), 'node_modules/bigint-buffer');
|
|
23
|
+
|
|
24
|
+
// Skip if module isn't installed
|
|
25
|
+
if (!existsSync(bigintBufferPath)) {
|
|
26
|
+
console.log('Skipping bigint-buffer build: folder not found');
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Verify node-gyp (native module build tool) is available
|
|
31
|
+
// node-gyp is required to compile the C++ code in bigint-buffer
|
|
32
|
+
try {
|
|
33
|
+
execSync('command -v node-gyp', { stdio: 'ignore' });
|
|
34
|
+
} catch {
|
|
35
|
+
console.log('Skipping bigint-buffer build: node-gyp not found');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Change to the module directory and run the native build
|
|
40
|
+
// node-gyp configure: Creates platform-specific build files
|
|
41
|
+
// node-gyp build: Compiles the native code
|
|
42
|
+
process.chdir(bigintBufferPath);
|
|
43
|
+
execSync('node-gyp configure', { stdio: 'inherit' });
|
|
44
|
+
execSync('node-gyp build', { stdio: 'inherit' });
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// Proper error handling for build failures
|
|
47
|
+
console.error('Error building bigint-buffer:', error);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|