2015-09-12 4 views
8

Come faccio a forzare babel NOT a guardare la directory principale per .babelrc?Disabilitare l'ereditarietà .babelrc

  • ho due .babelrc file: ./a/.babelrc e ./a/example/.babelrc.
  • Sono in esecuzione babel nel percorso ./a/example.
  • ./a/.babelrc definisce un plugin “lodash"
  • Non voglio usare questo plugin durante l'esecuzione babel in ./a/example

Ho provato a fissare ./a/example/.babelrc a:.

{ 
    "stage": 0, 
    "plugins": [] 
} 

Tuttavia, l'esecuzione babel nel percorso ./a/example utilizza ancora il plug-in "lodash"

$ pwd 
/a/example 
$ cat ./.babelrc 
{ 
    "stage": 0, 
    "plugins": [] 
} 
$ cat ./../.babelrc 
{ 
    "stage": 0, 
    "plugins": [ 
     "lodash" 
    ] 
} 
$ babel ./src/ 
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash' 
    [..] 
$ babel --babelrc ./.babelrc ./src/ 
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash' 
    [..] 

risposta

12

C'è una proprietà non documentata denominata breakConfig. Impostare breakConfig su true per disabilitare l'ereditarietà di configurazione.

Questo comportamento cambierà in 6.x. In 6.x Babel si romperà sul primo .babelrc che trova. La proprietà extends verrà utilizzata per denominare esplicitamente altri file .babelrc da cui ereditare.

+0

Esiste un problema che fa riferimento a tali modifiche per v6 @Gajus? – JMM

+0

@ JMM, no. Ho imparato a conoscerlo dalla chat con l'autore. – Gajus

+0

. @ Gajus OK grazie, questo è quello che ho capito :) Questo dovrebbe essere nel problema 6.0 però. – JMM