Repository navigation
fix(grabkit): add exports map with .mjs ESM build; treat empty 2xx as success - #1
Merged
Merged
Conversation
… success Without an exports map, Node ESM consumers resolved the CJS build and got a non-callable default import. Ship the ESM build as .mjs and route import/require through exports. An empty body on 200/201/202 was a GrabkitTransportError, so fire-and- forget endpoints (e.g. 202 Accepted) always looked failed. Treat any empty 2xx like 204: success with null data. Empty non-2xx still fails. Note: exports blocks deep imports such as grabkit/build/esm/grabkit.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Why
An end-to-end test of an analytics SDK built on grabkit turned up two bugs.
package.jsonhasmain(CJS) andmodule(ESM) but noexports. Node ignoresmodule, soimport grabkit from 'grabkit'loads the CJS build, and the default import is the module object rather than the function. Bundlers (Vite, webpack, Next) readmodule, which is why this hasn't shown up before.202 Acceptedwith no body came back asGrabkitTransportError: empty response body, even though the request worked.What changed
build/esm/grabkit.mjs.exportsroutesimportto the ESM build andrequireto the CJS build.typesand./package.jsonare exported too.[null, null, { statusCode }], the same as 204. An empty non-2xx response still fails.Tests
grabkit.test.ts: empty 200, 201 and 202 count as success; an empty 500 still fails. These were written first and failed before the fix.publishBundle.test.ts: imports the package by name under Node ESM and CJS and asserts the default export is a function. This fails onmainunder ESM.grabkit:testpasses (26 tests), and so doesgrabkit-integration:test.type: moduleproject. The default import is callable under both ESM and CJS, and an empty202from a local server returnserror: null, status: 202.Release notes
exportsmap blocks deep imports such asgrabkit/build/esm/grabkit.js, and the ESM file is renamed.packages/grabkit/package.jsonsays2.0.1, but npm has2.1.0, so it looks like the release step doesn't commit the version bump.🤖 Generated with Claude Code