Hacker News new | ask | show | jobs
by orf 2358 days ago
That's all totally awesome and cool, right up until the moment you want to add a comment to your configuration. Because you know, it's configuration, and that requires comments.

Quite a few tools went from just JSON configuration files to supporting both .js and .json.

Regarding caching, perhaps I'm mistaken but what's the issue there? Two JSON documents can be equivalent with different bytes so you need to re-parse the configuration file fairly often anyway. So what's the difference with just re-evaluating a .js configuration file and caching the output? If someone wants to put a `if (random() > 0.1)` statement in their config then that's their problem.

2 comments

We use json5, which allows comments.

You cannot statically cache the results of a .js file - it might include objects or functions that cannot be serialized, and might cause side effects that parcel cannot know about. If we supported .js config files, we would have to intentionally limit what you can return to basically just JSON, so you wouldn’t get much benefit from it and it would be hard to enforce.

Oh right! Thank you for your clarifying comments, this does sound pretty interesting. Sorry for being flippant before.

Looking forward to reading about the new release!

jsonp