@@ -159,21 +159,21 @@ createSymbol = function (node, globals, value, scope) {
159
159
} ;
160
160
161
161
// Creates variables from variable definitions
162
- const initVariables = function ( node , globals ) {
162
+ const initVariables = function ( node , globals , opts ) {
163
163
switch ( node . type ) {
164
164
case 'Program' : {
165
165
node . body . forEach ( ( childNode ) => {
166
- initVariables ( childNode , globals ) ;
166
+ initVariables ( childNode , globals , opts ) ;
167
167
} ) ;
168
168
break ;
169
169
} case 'ExpressionStatement' : {
170
- initVariables ( node . expression , globals ) ;
170
+ initVariables ( node . expression , globals , opts ) ;
171
171
break ;
172
172
} case 'VariableDeclaration' : {
173
173
node . declarations . forEach ( ( declaration ) => {
174
174
// let and const
175
175
const symbol = createSymbol ( declaration . id , globals , null , globals ) ;
176
- if ( node . kind === 'var' && globals . props . window ) {
176
+ if ( opts . initWindow && node . kind === 'var' && globals . props . window ) {
177
177
// If var, also add to window
178
178
globals . props . window . props [ declaration . id . name ] = symbol ;
179
179
}
@@ -315,7 +315,7 @@ const parse = function (ast, opt) {
315
315
if ( opts . initWindow ) {
316
316
globalVars . props . window = globalVars ;
317
317
}
318
- initVariables ( ast , globalVars ) ;
318
+ initVariables ( ast , globalVars , opts ) ;
319
319
mapVariables ( ast , globalVars ) ;
320
320
321
321
return {
0 commit comments