Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:
- name: Build Native Binding
run: pnpm --filter rstack build:native:release

- name: Test Native Binding
run: pnpm --filter rstack test:native

- name: Check Generated Native Files
run: git diff --exit-code -- packages/rstack/binding.cjs packages/rstack/binding.d.cts

Expand Down
5 changes: 3 additions & 2 deletions packages/rstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
},
"files": [
"bin",
"binding.cjs",
"binding.d.cts",
Comment thread
chenjiahan marked this conversation as resolved.
"dist",
"types",
"THIRD_PARTY_NOTICES.md"
Expand All @@ -65,8 +67,7 @@
"build:native": "napi build --platform --manifest-path ../../Cargo.toml --package rstack-binding --package-json-path package.json --output-dir . --js binding.cjs --dts binding.d.cts",
"build:native:release": "napi build --platform --release --manifest-path ../../Cargo.toml --package rstack-binding --package-json-path package.json --output-dir . --js binding.cjs --dts binding.d.cts",
"dev": "rslib -w",
"test": "rs test",
"test:native": "node --test tests/native-smoke.cjs"
"test": "rs test"
},
"dependencies": {
"@rsbuild/core": "catalog:",
Expand Down
1 change: 1 addition & 0 deletions packages/rstack/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig({
lib: './src/lib.ts',
lint: './src/lint.ts',
test: './src/test.ts',
'native/index': './src/native/index.ts',
fmtWorker: './src/fmt/worker.ts',
},
define: {
Expand Down
10 changes: 10 additions & 0 deletions packages/rstack/src/native/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createRequire } from 'node:module';
import path from 'node:path';

export type NativeBinding = typeof import('../../binding.cjs');

const require = createRequire(import.meta.url);
export const loadNativeBinding = (): NativeBinding => {
const packageJsonPath = require.resolve('rstack/package.json');
return require(path.join(path.dirname(packageJsonPath), 'binding.cjs')) as NativeBinding;
};
8 changes: 0 additions & 8 deletions packages/rstack/tests/native-smoke.cjs

This file was deleted.

6 changes: 6 additions & 0 deletions packages/rstack/tests/native/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expect, test } from 'rstack/test';
import { loadNativeBinding } from '../../dist/native/index.js';

test('passes a string through the private loader and Rust', () => {
expect(loadNativeBinding().nativePing('rstack')).toBe('pong:rstack');
Comment thread
chenjiahan marked this conversation as resolved.
});
1 change: 1 addition & 0 deletions scripts/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fnames
huskyrc
indentable
llms
napi
noformat
noprettier
nosystem
Expand Down