question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

what's the right approach for the root monorepo package and updateInternalDependencies with pnpm ?

See original GitHub issue

our monorepo package.json depends on some of the packages in the monorepo (a jest config preset), so yesterday when i made some changes to the jest config preset package, it didn’t update our root package.json. and as a result all our apps triggered a failed CodeBuild deployment due to pnpm install failing (due to the root package jest preset dep version not being bumped).

I’ve found that if i update our pnpm-workspace.yaml to describe the root package as a monorepo package, then changesets now updates the root package.

Without pnpm-workspace.yaml change

repo/
  package.json
    name: @reckon-web/repo
    deps:
      @reckon-web/jest-preset: 0.0.2

  apps/
    something:
      package.json
        name: @reckon-web/something-app
        deps:
          @reckon-web/jest-preset: 0.0.2

  packages/config/
    jest-preset/
      package.json
        name: @reckon-web/jest-preset
        version: 0.0.2

If i do a changeset like :

---
"@reckon-web/jest-preset": "patch"
---

something something something darkside

then i end up with:

repo/
  package.json
    name: @reckon-web/repo
    deps:
      @reckon-web/jest-preset: 0.0.2

  apps/
    something:
      package.json
        name: @reckon-web/something-app
        deps:
          @reckon-web/jest-preset: 0.0.3

  packages/config/
    jest-preset/
      package.json
        name: @reckon-web/jest-preset
        version: 0.0.3

if i change pnpm-workspace.yaml from :

packages:
  - 'packages/**'
  - 'design-system/packages/*'
  - 'design-system/storybook'
  - 'design-system/website'
  - 'apps/*'
  - 'services/*'
  - 'runbooks'
  - 'infrastructure'

to

packages:
  - '.'
  - 'packages/**'
  - 'design-system/packages/*'
  - 'design-system/storybook'
  - 'design-system/website'
  - 'apps/*'
  - 'services/*'
  - 'runbooks'
  - 'infrastructure'

then the above changeset resuts in :

repo/
  package.json
    name: @reckon-web/repo
    deps:
      @reckon-web/jest-preset: 0.0.3

  apps/
    something:
      package.json
        name: @reckon-web/something-app
        deps:
          @reckon-web/jest-preset: 0.0.3

  packages/config/
    jest-preset/
      package.json
        name: @reckon-web/jest-preset
        version: 0.0.3

Is this the right approach? or should we talk about supporting this via changesets configuration ?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinwolfcrcommented, Aug 18, 2022

This would be really helpful for me as well, this is my scenario:

  • I have a devtools repository where I am hosting my prettier, eslint, etc configs.
  • My devtools repository has a prettier config.
  • I am referencing that config in my root’s package.json
  • My monorepo root depends on the workspace containing the config.
  • I have a Husky hook that runs manypkg check before push

So, after running changeset version, everything works fine, except for the push part, since my config package bumped its version and it didn’t get updated in the root package.json, it throws an error.

A workaround I am doing is to run manypkg fix after changeset version and then removing the generated yarn.lock (since I’m using NPM), but that feels hacky.

1reaction
Andaristcommented, Apr 2, 2022

Ok, so to sum up - the proposed change is to just update dependency ranges in <root>/package.json regardless of the list of workspace packages. Would this change alone fix your problem? Do you want to work on a fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing a full-stack, multipackage monorepo using pnpm
The root workspace depends on both packages A and B; Package B depends on package A. Let's learn how to create this structure...
Read more >
How we configured pnpm and Turborepo for our monorepo
We decided to move to a monorepo to solve these issues. We chose pnpm as our package manager and Turborepo as our build...
Read more >
Workspace | pnpm
Workspace. pnpm has built-in support for monorepositories (AKA multi-package repositories, multi-project repositories, or monolithic repositories).
Read more >
Setup a Monorepo with PNPM workspaces and speed it up ...
In this article we're going to have a deep dive into setting up a new monorepo using PNPM workspaces that hosts a Remix...
Read more >
How to access a dependency that belongs to another package?
The pnpm package manager is superb, very fast. yarn just sucks when it comes to managing a monorepo. I have a monorepo with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found