Skip to content

fix: drop the unused index.* flag from caller detection - #89

Merged
Shinrai merged 1 commit into
nextfrom
fix/caller-detection-single-rule
Nov 28, 2026
Merged

Shinrai merged 1 commit into
nextfrom
fix/caller-detection-single-rule

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

pickPrimaryBaseFile() tracked a second flag for leaving a root index.* file but never read it. wisp has no root index.* anymore, so the only rule is the one the code already used: the first frame after the stack leaves src/ or dist/ is the caller. I dropped the dead flag and its eslint-disable, and rewrote the docstring to match. Behaviour is unchanged.

There's a new test for an ESM caller importing the package by name, through src/index.mjs under wisp-dev and through dist/index.mjs after a build. It sits next to the existing CommonJS caller test.

Resolves #12

pickPrimaryBaseFile() tracked a second flag for leaving a root index.* file but never read it. wisp has no root index.* anymore (the entries are src/index.* and dist/index.*), 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 dead flag, its eslint-disable and the two-flag docstring are gone; behaviour is unchanged.

Tests add an ESM caller importing the package by name, through src/index.mjs under wisp-dev and through dist/index.mjs after a build, next to the existing CommonJS caller.

Resolves #12
@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure labels Nov 28, 2026
@Shinrai
Shinrai merged commit 5f0ad68 into next Nov 28, 2026
37 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/caller-detection-single-rule branch November 28, 2026 07:34
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 -->

![coverage](https://img.shields.io/badge/coverage-99.7%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! fix → next v4 flow: fix contributor PR targeting the next integration branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant