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

Extract the babeljs plugin #18

Open
jdeniau opened this issue Apr 9, 2020 · 1 comment
Open

Extract the babeljs plugin #18

jdeniau opened this issue Apr 9, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@jdeniau
Copy link

jdeniau commented Apr 9, 2020

Hi,

I found your repo, that looks really efficient to generate prop-types.

I saw that the inject method does inject prop-types into a file content, but the file content need to be a JS file, not a TS one.

The Javascript reality is that build is really complex and babel does really simplify it.

As a matter of facte, I saw that you do have a babel plugin that injects proptypes into the AST, that is called by the inject method. But it has it's own configuration, of babel.

Do you think it would be possible to externalize this plugin to make a "real" babel plugin ?

The idea behind that is to have a babel config like that:

module.exports = {
  presets: [
    '@babel/typescript',
    '@babel/react',
    [
      '@babel/env',
    ],
  ],
  plugins: [
    // ...
    'your-babel-plugin',
  ]
};

thank you !

@merceyz merceyz added the enhancement New feature or request label Aug 17, 2020
@merceyz
Copy link
Owner

merceyz commented Aug 17, 2020

I saw that the inject method does inject prop-types into a file content, but the file content need to be a JS file, not a TS one.

It can be any valid source code, you just need to provide it the babel plugins to be able to understand it

/**
* Options passed to babel.transformSync
*/
babelOptions?: babel.TransformOptions;

Do you think it would be possible to externalize this plugin to make a "real" babel plugin ?

Sure, that should be possible

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

No branches or pull requests

2 participants