Skip to content
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
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install
- run: npm run test:all
# the built artifacts are committed (the demo pages load them) — fail if a
# change to src/ or tools/ was pushed without rebuilding dist/
- run: npm run build
- run: git diff --exit-code -- dist
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ each facet derives its own normal so the shading is flat.

## Minified build

`dist/tinywebgpu.min.js` — **15.7 KB** (7.7 KB gzipped), versus 91 KB for the source. Rebuild it with
`dist/tinywebgpu.min.js` — **15.5 KB** (7.4 KB gzipped), versus 91 KB for the source. Rebuild it with
`npm run build:min` (esbuild is the only dev dependency; consumers still install nothing).

It is a **production artifact and it is silent**: every `console` warning is stripped, and so are
Expand All @@ -306,10 +306,10 @@ accident.
## Tiny build (inline / on-chain embedding)

When the library has to be *inlined* — a single self-contained HTML file, an on-chain generative
artwork with a hard byte budget — 15.7 KB of it is still mostly features you are not using. A
artwork with a hard byte budget — 15.5 KB of it is still mostly features you are not using. A
procedural piece renders from a shader and never touches image loading, readback, or PNG export.

`npm run build:tiny` produces **`dist/tinywebgpu.tiny.js` — 8.8 KB** (4.6 KB gzipped) by dropping
`npm run build:tiny` produces **`dist/tinywebgpu.tiny.js` — 8.5 KB** (4.5 KB gzipped) by dropping
every optional entry point, and adding `--iife --no-banner` gets a classic
`<script>` that assigns `globalThis.WEBGPU` for the same size. Two of the dropped switches trade
*behavior* rather than entry points, so know what you are giving up:
Expand Down Expand Up @@ -352,7 +352,7 @@ node tools/build-min.mjs tiny --iife --no-banner --out=twg.js
node tools/build-min.mjs --config=my.config.mjs a config of your own
```

What each switch is worth, measured against the 15.7 KB build:
What each switch is worth, measured against the 15.5 KB build:

| `--without=` | Removes | Saves |
|---|---|---|
Expand Down
4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ the longer spellings above.
| File | Size | What it is |
|---|---|---|
| `src/tinywebgpu.js` | 91 KB | the source, with comments and every diagnostic. `main`/`exports` point here. |
| `dist/tinywebgpu.min.js` | 15.7 KB (7.7 gz) | `npm run build:min`. Silent: no console output, no compile-error window, no resource validator, no debug labels. Errors still throw with their messages. |
| `dist/tinywebgpu.tiny.js` | 8.8 KB (4.6 gz) | `npm run build:tiny`. The above, plus every optional entry point removed and error text folded to numbers. For inlining into a single file. |
| `dist/tinywebgpu.min.js` | 15.5 KB (7.4 gz) | `npm run build:min`. Silent: no console output, no compile-error window, no resource validator, no debug labels. Errors still throw with their messages. |
| `dist/tinywebgpu.tiny.js` | 8.5 KB (4.5 gz) | `npm run build:tiny`. The above, plus every optional entry point removed and error text folded to numbers. For inlining into a single file. |

`build:tiny` drops `writeTexture`, `loadTexture`, `readTexture`, buffer `.r()`, `save`, `show`,
the ping-pong helpers, `resizeCanvas`, depth support, mipmaps, the staging ring (in-frame writes become plain queue writes — last value per frame wins), the long aliases, and the named blend presets. Tiny builds also pack repeated WebGPU member names into a string table (`--no-pack` to skip). Keep any of them with
Expand Down
Loading