Repository navigation
Conversation
Make React/react-dom externalization conditional on the package's declared dependencies/peerDependencies. Updates bundler.getExternals to accept packageDependencies and only mark react/react-dom as externals when present (and never externalize the package being checked). Pass package dependency info into getExternals from checkBundleSize and adjust the cache key logic to reflect user-specified externals rather than computed defaults. Update tests to cover dependency/peerDependency cases and react/react-dom self-checks, and refresh README/CLI help text to document the new "smart externalization" behavior.
Reformatted several inline // comments into multiline /** ... */ block/JSDoc-style comments for clarity and line-wrapping. Changes touch getExternals and checkBundleSize in packages/bundlecheck/src/bundler.ts and the cache key explanation in packages/bundlecheck/src/index.ts. No functional behavior was changed.
There was a problem hiding this comment.
Pull request overview
This PR updates bundle externalization logic so that React and React-DOM are only treated as externals when they are actual dependencies/peerDependencies of the target package, and aligns cache keying and docs/CLI help with this behavior.
Changes:
- Refined
getExternalsto depend on a package’s declareddependencies/peerDependencies, and ensured React/React-DOM are not externalized when analyzing their own packages. - Updated
checkBundleSize, library API (getBundleStats/trend path), and CLI cache key computation to use user-specified externals (plusnoExternal) rather than previously hard-coded defaults. - Adjusted tests and README/CLI help text to cover the new “smart externalization” behavior and clarify how
--externaland--no-externalinteract with React/React-DOM.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/bundlecheck/src/parse.ts |
Updated CLI flag description for --external to describe the new automatic React/React-DOM externalization behavior and removed the now-unused DEFAULT_EXTERNALS import. |
packages/bundlecheck/src/index.ts |
Stopped importing getExternals and changed cache key construction in getBundleStats to depend only on user-specified externals and noExternal, with updated comments and option docs to match. |
packages/bundlecheck/src/bundler.ts |
Reworked getExternals to conditionally include React/React-DOM based on the package’s dependencies/peerDependencies (and never for the package itself), wiring it into checkBundleSize via the computed dependency list. |
packages/bundlecheck/src/__tests__/bundler.test.ts |
Updated and extended tests to assert the new behavior for packages with/without React/React-DOM in dependencies/peerDependencies, including self-checks for react and cases with additional externals. |
packages/bundlecheck/README.md |
Documented “smart externalization” semantics, clarified noExternal behavior for both CLI and library API, and annotated examples to show when React/React-DOM appear in externals based on peer dependency declarations. |
aversini
deleted the
fix(bundlechecker)-Only-externalize-React/react-dom-when-declared
branch
February 1, 2026 14:59
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.
Make React/react-dom externalization conditional on the package's declared dependencies/peerDependencies. Updates bundler.getExternals to accept packageDependencies and only mark react/react-dom as externals when present (and never externalize the package being checked). Pass package dependency info into getExternals from checkBundleSize and adjust the cache key logic to reflect user-specified externals rather than computed defaults. Update tests to cover dependency/peerDependency cases and react/react-dom self-checks, and refresh README/CLI help text to document the new "smart externalization" behavior.