build(deps): move styled-components to peerDependencies (CUI-37)#1173
Open
JeanMarcMilletScality wants to merge 1 commit into
Open
build(deps): move styled-components to peerDependencies (CUI-37)#1173JeanMarcMilletScality wants to merge 1 commit into
JeanMarcMilletScality wants to merge 1 commit into
Conversation
styled-components was a regular dependency, which let npm install a nested node_modules/@scality/core-ui/node_modules/styled-components in workspace consumers. That second instance yields two ThemeProvider contexts, so useTheme() returns undefined at test/build time (broke identity-ui Jest). Move it to peerDependencies to match react/react-dom and guarantee a single hoisted instance from the consumer. Add it to devDependencies so core-ui's own tsc build, Jest, and Storybook still resolve it (peer deps of the root package are not auto-installed; react is only present transitively via storybook/testing-library). No Module Federation runtime impact: the singleton version is negotiated from each consumer's rspack shared config (requiredVersion: deps[...]), independent of core-ui's dependency classification. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Hello jeanmarcmilletscality,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Contributor
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
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.
What
Move
styled-componentsfromdependenciestopeerDependencies(matchingreact/react-dom), and add it todevDependenciesso core-ui's own build/test/Storybook still resolve it.Why
As a regular
dependency, npm was free to install a nestednode_modules/@scality/core-ui/node_modules/styled-componentsin workspace consumers. That second instance yields twoThemeProvidercontexts, souseTheme()returnsundefinedat test/build time — this broke identity-ui's Jest run (140 failures fromCheckbox/theme consumers).Making it a peer guarantees a single hoisted instance provided by the consumer, exactly as
reactalready works.No Module Federation impact
The MF singleton version is negotiated from each consumer's rspack
sharedconfig (requiredVersion: deps['styled-components'], read from the consumer's own package.json), independent of core-ui's dependency classification. Runtime behavior is unchanged; this only affects install/build/test-time npm resolution.Why the devDependencies entry is required
Peer deps of the root package are not auto-installed for the package's own dev build.
reactsurvives peer-only here only because Storybook/testing-library pull it in transitively — nothing pullsstyled-components, sotscfails without the explicit devDep. Verified: peer-only → build fails across ~40 files; with devDep → clean.Verification
npm run buildclean,npm test→ 43 suites / 428 tests pass.--legacy-peer-depsinstall, cache-clean) — all confirm a single dedupedstyled-components@6.4.4, no nested copy:GroupsTabform-logic failures, unrelated — this commit changes only package metadata, not compiled code)🤖 Generated with Claude Code