@@ -1323,6 +1323,8 @@ exports.ModuleIdentifier = class ModuleIdentifier extends Base
1323
1323
children : [' original' , ' alias' ]
1324
1324
1325
1325
compileNode : (o ) ->
1326
+ variableName = @alias .value or @original .value
1327
+ o .scope .add variableName, ' import'
1326
1328
code = []
1327
1329
code .push @ makeCode @original .value
1328
1330
code .push @ makeCode " as #{ @alias .value } " if @alias ?
@@ -1368,20 +1370,18 @@ exports.Assign = class Assign extends Base
1368
1370
@value .klass = new Value @variable .base , properties
1369
1371
@value .name = name
1370
1372
@value .variable = @variable
1371
- unless @context
1373
+ if ( not @context ) or @context in [ ' import ' , ' export ' ]
1372
1374
varBase = @variable .unwrapAll ()
1373
1375
unless varBase .isAssignable ()
1374
1376
@variable .error " '#{ @variable .compile o} ' can't be assigned"
1375
1377
unless varBase .hasProperties ? ()
1376
- insideModuleStatement = no
1377
- for expression in o .scope .expressions .expressions
1378
- if expression instanceof Import or expression instanceof Export or expression instanceof ExportImport # But *not* ExportDefault
1379
- insideModuleStatement = yes
1380
- unless insideModuleStatement
1381
- if @param
1382
- o .scope .add varBase .value , ' var'
1383
- else
1384
- o .scope .find varBase .value
1378
+ if @context in [' import' , ' export' ]
1379
+ o .scope .add varBase .value , @context
1380
+ else if @param
1381
+ o .scope .add varBase .value , ' var'
1382
+ else
1383
+ o .scope .find varBase .value
1384
+
1385
1385
val = @value .compileToFragments o, LEVEL_LIST
1386
1386
@variable .front = true if isValue and @variable .base instanceof Obj
1387
1387
compiledName = @variable .compileToFragments o, LEVEL_LIST
@@ -1392,7 +1392,7 @@ exports.Assign = class Assign extends Base
1392
1392
compiledName .push @ makeCode ' "'
1393
1393
return compiledName .concat @ makeCode (" : " ), val
1394
1394
1395
- answer = compiledName .concat @ makeCode (" #{ @context or ' =' } " ), val
1395
+ answer = compiledName .concat @ makeCode (" #{ if @context and @context isnt ' export ' then @context else ' =' } " ), val
1396
1396
if o .level <= LEVEL_LIST then answer else @ wrapInBraces answer
1397
1397
1398
1398
# Brief implementation of recursive pattern matching, when assigning array or
0 commit comments