Skip to content

Commit

Permalink
Merge pull request #1 from bitfrost/bun
Browse files Browse the repository at this point in the history
expose yoga.wasm in a bun --compile friendly way
  • Loading branch information
bitfrost authored Mar 23, 2024
2 parents 964bd6b + 955940e commit 6fbc323
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16, 18]
node: [18, 20]
name: Test node v${{ matrix.node }}
steps:
- uses: actions/checkout@v3
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "release"

on:
workflow_dispatch:
inputs:
parameter:
description: hello

jobs:
build:
runs-on: ubuntu-latest
name: Compile C++ to wasm
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: mymindstorm/setup-emsdk@v12
with:
version: 3.1.31
actions-cache-folder: "emsdk-cache"
- name: Use pnpm
run: corepack enable pnpm && pnpm --version
- name: Install
run: pnpm install
- name: Build
run: pnpm build
- name: Upload bundle
uses: actions/upload-artifact@v3
with:
name: bundle
path: dist
test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
name: Test node v${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- name: Use pnpm
run: corepack enable pnpm && pnpm --version
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Download bundle
uses: actions/download-artifact@v3
with:
name: bundle
path: dist
- name: Install
run: pnpm install
- name: Type check
run: pnpm typecheck
- name: Test
run: pnpm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist/*
!dist/index.d.ts
!dist/asm.d.ts
!dist/auto.d.ts
!dist/bun.js
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
#@bitfrost:registry=https://npm.pkg.github.com
registry=https://registry.npmjs.org
#always-auth=true
6 changes: 6 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodejs 20.10.0
pnpm 8.15.5
python 3.11.3
# asdf plugin add emsdk https://github.com/RobLoach/asdf-emsdk.git
emsdk 3.1.50

11 changes: 11 additions & 0 deletions dist/bun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readFile } from "node:fs/promises";
import initYoga from "./index.js";

import yogaFile from './yoga.wasm';

const Yoga = await initYoga(
await readFile(yogaFile)
);

export * from "../yoga/javascript/src_js/generated/YGEnums.js";
export default Yoga;
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "yoga-wasm-web",
"name": "@bitfrost/yoga-wasm-web",
"version": "0.3.3",
"type": "module",
"types": "dist/index.d.ts",
Expand All @@ -26,6 +26,7 @@
},
"./auto": {
"types": "./dist/auto.d.ts",
"bun": "./dist/bun.js",
"browser": "./dist/browser.js",
"default": "./dist/node.js"
}
Expand All @@ -37,12 +38,19 @@
"test:asm": "ASM=true vitest run --dir ./test",
"test:wasm": "vitest run --dir ./test"
},
"repository": "shuding/yoga-wasm-web",
"repository": {
"type": "git",
"url": "git://github.com/bitfrost/yoga-wasm-web"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"license": "MIT",
"files": [
"dist",
"package.json",
"LICENSE"
"LICENSE",
"yoga/javascript/src_js/generated"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
Expand Down
Loading

0 comments on commit 6fbc323

Please sign in to comment.