Skip to content

chore(wasm): collapse js/ into root, keep TS sources in src/#606

Merged
bokuweb merged 2 commits intowasmfrom
chore/wasm-collapse-js-to-root
May 3, 2026
Merged

chore(wasm): collapse js/ into root, keep TS sources in src/#606
bokuweb merged 2 commits intowasmfrom
chore/wasm-collapse-js-to-root

Conversation

@bokuweb
Copy link
Copy Markdown
Member

@bokuweb bokuweb commented May 3, 2026

Summary

After #605 dropped the legacy JS impl, the dual root/ + js/ layout was no longer load-bearing — package.json at the root was just a private: true stub while the real package.json that publishes to npm lived one directory deeper.

This PR collapses js/ into the repo root so the root is the published package, then organises the TypeScript sources into src/ (the npm convention — keeps the root scannable instead of dumping a dozen .ts files next to package.json / Cargo.toml / README).

The package still publishes as @bokuweb/reg-cli-wasm@0.0.0-experimental6. Renaming to reg-cli is the next step once a publish dry-run lands cleanly.

Final layout

  • root: package.json, pnpm-lock.yaml, tsconfig.json, build.config.ts, reg.wasm, Cargo.toml/Cargo.lock, rust-toolchain.toml, README.md
  • src/: cli.ts, entry.ts, index.ts, progress.ts, proxy.{js,ts}, tracing.ts, utils.ts, worker.ts, ximgdiff.ts
  • test/, sample/, crates/, template/, report/, scripts/, bench/, docs/: unchanged

Moves (history-preserving git mv)

  • js/{*.ts, *.js, package.json, pnpm-lock.yaml, reg.wasm} → root, then *.{ts,js}src/
  • js/sample/sample/
  • js/test/test/

Path adjustments

  • build.config.ts: repoRoot = resolve(here, '..') → just here; entries → ./src/{index,cli,worker,entry}.ts
  • tsconfig.json: include./src/**/*.ts
  • test/{cli,library}.test.mjs: REPO/SAMPLE_REL/CLI/DIST/TMP_ROOT_* drop the leading js/ segment
  • scripts/build-wasm.sh: copies to ./reg.wasm (was js/reg.wasm)
  • .github/workflows/ci.yml: drop working-directory: js; rename steps
  • .gitignore: collapse the workspace path

Verification

  • pnpm install --frozen-lockfile
  • pnpm build ✓ (dist regenerated; tarball shasum identical byte-for-byte to pre-collapse: 0d8db1e5...)
  • pnpm test38 / 38
  • cargo +stable test -p reg_core --lib --locked12 / 12
  • npm pack --dry-run → publishable as @bokuweb/reg-cli-wasm@0.0.0-experimental6 (32 files, 926.6 kB)

Test plan

  • CI green
  • Confirm npm publish --dry-run (or actual publish) succeeds; once that's confirmed, the reg-cli rename PR is unblocked.

🤖 Generated with Claude Code

bokuweb and others added 2 commits May 3, 2026 14:02
The Wasm wrapper used to live under `js/` while the legacy JS impl
sat at the root. After #605 dropped the legacy impl the dual layout
was no longer load-bearing, just confusing — `package.json` at the
root was a stub `private: true` shim while the real package.json that
publishes to npm lived one directory deeper.

Moves (preserving git history via `git mv`)
-------------------------------------------
- js/{build.config.ts, cli.ts, entry.ts, index.ts, progress.ts,
  proxy.{js,ts}, tracing.ts, tsconfig.json, utils.ts, worker.ts,
  ximgdiff.ts, reg.wasm} → root
- js/sample/   → sample/
- js/test/     → test/
- js/package.json → root package.json (overwrites the stub; keeps the
  top-level `packageManager` field and adds a `repository` block)
- js/pnpm-lock.yaml → root pnpm-lock.yaml

Path adjustments
----------------
- build.config.ts: `repoRoot = resolve(here, '..')` → just `here`.
- test/{cli,library}.test.mjs: REPO/SAMPLE_REL/CLI/DIST/TMP_ROOT_*
  drop the leading `js/` segment.
- scripts/build-wasm.sh: copies to `./reg.wasm` (was `js/reg.wasm`).
- .github/workflows/ci.yml: drop `working-directory: js` from install/
  build/test steps; rename them.
- .gitignore: collapse the workspace path.

Verification
------------
- `pnpm install --frozen-lockfile` ✓
- `pnpm build` ✓ (dist regenerated; `reg-cli-wasm.*` chunks identical
  byte-for-byte to pre-collapse)
- `pnpm test` → 38 / 38 ✓
- `cargo +stable test -p reg_core --lib --locked` → 12 / 12 ✓
- `npm pack --dry-run` → publishable as
  `@bokuweb/reg-cli-wasm@0.0.0-experimental6` (32 files, 926 kB)
- end-to-end: `node ./dist/cli.mjs ./sample/actual ./sample/expected
  /tmp/diff -I` exits 0 with classic per-file output.

The package still publishes as `@bokuweb/reg-cli-wasm`. Renaming back
to `reg-cli` is the next step once a publish dry-run lands cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reverts the visual flatness from the previous collapse. Having a dozen
.ts files at the repo root next to package.json / Cargo.toml /
README.md was hard to scan; the npm convention is `src/` for the
TypeScript sources and the root for package metadata + build config.

Moved (history-preserving git mv): cli.ts, entry.ts, index.ts,
progress.ts, proxy.{js,ts}, tracing.ts, utils.ts, worker.ts,
ximgdiff.ts → src/

Build config:
- build.config.ts entries → ./src/{index,cli,worker,entry}.ts
- tsconfig.json `include` → ./src/**/*.ts

Stays at root: package.json, pnpm-lock.yaml, build.config.ts,
tsconfig.json, reg.wasm, sample/, test/, scripts/, crates/, template/,
report/.

Verified: pnpm build → identical tarball (`shasum 0d8db1e5...`,
926.6 kB, 32 files) as the flat layout. pnpm test → 38/38.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokuweb bokuweb changed the title chore(wasm): collapse js/ into the repo root (publishable from root as @bokuweb/reg-cli-wasm) chore(wasm): collapse js/ into root, keep TS sources in src/ May 3, 2026
@bokuweb bokuweb merged commit b95a1c6 into wasm May 3, 2026
2 checks passed
@bokuweb bokuweb deleted the chore/wasm-collapse-js-to-root branch May 3, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant