turbo icon indicating copy to clipboard operation
turbo copied to clipboard

fix: adding `PeerDependenciesMeta` to `NpmLockfile` to fix issue with `turbo prune`

Open derekaug opened this issue 2 years ago • 4 comments

When unmarshalling the package-lock.json, since PeerDependenciesMeta is not present on the NpmPackage struct it gets dropped when turbo prune does its thing. This caused npm ci to complain due to the package and lock-file being out of sync as described in #2739

By adding this property to the struct, it gets preserved when unmarshalling and persists in the lockfile after the prune, resulting in a pruned package and lock-file that remain in sync according to npm.

derekaug avatar Nov 16 '22 22:11 derekaug

@derekaug is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 16 '22 22:11 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Nov 17, 2022 at 6:22PM (UTC)
6 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Nov 17, 2022 at 6:22PM (UTC)

vercel[bot] avatar Nov 16 '22 22:11 vercel[bot]

This makes sense to me, but I want to defer to @chris-olszewski.

Is it possible to add just a unit test to show that the marshalling works, or better yet, produce the failure you're trying to fix?

Should be possible, just need to find the best way to add the case.

derekaug avatar Nov 17 '22 00:11 derekaug

First of all, thanks for fixing this! This looks correct to me. I'll stamp once there's a unit test just verifying that data can make the round trip. Something as simple as unmarshalling and marshalling back one of the entries with peerDependenciesMeta set would be enough e.g.

{
      "version": "13.0.0",
      "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.0.0.tgz",
      "integrity": "sha512-y2nqWS2tycWySdVhb+rhp6CuDmDazGySqkzzQZf3UTyfHyC7og1m5m/AtMFwCo5mtvDqvw1BENin52kV9733lg==",
      "dependencies": {
        "eslint-plugin-react": "^7.31.7",
        "eslint-plugin-react-hooks": "^4.5.0"
      },
      "peerDependencies": {
        "eslint": "^7.23.0 || ^8.0.0",
        "typescript": ">=3.3.1"
      },
      "peerDependenciesMeta": {
        "typescript": {
          "optional": true
        }
      }
    }

I added a test case that should show that unmarshalling / marshalling is working with npm lockfiles. Not sure it's exactly what you were expecting, or proper. Beginner Go dev here so please have some mercy. 😅

derekaug avatar Nov 17 '22 13:11 derekaug

The test looks great to me! Thanks for fixing this. I'll get it merged in once CI passes

Looks like the linter failed, I fixed the unchecked error and think it should be good to go now!

derekaug avatar Nov 17 '22 18:11 derekaug