Giter Site home page Giter Site logo

napi-101's Introduction


Speedy NAPI-RS template

Use this template

Click use this template above, then find and replace speedy-sourcemap to your desired naming.

Setup Rust toolchain

This project uses Rust and NAPI-RS, so you can install it with:

# Install Rust toolchain on MacOS, Linux.
# For Windows users, you may refer to the website listed above and install the corresponding `.exe`.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This command will install the latest stable version of Rust standard library, Cargo and other toolchain.

This project is also using Rust 2021, for those developers who have already installed Rust, you may update your toolchain to the latest stable version, which you can update it as follows:

rustup update stable

For more information about the setup, please heads to Rust and NAPI-RS

Setup Node.js

Pnpm is required for handling node modules, also pnpm workspace is enabled for the project, so you can install node modules with:

npm install -g pnpm

pnpm install # Install all node modules in the workspace

Setup WebAssembly

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Note: for Apple Silicons, you need to use cargo install wasm-pack to install wasm-pack

Repo Structure

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── benchmark # Your benchmark goes here
├── core
│   └── your_native_repo_goes_here # Your native repo goes here
├── node
│   ├── Cargo.toml
│   ├── __tests__
│   │   └── unit.spec.ts
│   ├── binding.js
│   ├── build.rs
│   ├── index.d.ts
│   ├── npm # This package is not intended for editing
│   ├── package.json
│   ├── src
│   │   ├── lib.rs
│   │   ├── test.rs
│   │   └── types.rs
│   └── tsconfig.json
├── wasm # Your wasm binding goes here
├── package.json
├── pnpm-workspace.yaml
└── rustfmt.toml # This file is not intended for editing

This project is also using Cargo workspaces for managing multiple crates.

Development

Build Node bindings

# This will only build the unoptimized version for testing
# , which is hugely useful when testing projects with heavy dependencies.
pnpm build:debug --dir node

# Regular optimized build
pnpm build --dir node

Build WebAssembly bindings

pnpm build:wasm

Testing

Rust

cargo test # This will test the whole cargo workspaces, and workspace members are declared in the <project-root>/Cargo.toml

Node

pnpm test # This will run tests under the `node` and `wasm` directory

Publishing

Rust(Cargo)

cargo publish

Node

Node addons are divided into difference npm packages for different platforms and architectures, which you can find here and this is not intended to be edited manually.

# Create a new npm release
cd node
npm version

Make sure you have your commit message starts with chore(release): publish, and CI will automatically publish the release. For more details please refer to CI.yaml

napi-101's People

Contributors

misakar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.