Skip to content

Commit f41a3e1

Browse files
committed
refactor(es/scope): rename exports_vars
1 parent ece8f3e commit f41a3e1

File tree

4 files changed

+45
-33
lines changed

4 files changed

+45
-33
lines changed

ecmascript/transforms/module/src/amd.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ where
220220

221221
for ident in found.drain(..) {
222222
scope
223-
.exported_vars
223+
.exported_bindings
224224
.entry((ident.sym.clone(), ident.span.ctxt()))
225225
.or_default()
226226
.push((ident.sym.clone(), ident.span.ctxt()));
@@ -361,14 +361,18 @@ where
361361

362362
let key = (orig.sym.clone(), orig.span.ctxt());
363363
if scope.declared_vars.contains(&key) {
364-
scope.exported_vars.entry(key.clone()).or_default().push(
365-
exported
366-
.clone()
367-
.map(|i| (i.sym.clone(), i.span.ctxt()))
368-
.unwrap_or_else(|| {
369-
(orig.sym.clone(), orig.span.ctxt())
370-
}),
371-
);
364+
scope
365+
.exported_bindings
366+
.entry(key.clone())
367+
.or_default()
368+
.push(
369+
exported
370+
.clone()
371+
.map(|i| (i.sym.clone(), i.span.ctxt()))
372+
.unwrap_or_else(|| {
373+
(orig.sym.clone(), orig.span.ctxt())
374+
}),
375+
);
372376
}
373377

374378
if let Some(ref src) = export.src {

ecmascript/transforms/module/src/common_js.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189
if !is_class {
190190
let mut scope = self.scope.borrow_mut();
191191
scope
192-
.exported_vars
192+
.exported_bindings
193193
.entry((ident.sym.clone(), ident.span.ctxt()))
194194
.or_default()
195195
.push((ident.sym.clone(), ident.span.ctxt()));
@@ -240,7 +240,7 @@ where
240240

241241
for ident in found.drain(..) {
242242
scope
243-
.exported_vars
243+
.exported_bindings
244244
.entry((ident.sym.clone(), ident.span.ctxt()))
245245
.or_default()
246246
.push((ident.sym.clone(), ident.span.ctxt()));
@@ -389,14 +389,18 @@ where
389389

390390
let key = orig.to_id();
391391
if scope.declared_vars.contains(&key) {
392-
scope.exported_vars.entry(key.clone()).or_default().push(
393-
exported
394-
.clone()
395-
.map(|i| (i.sym.clone(), i.span.ctxt()))
396-
.unwrap_or_else(|| {
397-
(orig.sym.clone(), orig.span.ctxt())
398-
}),
399-
);
392+
scope
393+
.exported_bindings
394+
.entry(key.clone())
395+
.or_default()
396+
.push(
397+
exported
398+
.clone()
399+
.map(|i| (i.sym.clone(), i.span.ctxt()))
400+
.unwrap_or_else(|| {
401+
(orig.sym.clone(), orig.span.ctxt())
402+
}),
403+
);
400404
}
401405

402406
if let Some(ref src) = export.src {

ecmascript/transforms/module/src/umd.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ where
230230

231231
for ident in found.drain(..) {
232232
scope
233-
.exported_vars
233+
.exported_bindings
234234
.entry((ident.sym.clone(), ident.span.ctxt()))
235235
.or_default()
236236
.push((ident.sym.clone(), ident.span.ctxt()));
@@ -365,14 +365,18 @@ where
365365
let mut scope_ref_mut = self.scope.borrow_mut();
366366
let scope = &mut *scope_ref_mut;
367367
if scope.declared_vars.contains(&key) {
368-
scope.exported_vars.entry(key.clone()).or_default().push(
369-
exported
370-
.clone()
371-
.map(|i| (i.sym.clone(), i.span.ctxt()))
372-
.unwrap_or_else(|| {
373-
(orig.sym.clone(), orig.span.ctxt())
374-
}),
375-
);
368+
scope
369+
.exported_bindings
370+
.entry(key.clone())
371+
.or_default()
372+
.push(
373+
exported
374+
.clone()
375+
.map(|i| (i.sym.clone(), i.span.ctxt()))
376+
.unwrap_or_else(|| {
377+
(orig.sym.clone(), orig.span.ctxt())
378+
}),
379+
);
376380
}
377381

378382
if let Some(ref src) = export.src {

ecmascript/transforms/module/src/util.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub struct Scope {
121121
/// Declared variables except const.
122122
pub(crate) declared_vars: Vec<Id>,
123123

124-
/// Maps of exported variables.
124+
/// Maps of exported bindings.
125125
///
126126
///
127127
/// e.g.
@@ -130,7 +130,7 @@ pub struct Scope {
130130
///
131131
/// - `export { a as b }`
132132
/// -> `{ a: [b] }`
133-
pub(crate) exported_vars: AHashMap<Id, Vec<Id>>,
133+
pub(crate) exported_bindings: AHashMap<Id, Vec<Id>>,
134134

135135
/// This is required to handle
136136
/// `export * from 'foo';`
@@ -604,7 +604,7 @@ impl Scope {
604604
let arg = arg.ident().unwrap();
605605
let mut scope = folder.scope_mut();
606606
let entry = scope
607-
.exported_vars
607+
.exported_bindings
608608
.entry((arg.sym.clone(), arg.span.ctxt()));
609609

610610
match entry {
@@ -744,7 +744,7 @@ impl Scope {
744744
let i = pat.ident().unwrap();
745745
let mut scope = folder.scope_mut();
746746
let entry = scope
747-
.exported_vars
747+
.exported_bindings
748748
.entry((i.id.sym.clone(), i.id.span.ctxt()));
749749

750750
match entry {
@@ -772,7 +772,7 @@ impl Scope {
772772
.filter_map(|i| {
773773
let mut scope = folder.scope_mut();
774774
let entry = match scope
775-
.exported_vars
775+
.exported_bindings
776776
.entry((i.sym.clone(), i.span.ctxt()))
777777
{
778778
Entry::Occupied(entry) => entry,

0 commit comments

Comments
 (0)