1
- use std:: { collections :: HashMap , ffi:: OsStr , path:: Path } ;
1
+ use std:: { ffi:: OsStr , path:: Path } ;
2
2
3
+ use indexmap:: IndexMap ;
3
4
use swc_core:: {
4
5
common:: { sync:: Lrc , Mark , SourceMap , SyntaxContext , DUMMY_SP } ,
5
6
ecma:: {
@@ -24,7 +25,7 @@ use crate::{
24
25
pub struct NodeReplacer < ' a > {
25
26
pub source_map : Lrc < SourceMap > ,
26
27
pub global_mark : Mark ,
27
- pub globals : HashMap < JsWord , ( SyntaxContext , ast:: Stmt ) > ,
28
+ pub globals : IndexMap < JsWord , ( SyntaxContext , ast:: Stmt ) > ,
28
29
pub filename : & ' a Path ,
29
30
pub is_esm : bool ,
30
31
pub unresolved_mark : Mark ,
@@ -186,7 +187,7 @@ impl<'a> VisitMut for NodeReplacer<'a> {
186
187
0 ..0 ,
187
188
self
188
189
. globals
189
- . drain ( )
190
+ . drain ( .. )
190
191
. map ( |( _, ( _, stmt) ) | ast:: ModuleItem :: Stmt ( stmt) ) ,
191
192
) ;
192
193
}
@@ -268,7 +269,7 @@ console.log(__filename);
268
269
let output_code = run_visit ( code, |context| NodeReplacer {
269
270
source_map : context. source_map . clone ( ) ,
270
271
global_mark : context. global_mark ,
271
- globals : HashMap :: new ( ) ,
272
+ globals : IndexMap :: new ( ) ,
272
273
filename : Path :: new ( "/path/random.js" ) ,
273
274
has_node_replacements : & mut has_node_replacements,
274
275
items : & mut items,
@@ -303,7 +304,7 @@ console.log(__dirname);
303
304
let output_code = run_visit ( code, |context| NodeReplacer {
304
305
source_map : context. source_map . clone ( ) ,
305
306
global_mark : context. global_mark ,
306
- globals : HashMap :: new ( ) ,
307
+ globals : IndexMap :: new ( ) ,
307
308
filename : Path :: new ( "/path/random.js" ) ,
308
309
has_node_replacements : & mut has_node_replacements,
309
310
items : & mut items,
@@ -341,7 +342,7 @@ function something(__filename, __dirname) {
341
342
let output_code = run_visit ( code, |context| NodeReplacer {
342
343
source_map : context. source_map . clone ( ) ,
343
344
global_mark : context. global_mark ,
344
- globals : HashMap :: new ( ) ,
345
+ globals : IndexMap :: new ( ) ,
345
346
filename : Path :: new ( "/path/random.js" ) ,
346
347
has_node_replacements : & mut has_node_replacements,
347
348
items : & mut items,
@@ -374,7 +375,7 @@ const filename = obj.__filename;
374
375
let output_code = run_visit ( code, |context| NodeReplacer {
375
376
source_map : context. source_map . clone ( ) ,
376
377
global_mark : context. global_mark ,
377
- globals : HashMap :: new ( ) ,
378
+ globals : IndexMap :: new ( ) ,
378
379
filename : Path :: new ( "/path/random.js" ) ,
379
380
has_node_replacements : & mut has_node_replacements,
380
381
items : & mut items,
@@ -403,7 +404,7 @@ const filename = obj[__filename];
403
404
let output_code = run_visit ( code, |context| NodeReplacer {
404
405
source_map : context. source_map . clone ( ) ,
405
406
global_mark : context. global_mark ,
406
- globals : HashMap :: new ( ) ,
407
+ globals : IndexMap :: new ( ) ,
407
408
filename : Path :: new ( "/path/random.js" ) ,
408
409
has_node_replacements : & mut has_node_replacements,
409
410
items : & mut items,
@@ -434,7 +435,7 @@ console.log(__dirname);
434
435
let output_code = run_visit ( code, |context| NodeReplacer {
435
436
source_map : context. source_map . clone ( ) ,
436
437
global_mark : context. global_mark ,
437
- globals : HashMap :: new ( ) ,
438
+ globals : IndexMap :: new ( ) ,
438
439
filename : Path :: new ( "/path/random.js" ) ,
439
440
has_node_replacements : & mut has_node_replacements,
440
441
items : & mut items,
0 commit comments