Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose yoga.wasm in a bun --compile friendly way #1

Merged
merged 6 commits into from
Mar 23, 2024
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
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
Loading