kentcdodds / kentcdodds/babel-plugin-codegen

BABEL error when configuring with babel.config.js and with typescript preset

Aperta
#40 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
347
Fork
27
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

- `babel-plugin-codegen` version: 4.1.4
- `node` version: v12.15.0
- `npm` version: 6.14.11

With these files:

**index.js**
```js
// @codegen
module.exports = `console.log("hello world!")`;
```
**babel.config.js**
```js
module.exports = {
presets: ['@babel/preset-typescript'],
plugins: ['codegen'],
};
```

I ran this command:
```
babel --plugins codegen index.js
```
and got this result:
```
Error: [BABEL] unknown: Configuration contains string/RegExp pattern, but no filename was passed to Babel
at matchPattern (/home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:431:11)
at /home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:418:35
at Array.some ()
at matchesPatterns (/home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:418:19)
at configFieldIsApplicable (/home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:400:10)
at configIsApplicable (/home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:395:41)
at /home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:256:13
at Array.forEach ()
at /home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:253:42
at buildPresetChain (/home/jallan/dev/codegen/node_modules/@babel/core/lib/config/config-chain.js:45:17)
```

Reproduction repository:

https://github.com/jackgeek/codegen-babel-plugin-problem

Problem description:

When using a `babel.config.js` file the above error occurs, however works fine if you change it to a `.babelrc` file. Also when you remove the typescript preset it works fine.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dai file segnalati index.js e babel.config.js, quindi usa il repository di riproduzione collegato per confrontare il comando babel che non funziona con il file .babelrc funzionante e i casi senza preset TypeScript. Il lavoro è completato quando il comando funziona con babel.config.js e @babel/preset-typescript senza l’errore di nome file segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
babel, typescript
Ambito
build-system
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.