Skip to content

feat(): Last step for project modernization#34

Merged
kalwalt merged 12 commits into
masterfrom
dev
Jun 4, 2026
Merged

feat(): Last step for project modernization#34
kalwalt merged 12 commits into
masterfrom
dev

Conversation

@kalwalt
Copy link
Copy Markdown
Member

@kalwalt kalwalt commented Jun 3, 2026

Summary

Roll-up of the toolchain, tests, CI, and docs work that landed on dev since the previous master cut. Closes the modernization roadmap (#31).

Build toolchain

  • Replace webpack + Babel with Vite. Five devDependencies (webpack, webpack-cli, babel-loader, @babel/core, @babel/preset-env) collapse to one (vite). Library mode emits the same two outputs as before: dist/ARFset.js (ESM) and dist/ARFset.umd.js (UMD with window.ARFset).
  • TOTAL_MEMORYINITIAL_MEMORY in tools/makem.cjs (the former was renamed in emscripten 1.39.x and now warns).
  • tools/makem.jstools/makem.cjs so Node treats the build script as CommonJS now that package.json has "type": "module".

Tests

  • Vitest unit tests for Utils (string2Uint8Data, fetchRemoteData, fetchRemoteDataBlobfetch stubbed) and the ARFset constructor (option defaults, partial overrides, initial fields, version banner; the wasm wrapper is mocked at import time).
  • Playwright e2e smoke test drives a real Chromium against example/example_es6.html, waits for display() to paint the canvas, and asserts non-empty pixel content + zero console errors.
  • vitest.config.js scopes Vitest discovery to tests/unit/**/*.test.js so it doesn't try to collect the Playwright spec.
  • playwright.config.js boots http-server automatically via the webServer block.

CI

  • .github/workflows/ci.yml with two parallel jobs:
    • unit: fast — npm ci + vitest run, no emsdk.
    • build-and-e2e: clones submodules, sets up emsdk via mymindstorm/setup-emsdk@v14 (cached), npm run build (wasm), npm run build-es6 (JS bundles), installs Chromium, runs Playwright. Uploads playwright-report/ as an artifact on failure for triage.
  • concurrency.cancel-in-progress aborts superseded runs on the same PR/branch.

Docs

  • README rewritten from a 6-line stub into a full user-facing doc:
    • Tagline + "what you get" summary.
    • Quick-start for both ESM (import) and <script> paths.
    • API table for the constructor options + every public method.
    • Documented nftMarker / imageEv events.
    • Mermaid flowchart of the data path (user → ARFset → fetch → wasm FS → wasm → nftMarker event → canvas).
    • Build-from-source section (emsdk + Python + submodules).
    • 0.3.x → 0.4.x migration block.
  • Dropped the empty-string contributors entry from package.json (npm publish was warning on it).
  • Ignored test-results/, playwright-report/, playwright/.cache/, coverage/ in .gitignore.

Test plan

  • npm test passes locally (Vitest, 12 tests)
  • npm run build produces arfset_wasm.{js,wasm} and arfset_ES6_wasm.js — no asm.js artifacts
  • npm run build-es6 produces dist/ARFset.js (ESM) and dist/ARFset.umd.js (UMD)
  • dist/ARFset.d.ts is preserved across builds
  • example/example_es6.html and example/demo.html behave identically to dev
  • CI runs green (unit + build-and-e2e) on this PR

Closes

Closes #26
Closes #27
Closes #28
Closes #29
Closes #30
Closes #31

claude added 2 commits June 3, 2026 22:00
Replaces webpack 5 + babel-loader + @babel/preset-env + @babel/core
with a single 'vite' devDependency. Vite uses esbuild internally
and targets esnext, matching the WebAssembly hard requirement of
the library's runtime.

- Add vite.config.js using Vite library mode. Produces the same two
  outputs as before (dist/ARFset.js as ESM, dist/ARFset.umd.js as UMD
  exposing window.ARFset) with no consumer-visible change in shape.
- Delete webpack.config.cjs.
- Replace 5 devDependencies (webpack, webpack-cli, babel-loader,
  @babel/core, @babel/preset-env) with 1 (vite).
- Update scripts: build-es6 -> 'vite build', dev-es6 -> 'vite build --watch'.
- Drop the obsolete 'watch' script (legacy js/ directory is gone).
- Preserve the hand-written dist/ARFset.d.ts across builds via
  emptyOutDir: false.

Refs #26
Refs #31
TOTAL_MEMORY was renamed to INITIAL_MEMORY in emscripten 1.39.x.
Modern emcc accepts both as an alias but warns; using the current
spelling silences the warning.

Refs #27
Refs #31
@kalwalt kalwalt self-assigned this Jun 3, 2026
@kalwalt kalwalt added enhancement New feature or request js code dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code labels Jun 3, 2026
@kalwalt kalwalt changed the title Dev last step for project mdernization Jun 3, 2026
@kalwalt kalwalt changed the title last step for project mdernization last step for project modernization Jun 3, 2026
kalwalt and others added 10 commits June 3, 2026 22:15
Two complementary layers:

Vitest covers the pure JS paths that don't need wasm:
- Utils.string2Uint8Data, fetchRemoteData, fetchRemoteDataBlob
  (fetch is stubbed via vi.fn so no network is touched)
- ARFset constructor (option handling, defaults, initial fields,
  version banner) with the wasm wrapper mocked out so importing
  src/ARFset.js stays cheap

Playwright drives a real Chromium against example_es6.html, waits
for the canvas to be populated by display(), and asserts the canvas
has non-empty pixel content. This exercises the full wasm -> JS ->
canvas path end to end.

Scripts:
  npm test                 -> vitest run
  npm run test:watch       -> vitest in watch mode
  npm run test:e2e:install -> playwright install --with-deps chromium
                              (one-shot per machine)
  npm run test:e2e         -> playwright test

devDependencies added: vitest, @playwright/test, http-server
(needed for Playwright's webServer block).

Refs #28
Refs #31
Two jobs that run on every PR and on pushes to dev/master:

- unit (fast): npm ci + vitest. No emsdk, no wasm.
- build-and-e2e: clones submodules, sets up emsdk via
  mymindstorm/setup-emsdk@v14 (cached), builds wasm
  (npm run build), builds JS bundles (npm run build-es6),
  installs Chromium, runs Playwright. Uploads the
  playwright-report/ directory on failure for triage.

concurrency.cancel-in-progress lets a new push to the same PR
abort the previous run automatically.

No auto-publish on tag yet; release is still a manual npm publish.

Refs #29
Refs #31
- exclude test artifacts files from git
…specs

Vitest discovers any *.test.js / *.spec.js by default and tried to
import tests/e2e/marker-load.spec.js, where @playwright/test's test()
errors out because it's invoked outside the Playwright runner.
provide tests and CI to the project
Replace the 6-line stub README with a full quick-start, API reference,
architecture diagram, build-from-source instructions, and 0.3.x ->
0.4.x migration notes.

- Quick-start sections for both ESM (import) and UMD (<script>) paths
- API table for ARFset constructor options and methods
- Documented events (nftMarker, imageEv) dispatched on document
- Mermaid flowchart of the user -> JS -> wasm -> canvas data flow,
  with a link into emscripten/ARimageFsetDisplay.cpp
- Build prerequisites (Node 22+, emsdk + EMSDK env, Python, submodules)
  and the four common npm scripts (build, build-es6, test, test:e2e)
- Migration block contrasting the old window.ARfset global with the new
  ARFsetModule.ARFset class

Also removes the empty-string contributors entry from package.json
that npm publish would otherwise warn about.

Refs #30
Refs #31
Replace the 6-line stub README with a full quick-start, API reference,
architecture diagram, build-from-source instructions, and 0.3.x ->
0.4.x migration notes.

- Quick-start sections for both ESM (import) and UMD (<script>) paths
- API table for ARFset constructor options and methods
- Documented events (nftMarker, imageEv) dispatched on document
- Mermaid flowchart of the user -> JS -> wasm -> canvas data flow,
  with a link into emscripten/ARimageFsetDisplay.cpp
- Build prerequisites (Node 22+, emsdk + EMSDK env, Python, submodules)
  and the four common npm scripts (build, build-es6, test, test:e2e)
- Migration block contrasting the old window.ARfset global with the new
  ARFsetModule.ARFset class

Also removes the empty-string contributors entry from package.json
that npm publish would otherwise warn about.

Refs #30
Refs #31
@kalwalt kalwalt changed the title last step for project modernization feat(): Last step for project modernization Jun 4, 2026
@kalwalt kalwalt merged commit 46882ca into master Jun 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment