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
65 changes: 65 additions & 0 deletions .changeset/per-variant-dist-dirs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
"@prosopo/account": patch
"@prosopo/api-express-router": patch
"@prosopo/api": patch
"@prosopo/api-route": patch
"@prosopo/audio-assets": patch
"@prosopo/captcha-severity": patch
"@prosopo/client-bundle-example": patch
"@prosopo/client-example-server": patch
"@prosopo/cli": patch
"@prosopo/common": patch
"@prosopo/config": patch
"@prosopo/cypress-shared": patch
"@prosopo/database": patch
"@prosopo/datasets": patch
"@prosopo/datasets-fs": patch
"@prosopo/detector-botd": patch
"@prosopo/detector": patch
"@prosopo/dotenv": patch
"@prosopo/env": patch
"@prosopo/fingerprint": patch
"@prosopo/icon-order-assets": patch
"@prosopo/ipinfo": patch
"@prosopo/keyring": patch
"@prosopo/lint": patch
"@prosopo/load-balancer": patch
"@prosopo/locale": patch
"@prosopo/logger": patch
"@prosopo/native-ja4": patch
"@prosopo/native-merkle": patch
"@prosopo/native-puzzle": patch
"@prosopo/procaptcha-audio": patch
"@prosopo/procaptcha-bundle": patch
"@prosopo/procaptcha-common": patch
"@prosopo/procaptcha": patch
"@prosopo/procaptcha-frictionless": patch
"@prosopo/procaptcha-icon-order": patch
"@prosopo/procaptcha-integration-build-config": patch
"@prosopo/procaptcha-pow": patch
"@prosopo/procaptcha-puzzle": patch
"@prosopo/procaptcha-react": patch
"@prosopo/procaptcha-wrapper": patch
"@prosopo/prosoponator-bot": patch
"@prosopo/provider": patch
"@prosopo/provider-mock": patch
"@prosopo/puzzle-assets": patch
"@prosopo/redis-client": patch
"@prosopo/scripts": patch
"@prosopo/server": patch
"@prosopo/types-database": patch
"@prosopo/types-env": patch
"@prosopo/types": patch
"@prosopo/user-access-policy": patch
"@prosopo/util-crypto": patch
"@prosopo/util": patch
"@prosopo/web-bot-auth": patch
"@prosopo/widget-skeleton": patch
"@prosopo/workspace": patch
---

Each kind of build now writes to its own folder under dist: dist/esm (vite ESM), dist/cjs (vite CommonJS), dist/types (declarations), dist/tsc (plain tsc), dist/bundle and dist/bundle-webpack (bundles) and dist/native (the Rust addons). Turbo caches each folder separately, so building one variant no longer overwrites or invalidates another. Package exports point at the new folders; anything importing a file from dist by path has to add the variant folder.

The Rust addons are no longer committed. They are built into dist/native, in debug for development and tests and fully optimised when NODE_ENV=production, so building them now needs a Rust toolchain.

Code that found the repo root or its certificates by climbing a fixed number of folders up from its own file now starts from its package's folder instead (new `packageDir` in @prosopo/util/node). The fixed count stopped working once the build output moved one folder deeper.
5 changes: 2 additions & 3 deletions .github/workflows/locales.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ jobs:

# vite.test.config.ts imports the built @prosopo/config and needs an
# .env.test, and the type tests resolve locale's other workspace
# dependencies (such as @prosopo/util) through their dist/*.d.ts, which
# only build:tsc emits — `build` is a vite bundle with no declarations.
- run: pnpm exec turbo run @prosopo/config#build build:tsc --filter='@prosopo/locale^...'
# dependencies (such as @prosopo/util) through their dist/types.
- run: pnpm exec turbo run @prosopo/config#build build:types --filter='@prosopo/locale^...'

- run: cp dev/scripts/env.test .env.test

Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ docker/dns-tenants.json
# ANDROID_HOME and breaks the build everywhere else, CI included.
local.properties

# napi builds only the linux target (see `napi.targets` in each native package),
# and that artefact is committed. A local build on any other platform is not.
packages/native-*/index.*.node
!packages/native-*/index.linux-x64-gnu.node

# Private key material, by shape rather than by path. A path-specific ignore
# only covers the directory someone thought of; this covers the shape. Nothing
# matching these is tracked, so there are no exceptions. If a public certificate
Expand Down
15 changes: 7 additions & 8 deletions demos/client-bundle-example/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@prosopo/client-bundle-example",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
}
},
Expand All @@ -14,13 +14,12 @@
"node": "^24"
},
"scripts": {
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
"build": "pnpm run build:cross-env --mode ${NODE_ENV:-development}",
"build:cross-env": "vite build --config vite.esm.config.ts",
"clean": "del-cli --verbose dist",
"build:esm": "vite build --config vite.esm.config.ts --mode ${NODE_ENV:-development}",
"build:tsc": "tsc --build --verbose",
"build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
"bundle": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.config.ts --mode $NODE_ENV",
"typecheck": "tsc --project tsconfig.types.json",
"build:types": "tsc --project tsconfig.types.json",
"start": "NODE_ENV=${NODE_ENV:-development}; vite serve ./src --port 9232 --config vite.config.ts --mode=$NODE_ENV",
"test": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --config ./vite.test.config.ts"
},
Expand Down
2 changes: 2 additions & 0 deletions demos/client-bundle-example/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "./dist/types",
"tsBuildInfoFile": null,
"declaration": true,
"declarationMap": true,
"composite": false
Expand Down
18 changes: 9 additions & 9 deletions demos/client-bundle-example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default defineConfig(({ command, mode }) => {
commonjsOptions: {
transformMixedEsModules: true,
},
outDir: "dist",
outDir: "dist/bundle",
emptyOutDir: false,
rollupOptions: {
input: {
Expand Down Expand Up @@ -287,35 +287,35 @@ export default defineConfig(({ command, mode }) => {
name: "copy-files",
closeBundle() {
// This runs after all other plugins have processed files
console.log("Copying additional files from src to dist...");
console.log("Copying additional files from src to dist/bundle...");
// Only copy assets and other non-HTML files since HTML files are processed by Vite
const srcAssetsDir = path.resolve(__dirname, "src/assets");

const destAssetsDir = path.resolve(__dirname, "dist/assets");
const destAssetsDir = path.resolve(__dirname, "dist/bundle/assets");
if (fs.existsSync(srcAssetsDir)) {
copyDirContents(srcAssetsDir, destAssetsDir);
}

// Copy any other necessary directories
const srcPluginsDir = path.resolve(__dirname, "src/plugins");
const destPluginsDir = path.resolve(__dirname, "dist/plugins");
const destPluginsDir = path.resolve(__dirname, "dist/bundle/plugins");
if (fs.existsSync(srcPluginsDir)) {
copyDirContents(srcPluginsDir, destPluginsDir);
}

// Final step: move any content from dist/src to dist root
const distSrcDir = path.resolve(__dirname, "dist/src");
const distDir = path.resolve(__dirname, "dist");
const distSrcDir = path.resolve(__dirname, "dist/bundle/src");
const distDir = path.resolve(__dirname, "dist/bundle");
if (fs.existsSync(distSrcDir)) {
console.log("Moving files from dist/src to dist root...");
console.log("Moving files from dist/bundle/src to dist/bundle...");
moveDirectoryContents(distSrcDir, distDir, true);

// Try to remove the now-empty dist/src directory
try {
fs.rmdirSync(distSrcDir);
console.log("Removed empty dist/src directory");
console.log("Removed empty dist/bundle/src directory");
} catch (err) {
console.warn("Could not remove dist/src directory:", err);
console.warn("Could not remove dist/bundle/src directory:", err);
}
}
},
Expand Down
15 changes: 7 additions & 8 deletions demos/client-example-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "@prosopo/client-example-server",
"version": "2.7.184",
"description": "Backend for client-example",
"main": "dist/app.js",
"types": "dist/app.d.ts",
"main": "dist/esm/app.js",
"types": "dist/types/app.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./dist/app.d.ts"
"types": "./dist/types/app.d.ts"
}
},
"type": "module",
Expand All @@ -17,16 +17,15 @@
},
"scripts": {
"dev": "NODE_ENV=${NODE_ENV:-development}; vite serve --mode=$NODE_ENV --config ./vite.config.ts --host",
"start": "NODE_ENV=${NODE_ENV:-development}; node ./dist/app.js",
"start": "NODE_ENV=${NODE_ENV:-development}; node ./dist/esm/app.js",
"start:bundle": "node ./dist/bundle/prosopo_client_example_server.app.bundle.js",
"build": "pnpm run build:cross-env --mode ${NODE_ENV:-development}",
"build:cross-env": "vite build --config vite.esm.config.ts",
"build:esm": "vite build --config vite.esm.config.ts --mode ${NODE_ENV:-development}",
"build:tsc": "tsc --build --verbose",
"build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
"docker-tag": "node ../../docker/docker-tag.mjs",
"build:docker": "docker buildx build --progress=plain --tag $(pnpm run --silent docker-tag) --platform linux/amd64 -f ./Dockerfile ../..",
"publish:docker": "docker push $(pnpm run --silent docker-tag)",
"typecheck": "tsc --project tsconfig.types.json",
"build:types": "tsc --project tsconfig.types.json",
"test": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --config ./vite.test.config.ts",
"test:watch": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest --config ./vite.test.config.ts",
"test:coverage": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --coverage --config ./vite.test.config.ts",
Expand Down
8 changes: 4 additions & 4 deletions demos/client-example-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import type { Server } from "node:http";
import https from "node:https";
import type { ServerOptions } from "node:https";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { ProsopoError } from "@prosopo/common";
import { loadEnv } from "@prosopo/dotenv";
import { getLogger } from "@prosopo/logger";
import { getServerConfig } from "@prosopo/server";
import type { ProsopoServerConfigOutput } from "@prosopo/types";
import { at, isMain } from "@prosopo/util";
import { packageDir } from "@prosopo/util/node";
import cors from "cors";
import express from "express";
import routesFactory from "./routes/routes.js";
Expand Down Expand Up @@ -120,10 +120,10 @@ export const resolvePort = (config: ProsopoServerConfigOutput): number => {
export const startServer = (
app: express.Express,
port: number,
dirname: string = path.dirname(fileURLToPath(import.meta.url)),
pkgDir: string | undefined = packageDir(import.meta.url),
): Server => {
if (isDevelopmentOrTest()) {
const certsDir = path.resolve(dirname, "../../../certs");
if (isDevelopmentOrTest() && pkgDir !== undefined) {
const certsDir = path.resolve(pkgDir, "../../certs");

const keyPath = path.join(certsDir, "server.key");
const certPath = path.join(certsDir, "server.crt");
Expand Down
8 changes: 4 additions & 4 deletions demos/client-example-server/src/tests/app.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ describe("startServer", () => {
test("serves HTTPS in development when the certificates exist", async () => {
process.env.NODE_ENV = "development";
const root = certDir();
// startServer resolves ../../../certs relative to the module, so the
// fake module directory sits three levels below the cert directory.
const moduleDir = path.join(root, "certs", "a", "b");
// startServer resolves ../../certs from the package directory, so the
// fake package sits two levels below the repo holding the certs.
const moduleDir = path.join(root, "certs", "a");
fs.mkdirSync(moduleDir, { recursive: true });
const certs = path.join(root, "certs");
// A throwaway self-signed pair would need openssl; the files only have
Expand All @@ -316,7 +316,7 @@ describe("startServer", () => {
.mockReturnValue(
fake as unknown as ReturnType<typeof https.createServer>,
);
startServer(express(), 1234, path.join(certs, "a", "b"));
startServer(express(), 1234, path.join(certs, "a"));
expect(createServer).toHaveBeenCalledTimes(1);
const options = createServer.mock.calls[0]?.[0] as {
key: Buffer;
Expand Down
3 changes: 2 additions & 1 deletion demos/client-example-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"outDir": "./dist/tsc",
"tsBuildInfoFile": "./dist/tsc/tsconfig.tsbuildinfo",
"lib": ["dom", "dom.iterable", "esnext"]
},
"include": [
Expand Down
2 changes: 2 additions & 0 deletions demos/client-example-server/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "./dist/types",
"tsBuildInfoFile": null,
"declaration": true,
"declarationMap": true,
"composite": false
Expand Down
13 changes: 6 additions & 7 deletions demos/cypress-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "2.8.160",
"private": true,
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
}
},
Expand Down Expand Up @@ -45,11 +45,10 @@
"vitest": "5.0.4"
},
"scripts": {
"build": "pnpm run build:cross-env --mode ${NODE_ENV:-development}",
"build:cross-env": "vite build --config vite.esm.config.ts",
"build:esm": "vite build --config vite.esm.config.ts --mode ${NODE_ENV:-development}",
"build:tsc": "tsc --build --verbose",
"build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
"typecheck": "tsc --project tsconfig.types.json",
"build:types": "tsc --project tsconfig.types.json",
"test": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --config ./vite.test.config.ts",
"cypress:open:client-bundle-example:image": "NODE_TLS_REJECT_UNAUTHORIZED=0 CAPTCHA_TYPE=image CYPRESS_BASE_URL='https://localhost:9232' cypress open --config-file cypress.image.config.js",
"cypress:run:client-bundle-example:image": "NODE_TLS_REJECT_UNAUTHORIZED=0 CAPTCHA_TYPE=image CYPRESS_BASE_URL='https://localhost:9232' cypress run --browser ${PROSOPO_CYPRESS_BROWSER:-chrome} --config-file cypress.image.config.js",
Expand Down
2 changes: 2 additions & 0 deletions demos/cypress-shared/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "./dist/types",
"tsBuildInfoFile": null,
"declaration": true,
"declarationMap": true,
"composite": false
Expand Down
6 changes: 3 additions & 3 deletions demos/detector-botd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"node": "^24"
},
"scripts": {
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
"build": "vite build --config vite.config.ts",
"clean": "del-cli --verbose dist",
"bundle": "vite build --config vite.config.ts",
"build:tsc": "tsc --build --verbose",
"typecheck": "tsc --project tsconfig.types.json",
"build:types": "tsc --project tsconfig.types.json",
"pool": "tsx src/pool.ts",
"test": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --config ./vite.test.config.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion demos/detector-botd/src/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const main = (): void => {
);
if (!existsSync(detectorPath)) {
throw new Error(
"no built detector: run `pnpm --filter @prosopo/detector-botd run build` first",
"no built detector: run `pnpm --filter @prosopo/detector-botd run bundle` first",
);
}
const out = resolve(process.env.INIT_CWD ?? process.cwd(), values.out);
Expand Down
3 changes: 2 additions & 1 deletion demos/detector-botd/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"outDir": "./dist/tsc",
"tsBuildInfoFile": "./dist/tsc/tsconfig.tsbuildinfo",
"module": "NodeNext",
"lib": ["es2022", "dom"]
},
Expand Down
2 changes: 2 additions & 0 deletions demos/detector-botd/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "./dist/types",
"tsBuildInfoFile": null,
"declaration": true,
"declarationMap": true,
"composite": false
Expand Down
Loading
Loading