fix: correct dual-package hazard in package exports#237
Merged
Conversation
package.json declared "type": "module" but "main" still pointed to the CommonJS build (dist/maquette.cjs.js). Because the file extension was .js, Node/Vite parsed it as ESM despite its CommonJS content, causing "ReferenceError: exports is not defined" in consumers. Rename the CJS build output to dist/maquette.cjs (unambiguous CommonJS regardless of "type": "module") and add an explicit exports map so import/require resolve to the correct build.
Copilot started reviewing on behalf of
Joeri van Oostveen (jvanoostveen)
July 6, 2026 18:04
View session
There was a problem hiding this comment.
Pull request overview
Fixes a dual-package resolution hazard where the package is marked "type": "module" but previously pointed "main" at a CommonJS build with a .js extension, causing some consumers to parse the CJS file as ESM and fail at runtime.
Changes:
- Rename the CommonJS entrypoint from
dist/maquette.cjs.jstodist/maquette.cjsvia the"main"field. - Add an explicit
"exports"map soimportandrequireresolve to the correct builds (and expose./package.json).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Johan Gorter (johan-gorter)
previously approved these changes
Jul 7, 2026
Johan Gorter (johan-gorter)
approved these changes
Jul 7, 2026
|
To create a fully functional ESM library in Node, you also need to explicitly add the |
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.
package.json declared "type": "module" but "main" still pointed to the
CommonJS build (dist/maquette.cjs.js). Because the file extension was
.js, Node/Vite parsed it as ESM despite its CommonJS content, causing
"ReferenceError: exports is not defined" in consumers.
Rename the CJS build output to dist/maquette.cjs (unambiguous
CommonJS regardless of "type": "module") and add an explicit exports
map so import/require resolve to the correct build.