@@ -6,7 +6,6 @@ const normalizeOptions = require('./utils/normalize-options').normalizeOptions;
6
6
7
7
function macros ( babel ) {
8
8
let t = babel . types ;
9
- let options ;
10
9
11
10
function buildIdentifier ( value , name ) {
12
11
let replacement = t . booleanLiteral ( value ) ;
@@ -27,9 +26,9 @@ function macros(babel) {
27
26
return {
28
27
name : 'babel-feature-flags-and-debug-macros' ,
29
28
visitor : {
30
- ImportSpecifier ( path ) {
29
+ ImportSpecifier ( path , state ) {
31
30
let importPath = path . parent . source . value ;
32
- let flagsForImport = options . flags [ importPath ] ;
31
+ let flagsForImport = state . opts . flags [ importPath ] ;
33
32
34
33
if ( flagsForImport ) {
35
34
let flagName = path . node . imported . name ;
@@ -58,9 +57,9 @@ function macros(babel) {
58
57
} ,
59
58
60
59
ImportDeclaration : {
61
- exit ( path ) {
60
+ exit ( path , state ) {
62
61
let importPath = path . node . source . value ;
63
- let flagsForImport = options . flags [ importPath ] ;
62
+ let flagsForImport = state . opts . flags [ importPath ] ;
64
63
65
64
// remove flag source imports when no specifiers are left
66
65
if ( flagsForImport && path . get ( 'specifiers' ) . length === 0 ) {
@@ -71,16 +70,16 @@ function macros(babel) {
71
70
72
71
Program : {
73
72
enter ( path , state ) {
74
- options = normalizeOptions ( state . opts ) ;
75
- this . macroBuilder = new Macros ( babel , options ) ;
73
+ state . opts = normalizeOptions ( state . opts ) ;
74
+ this . macroBuilder = new Macros ( babel , state . opts ) ;
76
75
77
76
let body = path . get ( 'body' ) ;
78
77
79
78
body . forEach ( item => {
80
79
if ( item . isImportDeclaration ( ) ) {
81
80
let importPath = item . node . source . value ;
82
81
83
- let debugToolsImport = options . debugTools . debugToolsImport ;
82
+ let debugToolsImport = state . opts . debugTools . debugToolsImport ;
84
83
85
84
if ( debugToolsImport && debugToolsImport === importPath ) {
86
85
if ( ! item . node . specifiers . length ) {
0 commit comments