Detect webpack-bundled CommonJS default exports#276
Merged
andrewbranch merged 1 commit intoJul 9, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: c4be7e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Improves @arethetypeswrong/core’s export-shape inference to correctly recognize default exports in webpack-bundled CommonJS output where the effective exports object is passed/aliased through the bootstrap wrapper, preventing false “incorrect default export” reports (Fixes #212).
Changes:
- Extend probable-export detection to recognize webpack bootstrap patterns and extract assignments to the entry module’s
exportsparameter. - Add coverage for webpack-bundled CJS default exports in both
getProbableExportsand theexportDefaultDisagreementrule tests. - Publish a patch changeset for the core package.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/internal/getProbableExports.ts | Adds a webpack bootstrap detector as a fallback to infer probable exports from bundled entry modules. |
| packages/core/test/getProbableExports.test.ts | Adds a webpack CJS fixture asserting __esModule and default are detected. |
| packages/core/test/problems/exportDefaultDisagreement.test.ts | Adds a regression test ensuring the default-export disagreement rule ignores the webpack-bundled CJS wrapper case. |
| .changeset/gentle-bundles-detect.md | Declares a patch release for the core package describing the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+190
to
+204
| function isModuleExports(node: ts.Expression) { | ||
| return ( | ||
| ts.isAccessExpression(node) && | ||
| ts.isIdentifier(node.expression) && | ||
| node.expression.text === "module" && | ||
| getNameOfAccessExpression(node) === "exports" | ||
| ); | ||
| } | ||
|
|
||
| function getNameOfAccessExpression(accessExpression: ts.AccessExpression): string | undefined { | ||
| const node = ts.getNameOfAccessExpression(accessExpression); | ||
| if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) { | ||
| return node.text; | ||
| } | ||
| } |
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.
Webpack-bundled CommonJS libraries could be reported as incorrect default exports when the wrapper hid the actual
exports.defaultassignment inside the entry module. The export detector now follows that wrapper and aliasedexportsobject; the esbuild, Babel, and SWC helper paths stay on their current branches.Verification covered the bundled fixture, core tests,
pnpm tsgo,pnpm check-dts,pnpm build, and the full workspace test suite with 58 core tests and 30 CLI tests passing. Fixes #212