cli icon indicating copy to clipboard operation
cli copied to clipboard

Convert configs from .json to .js or .ts

Open Alexander-Taran opened this issue 6 years ago • 6 comments

I'm submitting a discussion request

  • Language: all

  • Loader/bundler: all

Current behavior:

Config files are now mostly in .json format which does not allow comments. https://stackoverflow.com/questions/244777/can-comments-be-used-in-json

  • What is the desired behavior? Have most config files in .js format Like webpack.config.js
module.exports = {
// same json, but now it can have comments along
}

  • What is the motivation / use case for changing the behavior?

I think it would be useful to have commented config files. It improves usage by new developers. And is generally a good practice. Like in website usage - every additional step increases drop rate. Figuring out what that line means and how to use it now requires.. If it's not mentioned in the docs -> hours of googling and parsing the issues That is for the patient ones

Some drawbacks: I guess that now configs are read and modified as objects and are written the same way by the CLI. Maintaining that ease of modifying config with CLI would be a challenge.

there is a jsonc parser by MS https://github.com/Microsoft/node-jsonc-parser

but no writer of course..

Well It is a dream of improving something for newcomers Not actionable

Alexander-Taran avatar Mar 06 '18 10:03 Alexander-Taran

Similar to #781 (Yaml config)... Commented configs is a must.

The huge gap between the cli help and actually having to edit the config file without any help is a big usability gap.

JoakimSoderberg avatar Mar 19 '18 22:03 JoakimSoderberg

I also want my aurelia.json to be upgraded to aureliarc.js, not only for comments (which I want too), but also for simplifying cli implementation. We can conditionally build the config, so we can cut off some code from cli that supports condition in aurelia.json, like:

{
  "name": "aurelia-testing",
  "env": "dev"
}

3cp avatar Aug 10 '18 07:08 3cp

I would like to add a different motivation to prefer js over json config files. In my Aurelia setup I moved all my config files in an npm package (coding standards). JS files can easily extend another js/json config and be merged using a spread operator.

(Not a fan of adding comments btw, if you need to comment code it generally means something needs to be improved)

michaelw85 avatar Feb 20 '19 20:02 michaelw85

if you need to comment code it generally means something needs to be improved.

I think most coders will disagree 😃

3cp avatar Feb 20 '19 20:02 3cp

Remeber that we are discussing add comments to configurations. I would say it is really valuable to have comments in configuration.

I would love to se .ts instead of .json

magnusdanielson avatar May 15 '19 22:05 magnusdanielson

bump

Alexander-Taran avatar Aug 10 '21 22:08 Alexander-Taran