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

chore(npm): add types packages as optional peer deps #3509

Merged
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
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"
}
}
14 changes: 14 additions & 0 deletions package-lock.json

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

15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,23 @@
"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"
},
"optionalPeerDependencies": {
"@types/styled-components": "^5.1.11"
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
},
"@types/styled-components": {
"optional": true
}
},
"prettier": "@github/prettier-config",
"size-limit": [
Expand Down
Loading