turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Regression unable to use comments anymore in `turbo.json`

Open weyert opened this issue 2 years ago • 6 comments

What version of Turborepo are you using?

1.2.11

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

In the past JSON5 support was added to turbo.json but adding // comment now breaks with:

error unmarshalling invalid character '/' looking for beginning of object key string
ERROR  turbo.json: invalid character '/' looking for beginning of object key string

Expected Behavior

Able to use JSON5 format in turbo.json to allow comments

To Reproduce

Add a comment e.g.

    "test": {
      // "dependsOn": ["^build"],
      "outputs": ["coverage/junit.xml"]
    },

weyert avatar May 23 '22 16:05 weyert

Huh, it looks like this doesn't even work if I check out the commit that json5 support was added in. Weirdly, comments in some other locations work.

{
  "pipeline": {
    // This works
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**"]
    }
  }
}

vs

{
  "pipeline": {
    "build": {
      // This doesn't work
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**"]
    }
  }
}

I guess we need to move to a better json5 library.

gsoltis avatar May 24 '22 18:05 gsoltis

Oh no, that's a bummer. I would have sworn this was working. I will see if I can resolve it myself later this week

weyert avatar May 24 '22 21:05 weyert

Just opened a pull request or this issue.

Feel free to give feedback. :D

helloiambguedes avatar Jul 02 '22 16:07 helloiambguedes

@bguedes-moz Awesome, thank you :))

weyert avatar Jul 02 '22 17:07 weyert

I'd also like to suggest adding to the documentation that JSON5 is supported. I didn't know about that until looking through the GitHub issues. Perhaps something here like "turbo.json supports JSON5, so it can include comments."

trevorr avatar Jul 05 '22 17:07 trevorr

This is working for me today, maybe this can be closed?

dobesv avatar Aug 10 '22 03:08 dobesv

Yup, fixed in #1472

gsoltis avatar Aug 24 '22 20:08 gsoltis