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

Support babel plugin options in experimentalBabelParserPluginsList #86

Closed
saaryab opened this issue Oct 7, 2021 · 2 comments · Fixed by #88
Closed

Support babel plugin options in experimentalBabelParserPluginsList #86

saaryab opened this issue Oct 7, 2021 · 2 comments · Fixed by #88

Comments

@saaryab
Copy link
Contributor

saaryab commented Oct 7, 2021

Hi @byara (or whoever is working on this now),

Thanks for making and maintaining this plugin!

experimentalBabelParserPluginsList allows adding custom babel parser plugins, but it does not allow sending plugin options.

For example, @ShigotoMitame was using the decorators plugin with the following options:

plugins: ['typescript', 'jsx', ['decorators', {'decoratorsBeforeExport': true}], 'classProperties'],

It seems like the preprocessor.js code should allow any type of babel plugin, both a string and an array of [PLUGIN_NAME: string, PLUGIN_OPTIONS: object], but when adding a plugin with options I get the following error:

$ /home/.../project/node_modules/.bin/prettier -w .
[error] Invalid experimentalBabelParserPluginsList value. Expected an array of a string, but received [["decorators", { decoratorsBeforeExport: true }]].
error Command failed with exit code 1.

When adding these options directly in preprocessor.js like @ShigotoMitame did everything works as expected so it looks liek this is a validation issue caused by prettier's options which don't seem to support any complex values:

 * @property {'int' | 'boolean' | 'choice' | 'path'} type

https://github.com/prettier/prettier/blob/5909f5b3f191a0a32f759e1f4378477d3b90e28e/src/main/core-options.js#L17

As a work around I was wondering if you would consider supporting taking the plugins directly from a babelrc file, or at least allowing JSON in the experimentalBabelParserPluginsList array to support plugins with options.

Originally posted by @saaryab in #12 (comment)

@saaryab
Copy link
Contributor Author

saaryab commented Oct 13, 2021

I created a PR with a fix to allow passing JSON options in the experimentalBabelParserPluginsList1 array:
#88

@byara byara linked a pull request Oct 14, 2021 that will close this issue
@byara byara closed this as completed Oct 20, 2021
@byara
Copy link
Collaborator

byara commented Oct 20, 2021

PR merged.

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

Successfully merging a pull request may close this issue.

2 participants