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.

Integration with Rush: how to use with no root package.json file?

See original GitHub issue

Problem

I’m exploring integrating the changeset tool into a Rush monorepo.

In a Rush monorepo, there is no root package.json (it’s generally forbidden and/or discouraged), and instead all of the paths for your individual projects are stored in a root rush.json file.

I’m not sure exactly what package or tool is looking for the root package:

❯ changeset
🦋  error NoPkgJsonFound [Error]: No package.json could be found upwards from the directory /Users/enelson/dev/rushstack2
🦋  error     at _callee4$ (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@manypkg/find-root/dist/find-root.cjs.dev.js:217:19)
🦋  error     at tryCatch (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
🦋  error     at Generator.<anonymous> (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
🦋  error     at Generator.next (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21)
🦋  error     at asyncGeneratorStep (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
🦋  error     at _next (/Users/enelson/.nvm/versions/node/v16.15.0/lib/node_modules/@changesets/cli/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9) {
🦋  error   directory: '/Users/enelson/dev/rushstack2'
🦋  error }

Proposed solution

I think first off, if I could get it to the point where at least it is not erroring, maybe I would be able to add a changeset if I explicitly told it what package it was? But ideally, I could add code to get the package list from rush.json projects: [] field, and pass that into changeset to inform it of the projects in the repo.

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Dec 9, 2022

The type that you have to return from get-packages is this:

export declare type Packages = {
    tool: Tool;
    packages: Package[];
    root: Package;
};

So it seems likely that you need to “fake” the root here - it has to contain .packageJson. I think that it’s likely that you end up with a crash here: https://github.com/changesets/changesets/blob/e02a0c4b7ec869d21b10495138d9fb193b213917/packages/get-dependents-graph/src/get-dependency-graph.ts#L67

0reactions
elliot-nelsoncommented, Dec 9, 2022

Bingo! It works. I’ll play with it and put up a PR this weekend possibly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling CI builds
Install NPM packages in the common folder, but don't automatically do "rush link" rush install --no-link # Run "rush link" explicitly, so your...
Read more >
rushstack/CHANGELOG.json at main · microsoft ...
"comment": "Fix an issue where if the package manager is PNPM 6.1.0 or newer, and `pnpmStore` is set to `\"local\"`, then a global...
Read more >
npm, pnpm, and Yarn | PhpStorm Documentation
To run or debug several scripts, use a run configuration or the npm tool window. Open the package.json file in the editor, click...
Read more >
Lerna is Officially Dead. Long Live Monorepos
In pnpm the workspace configuration lives in pnpm-workspace.yaml whilst in yarn and npm is it placed in root package.json . Example using npm...
Read more >
Getting Started - PnP/PnPjs
SPFx Version 1.12.1 => 1.14.0¶ · Uninstall existing rush stack compiler (replace the ? with the version that is currently referenced in your...
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