Skip to content

Commit a64040f

Browse files
fix: improve cross-platform module loading
- Replace hardcoded platform-specific path with NAPI-RS loader - Update module loading to use ES module imports - Configure Biome to ignore generated files - Fix format/lint/check targets to use Biome - Update documentation with accurate module loading details
1 parent 97b4636 commit a64040f

File tree

5 files changed

+153
-168
lines changed

5 files changed

+153
-168
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ This project consists of three main components:
2121

2222
## Native Module Structure
2323

24-
The native module is built using NAPI-RS and follows its naming convention:
24+
The native module is built using NAPI-RS and provides cross-platform support:
2525

2626
- Platform-specific builds are named `cel-typescript.<platform>-<arch>.node` (e.g., `cel-typescript.darwin-arm64.node` for Apple Silicon Macs)
27-
- During build and installation, NAPI-RS automatically creates an `index.node` symlink pointing to the appropriate platform-specific build
28-
- This structure allows for cross-platform distribution while maintaining platform-specific optimizations
29-
- The symlink is managed by NAPI-RS and will be different for each contributor based on their platform
27+
- NAPI-RS generates a platform-agnostic loader (`index.js`) that automatically detects the current platform and loads the appropriate `.node` file
28+
- The module interface is defined in `src/binding.d.ts` which declares the types for the native module
29+
- At runtime, the TypeScript wrapper (`src/index.ts`) uses the NAPI-RS loader to dynamically load the correct native module
30+
- This structure allows for seamless cross-platform distribution while maintaining platform-specific optimizations
3031

3132

3233
## How it Works

index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/* auto-generated by NAPI-RS */
55

66
export declare class CelProgram {
7-
constructor();
8-
static compile(source: string): CelProgram;
9-
execute(context: JsonValue): JsonValue;
7+
constructor()
8+
static compile(source: string): CelProgram
9+
execute(context: JsonValue): JsonValue
1010
}

0 commit comments

Comments
 (0)