这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: add JSONC support #10083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Mar 5, 2025
Merged

feat: add JSONC support #10083

merged 27 commits into from
Mar 5, 2025

Conversation

anthonyshew
Copy link
Contributor

@anthonyshew anthonyshew commented Mar 4, 2025

Description

JSONC allows the use of comments in JSON files. Until now, our configuration parser allowed comments in JSON by accident, which made for awkwardness talked about in #3793.

With this PR, we're now able to support turbo.jsonc in both the root configuration and in Package Configurations. The file will be properly used for hashing and users can use .jsonc that will work with their editors and other tooling.

Testing Instructions

Tests have been added in this PR and I've hand-tested with create-turbo, both turbo and some packages. Would appreciate some more hand-testing, just in case, along with your code review.

@anthonyshew anthonyshew requested a review from a team as a code owner March 4, 2025 04:10
Copy link

vercel bot commented Mar 4, 2025

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

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 1:14pm

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Maybe get another review for the Rust changes (especially loader.rs) since I rewrote some chunks.

@anthonyshew
Copy link
Contributor Author

Looks great to me. Thanks for all the assists.

@anthonyshew anthonyshew merged commit fb32965 into main Mar 5, 2025
44 checks passed
@anthonyshew anthonyshew deleted the shew/ce135 branch March 5, 2025 16:14
chris-olszewski added a commit that referenced this pull request Mar 5, 2025
…10106)

### Description

#10083 missed including `turbo.jsonc` as a global dependency when doing
SCM based filters

### Testing Instructions

👀
chris-olszewski added a commit that referenced this pull request Mar 31, 2025
### Description

#10083 introduced a bug where we swallow validation errors and end up
silently ignoring these workspace `turbo.json` files. This PR fixes that
by distinguishing a missing `turbo.json` from a failed read.

The bug stems from the fact that a missing file and a failed read were
both errors so `turbo_json.or(turbo_jsonc)` could choose a missing
turbo.json error (which is fine, not all workspaces need `turbo.json`s)
over a validation error for the file that is present. We replace `.or`
with an extremely explicit `match` that goes through all the possible
combinations.

### Testing Instructions
Added unit test

Quick manual verification
```
[0 olszewski@macbookpro] /Users/olszewski/code/vercel/turborepo $ turbo_dev build   
 WARNING  No locally installed `turbo` found. Using version: 2.4.5-canary.6.
turbo 2.4.5-canary.6

turbo_json_parse_error

  × Failed to parse turbo.json.
  ╰─▶   × Found an unknown key `lol`.
          ╭─[cli/turbo.json:9:7]
        8 │     "rust-src": {
        9 │       "lol": true,
          ·       ─────
       10 │       "env": [
          ╰────
```
@neochief
Copy link

probably related: #10323

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.

[turborepo] .jsonc support (Json with comments)
3 participants