Skip to content

Commit 268e0c6

Browse files
fix(core): stop bundling vitest into public entry points (#17)
* fix(core): stop bundling vitest into public entry points `src/index.ts` re-exported the generic test helpers via `export * as tests from "./tests/index.js"`. A re-exported namespace cannot be tree-shaken, so the helpers and their top-level `import { expect } from "vitest"` were bundled into every public entry (dist/index.js, dist/index.cjs, dist/index.iife.js). Because vitest is only a devDependency, importing `@frosts/core` — or any `@frosts/<curve>` that depends on it — crashed at module load with ERR_MODULE_NOT_FOUND for consumers without vitest installed. The test helpers are now published under a dedicated `@frosts/core/tests` subpath instead of the main entry. The build uses code splitting so the subpath shares the same core runtime chunks as the main entry, preserving the `instanceof` checks in the helpers (avoiding a dual-package hazard). IIFE, which cannot be split, is built separately for the public entry only. Consumers of the generic test functions update their imports: -import { tests } from "@frosts/core"; +import * as tests from "@frosts/core/tests"; Verified: public entries and shared chunks contain no vitest import; importing `@frosts/core` and `@frosts/ed25519` succeeds in a sandbox without vitest; full test suite and typecheck pass across all packages. Fixes the published 0.2.2-alpha.1 / 0.2.2-alpha.3 crash reported on GitHub. * chore(deps): update all dependencies to their latest versions Bump dev tooling and runtime dependencies across the workspace: - typescript 5.9 -> 6.0 - eslint 9 -> 10, @eslint/js 9 -> 10 - @types/node 25 -> 26 - tsdown 0.20 -> 0.22, typedoc 0.28.5 -> 0.28.19, vitest 4.0 -> 4.1 - @typescript-eslint/* 8.53 -> 8.61, eslint-config-turbo 2.7 -> 2.9 - @noble/curves & @noble/hashes 2.0 -> 2.2 - prettier, turbo and @changesets/cli to latest Adjustments required by the upgrades: - tsconfig: add the DOM lib (TextEncoder / Web Crypto globals are no longer provided as Node globals by @types/node 26); widen core's rootDir so TypeScript 6 accepts the interop test's cross-package source imports (TS6059). - tsdown: migrate the deprecated `external` option to `deps.neverBundle`, and disable the ineffective-dynamic-import check in core (intentional pattern under code splitting). - source: cast getRandomValues buffers to Uint8Array<ArrayBuffer> for the stricter lib.dom signature, attach `cause` to a re-thrown error, and drop type assertions now flagged as unnecessary by TS 6's improved inference. format, lint, typecheck, build and tests all pass with no warnings. * chore: release v0.2.2-alpha.4 and drop changesets - Bump all packages and the workspace root to 0.2.2-alpha.4 via scripts/bump-version.ts. - Add a CHANGELOG.md to every published package documenting alpha.4 (the @frosts/core vitest-at-import fix and the dependency refresh), and include CHANGELOG.md in each package's published `files`. - Remove changesets, which the project does not use for versioning (versions are managed by scripts/bump-version.ts): delete the .changeset directory and the @changesets/cli devDependency, and replace the `changeset publish` step in the release workflow with a direct `npm publish --provenance` over the public packages. - Update the README version and TypeScript badges (0.2.2-alpha.4, TS 6.0). * ci(links): ignore bot-blocked npm and IACR links in markdown link check The npm package pages (npmjs.com) and IACR ePrint archive (eprint.iacr.org) return HTTP 403 to the link checker's automated requests even though the links are valid. Add a markdown-link-check config that ignores those two hosts and wire it into the Link Checker workflow via `config-file`.
1 parent 06fcae7 commit 268e0c6

74 files changed

Lines changed: 422 additions & 276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.changeset/config.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.changeset/pre.json

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^https?://(www\\.)?npmjs\\.com/"
5+
},
6+
{
7+
"pattern": "^https?://eprint\\.iacr\\.org/"
8+
}
9+
]
10+
}

.github/workflows/links.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ jobs:
1717
uses: gaurav-nelson/github-action-markdown-link-check@v1
1818
with:
1919
use-quiet-mode: "yes"
20+
config-file: ".github/markdown-link-check-config.json"

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ jobs:
5959
run: bun run scripts/replace-workspace-protocols.ts
6060

6161
- name: Publish to NPM
62-
run: bun changeset publish --provenance
62+
run: |
63+
for PKG in packages/*; do
64+
if [ -f "$PKG/package.json" ]; then
65+
echo "Publishing $PKG ..."
66+
(cd "$PKG" && npm publish --provenance --access public --tag alpha)
67+
fi
68+
done
6369
env:
6470
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
71+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6672

6773
tag:
6874
name: Add NPM Tag (${{ matrix.tag }})

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frosTS - FROST for TypeScript
22

3-
[![Version](https://img.shields.io/badge/version-0.2.2--alpha.3-green)](https://github.com/leonardocustodio/bcts/releases)
4-
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue)](https://www.typescriptlang.org/)
3+
[![Version](https://img.shields.io/badge/version-0.2.2--alpha.4-green)](https://github.com/leonardocustodio/bcts/releases)
4+
[![TypeScript](https://img.shields.io/badge/TypeScript-6.0-blue)](https://www.typescriptlang.org/)
55
[![Monorepo](https://img.shields.io/badge/Monorepo-Turborepo-blueviolet)](https://turbo.build/)
66
[![Package Manager](https://img.shields.io/badge/Package%20Manager-Bun-FFD700)](https://bun.sh/)
77
[![RFC 9591](https://img.shields.io/badge/RFC-9591-informational)](https://datatracker.ietf.org/doc/rfc9591/)

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frosts",
3-
"version": "0.2.2-alpha.3",
3+
"version": "0.2.2-alpha.4",
44
"private": true,
55
"description": "TypeScript implementation of FROST (Flexible Round-Optimized Schnorr Threshold) signatures for threshold cryptography",
66
"author": "Leonardo Custodio <leonardo.custodio@parity.io> (https://github.com/leonardocustodio)",
@@ -41,10 +41,9 @@
4141
"bump-version": "bun run scripts/bump-version.ts"
4242
},
4343
"devDependencies": {
44-
"@changesets/cli": "^2.29.8",
45-
"prettier": "^3.8.1",
46-
"turbo": "^2.7.6",
47-
"typescript": "^5.9.3"
44+
"prettier": "^3.8.4",
45+
"turbo": "^2.9.18",
46+
"typescript": "^6.0.3"
4847
},
4948
"packageManager": "bun@1.3.6",
5049
"workspaces": [

packages/core/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# @frosts/core
2+
3+
## 0.2.2-alpha.4
4+
5+
### Patch Changes
6+
7+
- Fixed `@frosts/core` crashing at import time for consumers that do not have `vitest` installed. The generic, parameterized test helpers — and their top-level `vitest` import — are no longer bundled into the public entry points (`dist/index.js`, `dist/index.cjs`, `dist/index.iife.js`). They are now published under the dedicated `@frosts/core/tests` subpath instead. Consumers of the helpers should update their imports:
8+
9+
```diff
10+
-import { tests } from "@frosts/core";
11+
+import * as tests from "@frosts/core/tests";
12+
```
13+
14+
- Updated all dependencies to their latest versions (TypeScript 6, ESLint 10, tsdown 0.22, Vitest 4.1, typedoc 0.28.19, @types/node 26).

packages/core/package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@frosts/core",
3-
"version": "0.2.2-alpha.3",
3+
"version": "0.2.2-alpha.4",
44
"type": "module",
55
"description": "Core types and traits for FROST (Flexible Round-Optimized Schnorr Threshold) signatures",
66
"license": "MIT",
@@ -24,12 +24,20 @@
2424
"import": "./dist/index.js",
2525
"require": "./dist/index.cjs",
2626
"default": "./dist/index.js"
27-
}
27+
},
28+
"./tests": {
29+
"types": "./dist/tests/index.d.ts",
30+
"import": "./dist/tests/index.js",
31+
"require": "./dist/tests/index.cjs",
32+
"default": "./dist/tests/index.js"
33+
},
34+
"./package.json": "./package.json"
2835
},
2936
"files": [
3037
"dist",
3138
"src",
32-
"README.md"
39+
"README.md",
40+
"CHANGELOG.md"
3341
],
3442
"scripts": {
3543
"build": "tsdown",
@@ -56,16 +64,16 @@
5664
},
5765
"dependencies": {},
5866
"devDependencies": {
59-
"@eslint/js": "^9.39.2",
67+
"@eslint/js": "^10.0.1",
6068
"@frosts/eslint": "workspace:*",
6169
"@frosts/tsconfig": "workspace:*",
62-
"@types/node": "^25.0.10",
63-
"eslint": "^9.39.2",
64-
"fast-check": "^4.5.3",
65-
"prettier": "^3.8.1",
66-
"tsdown": "^0.20.1",
67-
"typedoc": "^0.28.5",
68-
"typescript": "^5.9.3",
69-
"vitest": "^4.0.18"
70+
"@types/node": "^26.0.0",
71+
"eslint": "^10.5.0",
72+
"fast-check": "^4.8.0",
73+
"prettier": "^3.8.4",
74+
"tsdown": "^0.22.3",
75+
"typedoc": "^0.28.19",
76+
"typescript": "^6.0.3",
77+
"vitest": "^4.1.9"
7078
}
7179
}

0 commit comments

Comments
 (0)