Skip to content

wasm-pack -> justfile #2931

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions frontend/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://just.systems

output := 'wasm'/'pkg'/'graphite_wasm_bg.wasm'

build profile='debug':
# Build the rust code into the target directory
cargo build -p graphite-wasm --lib --target wasm32-unknown-unknown --color=always {{ if profile != "debug" { "--release" } else { "" } }}

# Create a directory to store the package in
mkdir -p pkg

# Build the JS glue and patch wasm
wasm-bindgen \
{{ '..' / 'target' / 'wasm32-unknown-unknown' / if profile != "debug" { 'release' / 'graphite_wasm.wasm' } else { 'debug' / 'graphite_wasm.wasm' } }} \
--out-dir {{ 'wasm' / 'pkg' }} --typescript --target web \
{{ if profile != "release" { "--debug" } else { "" } }} \
{{ if profile == "release" { "--no-demangle" } else { "" } }} \
{{ if profile == "profiling" { "--keep-debug" } else { "" } }}

# Apply optimisations (if necessary)
{{ if profile != 'debug' { "wasm-opt " + output + " -o " + output + " -Os -g" } else { "" } }}


228 changes: 225 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"lint-fix": "eslint . --fix && tsc --noEmit",
"---------- INTERNAL ----------": "",
"setup": "node package-installer.js",
"wasm:build-dev": "wasm-pack build ./wasm --dev --target=web",
"wasm:build-profiling": "wasm-pack build ./wasm --profiling --target=web",
"wasm:build-production": "wasm-pack build ./wasm --release --target=web",
"wasm:watch-dev": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"wasm-pack build . --dev --target=web -- --color=always\"",
"wasm:watch-profiling": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"wasm-pack build . --profiling --target=web -- --color=always\"",
"wasm:watch-production": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"wasm-pack build . --release --target=web -- --color=always\""
"wasm:build-dev": "just build debug",
"wasm:build-profiling": "just build profiling",
"wasm:build-production": "just build release",
"wasm:watch-dev": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"just --color=always build debug\"",
"wasm:watch-profiling": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"just --color=always build profiling\"",
"wasm:watch-production": "cargo watch --postpone --watch-when-idle --workdir=wasm --shell \"just --color=always build release\""
},
"dependencies": {
"@fontsource/inconsolata": "^5.2.5",
Expand All @@ -45,6 +45,7 @@
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-svelte": "^2.44.0",
"just-install": "^2.0.2",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
Expand Down
Loading
Loading