Repository navigation
Conversation
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.
There was a problem hiding this comment.
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_SUBPATHSmapping 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 |
aversini
deleted the
fix(bundlecheck)-Expand-externals-for-esbuild-and-retry-bundling
branch
February 1, 2026 16:30
Merged
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.
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.