File tree 6 files changed +38
-4
lines changed
core/integration-tests/test
integration/scope-hoisting/es6
named-export-variable-rename
named-export-variable-rename-wrapped
6 files changed +38
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { foo } from './b' ;
2
+
3
+ output = foo ;
Original file line number Diff line number Diff line change
1
+ var bar = module && 2 ;
2
+ export { bar as foo } ;
Original file line number Diff line number Diff line change
1
+ import { foo } from './b' ;
2
+
3
+ output = foo ;
Original file line number Diff line number Diff line change
1
+ var bar = 2 ;
2
+ export { bar as foo } ;
Original file line number Diff line number Diff line change @@ -123,6 +123,29 @@ describe('scope hoisting', function() {
123
123
assert . equal ( output , 2 ) ;
124
124
} ) ;
125
125
126
+ it ( 'supports named exports of variables with a different name' , async function ( ) {
127
+ let b = await bundle (
128
+ path . join (
129
+ __dirname ,
130
+ '/integration/scope-hoisting/es6/named-export-variable-rename/a.js' ,
131
+ ) ,
132
+ ) ;
133
+
134
+ let output = await run ( b ) ;
135
+ assert . equal ( output , 2 ) ;
136
+ } ) ;
137
+ it ( 'supports named exports of variables with a different name when wrapped' , async function ( ) {
138
+ let b = await bundle (
139
+ path . join (
140
+ __dirname ,
141
+ '/integration/scope-hoisting/es6/named-export-variable-rename-wrapped/a.js' ,
142
+ ) ,
143
+ ) ;
144
+
145
+ let output = await run ( b ) ;
146
+ assert . equal ( output , 2 ) ;
147
+ } ) ;
148
+
126
149
it ( 'supports renaming non-ASCII identifiers' , async function ( ) {
127
150
let b = await bundle (
128
151
path . join (
Original file line number Diff line number Diff line change @@ -268,14 +268,15 @@ impl<'a> Fold for Hoist<'a> {
268
268
// A variable will appear only once in the `exports` mapping but
269
269
// could be exported multiple times with different names.
270
270
// Find the original exported name, and remap.
271
- let orig_exported = self . collect . exports . get ( & id) . unwrap ( ) ;
272
271
let id = if self . collect . should_wrap {
273
- Ident :: new ( orig_exported . clone ( ) , DUMMY_SP )
272
+ id . 0
274
273
} else {
275
- self . get_export_ident ( DUMMY_SP , orig_exported)
274
+ self
275
+ . get_export_ident ( DUMMY_SP , self . collect . exports . get ( & id) . unwrap ( ) )
276
+ . sym
276
277
} ;
277
278
self . exported_symbols . push ( ExportedSymbol {
278
- local : id. sym ,
279
+ local : id,
279
280
exported,
280
281
loc : SourceLocation :: from ( & self . collect . source_map , named. span ) ,
281
282
} ) ;
You can’t perform that action at this time.
0 commit comments