Skip to content
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

Document plugin options and how to set them #400

Closed
probins opened this issue Feb 2, 2017 · 3 comments
Closed

Document plugin options and how to set them #400

probins opened this issue Feb 2, 2017 · 3 comments
Labels

Comments

@probins
Copy link
Contributor

probins commented Feb 2, 2017

I'm new to Babili, and am finding the docs frustratingly limited.

  1. https://github.com/babel/babili/tree/master/packages/babel-preset-babili says that using .babelrc is 'recommended', but the babili command uses --no-babelrc - which seems contradictory
  2. if I can't use .babelrc, is there a command option to set plugin options, and if so what's the syntax?
  3. if I can't define options on the babili command, I should be able to use the babel command with .babelrc, right? Individual plugins, such as https://github.com/babel/babili/tree/master/packages/babel-plugin-minify-mangle-names, give examples of setting options, but AIUI this would mean only those plugins would be used, which is not what I want. I want to use the preset but set options on one or more plugins.
  4. https://github.com/babel/babili/tree/master/packages/babel-preset-babili gives an example of setting options for the preset in .babelrc, but these either ('unsafe') don't correspond to a particular plugin or (mangle/blacklist) are in a different syntax from those which do. I can just about work out how these correspond by looking in https://github.com/babel/babili/blob/master/packages/babel-preset-babili/src/index.js, but ISTM it would be much better if these options were clearly documented.
@boopathi
Copy link
Member

boopathi commented Feb 2, 2017

1

If you're using babel-preset-babili you're using babel with a babelrc file. babili is a command line tool that just applies the transformations specific to babili and we don't want the presence of other babelrc to interfere with this as it will come out surprising - the transformations that are not specific to babili. But when using a preset, you explicitly specify alongside babili the other transformations you want.

2,3,4

The preset is able to toggle plugins as well as pass the options down to the plugins it uses and the corresponding plugin options are available in the respective plugin README which is also linked in the preset options. Refer to preset options given in the preset docs (https://github.com/babel/babili/tree/master/packages/babel-preset-babili). If you think the docs can be improved, we are accepting PullRequests and I'll be happy to merge it.

@boopathi boopathi closed this as completed Feb 2, 2017
@probins
Copy link
Contributor Author

probins commented Feb 2, 2017

you explicitly specify alongside babili the other transformations you want

but I don't want any other transformations. I want to set options on the plugins that are part of the babili preset. With the babel command, I can specify options in a .babelrc or on the command line with no-babelrc. I'm not sure whether there is a command-line option for specifying plugin options, but if not I have to use a .babelrc. AIUI, the babili command is a convenience babel command with the babili preset pre-defined. But if it always uses no-babelrc, then how do I specify plugin options for the preset? If I can't do this with the babili command and have to use babel instead, then the docs should say so. I'm happy to create a PR to document this, but I can't do that until I know how this is supposed to work.

Point 4 was my bad, as I saw 'Via Node API' and stopped scrolling. The Options section does indeed document what needs to be defined. There is however a discrepancy: the babelrc section gives "blacklist": ["MyCustomError"] whereas the plugin docs state that this should be a JS object. Error, or is array also possible?

@boopathi
Copy link
Member

boopathi commented Feb 2, 2017

It is supposed to accept Array too. Thanks for reminding. I just pushed the change.

The command line now doesn't support the options to be passed to the preset. We can add that in future. You can use babel cli with a babelrc and this preset to add options (in the babelrc file).

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

No branches or pull requests

2 participants