kentcdodds / kentcdodds/babel-plugin-codegen
Doesn't work if config is in "babel.config.js" file
- Dominant language
- TypeScript
- Stars
- 347
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
- `babel-plugin-codegen` version: 3.0.0
- `node`version: 10.13.0
- `npm` (or `yarn`) version: 1.12.3
Plugin doesn't work if your Babel config is in `babel.config.js`, but all works fine if it is in `.babelrc`
babel.config.js
```
module.exports = function() {
return {
presets: ['babel-preset-expo'],
plugins: ['codegen'],
}
}
```
.babelrc
```
{
"presets": ["babel-preset-expo"],
"plugins": [
"codegen"
]
}
```
What you did:
```
// @codegen
module.exports = '
module.exports = []
'
```
What happened:
When I use `babel.config.js`, I get export from module as string "module.exports = []", like there is no top comment "// @codegen".
When I use `.babelrc`, I get empty array as export from module, as it should be.
Reproduction repository:
https://github.com/serhiipalash/test-babel-codegen
Latest Expo has babel config in `babel.config.js`, and I don't want to change it as it is the standard for all future releases.
Contributor guide
Research direction
Start with the linked reproduction repository and compare the plugin behavior under babel.config.js and .babelrc. Trace how the Babel configuration is loaded and how the // @codegen comment is detected. Done means the babel.config.js example exports the generated empty array just like the .babelrc example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100