Skip to content

ci: add styled-components migration report #6158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025

Conversation

joshblack
Copy link
Member

@joshblack joshblack commented Jun 2, 2025

Add report on styled-components migration to our Migration Status daily job.

Copy link

changeset-bot bot commented Jun 2, 2025

⚠️ No Changeset found

Latest commit: 20d0360

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@joshblack
Copy link
Member Author

Example Output


styled-components Migration

This report tracks our status migrating files from styled-components to CSS Modules.

Status

Status by file count

Status by file count

Status by file size

Status by file size

Not Migrated (45)

Filepath Size (kB)
packages/react/src/ActionList/Item.tsx 24.43kB
packages/react/src/stories/useFocusZone.stories.tsx 22.17kB
packages/react/src/NavList/NavList.tsx 18.58kB
packages/react/src/UnderlineNav/UnderlineNav.tsx 17.53kB
packages/react/src/deprecated/ActionList/Item.tsx 14.64kB
packages/react/src/LabelGroup/LabelGroup.tsx 13.3kB
packages/react/src/stories/deprecated/ActionList.stories.tsx 12.69kB
packages/react/src/stories/useFocusTrap.stories.tsx 12.38kB
packages/react/src/DataTable/Pagination.tsx 12.33kB
packages/react/src/FilteredActionList/FilteredActionListWithModernActionList.tsx 9.96kB
packages/react/src/stories/useAnchoredPosition.stories.tsx 9.87kB
packages/react/src/stories/deprecated/ActionMenu.stories.tsx 9.86kB
packages/react/src/ToggleSwitch/ToggleSwitch.tsx 9.4kB
packages/react/src/deprecated/ActionList/List.tsx 8.99kB
packages/react/src/FilteredActionList/FilteredActionListWithDeprecatedActionList.tsx 8.8kB
packages/react/src/ThemeProvider.tsx 7.88kB
packages/react/src/StateLabel/StateLabel.tsx 5.25kB
packages/react/src/Tooltip/Tooltip.tsx 4.71kB
packages/react/src/LabelGroup/LabelGroup.features.stories.tsx 3.89kB
packages/react/src/utils/test-matchers.tsx 3.87kB
packages/react/src/TabNav/TabNav.tsx 3.78kB
packages/react/src/Caret.tsx 3.33kB
packages/react/src/Button/types.ts 3.21kB
packages/react/src/deprecated/UnderlineNav/UnderlineNav.tsx 3.13kB
packages/react/src/stories/ThemeProvider.stories.tsx 2.52kB
packages/react/src/Spinner/Spinner.tsx 2.42kB
packages/react/src/LabelGroup/LabelGroup.stories.tsx 2.17kB
packages/react/src/deprecated/ActionList/Header.tsx 1.88kB
packages/react/src/PointerBox/PointerBox.tsx 1.83kB
packages/react/src/Text/Text.tsx 1.45kB
packages/react/src/Box/Box.tsx 1.32kB
packages/react/src/CircleBadge/CircleBadge.tsx 1.28kB
packages/react/src/Truncate/Truncate.tsx 1.26kB
packages/react/src/internal/components/ValidationAnimationContainer.tsx 1.22kB
packages/react/src/FormControl/FormControlLeadingVisual.tsx 1.06kB
packages/react/src/deprecated/ActionList/Group.tsx 1.01kB
packages/react/src/utils/create-component.ts 0.95kB
packages/react/src/Octicon/Octicon.tsx 0.93kB
packages/react/src/deprecated/FilteredSearch/FilteredSearch.tsx 0.86kB
packages/react/src/internal/utils/getGlobalFocusStyles.ts 0.81kB
packages/react/src/internal/utils/sharedCheckboxAndRadioStyles.ts 0.75kB
packages/react/src/internal/components/BoxWithFallback.tsx 0.71kB
packages/react/src/deprecated/ActionList/Divider.tsx 0.7kB
packages/react/src/_VisuallyHidden.tsx 0.53kB
packages/react/src/internal/components/ButtonReset.tsx 0.5kB

Migrated (604)

There are 604 files that do not include styled-components in Primer React.

Copy link
Contributor

github-actions bot commented Jun 2, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 94.51 KB (0%)
packages/react/dist/browser.umd.js 94.64 KB (0%)

@github-actions github-actions bot temporarily deployed to storybook-preview-6158 June 2, 2025 19:25 Inactive
@joshblack joshblack added the skip changeset This change does not need a changelog label Jun 3, 2025
@joshblack joshblack marked this pull request as ready for review June 3, 2025 15:44
@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 15:44
@joshblack joshblack requested a review from a team as a code owner June 3, 2025 15:44
@joshblack joshblack requested review from hectahertz and jonrohan June 3, 2025 15:44
Copy link
Contributor

@Copilot Copilot AI left a comment

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 adds a new script and CI job to report on the progress of migrating from styled-components to CSS Modules.

  • Introduces styled-components-migration-status.mts to scan .ts/.tsx files, calculate sizes, and generate a markdown report.
  • Adds a styled-components job in the migration-status.yml workflow to run the migration script and append its output to the GitHub Actions summary.

Reviewed Changes

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

File Description
script/styled-components-migration-status.mts New script that gathers file sizes and migration status for styled-components usage
.github/workflows/migration-status.yml CI job to execute the new migration report script
Comments suppressed due to low confidence (1)

.github/workflows/migration-status.yml:8

  • [nitpick] The job ID styled-components is generic; consider renaming it to styled-components-migration-status for clarity and consistency with other job names.
  styled-components:

Comment on lines +4 to +5

const directory = path.resolve(import.meta.dirname, '..')
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

Node ESM does not provide import.meta.dirname. Use import.meta.url with fileURLToPath and path.dirname to derive the script directory.

Suggested change
const directory = path.resolve(import.meta.dirname, '..')
import { fileURLToPath } from 'node:url'
const directory = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')

Copilot uses AI. Check for mistakes.

run: npm ci
- name: Run migration script
run: |
node --experimental-strip-types script/styled-components-migration.mts >> $GITHUB_STEP_SUMMARY
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

The script filename in this step (styled-components-migration.mts) does not match the actual file (styled-components-migration-status.mts), causing the job to fail.

Suggested change
node --experimental-strip-types script/styled-components-migration.mts >> $GITHUB_STEP_SUMMARY
node --experimental-strip-types script/styled-components-migration-status.mts >> $GITHUB_STEP_SUMMARY

Copilot uses AI. Check for mistakes.

Comment on lines 35 to 43
const migrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return !contents.match(/styled-components/)
})

const notMigrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return contents.match(/styled-components/)
})
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

The script reads each file twice (once for migrated and once for notMigrated). Consider a single pass to categorize files and accumulate sizes to reduce I/O.

Suggested change
const migrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return !contents.match(/styled-components/)
})
const notMigrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return contents.match(/styled-components/)
})
const migrated = [];
const notMigrated = [];
let migratedSize = 0;
for (const { filepath, size } of matches) {
const contents = fs.readFileSync(filepath, 'utf8');
if (contents.match(/styled-components/)) {
notMigrated.push({ filepath, size });
} else {
migrated.push({ filepath, size });
migratedSize += size;
}
}

Copilot uses AI. Check for mistakes.

@joshblack
Copy link
Member Author


const migrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return !contents.match(/styled-components/)
Copy link
Member

Choose a reason for hiding this comment

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

Should we check more things like inclusion of SxProp or Box

@joshblack joshblack added this pull request to the merge queue Jun 4, 2025
Merged via the queue into main with commit 100c9cf Jun 4, 2025
37 checks passed
@joshblack joshblack deleted the ci/add-styled-components-migration-report branch June 4, 2025 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants