Skip to content

Commit

Permalink
Sort global deps before injecting imports (#8818)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcompiles authored Feb 7, 2023
1 parent 9f673b0 commit adb01fe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/transformers/js/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ sha-1 = "0.10.0"
dunce = "1.0.1"
pathdiff = "0.2.0"
path-slash = "0.1.4"
indexmap = "1.9.2"
5 changes: 3 additions & 2 deletions packages/transformers/js/core/src/global_replacer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use indexmap::IndexMap;
use path_slash::PathBufExt;
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::path::Path;

use swc_atoms::JsWord;
Expand All @@ -14,7 +15,7 @@ pub struct GlobalReplacer<'a> {
pub source_map: &'a SourceMap,
pub items: &'a mut Vec<DependencyDescriptor>,
pub global_mark: Mark,
pub globals: HashMap<JsWord, (SyntaxContext, ast::Stmt)>,
pub globals: IndexMap<JsWord, (SyntaxContext, ast::Stmt)>,
pub project_root: &'a Path,
pub filename: &'a Path,
pub decls: &'a mut HashSet<Id>,
Expand Down
3 changes: 2 additions & 1 deletion packages/transformers/js/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::str::FromStr;

use indexmap::IndexMap;
use path_slash::PathExt;
use serde::{Deserialize, Serialize};
use swc_common::comments::SingleThreadedComments;
Expand Down Expand Up @@ -369,7 +370,7 @@ pub fn transform(config: Config) -> Result<TransformResult, std::io::Error> {
source_map: &source_map,
items: &mut global_deps,
global_mark,
globals: HashMap::new(),
globals: IndexMap::new(),
project_root: Path::new(&config.project_root),
filename: Path::new(&config.filename),
decls: &mut decls,
Expand Down

0 comments on commit adb01fe

Please sign in to comment.