Repository navigation
refactor: build dist one file per module instead of bundling - #91
Merged
Merged
Conversation
@cldmv/vitest-runner 1.5.6 to 1.11.4, @cldmv/configs 1.4.0 to 1.5.0, @cldmv/fix-headers 2.2.6 to 2.6.1, @cldmv/jsonv and @cldmv/prettier-plugin-jsonv 1.1.5/1.1.4 to 1.2.4, and npm update for the rest. No lint fixes were needed. The CI gate (build:ci, then ci:coverage) matched the baseline in k3s-test: 85 passed, 1 skipped, coverage 100% statements / 98.9% branches / 100% functions / 100% lines. fix-headers 2.6.1 also restamped the headers of 51 files: @filename is now written without a leading slash. dependabot.yml takes the npm groups from the CLDMV/.github v4.47.0 template (CLDMV/.github#593).
The build now minifies each src module in place with esbuild (bundle: false, keepNames, node16 target) and copies src/index.cjs verbatim, replacing the tsup bundle. The require() and import export shapes are unchanged; the caller-resolution tests moved to tests/built and now also check the per-module layout. Resolves #83
Shinrai
force-pushed
the
refactor/per-module-build
branch
from
November 28, 2026 18:15
df8eba2 to
f89423c
Compare
Shinrai
previously approved these changes
Nov 28, 2026
cldmv-bot
Bot
dismissed
Shinrai’s stale review
November 28, 2026 22:41
The merge-base changed after approval.
This was referenced Nov 28, 2026
Shinrai
added a commit
that referenced
this pull request
Nov 29, 2026
## 🚀 What's Changed ### 💥 Breaking Changes _No breaking changes_ ### ✨ Features _No new features_ ### 🐛 Bug Fixes _No bug fixes_ ### 📦 Dependencies _No dependency updates_ ### 🔧 Other Changes - docs: cover #89, #90 and #91 in the v2.0.0 changelog (3946fd1) <details> <summary>👥 Contributors</summary> - @Shinrai </details>
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 29, 2026
# `@cldmv/wisp` v2.0.0 Changelog
**Release Date**: November 2026
**Release Type**: Major
**Branch**: `release/2.0.0`
---
## Overview
`require("@cldmv/wisp")` now returns the module object `{ default, wisp, wispSync }`, the same exports `import` gives you, instead of the `wisp` function. That is the only change to the public surface, and it only affects CommonJS callers that called the result of `require()` directly. ESM `import` is unchanged, and so are the options, the JSON loading behaviour and the supported Node.js range.
Caller detection loses a dead flag and `dist/` is now built one minified file per module instead of a tsup bundle, neither of which changes behaviour. The rest of the release is test and CI housekeeping and development-dependency bumps. The package still has no runtime dependencies.
---
## 💥 Breaking Changes
### The CommonJS entry returns the module object ([#86](#86), fixes [#85](#85))
`src/index.cjs`, published as `dist/index.cjs`, is now the generic CLDMV shim. It loads `index.mjs` through synchronous `require(esm)` and hands back what `import` sees. The ESM entry exports two distinct values, `wisp` and `wispSync` (`default` is `wisp`), so `require("@cldmv/wisp")` returns the module object `{ default, wisp, wispSync }` and not the `wisp` function. Before, the CommonJS entry unwrapped the function, so `require("@cldmv/wisp")("./data.json")` worked. It now throws, because the module object is not callable.
- `require(x)(…)` becomes `require(x).wisp(…)`, or `const { wisp } = require(x)`.
- `.wisp`, `.wispSync`, `.default` and destructuring keep working.
- ESM `import` is unchanged.
The `require()` Node.js range is the same as in [v1.0.9](https://github.com/CLDMV/wisp/blob/v2.0.0/docs/changelog/v1/v1.0.9.md): `^20.19.0` or `>=22.13.0`, with the same `ERR_REQUIRE_ESM` message pointing at `import()` on older versions.
---
## 🐛 Bug Fixes
- **Dead flag removed from caller detection** ([#89](#89), resolves [#12](#12)). `pickPrimaryBaseFile()` tracked a second flag for leaving a root `index.*` file but never read it. wisp has no root `index.*` file any more, so the only rule is the one the code already used: the first frame after the stack leaves `src/` or `dist/` is the caller. The flag and its eslint-disable are gone and the docstring matches. Behaviour is unchanged, and a new test covers an ESM caller importing the package by name, through `src/index.mjs` under `wisp-dev` and through `dist/index.mjs` after a build.
---
## 🔧 CI & tooling
- **`npm test` also runs the suite against the build.** The new `test:dist` script builds the package and runs the Vitest suite with `--mode=dist`, so the published `dist/` is tested as well as `src/`. `test` and `ci:coverage` call it ([#74](#74)).
- **The `wisp-dev` condition is set with `devCondition()`.** `test.nodeOptions` is not a Vitest option and passed nothing to the workers. The Vitest configuration now uses `devCondition()` from `@cldmv/configs` 1.4.0, which sets `resolve.conditions`, `ssr.resolve.conditions` and `test.execArgv` ([#72](#72)).
- **`sync-release-notes.yml` added.** The companion workflow syncs release bodies from the per-version changelog files and creates missing version tags ([#80](#80)).
- **`ci.yml` synced with the v4.43.0 template** ([#82](#82)).
- **`dist/` is built one file per module.** The tsup bundle is replaced by `scripts/build.mjs`, which minifies each `src` file in place with esbuild (`bundle: false`, `keepNames`, `node16` target, source maps written next to the output but left out of the tarball) and copies `src/index.cjs` verbatim. `dist/` now mirrors `src/`, so `dist/index.mjs` imports `dist/wisp.mjs`, which imports `dist/lib/resolve-from-caller.mjs`, and every module exists once. The `require()` and `import` export shapes are unchanged. The caller-resolution tests moved from `tests/bundle` to `tests/built` and also check the per-module layout. `tsup` is gone and `esbuild` is a dev dependency ([#91](#91), resolves [#83](#83)).
- **Superseded CI runs on `next` and `hotfixes` are cancelled**, so a new push no longer queues behind runs for commits that have already been replaced. The block is synced with the CLDMV/.github v4.46.0 template ([#87](#87), fixes [#84](#84)).
---
## 📚 Documentation
- The README's usage section now says what `require("@cldmv/wisp")` returns, and the Contributing section describes `test` and `test:dist` ([#86](#86), [#74](#74)).
- **NEW:** [docs/changelog/v2/v2.0.0.md](https://github.com/CLDMV/wisp/blob/v2.0.0/docs/changelog/v2/v2.0.0.md): this changelog.
- README What's New promoted to v2.0.0.
---
## 🔧 Dependencies
- **Runtime**: none, unchanged.
- `vitest` and `@vitest/coverage-v8` 5.0.5 → 5.1.0 ([#75](#75)).
- `@cldmv/fix-headers` 2.2.4 → 2.2.6 ([#76](#76)).
- `@cldmv/configs` 1.3.0 → 1.4.0 ([#72](#72)).
---
## Upgrade notes
- If you load wisp from CommonJS and call the result of `require()` directly, change `require("@cldmv/wisp")(…)` to `require("@cldmv/wisp").wisp(…)`, or use `const { wisp } = require("@cldmv/wisp")`.
- `.wisp`, `.wispSync`, `.default` and destructuring work as before, and ESM `import` needs no change.
- `dist/` now has one file per module (`dist/index.mjs`, `dist/wisp.mjs`, `dist/lib/…`) instead of a single bundle. Deep imports into `dist/` were never supported, and the `exports` map is unchanged.
- Nothing changes for the Node.js version: `engines.node` is still `>=16.0.0`, and `require()` needs `^20.19.0` or `>=22.13.0`.
<details>
<summary>👥 Contributors</summary>
- @Shinrai
</details>
---
<!-- coverage-start -->

| Metric | Coverage |
|--------|----------|
| Statements | 100.0% |
| Branches | 98.9% |
| Functions | 100.0% |
| Lines | 100.0% |
*Avg: **99.7%** · `96931da` · Node lts/**
<!-- coverage-end -->
<!-- co-authors -->
Co-authored-by: Shinrai <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
No bug fixes
📦 Dependencies
🔧 Other Changes
👥 Contributors