Skip to content

fix(bundlecheck): Expand externals for esbuild and retry bundling - #495

Merged
aversini merged 2 commits into
mainfrom
fix(bundlecheck)-Expand-externals-for-esbuild-and-retry-bundling
Feb 1, 2026
Merged

aversini merged 2 commits into
mainfrom
fix(bundlecheck)-Expand-externals-for-esbuild-and-retry-bundling

Conversation

@aversini

@aversini aversini commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

Add support for expanding external package subpaths for esbuild and improve bundling robustness. Introduces EXTERNAL_SUBPATHS in defaults and a new expandExternalsForEsbuild helper to include subpaths like react/jsx-runtime and react-dom/client. Update bundler to use expanded externals, perform a silent first build, and automatically add react/react-dom to externals and retry when unresolved-import errors occur (to handle packages that omit proper peerDependencies). Adds unit tests for expandExternalsForEsbuild and minor doc/comment updates.

Add support for expanding external package subpaths for esbuild and improve bundling robustness. Introduces EXTERNAL_SUBPATHS in defaults and a new expandExternalsForEsbuild helper to include subpaths like react/jsx-runtime and react-dom/client. Update bundler to use expanded externals, perform a silent first build, and automatically add react/react-dom to externals and retry when unresolved-import errors occur (to handle packages that omit proper peerDependencies). Adds unit tests for expandExternalsForEsbuild and minor doc/comment updates.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances esbuild bundling reliability by adding automatic subpath externalization for React packages and implementing retry logic for unresolved imports. The changes address the issue that esbuild doesn't automatically externalize package subpaths (like react/jsx-runtime), which can cause bundling failures.

Changes:

  • Introduces EXTERNAL_SUBPATHS mapping to track common subpaths for React and React-DOM
  • Adds expandExternalsForEsbuild() helper to expand base package names to include their subpaths
  • Implements two-phase bundling with automatic retry that adds React/React-DOM to externals when unresolved-import errors occur

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/bundlecheck/src/defaults.ts Adds EXTERNAL_SUBPATHS constant mapping React packages to their common subpath exports
packages/bundlecheck/src/bundler.ts Updates bundling logic to expand externals for esbuild and implements retry logic with automatic React external detection
packages/bundlecheck/src/tests/bundler.test.ts Adds comprehensive unit tests for expandExternalsForEsbuild function covering various scenarios

Comment thread packages/bundlecheck/src/bundler.ts
Comment thread packages/bundlecheck/src/bundler.ts Outdated
Comment thread packages/bundlecheck/src/bundler.ts
Comment thread packages/bundlecheck/src/bundler.ts
Comment thread packages/bundlecheck/src/bundler.ts Outdated
@aversini
aversini merged commit f50ed40 into main Feb 1, 2026
6 checks passed
@aversini
aversini deleted the fix(bundlecheck)-Expand-externals-for-esbuild-and-retry-bundling branch February 1, 2026 16:30
@aversini aversini mentioned this pull request Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants