Skip to content

Commit

Permalink
Fix pnpm guide (#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronMoat authored Jul 29, 2024
1 parent add77f9 commit 7294b08
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions docs/deep-dives/pnpm.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,28 @@ This migration guide assumes that your project was scaffolded with a **skuba** t

6. Run `pnpm skuba format`

7. Remove the `.npmrc` ignore entry from `.gitignore` and `.dockerignore`

Heed the warning and ensure that a safe `.npmrc` is included in the same commit.

```diff
yarn-error.log
# end managed by skuba
-
- # Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
- # IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.
- # You can use `skuba format` to generate the file or otherwise commit an empty file.
- # Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
- .npmrc
```
A safe `.npmrc` will be synthesised for you in the next step.

8. Run `pnpm skuba format`

This will synthesise managed hoist patterns into `.npmrc`.

7. Include additional hoisting settings in `.npmrc`
9. Include additional hoisting settings in `.npmrc`

Skip this step if your project does not use Serverless.

Expand All @@ -161,28 +180,13 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
+ shamefully-hoist=true
```

8. Remove the `.npmrc` ignore entry from `.gitignore` and `.dockerignore`

Heed the warning and ensure that a safe `.npmrc` is included in the same commit.

```diff
yarn-error.log
# end managed by skuba
-
- # Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
- # IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.
- # You can use `skuba format` to generate the file or otherwise commit an empty file.
- # Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
- .npmrc
```
9. Run `rm -rf node_modules && pnpm install`
10. Run `rm -rf node_modules && pnpm install`

This will ensure your local workspace will not have any lingering hoisted dependencies from `yarn`.
This will ensure your local workspace will not have any lingering hoisted dependencies from `yarn`.

If you have a monorepo, delete all sub-package `node_modules` directories.
If you have a monorepo, delete all sub-package `node_modules` directories.

10. Run `pnpm skuba lint`
11. Run `pnpm skuba lint`

After running `pnpm install`,
you may notice that some module imports no longer work.
Expand All @@ -197,7 +201,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t

Run `pnpm install foo` to resolve this error.

11. Modify `Dockerfile` or `Dockerfile.dev-deps`
12. Modify `Dockerfile` or `Dockerfile.dev-deps`

Your build pipeline may have previously mounted an ephemeral `.npmrc` with an auth token at `/workdir`.
This needs to be mounted elsewhere to avoid overwriting the new pnpm configuration stored in `.npmrc`.
Expand Down Expand Up @@ -235,7 +239,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t

Review [`Dockerfile.dev-deps`] from the new `koa-rest-api` template as a reference point.

12. Replace `yarn` with `pnpm` in `Dockerfile`
13. Replace `yarn` with `pnpm` in `Dockerfile`

As `pnpm fetch` does not actually install packages,
run a subsequent `pnpm install --offline` before any command which may reference a dependency.
Expand Down Expand Up @@ -271,7 +275,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
ENV NODE_ENV=production
```

13. Modify plugins in `.buildkite/pipeline.yml`
14. Modify plugins in `.buildkite/pipeline.yml`

Your build pipeline may have previously output an ephemeral `.npmrc` with an auth token on the build agent.
This needs to be output elsewhere to avoid overwriting the new pnpm configuration stored in `.npmrc`.
Expand Down Expand Up @@ -300,7 +304,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
+ secrets: id=npm,src=tmp/.npmrc
```

14. Run `pnpm install --offline` and replace `yarn` with `pnpm` in `.buildkite/pipeline.yml`
15. Run `pnpm install --offline` and replace `yarn` with `pnpm` in `.buildkite/pipeline.yml`

```diff
- label: 🧪 Test & Lint
Expand All @@ -317,7 +321,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
+ - pnpm lint
```

15. Search for other references to `yarn` in your project. Replace these with `pnpm` where necessary.
16. Search for other references to `yarn` in your project. Replace these with `pnpm` where necessary.

## FAQ

Expand Down

0 comments on commit 7294b08

Please sign in to comment.