Skip to content

docs(package-layout): ship dist/ as one file per module and use one generic index.cjs shim - #584

Merged
Shinrai merged 4 commits into
nextfrom
docs/package-layout-no-bundle
Nov 26, 2026
Merged

Shinrai merged 4 commits into
nextfrom
docs/package-layout-no-bundle

Conversation

@cldmv-bot

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

Copy link
Copy Markdown
Contributor

docs/conventions/package-layout.md no longer prescribes a tsup bundle: dist/ mirrors src/, one file per module, minified in place with keepNames, no bundling, splitting or chunk-* files, and a CLI builds to dist/bin/ importing the library by relative path. The Build section shows the esbuild bundle: false script and cites the released references — vitest-runner 1.11.1 (scripts/build.mjs, plain .mjs), fix-headers 2.5.1 and lib-sqlite-wasm 0.2.1 (scripts/build-js.mjs, TypeScript). The bundle-size example uses dist/**/*.mjs; the matcher already treated dist/**.mjs the same and new tests pin both.

src/index.cjs is now one generic shim for every library, shipped as examples/package-layout/src/index.cjs: one distinct export comes back as that value (aliases count once), anything else as the module object import gives. No hand-written .default unwraps or attached aliases; the possible plugin-host exception stays to be checked.

Resolves #582, resolves #589

@cldmv-bot cldmv-bot Bot added ! docs → next v4 flow: docs contributor PR targeting the next integration branch area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure type: documentation Relates to docs, README updates, guides, or inline code comments labels Nov 26, 2026
@cldmv-bot cldmv-bot Bot added type: ci Changes to CI workflows, actions, or build pipelines type: config Changes to repository or project configuration files labels Nov 26, 2026
@cldmv-bot cldmv-bot Bot changed the title docs(package-layout): ship dist/ as one file per module, never a bundle ci: forward the build cache inputs through workflow-publish.yml Nov 26, 2026
@cldmv-bot

cldmv-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (ci).

  • Before: docs(package-layout): ship dist/ as one file per module, never a bundle
  • After: ci: forward the build cache inputs through workflow-publish.yml

If this isn't what you want, edit the title — the normalizer won't re-fire as long as the title stays conventional.

@Shinrai Shinrai changed the title ci: forward the build cache inputs through workflow-publish.yml docs(package-layout): ship dist/ as one file per module and use one generic index.cjs shim Nov 26, 2026
@cldmv-bot cldmv-bot Bot changed the title docs(package-layout): ship dist/ as one file per module and use one generic index.cjs shim ci: forward the build cache inputs through workflow-publish.yml Nov 26, 2026
The convention prescribed a tsup bundle, which duplicates code as soon
as a package has more than one entry: vitest-runner's CLI bundle
re-ships the library, and lib-sqlite-wasm needed splitting and hashed
chunk-* files to keep instanceof working. dist/ now mirrors src/, each
file minified in place with keepNames, a CLI builds to dist/bin/ and
imports the library by relative path, and the index.cjs shim is copied
as before. The Build section shows the esbuild bundle: false script and
points at lib-sqlite-wasm for TypeScript sources; the migration table
gets a row for tsup bundles.

The bundle-size dist_paths example uses dist/**/*.mjs, and two new
tests pin that both it and dist/**.mjs match files at every depth.

Resolves #582
src/index.cjs is the version guard plus module.exports =
require("./index.mjs") and nothing else, so require() returns the same
module object as import. Unwrapping .default only worked for
single-function packages and hand-attached names drift from the ESM
exports. A package that unwraps today changes it in its next major. A
plugin whose host require()s it and needs the plugin object may keep an
unwrap once that's checked and commented. The migration table gets a
row for it.

Resolves #589
Replaces the plain re-export rule with the drop-in shim from #589: after
the version guard it returns the single exported value when the ESM
entry has one distinct value (aliases count once), and the module object
otherwise. The file ships as examples/package-layout/src/index.cjs, and
the doc shows both cases, drops hand-written unwraps and aliases, and
keeps the plugin exception to be checked per host.

Resolves #589
vitest-runner 1.11.1 (scripts/build.mjs) is the plain .mjs reference and
fix-headers 2.5.1 builds the same way; lib-sqlite-wasm 0.2.1
(scripts/build-js.mjs) is the TypeScript one.
@Shinrai
Shinrai force-pushed the docs/package-layout-no-bundle branch from 3a7b965 to 4bf0fe9 Compare November 26, 2026 05:23
@Shinrai Shinrai changed the title ci: forward the build cache inputs through workflow-publish.yml docs(package-layout): ship dist/ as one file per module and use one generic index.cjs shim Nov 26, 2026
@Shinrai
Shinrai merged commit e56cd05 into next Nov 26, 2026
19 checks passed
@cldmv-bot
cldmv-bot Bot deleted the docs/package-layout-no-bundle branch November 26, 2026 21:13
cldmv-bot Bot added a commit that referenced this pull request Nov 27, 2026
# v4.46.0 — 2026-11-26

Minor release: CI stops wasting the org's hosted runners, the package convention stops bundling, and an optional build check lands for other runner OSes.

## Features

- **Extra-OS build check.** `workflow-ci.yml` gains `extra_build_os`, a JSON list of runner labels (default `[]`). Each label gets one `🍎 Build & Test (<os>)` job on the latest LTS Node that runs the same build-and-test step as the Linux matrix legs — install, `build_command`, `test_command` — with no coverage, lint or Node matrix. It skips docs-only runs, cancels with its run, and a failure blocks `✅ Required PR Check` like a failed matrix leg. For builds that depend on the host platform (per-platform toolchains, the host `make` and `cc`); macOS runners are scarce, so list only what the build needs. ([#587](#587))
- **A cap on the Node matrix.** `workflow-ci.yml` gains `max_parallel` (default 2, `0` = no cap), applied to the build-and-test matrix, so one heavy repo can't take every hosted job slot the org has within a single run. ([#586](#586))

## Bug Fixes

- **Superseded CI runs on `next` and `hotfixes` are cancelled.** The `ci.yml` template gave every run on next, hotfixes and the release PRs a unique concurrency group, so superseded runs never stopped: on 2026-11-26 slothlet held 60 in-progress runs at once and took every hosted job slot in the org for about an hour. Only the release base branch (each push there is a release) keeps a unique group now; everything else cancels the older run. Release PRs only wait on their head's run since CI status ownership (v4.43.0), and the Commit Subjects check on next/hotfixes now compares the default branch with the pushed tip, so a cancelled push's commits are still checked by the next run. The concurrency block lives in each repo's `ci.yml` — re-run org onboarding or re-copy the block per repo. Fixes [#583](#583) ([#586](#586))
- **A docs-only last merge no longer greens the release PR.** The release PR takes its required check from the push run on next, and that push was judged docs-only from its own range — so when the changelog PR was the last merge, the ruleset showed the release PR mergeable while its own full-matrix run was still going. A push to next or hotfixes is now judged by everything unreleased (the default branch compared to the pushed tip); if that compare fails, the push's own range decides. Fixes [#588](#588) ([#590](#590))

## Documentation

- **No more bundling.** `docs/conventions/package-layout.md` now says `dist/` mirrors `src/`, one file per module, minified in place with `keepNames`: no bundling, no `splitting`, no `chunk-*` files, and no code shipped twice — a CLI builds to `dist/bin/` and imports the library by relative path. Bundling duplicates code as soon as a package has more than one entry: vitest-runner's CLI bundle re-shipped the library, and lib-sqlite-wasm needed hashed chunks to keep `instanceof` working across its four entries. The Build section shows the esbuild `bundle: false` script and cites the released references: vitest-runner 1.11.1 (`scripts/build.mjs`), fix-headers 2.5.1, and lib-sqlite-wasm 0.2.1 (`scripts/build-js.mjs`) for TypeScript sources. The bundle-size example uses `dist/**/*.mjs`. Fixes [#582](#582) ([#584](#584))
- **One generic `index.cjs`.** `src/index.cjs` is the same file in every library (`examples/package-layout/src/index.cjs`): after the version guard it returns the single exported value when the ESM entry has one distinct value (aliases count once), otherwise the module object `import` gives. Hand-written `.default` unwraps and attached aliases drift from the ESM exports and break named exports on any package with more than one; packages whose `require()` result changes adopt the shim in their next major. Fixes [#589](#589) ([#584](#584))

## Upgrade notes

- The concurrency change ships in the caller template: re-run org onboarding (or re-copy the block) for every repo's `ci.yml` after this release, slothlet first. Until then, superseded runs on a repo's `next`/`hotfixes` still run to the end.
- Repos whose builds depend on the host platform set `extra_build_os` in `ci.yml`; the default `[]` keeps it off.
- Repos still on a tsup bundle migrate per the new convention; per-repo migration issues follow.
- New libraries copy `examples/package-layout/src/index.cjs`; existing ones that unwrap `.default` adopt the shim in their next major.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

<!-- 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 ! docs → next v4 flow: docs contributor PR targeting the next integration branch type: ci Changes to CI workflows, actions, or build pipelines type: config Changes to repository or project configuration files type: documentation Relates to docs, README updates, guides, or inline code comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant