Comments in Jetpack SDK's package.json

5 views
Skip to first unread message

Nickolay Ponomarev

unread,
Apr 2, 2010, 3:01:43 PM4/2/10
to mozilla-la...@googlegroups.com
Hi,

As far as I can see, package.json in Jetpack SDK is expected to be "true" JSON, which in particular means (unless I'm missing something) you can't have /* */ or // comments there. I hit this a few times already (e.g. when needing to comment out dependencies for testing) and it's annoying (as well as having to wrap the key names in quotes).

Even install.rdf and chrome.manifest allow comments :)

Does anyone else think it's a problem? What's the best way to fix this?

Nickolay

Kris Kowal

unread,
Apr 2, 2010, 3:34:04 PM4/2/10
to mozilla-la...@googlegroups.com
On Fri, Apr 2, 2010 at 12:01 PM, Nickolay Ponomarev <asqu...@gmail.com> wrote:
> As far as I can see, package.json in Jetpack SDK is expected to be "true"
> JSON, which in particular means (unless I'm missing something) you can't
> have /* */ or // comments there. I hit this a few times already (e.g. when
> needing to comment out dependencies for testing) and it's annoying (as well
> as having to wrap the key names in quotes).

I usually put bogus "!" properties in objects for this purpose.

{
"!": "The purpose of this file."
}

Kris Kowal

Nickolay Ponomarev

unread,
Apr 2, 2010, 3:43:55 PM4/2/10
to mozilla-la...@googlegroups.com
On Fri, Apr 2, 2010 at 11:34 PM, Kris Kowal <cowber...@gmail.com> wrote:
I usually put bogus "!" properties in objects for this purpose.

{
   "!": "The purpose of this file."
}

That lets you add descriptive comments, but does not let you easily comment out sections of the file  (e.g. part of a dependency array or even an existing key-value pair).

Nickolay

Atul Varma

unread,
Apr 4, 2010, 1:28:18 PM4/4/10
to mozilla-la...@googlegroups.com, Nickolay Ponomarev
Yeah, this is a big annoyance I've found myself, though Kris' solution is quite clever.  The unfortunate thing is that since JSON is a standard, and package.json needs to be readable by any of the many implementations of parsers out there, I can't really think of any way around this limitation. :(

Let me know if you do think of one, though. On a per-entry basis, it may be possible for us to have the platform ignore e.g. dependencies that start with "!" or "//", thereby pushing the solution out of the parsing layer...

- Atul
--
You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
To post to this group, send email to mozilla-la...@googlegroups.com.
To unsubscribe from this group, send email to mozilla-labs-jet...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=en.

Nickolay Ponomarev

unread,
Apr 4, 2010, 1:56:01 PM4/4/10
to mozilla-la...@googlegroups.com
On Sun, Apr 4, 2010 at 9:28 PM, Atul Varma <ava...@mozilla.com> wrote:
The unfortunate thing is that since JSON is a standard, and package.json needs to be readable by any of the many implementations of parsers out there,

Why is that? Is package.json a thing from CommonJS too? If it's Jetpack-only thing I would prefer to hack the readers jetpack uses to support comments. Chromium supports comments in extension's manifest.json, although I didn't find any discussions about that decision.

Nickolay

Atul Varma

unread,
Apr 4, 2010, 2:05:08 PM4/4/10
to mozilla-la...@googlegroups.com, Nickolay Ponomarev
Oh, very interesting that Chromium supports comments.

package.json is indeed a thing from CommonJS.

All the potential ways I can think of getting around this limitation would involve a lot of work and also conflict with CommonJS, so I'm thinking we should probably just deal with this annoyance, as we've got plenty more awesome things to work on--like your Page Mods implementation, which I'll be trying out shortly. :)

- Atul

Myk Melez

unread,
Apr 5, 2010, 12:02:28 PM4/5/10
to mozilla-la...@googlegroups.com, Atul Varma, Nickolay Ponomarev
On 04/04/2010 11:05 AM, Atul Varma wrote:
All the potential ways I can think of getting around this limitation would involve a lot of work and also conflict with CommonJS, so I'm thinking we should probably just deal with this annoyance,
I agree. However, it may be worth raising the issue in the CommonJS community, if someone is interested in taking that on.

-myk

Reply all
Reply to author
Forward
0 new messages