Repository navigation
fix: publish a single-file ESM bundle that Node can load (4.1.6) - #241
Merged
Merged
Conversation
dist/index.js (the "import" entry since 4.1.4) contains extensionless relative imports, which Node's ESM loader cannot resolve. Let rollup produce dist/maquette.mjs next to the CJS and UMD bundles, and bundle the type declarations into dist/maquette.d.mts / dist/maquette.d.cts so types resolve for node16 ESM and CJS as well. - exports: import -> maquette.mjs, require -> maquette.cjs, each with its own types; drop the "browser" condition so bundlers get ESM - add "sideEffects": false - add check-package (attw + a smoke test that installs the packed tarball and loads it via import and require) to the ci script - bump to 4.1.6 Fixes #240 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The lockfile still identifies the root package as version 4.1.5 rather than 4.1.6.
0 open findings
What changed in this PR
Publishes Node-compatible single-file ESM/CJS bundles with matching bundled declarations and package validation.
Changes:
- Adds ESM and declaration bundling.
- Updates package exports and release metadata.
- Adds CI package-loading and type-resolution checks.
| File | Description |
|---|---|
rollup.config.js |
Adds ESM and declaration bundles. |
package.json |
Updates exports, scripts, dependencies, and version. |
package-lock.json |
Locks new tooling dependencies. |
tools/check-package-loads.ts |
Smoke-tests ESM and CJS package loading. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Johan Gorter (johan-gorter)
enabled auto-merge
October 12, 2026 08:10
Johan Gorter (johan-gorter)
requested a review
from Joeri van Oostveen (jvanoostveen)
October 12, 2026 08:10
Joeri van Oostveen (jvanoostveen)
approved these changes
Oct 12, 2026
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.
Fixes #240.
Problem
Since 4.1.4,
exports["."].importpoints atdist/index.js. That file comes straight fromtscand keeps its extensionless relative imports (./cache,./dom, …), so Node, Vitest and Jest ESM all fail withERR_MODULE_NOT_FOUND. The type declarations have the same problem:attwreported an internal resolution error for node16 and "Masquerading as ESM" for node16 from CJS.Changes
dist/maquette.mjs(ES format, with sourcemap) fromdist/index.js, next to the existing CJS and UMD bundles.rollup-plugin-dtsbundles the declarations intodist/maquette.d.mtsanddist/maquette.d.cts, so ESM and CJS consumers each get correctly typed single-file declarations. This goes beyond the issue, butattwcannot pass without it.exports["."]:import→{ types: maquette.d.mts, default: maquette.mjs },require→{ types: maquette.d.cts, default: maquette.cjs }.browsercondition, so bundlers get the ESM bundle instead of UMD.dist/maquette.umd.js/.min.jsare still published for<script>use."sideEffects": false.mainandtypesare unchanged.check-packagescript, run at the end ofnpm run ci:attw --pack .reports no problems for node10, node16 (CJS and ESM) and bundler.tools/check-package-loads.tspacks the package, installs the tarball in a temp directory and loads it from Node through bothimportandrequire. If I pointimportback atdist/index.js, this check fails with the exact error from the issue.Verification
npm run cipasses locally: lint, 95 tests, file-size check (3.65 kB gzipped), attw and the smoke test.Follow-up
After 4.1.6 is published, remove the 4.1.3 pin and the Dependabot ignore for
maquettein the Focus repo.🤖 Generated with Claude Code