Skip to content

Commit

Permalink
napi build
Browse files Browse the repository at this point in the history
  • Loading branch information
topheman committed Oct 28, 2024
1 parent 277c384 commit 242fe2f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

- [oxc](./oxc/README.md)
- [oxc / Explore crates](./oxc/explore.md)
- [oxc / Bundling (js)](./oxc/explore-js-bundling.md)
- [oxc / Build](./oxc/build.md)

## oxc-resolver
Expand All @@ -27,6 +28,7 @@
## napi

- [napi](./napi/README.md)
- [napi / Build](./napi/build.md)
- [napi / Class](./napi/class.md)

## rust / crates
Expand Down
32 changes: 32 additions & 0 deletions src/napi/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# napi / Build

The [napi-build](https://crates.io/crates/napi-build) crate is used for the build part.

A `build.rs` file is in the crate/package where you want to generate bindings from `src/lib.rs`.

The `build.rs` will only contain this kind of code:

```rust
extern crate napi_build;

fn main() {
napi_build::setup();
}
```

Then, you will call something like:

```sh
napi build --platform --release
```

Which will generate:

- the binaries for the targeted platforms
- the bindings:
- `.d.ts` TypeScript decleration files
- `.js` glue code to load and bind the binary to JavaScript runtime

When running it from a task in a `package.json`, a configuration can be passed to a [`napi` field](https://napi.rs/docs/cli/napi-config.en#schema)

<https://napi.rs/docs/introduction/simple-package>
4 changes: 4 additions & 0 deletions src/oxc/explore-js-bundling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# oxc / Bundling (js)

First, read [napi / Build](../napi/build.md).

0 comments on commit 242fe2f

Please sign in to comment.