Skip to content

Commit

Permalink
refactor(es/dep-graph): Remove SourceMap dependency (#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jul 13, 2021
1 parent d13eff9 commit 6dc6d8a
Show file tree
Hide file tree
Showing 32 changed files with 347 additions and 353 deletions.
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.28.1"
version = "0.29.0"

[lib]
name = "swc"
Expand All @@ -31,30 +31,30 @@ serde = {version = "1", features = ["derive"]}
serde_json = "1"
sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_bundler = {version = "0.45.0", path = "./bundler"}
swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.48.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.61.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.20.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.10.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_parser = {version = "0.62.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.28.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.58.0", path = "./ecmascript/transforms", features = [
swc_bundler = {version = "0.46.0", path = "./bundler"}
swc_common = {version = "0.11.0", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.49.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.62.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.21.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.11.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_parser = {version = "0.63.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.29.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.59.0", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_utils = {version = "0.39.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.34.0", path = "./ecmascript/visit"}
swc_node_base = {version = "0.1.0", path = "./node/base"}
swc_ecma_utils = {version = "0.40.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.35.0", path = "./ecmascript/visit"}
swc_node_base = {version = "0.2.0", path = "./node/base"}
swc_visit = {version = "0.2.3", path = "./visit"}

[dev-dependencies]
rayon = "1"
testing = {version = "0.10.5", path = "./testing"}
testing = {version = "0.11.0", path = "./testing"}
walkdir = "2"

[[example]]
Expand Down
22 changes: 11 additions & 11 deletions bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.45.0"
version = "0.46.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand All @@ -32,22 +32,22 @@ rayon = {version = "1", optional = true}
relative-path = "1.2"
retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.10.16", path = "../common"}
swc_ecma_ast = {version = "0.48.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.61.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.10.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.62.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.58.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.39.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.34.0", path = "../ecmascript/visit"}
swc_common = {version = "0.11.0", path = "../common"}
swc_ecma_ast = {version = "0.49.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.62.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.11.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.63.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.59.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.40.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.35.0", path = "../ecmascript/visit"}

[dev-dependencies]
hex = "0.4"
ntest = "0.7.2"
reqwest = {version = "0.10.8", features = ["blocking"]}
sha-1 = "0.9"
swc_ecma_transforms = {version = "0.58.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.59.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.10.5", path = "../testing"}
testing = {version = "0.11.0", path = "../testing"}
url = "2.1.1"
walkdir = "2"
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_common"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.23"
version = "0.11.0"

[features]
concurrent = ["parking_lot"]
Expand Down
55 changes: 33 additions & 22 deletions common/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,16 @@ pub trait Comments {
fn has_leading(&self, pos: BytePos) -> bool;
fn move_leading(&self, from: BytePos, to: BytePos);
fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>;
fn get_leading(&self, pos: BytePos) -> Option<Vec<Comment>>;

fn add_trailing(&self, pos: BytePos, cmt: Comment);
fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>);
fn has_trailing(&self, pos: BytePos) -> bool;
fn move_trailing(&self, from: BytePos, to: BytePos);
fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>;
fn get_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>;

fn add_pure_comment(&self, pos: BytePos) {
let mut leading = self.take_leading(pos);
let pure_comment = Comment {
kind: CommentKind::Block,
span: DUMMY_SP,
text: "#__PURE__".into(),
};

match &mut leading {
Some(comments) => {
if !comments.iter().any(|c| c.text == pure_comment.text) {
comments.push(pure_comment);
}
}
None => {
leading = Some(vec![pure_comment]);
}
}
if let Some(leading) = leading {
self.add_leading_comments(pos, leading);
}
}
fn add_pure_comment(&self, pos: BytePos);
}

macro_rules! delegate {
Expand All @@ -84,6 +65,10 @@ macro_rules! delegate {
(**self).take_leading(pos)
}

fn get_leading(&self, pos: BytePos) -> Option<Vec<Comment>> {
(**self).get_leading(pos)
}

fn add_trailing(&self, pos: BytePos, cmt: Comment) {
(**self).add_trailing(pos, cmt)
}
Expand All @@ -104,6 +89,10 @@ macro_rules! delegate {
(**self).take_trailing(pos)
}

fn get_trailing(&self, pos: BytePos) -> Option<Vec<Comment>> {
(**self).get_trailing(pos)
}

fn add_pure_comment(&self, pos: BytePos) {
(**self).add_pure_comment(pos)
}
Expand Down Expand Up @@ -181,6 +170,10 @@ impl Comments for SingleThreadedComments {
self.leading.borrow_mut().remove(&pos)
}

fn get_leading(&self, pos: BytePos) -> Option<Vec<Comment>> {
self.leading.borrow().get(&pos).map(|c| c.to_owned())
}

fn add_trailing(&self, pos: BytePos, cmt: Comment) {
self.trailing.borrow_mut().entry(pos).or_default().push(cmt);
}
Expand Down Expand Up @@ -216,6 +209,24 @@ impl Comments for SingleThreadedComments {
fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>> {
self.trailing.borrow_mut().remove(&pos)
}

fn get_trailing(&self, pos: BytePos) -> Option<Vec<Comment>> {
self.trailing.borrow().get(&pos).map(|c| c.to_owned())
}

fn add_pure_comment(&self, pos: BytePos) {
let mut leading_map = self.leading.borrow_mut();
let leading = leading_map.entry(pos).or_default();
let pure_comment = Comment {
kind: CommentKind::Block,
span: DUMMY_SP,
text: "#__PURE__".into(),
};

if !leading.iter().any(|c| c.text == pure_comment.text) {
leading.push(pure_comment);
}
}
}

impl SingleThreadedComments {
Expand Down
18 changes: 9 additions & 9 deletions ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.45.0"
version = "0.46.0"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -28,13 +28,13 @@ react = ["swc_ecma_transforms/react"]
typescript = ["swc_ecma_transforms/typescript"]

[dependencies]
swc_ecma_ast = {version = "0.48.0", path = "./ast"}
swc_ecma_codegen = {version = "0.61.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.30.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.11.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.62.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.58.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.39.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.34.0", path = "./visit", optional = true}
swc_ecma_ast = {version = "0.49.0", path = "./ast"}
swc_ecma_codegen = {version = "0.62.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.31.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.12.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.63.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.59.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.40.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.35.0", path = "./visit", optional = true}

[dev-dependencies]
4 changes: 2 additions & 2 deletions ecmascript/ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ast"
repository = "https://github.com/swc-project/swc.git"
version = "0.48.1"
version = "0.49.0"

[features]
default = []
Expand All @@ -19,7 +19,7 @@ num-bigint = {version = "0.2", features = ["serde"]}
serde = {version = "1.0.88", features = ["derive"]}
string_enum = {version = "0.3.1", path = "../../macros/string_enum"}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_common = {version = "0.11.0", path = "../../common"}

[dev-dependencies]
serde_json = "1"
12 changes: 6 additions & 6 deletions ecmascript/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.61.1"
version = "0.62.0"

[dependencies]
bitflags = "1"
num-bigint = {version = "0.2", features = ["serde"]}
sourcemap = "6"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.21", path = "../../common"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_common = {version = "0.11.0", path = "../../common"}
swc_ecma_ast = {version = "0.49.0", path = "../ast"}
swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
swc_ecma_parser = {version = "0.63.0", path = "../parser"}

[dev-dependencies]
swc_common = {version = "0.10.16", path = "../../common", features = ["sourcemap"]}
testing = {version = "0.10.5", path = "../../testing"}
swc_common = {version = "0.11.0", path = "../../common", features = ["sourcemap"]}
testing = {version = "0.11.0", path = "../../testing"}
12 changes: 6 additions & 6 deletions ecmascript/dep-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_dep_graph"
repository = "https://github.com/swc-project/swc.git"
version = "0.30.0"
version = "0.31.0"

[dependencies]
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}
swc_common = {version = "0.11.0", path = "../../common"}
swc_ecma_ast = {version = "0.49.0", path = "../ast"}
swc_ecma_visit = {version = "0.35.0", path = "../visit"}

[dev-dependencies]
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
swc_ecma_parser = {version = "0.63.0", path = "../parser"}
testing = {version = "0.11.0", path = "../../testing"}

0 comments on commit 6dc6d8a

Please sign in to comment.