README.dev.md
May 9, 2022 ยท View on GitHub
Developing in this monorepo
There are a few directories in this monorepo:
box2d- This is a git submodule of the
box2dC++ source code.
- This is a git submodule of the
box2d-wasm- Compiles
box2dto WebAssembly- Compiled using Emscripten toolchain
- Creates
.jsbindings to WebAssembly functionality- Exported functionality is described as
.idlWebIDL bindings - Bindings emitted via WebIDL binder
- Exported functionality is described as
- Creates
.d.tsdeclarations for.jsbindings- Declarations generated by
webidl-to-ts
- Declarations generated by
- Compiles
webidl-to-ts- Generates TypeScript
.d.tsdeclarations from.idlWebIDL bindings files..idlfile parsed using W3C's WebIDL parser- TypeScript declarations created with TypeScript Compiler API
- Generates TypeScript
integration-test- For testing changes you've developed to
box2d-wasm - Svelte application that demonstrates how to consume
box2d-wasmvia TypeScript
- For testing changes you've developed to
demo- Examples of how to integrate
box2d-wasminto your application
- Examples of how to integrate
Clone repository
Clone this repository using --recursive, to ensure that the box2d submodule is available.
Tutorial: Using submodules in Git
# start in root of repository
git clone --recursive git@github.com:Birch-san/box2d-wasm.git
cd box2d-wasm
Instantiate packages
pnpm is used to manage packages in this monorepo. In particular, it creates a symlink that enables integration-test to consume build artifacts from box2d-wasm.
# from root of repository
npm i -g pnpm
pnpm i
# compile webidl-to-ts from TS to JS, so that box2d-wasm can consume it to generate typings
pnpm --filter=webidl-to-ts build
Compile Box2D to WASM + generate .js and .d.ts bindings
See README of box2d-wasm package.
Test box2d-wasm functionality inside an application
See README of integration-test package.