Repository navigation
fix(cjs): keep .default and the ESM names on require() - #222
Merged
Merged
Conversation
require() returns the fixHeaders function again with .default and .fixHeaders set on it, so require(x).default and const { fixHeaders } = require(x) work as before.
The test already checks that dist/index.cjs is byte-for-byte the src/ shim and that it loads ./index.mjs, so a size cap adds nothing and only breaks when the shim or its header grows.
Replaces the old size cap. The hash covers everything below the fix-headers file header, so restamped dates don't change it but any edit to the shim does. Also corrects the shim's doc comment to say require() carries .default and .fixHeaders.
Shinrai
approved these changes
Nov 29, 2026
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 29, 2026
# `@cldmv/fix-headers` v2.6.2 Changelog
**Release Date**: November 2026
**Release Type**: Patch
**Branch**: `next` → `master`
---
## Overview
The CommonJS entry now follows the usual CommonJS convention of an export plus `.default` and its names. For fix-headers `require("@cldmv/fix-headers")` is still the `fixHeaders` function, as before, and it now also carries `.default` and `.fixHeaders`, so `require(x).default`, `require(x).fixHeaders` and `const { fixHeaders } = require(x)` all work. The release also bumps the repository's dev tools; fix-headers' options and header output are unchanged.
---
## 🐛 Bug Fixes
### CJS shim keeps `.default` and the ESM names on `require()` ([#222](#222))
`src/index.cjs` is the generic CLDMV drop-in shim. Its earlier version returned a lone exported value bare, with no names on it, which left `require(x).default` and destructured named imports undefined. The shim now attaches `.default` and every ESM export name to that value when all the exports are one function or object, and returns the module object, as before, when the entry exports several distinct values.
fix-headers' `src/index.mjs` exports `fixHeaders` as both a named and the default export, so all its exports are one value:
- Before: `require("@cldmv/fix-headers")` was the `fixHeaders` function, with no `.default` and no `.fixHeaders`.
- Now: it is the same function, carrying `.default` and `.fixHeaders`, both pointing back at the function. Calling `require(x)(options)` works exactly as before.
The tests assert the new properties, and the integration test no longer caps `dist/index.cjs` at 2 KB. It compares a sha256 of the shim body, with the fix-headers file header stripped so restamped dates don't matter, against the reviewed version, so the build can't drift from the shared shim unnoticed.
---
## 🔧 Dependencies
Development dependencies only; the runtime dependency (`ignore`) is unchanged ([#224](#224)).
- `@cldmv/vitest-runner` 1.11.3 → 1.11.4.
- `@cldmv/eslint-plugin-jsonv` `^1.0.10` → `^2.0.0` (locked 1.1.2 → 2.0.0), `@cldmv/jsonv` and `@cldmv/prettier-plugin-jsonv` to `^1.2.4`.
- `@cldmv/configs` stays at 1.5.0.
## 📚 Documentation
- **NEW:** [docs/changelog/v2/v2.6.2.md](https://github.com/CLDMV/fix-headers/blob/v2.6.2/docs/changelog/v2/v2.6.2.md), this changelog.
- README What's New promoted to v2.6.2.
---
## Upgrade notes
- Nothing to do. `require("@cldmv/fix-headers")` still returns the `fixHeaders` function; it just has `.default` and `.fixHeaders` on it too. The behaviour matches [v2.6.1](https://github.com/CLDMV/fix-headers/blob/v2.6.2/docs/changelog/v2/v2.6.1.md).
<details>
<summary>👥 Contributors</summary>
- @Shinrai
</details>
---
<!-- coverage-start -->

| Metric | Coverage |
|--------|----------|
| Statements | 99.9% |
| Branches | 98.8% |
| Functions | 100.0% |
| Lines | 99.9% |
*Avg: **99.6%** · `8a9d2fd` · 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
📦 Dependencies
No dependency updates
🔧 Other Changes
👥 Contributors