Skip to content

Commit

Permalink
Merge 67d98c2 into 10799c6
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Sep 18, 2023
2 parents 10799c6 + 67d98c2 commit 133e879
Show file tree
Hide file tree
Showing 64 changed files with 407 additions and 568 deletions.
63 changes: 44 additions & 19 deletions Cargo.lock

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

14 changes: 10 additions & 4 deletions crates/turbopack-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_qs = { workspace = true }
sourcemap = { workspace = true }
swc_core = { workspace = true, features = [
"__parser",
"ecma_minifier",
"ecma_minifier_concurrent",
swc = "0.266.0"
swc_atoms = "0.5.9"
swc_common = "0.32.1"
swc_ecma_ast = "0.109.1"
swc_ecma_codegen = "0.145.0"
swc_ecma_minifier = "0.187.0"
swc_ecma_parser = "0.140.0"
swc_ecma_transforms_base = { version = "0.133.0", features = [
"concurrent-renamer",
] }
swc_ecma_visit = "0.95.1"

turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true }
Expand Down
46 changes: 20 additions & 26 deletions crates/turbopack-build/src/ecmascript/minify.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
use std::{io::Write, sync::Arc};

use anyhow::{bail, Context, Result};
use swc_core::{
base::{try_with_handler, Compiler},
common::{
comments::{Comments, SingleThreadedComments},
BytePos, FileName, FilePathMapping, LineCol, Mark, SourceMap as SwcSourceMap, GLOBALS,
},
ecma::{
self,
ast::{EsVersion, Program},
codegen::{
text_writer::{self, JsWriter, WriteJs},
Emitter, Node,
},
minifier::option::{ExtraOptions, MinifyOptions},
parser::{lexer::Lexer, Parser, StringInput, Syntax},
visit::FoldWith,
},
use swc::{try_with_handler, Compiler};
use swc_common::{
comments::{Comments, SingleThreadedComments},
BytePos, FileName, FilePathMapping, LineCol, Mark, SourceMap as SwcSourceMap, GLOBALS,
};
use swc_ecma_ast::{EsVersion, Program};
use swc_ecma_codegen::{
text_writer::{self, JsWriter, WriteJs},
Emitter, Node,
};
use swc_ecma_minifier::option::{ExtraOptions, MinifyOptions};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
use swc_ecma_visit::FoldWith;
use turbo_tasks::Vc;
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{
Expand Down Expand Up @@ -77,14 +72,13 @@ async fn perform_minify(path: Vc<FileSystemPath>, code_vc: Vc<Code>) -> Result<V
let top_level_mark = Mark::new();

Ok(compiler.run_transform(handler, false, || {
let mut program =
program.fold_with(&mut swc_core::ecma::transforms::base::resolver(
unresolved_mark,
top_level_mark,
false,
));
let mut program = program.fold_with(&mut swc_ecma_transforms_base::resolver(
unresolved_mark,
top_level_mark,
false,
));

program = swc_core::ecma::minifier::optimize(
program = swc_ecma_minifier::optimize(
program,
cm.clone(),
Some(&comments),
Expand All @@ -100,7 +94,7 @@ async fn perform_minify(path: Vc<FileSystemPath>, code_vc: Vc<Code>) -> Result<V
},
);

program.fold_with(&mut ecma::transforms::base::fixer::fixer(Some(
program.fold_with(&mut swc_ecma_transforms_base::fixer::fixer(Some(
&comments as &dyn Comments,
)))
}))
Expand Down Expand Up @@ -138,7 +132,7 @@ fn print_program(
)))) as Box<dyn WriteJs>;

let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config::default().with_minify(true),
cfg: swc_ecma_codegen::Config::default().with_minify(true),
comments: None,
cm: cm.clone(),
wr,
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serde = { workspace = true, features = ["rc"] }
serde_json = { workspace = true, features = ["preserve_order"] }
serde_qs = { workspace = true }
sourcemap = { workspace = true }
swc_core = { workspace = true, features = ["ecma_preset_env", "common"] }
swc_ecma_preset_env = "0.201.0"
tracing = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-env = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use anyhow::{anyhow, bail, Context, Result};
use serde::{Deserialize, Serialize};
use swc_core::ecma::preset_env::{Version, Versions};
use swc_ecma_preset_env::{Version, Versions};
use turbo_tasks::{Value, Vc};
use turbo_tasks_env::ProcessEnv;

Expand Down
23 changes: 8 additions & 15 deletions crates/turbopack-css/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,20 @@ indoc = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
swc_atoms = "0.5.9"
swc_common = "0.32.1"
swc_css_ast = { version = "0.139.1", features = ["serde", "serde-impl"] }
swc_css_codegen = "0.149.1"
swc_css_compat = "0.25.1"
swc_css_modules = "0.27.1"
swc_css_parser = "0.148.1"
swc_css_visit = { version = "0.138.1", features = ["path"] }
turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true }
turbo-tasks-hash = { workspace = true }
turbopack-core = { workspace = true }
turbopack-ecmascript = { workspace = true }
turbopack-swc-utils = { workspace = true }

swc_core = { workspace = true, features = [
"ecma_ast",
"css_ast",
"css_ast_serde",
"css_codegen",
"css_parser",
"css_utils",
"css_visit",
"css_visit_path",
"css_compat",
"css_modules",
"common",
"common_concurrent",
] }

[build-dependencies]
turbo-tasks-build = { workspace = true }
12 changes: 4 additions & 8 deletions crates/turbopack-css/src/asset.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use anyhow::Result;
use swc_core::{
common::{Globals, GLOBALS},
css::{
ast::{AtRule, AtRulePrelude, Rule},
codegen::{writer::basic::BasicCssWriter, CodeGenerator, Emit},
visit::{VisitMutWith, VisitMutWithPath},
},
};
use swc_common::{Globals, GLOBALS};
use swc_css_ast::{AtRule, AtRulePrelude, Rule};
use swc_css_codegen::{writer::basic::BasicCssWriter, CodeGenerator, Emit};
use swc_css_visit::{VisitMutWith, VisitMutWithPath};
use turbo_tasks::{TryJoinIterExt, Value, ValueToString, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{
Expand Down
Loading

0 comments on commit 133e879

Please sign in to comment.