Skip to content
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

Make styled-components types an optional peer peer dependency #3399

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-windows-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Makes @types/styled-components an optional peer dependency, not a dependency
36 changes: 14 additions & 22 deletions .github/workflows/consumer_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,33 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

# `prepare` is a special case in `npm` and likes to run all the time, even
# with `--ignore-scripts` and even when using `npm link @primer/react
# --ignore-scripts`. This just removes it entirely for the duration of
# this workflow.
- name: Remove "prepare" script
run: npm pkg delete scripts.prepare

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Install only production dependencies
run: npm ci --production

- name: Link
run: npm link

- name: Link and test
id: link-and-test
# Output the artifact as a tarball in `consumer-test`. Write the
# information for this package in `consumer-test/pack.json` so we can read
# from it later to install the package
- name: Create a tarball for the package
run: npm pack --pack-destination consumer-test --json > consumer-test/pack.json
- name: Clean package directory
run: |
npm run clean
rm -rf node_modules
- name: Test
id: test
working-directory: consumer-test
run: |
# Read the filename for the tarball from `pack.json`
npm install $(jq -r '.[0].filename' pack.json)
npm install
npm link @primer/react
npm run check

- name: Add annotation
if: failure() && steps.link-and-test.conclusion == 'failure'
if: failure() && steps.test.conclusion == 'failure'
run: |
echo "::error file=tsconfig.build.json::Test package could not build. See https://github.com/primer/react/blob/main/consumer-test"
1 change: 1 addition & 0 deletions consumer-test/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import {Box} from '@primer/react'

export default function App() {
Expand Down
6 changes: 6 additions & 0 deletions consumer-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/styled-components": "^5.1.11",
"@primer/react": "*",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"styled-components": "^5.3.11",
"typescript": "~4.7.2"
}
}
35 changes: 28 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
"@styled-system/css": "^5.1.5",
"@styled-system/props": "^5.1.5",
"@styled-system/theme-get": "^5.1.2",
"@types/styled-components": "^5.1.11",
"@types/styled-system": "^5.1.12",
"@types/styled-system__css": "^5.0.16",
"@types/styled-system__theme-get": "^5.0.1",
Expand Down Expand Up @@ -171,6 +170,7 @@
"@types/node": "16.11.11",
"@types/react": "18.0.28",
"@types/react-dom": "18.2.6",
"@types/styled-components": "^5.1.11",
"@typescript-eslint/eslint-plugin": "5.59.6",
"@typescript-eslint/parser": "5.59.6",
"ajv": "8.12.0",
Expand Down Expand Up @@ -258,10 +258,24 @@
"yaml": "2.2.2"
},
"peerDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/styled-components": "^5.1.11",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"styled-components": "4.x || 5.x"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
},
"@types/styled-components": {
"optional": true
}
},
"prettier": "@github/prettier-config",
"size-limit": [
{
Expand Down
1 change: 0 additions & 1 deletion src/CounterLabel/CounterLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const CounterLabel = forwardRef<HTMLSpanElement, CounterLabelProps>(
)}
{...props}
as="span"
// @ts-expect-error Box is expecting a divelement, but this component forces a span element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This started giving me a type error and I'm not sure why

ref={forwardedRef}
>
{children}
Expand Down