Skip to content

Allow Changesets to be executed from non-root directories#1806

Merged
Andarist merged 26 commits into
changesets:mainfrom
luisadame:feature/#545--find-changeset-root-folder
Feb 24, 2026
Merged

Allow Changesets to be executed from non-root directories#1806
Andarist merged 26 commits into
changesets:mainfrom
luisadame:feature/#545--find-changeset-root-folder

Conversation

@luisadame
Copy link
Copy Markdown
Contributor

@luisadame luisadame commented Dec 18, 2025

Context

Allows changesets to be executed from deeply nested folders within a monorepo that has the .changeset folder at the root of it.

A common example of this is a monorepo with two packages: frontend and backend. These packages might have different scripts that people run within those folders. When they finish some piece of work, they have to change directories back to the root to create a changeset.

This change helps exactly with that, but also, with most of the changeset commands.

Implementation details

I've added a new package to determine the root of the project: @manypkg/find-root. This package gets dynamically imported when the current directory doesn't have a changeset folder. Then, it will try to determine if the root has a changeset folder or not. Otherwise the same behavior as always executes, which is throwing an error.

Questions/Unknowns

The new package is an ES module and therefore I've had some issues using it here, in terms of typings, execution, and testing.

  • The types can't be determined because the current TS module resolution can't work with ESM (as typescript compiler said when I run it).
  • I initially imported the package at the top of the file, but that doesn't work well in CJS. However, the dynamic import seems to bypass that issue.
  • Because it uses that dynamic import now the test suite has to run with a special node flag to enable that feature.

My question is, are we ok with this? I'm open to other ideas or suggestions.

fixes #545
fixes #1824

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 204a570

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.91%. Comparing base (59552f9) to head (204a570).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/run.ts 58.33% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1806      +/-   ##
==========================================
+ Coverage   81.74%   81.91%   +0.17%     
==========================================
  Files          55       55              
  Lines        2355     2356       +1     
  Branches      705      705              
==========================================
+ Hits         1925     1930       +5     
+ Misses        425      421       -4     
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@luisadame luisadame force-pushed the feature/#545--find-changeset-root-folder branch from 5aa603c to 4fbd2bd Compare December 18, 2025 20:47
@luisadame luisadame changed the title Feature/#545 find changeset root folder feat(cli): allow changesets to be executed from nested non-root folders (#545) Dec 18, 2025
@luisadame luisadame marked this pull request as ready for review December 18, 2025 22:35
Comment thread .changeset/warm-numbers-doubt.md Outdated
@Andarist Andarist changed the title feat(cli): allow changesets to be executed from nested non-root folders (#545) Allow Changesets to be executed from non-root directories (#545) Feb 24, 2026
@Andarist Andarist enabled auto-merge February 24, 2026 13:35
@Andarist Andarist added this pull request to the merge queue Feb 24, 2026
@Andarist Andarist changed the title Allow Changesets to be executed from non-root directories (#545) Allow Changesets to be executed from non-root directories Feb 24, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Feb 24, 2026
@Andarist Andarist added this pull request to the merge queue Feb 24, 2026
@Andarist Andarist enabled auto-merge February 24, 2026 15:07
@Andarist Andarist added this pull request to the merge queue Feb 24, 2026
Merged via the queue into changesets:main with commit 0e8e01e Feb 24, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Feb 24, 2026
nnecec pushed a commit to nnecec/changesets-docs that referenced this pull request Apr 16, 2026
…#1806)

* add find-root package

* find root and use it across commands

* import the package dinamically to avoid the resolution errors?

* add some types and expect the error from module resolution

* changeset

* add tests

* enable esm in jest

* enable it in ci too

* test no changeset folder

* test rest of commands

* do it better

* missing line

* assert the error thrown is actually a lack of changeset folder

* revert redundant changes

* simplify

* fix

* tweak

* tweak

* fix

* fix

* tweak tests

* fix test

* Apply suggestion from @Andarist

---------

Co-authored-by: Mateusz Burzyński <[email protected]>
@xccxcs
Copy link
Copy Markdown

xccxcs commented Apr 20, 2026

If the .changeset directory is included in the execution directory, it will still look up to the parent directory until the most root .changeset directory is found, which will cause the configuration of the .changeset folder in my subdirectory to be invalidated

@Andarist
Copy link
Copy Markdown
Member

@xccxcs please raise a new issue describing your directory structure in more detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enterPre() always creates pre.json at the top level of a monorepo There is no .changeset folder

3 participants