Skip to content

Give every build variant its own dist subdirectory - #3605

Merged
goastler merged 3 commits into
mainfrom
dist-variant-dirs
Oct 24, 2026
Merged

goastler merged 3 commits into
mainfrom
dist-variant-dirs

Conversation

@goastler

Copy link
Copy Markdown
Member

What changed: each kind of build output now gets its own folder under dist/, its own npm script and its own turbo task. Before, everything was written straight into dist/.

folder made by script / turbo task
dist/esm vite, ESM build:esm
dist/cjs vite, CommonJS build:cjs
dist/types tsc, .d.ts only build:types (was typecheck)
dist/tsc tsc --build build:tsc
dist/bundle, dist/bundle-webpack vite / webpack bundles bundle, bundle:iife, bundle:webpack
dist/native napi (Rust) build:native
  • build is now just a turbo task that runs build:esm, build:types and build:native.
  • Each task caches only its own folder, so running one variant no longer overwrites or invalidates another. Adding a new variant later means one more script, one more turbo task and one more folder.
  • main / types / exports in every package point at the new folders.
  • The native .node files are no longer committed. build:native makes them: a debug build normally, the fully optimised LTO build when NODE_ENV=production. Building the native packages now needs a Rust toolchain.

Effect: imports work as before, because they go through package exports. Anything that hard-coded a dist/... path has been updated: Dockerfiles, the CLI bundle's native-file copying, locale catalogue lookup, the client-bundle-example deploy path and the locales workflow. Deep imports into dist/ from outside the repo would need updating.

Code that found the repo root or the dev TLS certs by counting ../ from its own file (provider API, client example server, @prosopo/workspace, the self-hosted env script) now starts from its package folder, using a new packageDir helper in @prosopo/util/node. Otherwise it would have looked one folder too low now that builds sit in dist/esm.

Pairs with prosopo/fingerprintjs#12, which makes the same change in the fingerprintjs submodule.

Tests:

  • Ran in a clean worktree:
    • turbo run build, all tasks green
    • a second run with every task cached
    • deleted dist/esm and dist/native folders restored from cache
    • build:tsc and build:cjs
    • the CLI, procaptcha and IIFE bundles, and the webpack bundle
    • unit tests for locale, config, user-access-policy, the native packages, procaptcha-bundle and cli
  • New unit tests for packageDir; updated the cert-lookup test in client-example-server.
  • Updated the i18n backend unit tests for the simpler catalogue path.

@goastler goastler self-assigned this Oct 24, 2026
@goastler
goastler marked this pull request as ready for review October 24, 2026 01:55
@goastler
goastler merged commit 2086040 into main Oct 24, 2026
22 checks passed
@goastler
goastler deleted the dist-variant-dirs branch October 24, 2026 02:26
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