Uh oh!
There was an error while loading. Please reload this page.
Detect webpack-bundled CommonJS default exports - #276
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.
| 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; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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