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.

Add projectRoot option to config file

See original GitHub issue

Affected Packages

cli config

Problem

Our monorepo gets placed not in the project root, but in a subfolder (call it @my-awesome-project), like this:

- @my-awesome-project/
  - packages/
    - package-1/
      - package.json # @my-awesome-project/package-1
    - package-2/
      - package.json # @my-awesome-project/package-2
    - ...etc
  - package.json
  - pnpm-workspace.yaml
- demo/
  - src/
  - package.json # a test React project that helps in the package development. Uses the packages from `@my-awesome-project`
- package.json # this is just for maintenance reasons, but must be kept

The reason of this approach is to be able to keep the demo test project in the same repo (but not being part of the workspace in @my-awesome-project), and completely separate the node_modules folders of @my-awesome-project and demo.

If I install changesets in the @my-awesome-project, it works as expected, except of the .changeset gets created in that folder (and not the root), and the changesets-bot cannot find it.

If I install changesets in the project root, it won’t find the @my-awesome-project and its packages.

Am I missing something? Is there any other solution?

Proposed solution

I think that it could be a viable solution to add a projectRoot option to the config.json, where the user can set the path to the root folder of the workspace ("." by default, and "./@my-awesome-project" in my case), and use path.join(cwd, config.projectRoot) instead of cwd in all internal getPackages() calls.

Possibly related to #545

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Oct 10, 2021

@bencergazda sorry for the late reply - the last months were really busy for me (well, they still are) and I’m only digging through issues here now. Trying to respond as much as I can and maybe pick some stuff up.

I recognize your problem described here but I wonder if maybe instead of adding a new option your first intuition was right?

If I install changesets in the @my-awesome-project, it works as expected, except of the .changeset gets created in that folder (and not the root), and the changesets-bot cannot find it.

It seems that maybe the true issue here is in the implementation of the changesets-bot? Maybe it should not assume that the .changeset directory is at the root of the project? Because what if you’d have multiple changeset “roots” in your huge monorepo? By making the detection smarter there we could cover a more broad set of possible monorepo structures.

0reactions
Andaristcommented, Oct 12, 2021

Sure thing - take your time. I probably won’t go into this (but could give you pointers on how to do this, review the PR, and so on) because the priority of this seems rather low at the moment. There are just more pressing issues to handle that affect more people.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add projectRoot option to config file · Issue #594 - GitHub
I think that it could be a viable solution to add a projectRoot option to the config.json, where the user can set the...
Read more >
The creeping scourge of tooling config files in project root ...
I don't get this, what's the problem here? Having config files in root means you know they can apply to all sub directories....
Read more >
PhpStorm: how to use project root variable or relative path in ...
When you create a new project, its Default configuration file variable will be set to the file offset from your project root, and...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Configuring Vite
Configuring Vite #. When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project...
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