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

Migrate to pnpm #1123

Merged
merged 31 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2f3cfa7
Initial import into pnpm (needed to update build settings package ref…
jeremywiebe Feb 28, 2025
b0ab325
Use workspace:* version for all in-repo dependencies
jeremywiebe Feb 28, 2025
c6311c8
Prevent usage of package managers other than pnpm and pin pnpm to v10…
jeremywiebe Feb 28, 2025
46a3ade
Fix workspace refs to be workspace:*
jeremywiebe Feb 28, 2025
423e5c7
Delete remaining yarn.lock files
jeremywiebe Feb 28, 2025
4632b10
Approve packages that have post-install scripts
jeremywiebe Feb 28, 2025
988f9b4
Migrate typedoc config to be a js file so we can just glob the packag…
jeremywiebe Feb 28, 2025
b8d8b1f
Move all scripts to use pnpm instead of yarn
jeremywiebe Feb 28, 2025
33483bc
Fix globbing in check-type-definitions so that `pnpm build:types` works
jeremywiebe Feb 28, 2025
6bca055
Fix globbing in pre-publish-check-ci.js
jeremywiebe Feb 28, 2025
8bdc337
ESLint: ignore generated docs/ directory
jeremywiebe Feb 28, 2025
77641e0
Add dependencies to eslint-plugin-khan that used to be available impl…
jeremywiebe Feb 28, 2025
c1a7ed5
ESLint: allow typedoc.config.js to be CJS
jeremywiebe Feb 28, 2025
8e4cb01
Restore missing piece of publish:ci script
jeremywiebe Feb 28, 2025
6bb6436
Update Github actions to use pnpm
jeremywiebe Feb 28, 2025
5ce32e9
Get rid of more yarn-isms
jeremywiebe Mar 1, 2025
403045b
Bump actions
jeremywiebe Mar 17, 2025
8ab35cf
Upgrade to shared-node-cache-v3 which supports pnpm
jeremywiebe Mar 20, 2025
6f61daa
Revert unnecessary change to .eslintignore
jeremywiebe Mar 20, 2025
1aff0f8
docs(changeset):
jeremywiebe Mar 20, 2025
586a841
docs(changeset): Migrate packages to use pnpm internally
jeremywiebe Mar 20, 2025
3f7cbe6
Restore yarn-error.log line in .gitignore
jeremywiebe Mar 20, 2025
0e0ea61
Remove unneeded 'globstar: true' option on fglob.sync() call
jeremywiebe Mar 20, 2025
297342e
Remove 'overrides' comment entry
jeremywiebe Mar 20, 2025
d01ba74
Add 'run' to scripts for in-package tests
jeremywiebe Mar 20, 2025
4099e37
Fix workspace refs to be workspace:*
jeremywiebe Mar 20, 2025
5931174
Update utils/pre-publish-check-ci.js
jeremywiebe Mar 20, 2025
c48e2dd
Fix so we can use ancesdir in workspace
jeremywiebe Mar 20, 2025
38b7a6d
Restore resolution override comment - I think this works
jeremywiebe Mar 20, 2025
9bd657a
Just use latest pnpm
jeremywiebe Mar 20, 2025
f75f2b2
Merge branch 'main' into jer/pnpm
jeremywiebe Mar 21, 2025
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
2 changes: 2 additions & 0 deletions .changeset/modern-actors-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
16 changes: 16 additions & 0 deletions .changeset/smart-beds-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@khanacademy/wonder-stuff-render-environment-jsdom": patch
"@khanacademy/wonder-stuff-render-server": patch
"demo": patch
"@khanacademy/wonder-stuff-testing": patch
"@khanacademy/wonder-stuff-sentry": patch
"@khanacademy/wonder-stuff-server": patch
"@khanacademy/eslint-config": patch
"@khanacademy/eslint-plugin": patch
"@khanacademy/wonder-stuff-core": patch
"@khanacademy/wonder-stuff-i18n": patch
"@khanacademy/wonder-stuff-ci": patch
"@khanacademy/ws-dev-build-settings": patch
---

Migrate packages to use pnpm internally
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
},
overrides: [
{
files: ["utils/*.js"],
files: ["utils/*.js", "typedoc.config.js"],
rules: {
"import/no-commonjs": "off",
},
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn.lock linguist-generated
pnpm-lock.yaml linguist-generated
6 changes: 3 additions & 3 deletions .github/workflows/node-ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -50,11 +50,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: ${{ matrix.node-version }}
- name: Run tests with coverage
run: yarn coverage
run: pnpm run coverage
- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -47,7 +47,7 @@ jobs:
- name: Checking out latest commit
uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -67,30 +67,30 @@ jobs:
name: Files that would trigger a full eslint run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: '.eslintrc.js,yarn.lock,.eslintignore'
files: '.eslintrc.js,pnpm-lock.yaml,pnpm-workspace.yaml,.eslintignore'

- name: Build so that inter-package references are resolved
run: yarn build
run: pnpm run build

- name: Build Types
run: yarn build:types
run: pnpm run build:types

# Linting / type checking
- name: Eslint
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.eslint-reset.outputs.filtered }}
full: yarn lint:ci .
full: pnpm run lint:ci .
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn lint:ci {}
limited: pnpm run lint:ci {}

- name: Typecheck
if: steps.js-ts-files.outputs.filtered != '[]'
run: yarn typecheck
run: pnpm run typecheck

# Collect and record coverage
- name: Run Jest with coverage
run: yarn coverage
run: pnpm run coverage
- name: Upload Coverage
# We don't bother collecting a record of coverage for dependabot changes
if: ${{ github.actor != 'dependabot[bot]' }}
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -156,7 +156,7 @@ jobs:
id: changed

- name: Build so that inter-package references are resolved
run: yarn build
run: pnpm run build

- id: jest-reset
uses: Khan/actions@filter-files-v1
Expand All @@ -165,7 +165,8 @@ jobs:
changed-files: ${{ steps.changed.outputs.files }}
files: |
jest.config.js
yarn.lock
pnpm-lock.yaml
pnpm-workspace.yaml
test.config.js
test.transform.js

Expand All @@ -180,6 +181,6 @@ jobs:
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.jest-reset.outputs.filtered }}
full: yarn test
full: pnpm run test
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn test --findRelatedTests --passWithNoTests {}
limited: pnpm run test --findRelatedTests --passWithNoTests {}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
fetch-depth: 0

- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
uses: Khan/actions@shared-node-cache-v3
with:
node-version: 20.x

- name: Build Typedoc
# Generate nice docs inside "docs/" folder
run: yarn build:docs
run: pnpm run build:docs

- name: Deploy to GitHub pages
uses: JamesIves/github-pages-deploy-action@v4
Expand All @@ -57,7 +57,7 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
publish: yarn publish:ci
publish: pnpm run publish:ci
env:
# We use a Personal Access Token here rather than the GITHUB_TOKEN
# so that it will trigger our other actions. The token has to be on
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ To work in the `wonder-stuff` repository, follow these steps:

1. Clone the repository
`git clone [email protected]:Khan/wonder-stuff.git`
2. Install `yarn` (see [🔗yarnpkg.com](https://yarnpkg.com))
3. Run `yarn install` to install the dependencies
2. Install `pnpm` (see [🔗pnpm](https://pnpm.io))
3. Run `pnpm install` to install the dependencies

You can now work on `wonder-stuff`. We prefer [🔗Visual Studio Code](https://code.visualstudio.com/) as our development environment (it's cross-platform and awesome), but please use what you feel comfortable with (we'll even forgive you for using vim).

Expand All @@ -46,17 +46,17 @@ We love code reviews. If there are open pull requests, please feel free to revie

To ensure code quality, we use prettier, TypeScript, eslint, and jest. These are all executed automatically on commit, so don't worry if you forget to run them before you commit. They are also executed when you submit, edit, or push to a pull request to ensure the contribution meets our code quality standard.

To execute these operations outside of a pull request or commit operation, you can use `yarn`.
To execute these operations outside of a pull request or commit operation, you can use `pnpm`.

- `yarn typecheck`
- `yarn lint`
- `yarn test`
- `pnpm typecheck`
- `pnpm lint`
- `pnpm test`

💭**REMEMBER** If you would like to contribute code changes to the project, first make sure there's a corresponding issue for the change you wish to make.

## 📦 Build And Publish

Anyone can create a local build of the distributed code by running `yarn build`.
Anyone can create a local build of the distributed code by running `pnpm build`.

### Publishing

Expand Down
3 changes: 2 additions & 1 deletion build-settings/check-type-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* files instead. Since we don't want to ship source code in every package,
* we want to guard against this.
*
* This script should be run after `yarn build:types`. It will scan the type
* This script should be run after `pnpm build:types`. It will scan the type
* definitions of each package for any types that are being incorrectly
* imported from other the source code of other packages, and flag them,
* exiting with a non-zero status code if any are found.
Expand All @@ -24,6 +24,7 @@ const packagesDir = path.join(rootDir, "packages");
const typeDefinitionFiles = fglob.sync("**/*.d.ts", {
cwd: packagesDir,
onlyFiles: true,
ignore: ["**/node_modules/**"],
});

let foundErrors = false;
Expand Down
51 changes: 30 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
"author": "Jeff Yates <[email protected]>",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*",
"build-settings"
],
"engines": {
"node": ">=16"
"node": ">=16",
"pnpm": ">=10"
},
"devDependencies": {
"@babel/core": "^7.23.0",
Expand All @@ -24,6 +21,7 @@
"@google-cloud/logging-winston": "^4.2.4",
"@google-cloud/profiler": "^4.2.0",
"@google-cloud/trace-agent": "^5.1.6",
"@jest/globals": "^29.7.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.3",
Expand All @@ -39,6 +37,8 @@
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "8.17.0",
"@typescript-eslint/parser": "8.17.0",
"@typescript-eslint/rule-tester": "^8.17.0",
"ancesdir": "^5.0.1",
"babel-jest": "^29.7.0",
"babel-watch": "^7.8.1",
"eslint": "^8.55.0",
Expand Down Expand Up @@ -74,28 +74,37 @@
"typescript": "5.7.3",
"winston": "^3.10.0"
},
"resolutions": {
"//": "we need to pin wide-align/string-width because v5 & up are ESM only",
"wide-align/string-width": "^4.2.0",
"node-gyp": "^10.0.0"
"pnpm": {
"overrides": {
"wide-align>string-width-docs": "we need to pin wide-align/string-width because v5 & up are ESM only",
"wide-align>string-width": "^4.2.0",
"node-gyp": "^10.0.0"
},
"onlyBuiltDependencies": [
"@swc/core",
"pprof",
"protobufjs"
]
},
"scripts": {
"preinstall": "npx -y only-allow pnpm",
"rollup": "rollup -c build-settings/rollup.config.mjs",
"build": "yarn rollup",
"build:prodsizecheck": "yarn rollup --configPlatforms='browser' --configFormats='esm' --configEnvironment='production'",
"build:types": "yarn tsc --build --verbose tsconfig-build.json && ./build-settings/check-type-definitions.ts",
"build": "pnpm run rollup",
"build:prodsizecheck": "pnpm run rollup --configPlatforms='browser' --configFormats='esm' --configEnvironment='production'",
"build:types": "pnpm tsc --build --verbose tsconfig-build.json && ./build-settings/check-type-definitions.ts",
"build:docs": "typedoc",
"watch": "yarn rollup --watch",
"watch": "pnpm run rollup --watch",
"clean": "rm -rf packages/wonder-stuff-*/dist && rm -rf node_modules && rm -rf packages/*/node_modules && rm -f packages/*/*.tsbuildinfo",
"coverage": "yarn run jest --coverage",
"coverage": "pnpm jest --coverage",
"format": "prettier --write .",
"lint": "yarn lint:ci .",
"lint": "pnpm run lint:ci .",
"lint:ci": "eslint --ext .ts --ext .js",
"lint:pkg-json": "yarn npmPkgJsonLint ./packages/wonder-stuff-*",
"publish:ci": "yarn run lint:pkg-json && node utils/pre-publish-check-ci.js && git diff --stat --exit-code HEAD && yarn build && yarn build:types && changeset publish",
"test": "yarn jest",
"lint:pkg-json": "pnpm npmPkgJsonLint ./packages/wonder-stuff-*",
"publish:ci": "pnpm run lint:pkg-json && node utils/pre-publish-check-ci.js && git diff --stat --exit-code HEAD && pnpm run build && pnpm run build:types && changeset publish",
"test": "pnpm jest",
"typecheck": "tsc",
"nochangeset": "yarn changeset add --empty",
"add:devdepbysha": "bash -c 'yarn add -W --dev \"git+https://[email protected]/Khan/$0.git#$1\"'"
}
"nochangeset": "pnpm changeset add --empty",
"add:devdepbysha": "bash -c 'pnpm add --workspace-root --save-dev \"git+https://[email protected]/Khan/$0.git#$1\"'"
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/eslint-config-khan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Shared Khan Academy eslint configuration.

## Quick Start

- `yarn add @khanacademy/eslint-config`
- `(yarn|pnpm) add --save-dev @khanacademy/eslint-config`
- Update your .eslintrc.js file to:
- extend `"@khanacademy"`
- include settings for `"import/resolver"`
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-khan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"author": "Kevin Barabash <[email protected]>",
"license": "MIT",
"peerDependencies": {
"@khanacademy/eslint-plugin": "^3.1.1",
"@khanacademy/eslint-plugin": "workspace:*",
"@typescript-eslint/eslint-plugin": "8.17.0",
"@typescript-eslint/parser": "8.17.0",
"eslint": "^8.55.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/eslint-plugin-khan/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ the custom eslint rules this plugin provides.

After making a change to the plugin source code, you'll need to take following steps to
update the demo:
- run `yarn build` from the root directory of the repository
- run `pnpm install` and `pnpm build` from the root directory of the repository
- `cd packages/eslint-plugin-khan/demo`
- `rm node_modules`
- `yarn install`
- `yarn eslint .`
- `pnpm eslint .`

Your editor/IDE should report eslint errors that accurately reflect the changes you made
to the plugin.
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-khan/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx ."
},
"devDependencies": {
"@khanacademy/eslint-plugin": "^3.1.1",
"@khanacademy/eslint-plugin": "workspace:*",
"eslint": "^8.55.0",
"typescript": "^5.0.4"
},
Expand Down
Loading