Skip to content

[CLI] No option for the babel config #637

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

Closed
tleunen opened this issue Mar 11, 2016 · 13 comments
Closed

[CLI] No option for the babel config #637

tleunen opened this issue Mar 11, 2016 · 13 comments

Comments

@tleunen
Copy link

tleunen commented Mar 11, 2016

A recent commit introduces a way to configure the babel configuration for Ava, but there's currently no way in the CLI to set this configuration. Only the package.json way.

Having it in the CLI would be great.

(see #573 (comment))

@jamestalmage
Copy link
Contributor

Babel offers fairly robust configuration from the CLI, allowing plugins, presets, and all kinds of other options to be passed in:

  Usage: babel [options] <files ...>

  Options:

    -h, --help                           output usage information
    -f, --filename [filename]            filename to use when reading from stdin - this will be used in source-maps, errors etc
    --retain-lines                       retain line numbers - will result in really ugly code
    --no-highlight-code                  enable/disable ANSI syntax highlighting of code frames (on by default)
    --presets [list]
    --plugins [list]
    --ignore [list]                      list of glob paths to **not** compile
    --only [list]                        list of glob paths to **only** compile
    --no-comments                        write comments to generated output (true by default)
    --compact [booleanString]            do not include superfluous whitespace characters and line terminators [true|false|auto]
    --minified                           save as much bytes when printing [true|false]
    -s, --source-maps [booleanString]    [true|false|inline]
    --source-map-target [string]         set `file` on returned source map
    --source-file-name [string]          set `sources[0]` on returned source map
    --source-root [filename]             the root from which all sources are relative
    --no-babelrc                         Whether or not to look up .babelrc and .babelignore files
    --source-type [string]
    --auxiliary-comment-before [string]  print a comment before any injected non-user code
    --auxiliary-comment-after [string]   print a comment after any injected non-user code
    --module-root [filename]             optional prefix for the AMD module formatter that will be prepend to the filename on module definitions
    -M, --module-ids                     insert an explicit id for modules
    --module-id [string]                 specify a custom name for module ids
    -x, --extensions [extensions]        List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx]
    -w, --watch                          Recompile files on changes
    -o, --out-file [out]                 Compile all input files into a single file
    -d, --out-dir [out]                  Compile an input directory of modules into an output directory
    -D, --copy-files                     When compiling a directory copy over non-compilable files
    -q, --quiet                          Don't log anything
    -V, --version                        output the version number

From that list, I think only a few are applicable here:

  • --presets
  • --plugins
  • --ignore
  • --only
  • --no-babelrc

Which of these do we actually want to implement, and how should it look?

@sindresorhus
Copy link
Member

Which of these do we actually want to implement, and how should it look?

None. We could allow --babel=[inherit|false] on the CLI. Rest should IMHO be in package.json.

@tleunen
Copy link
Author

tleunen commented Mar 11, 2016

Yep, usually it will always be inherit anyway.. Or maybe also --babelrc=[file path]?

@sindresorhus
Copy link
Member

Having it in the CLI would be great.

Btw, why? When would you need to have it on the CLI?

@jamestalmage
Copy link
Contributor

None

I agree.

usually it will always be inherit anyway

If that is the case, then why do a CLI option at all? IMO, CLI options should be for config options you want to change occasionally or contextually (i.e.: default to mini reporter, but use verbose on the CI server).

@tleunen
Copy link
Author

tleunen commented Mar 11, 2016

@sindresorhus When you want to run ava but dont want to pollute package.json with ava specific configs.

@jamestalmage afaik, the default value is not inherit so having the option make sense to set it.

@jamestalmage
Copy link
Contributor

but dont want to pollute package.json with ava specific configs.

If that's the only rationale for adding a CLI option, then 👎. Is there some specific reason config via package.json can't be used other than personal preference?

the default value is not inherit

Correct, but if your tests need the inherit option, then set it once in package.json, and avoid littering all your scripts / command prompts with an unneeded flag that must be the same every time.

@sindresorhus
Copy link
Member

If that is the case, then why do a CLI option at all? IMO, CLI options should be for config options you want to change occasionally or contextually (i.e.: default to mini reporter, but use verbose on the CI server).

Agreed.

When you want to run ava but dont want to pollute package.json with ava specific configs.

I was asking more about whether you actually had to use the CLI. If it's just a matter of preference, we're not very likely to add it. You'll usually end up having to add the flag to the npm run script, so you'll "pollute" package.json either way.

@tleunen
Copy link
Author

tleunen commented Mar 11, 2016

Well.. of course the command will probably be inside a npm script..
Or at least make ava use the configs property in package.json instead of a "root property". I don't think it's the case at the moment

@sindresorhus
Copy link
Member

Or at least make ava use the configs property in package.json instead of a "root property". I don't think it's the case at the moment

There's no configs property in package.json. Some might use it, but most use a top-level property (Babel, ESLint, XO, nyc, etc does it) and that's what we prefer here too.

@jamestalmage
Copy link
Contributor

Or at least make ava use the configs property in package.json instead of a "root property". I don't think it's the case at the moment

We chose the root property on purpose. If you have valid needs for either request (CLI or non-top-level config), you will find us happy to accommodate. Unfortunately, "my preference differs from yours" isn't generally a good enough reason for us to add overhead.

@tleunen
Copy link
Author

tleunen commented Mar 11, 2016

https://docs.npmjs.com/files/package.json#config ?

Ok that's a choice you made. But I still think it should be set as a cli option as well... If you don't want, that's fine. I'll just wait for ava to get the default value to inherit in that case.

@vadimdemedes
Copy link
Contributor

I agree that we shouldn't expose any babel-related options in our CLI.

  • --presets
  • --plugins
  • --ignore
  • --only

These look like they might be needed for AVA itself at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants