Unverified Commit 8659d6f8 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Revert "chore: Update swc" (#41015)

It seems we may have regressed on perf in the WASM build as we are
seeing build timeouts in our tests

x-ref:
https://github.com/vercel/next.js/actions/runs/3148769274/jobs/5119807405
x-ref:
https://github.com/vercel/next.js/actions/runs/3148820726/jobs/5119928862

Reverts vercel/next.js#40983
parent 3d4dde8f
[build] [build]
rustdocflags = []
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.aarch64-apple-darwin]
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.aarch64-unknown-linux-gnu] [target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc" linker = "aarch64-linux-gnu-gcc"
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.aarch64-unknown-linux-musl] [target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc" linker = "aarch64-linux-musl-gcc"
...@@ -11,7 +27,31 @@ rustflags = [ ...@@ -11,7 +27,31 @@ rustflags = [
"target-feature=-crt-static", "target-feature=-crt-static",
"-C", "-C",
"link-arg=-lgcc", "link-arg=-lgcc",
"-Z",
"new-llvm-pass-manager=no",
] ]
[target.armv7-unknown-linux-gnueabihf] [target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc" linker = "arm-linux-gnueabihf-gcc"
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.aarch64-linux-android]
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.aarch64-pc-windows-msvc]
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
[target.wasm32-unknown-unknown]
rustflags = [
"-Z",
"new-llvm-pass-manager=no",
]
\ No newline at end of file
This diff is collapsed.
...@@ -28,7 +28,7 @@ styled_jsx = {path="../styled_jsx"} ...@@ -28,7 +28,7 @@ styled_jsx = {path="../styled_jsx"}
modularize_imports = {path="../modularize_imports"} modularize_imports = {path="../modularize_imports"}
tracing = { version = "0.1.32", features = ["release_max_level_info"] } tracing = { version = "0.1.32", features = ["release_max_level_info"] }
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"common_concurrent", "common_concurrent",
"ecma_ast", "ecma_ast",
"ecma_visit", "ecma_visit",
...@@ -48,6 +48,6 @@ swc_core = { version = "0.28.4", features = [ ...@@ -48,6 +48,6 @@ swc_core = { version = "0.28.4", features = [
] } ] }
[dev-dependencies] [dev-dependencies]
swc_core = { version = "0.28.4", features = ["testing_transform"] } swc_core = { version = "0.27.4", features = ["testing_transform"] }
testing = "0.31.3" testing = "0.31.1"
walkdir = "2.3.2" walkdir = "2.3.2"
...@@ -8,7 +8,7 @@ use once_cell::sync::Lazy; ...@@ -8,7 +8,7 @@ use once_cell::sync::Lazy;
use swc_core::{ use swc_core::{
base::{try_with_handler, Compiler}, base::{try_with_handler, Compiler},
common::{FileName, FilePathMapping, SourceMap, GLOBALS}, common::{FileName, FilePathMapping, SourceMap},
ecma::transforms::base::pass::noop, ecma::transforms::base::pass::noop,
}; };
...@@ -41,7 +41,6 @@ export function getServerSideProps() { ...@@ -41,7 +41,6 @@ export function getServerSideProps() {
); );
assert!( assert!(
try_with_handler(COMPILER.cm.clone(), Default::default(), |handler| { try_with_handler(COMPILER.cm.clone(), Default::default(), |handler| {
GLOBALS.set(&Default::default(), || {
COMPILER.process_js_with_custom_pass( COMPILER.process_js_with_custom_pass(
fm, fm,
None, None,
...@@ -51,7 +50,6 @@ export function getServerSideProps() { ...@@ -51,7 +50,6 @@ export function getServerSideProps() {
|_, _| noop(), |_, _| noop(),
) )
}) })
})
.is_ok() .is_ok()
); );
assert_eq!( assert_eq!(
......
...@@ -19,9 +19,9 @@ regex = "1.5" ...@@ -19,9 +19,9 @@ regex = "1.5"
serde = "1" serde = "1"
sourcemap = "6.0.1" sourcemap = "6.0.1"
tracing = { version = "0.1.32", features = ["release_max_level_info"] } tracing = { version = "0.1.32", features = ["release_max_level_info"] }
swc_core = { version = "0.28.4", features = ["common", "ecma_ast","ecma_codegen", "ecma_utils", "ecma_visit", "trace_macro"] } swc_core = { version = "0.27.4", features = ["common", "ecma_ast","ecma_codegen", "ecma_utils", "ecma_visit", "trace_macro"] }
[dev-dependencies] [dev-dependencies]
swc_core = { version = "0.28.4", features = ["testing_transform", "ecma_transforms_react"] } swc_core = { version = "0.27.4", features = ["testing_transform", "ecma_transforms_react"] }
testing = "0.31.3" testing = "0.31.1"
serde_json = "1" serde_json = "1"
...@@ -15,8 +15,8 @@ handlebars = "4.2.1" ...@@ -15,8 +15,8 @@ handlebars = "4.2.1"
once_cell = "1.13.0" once_cell = "1.13.0"
regex = "1.5" regex = "1.5"
serde = "1" serde = "1"
swc_core = { version = "0.28.4", features = ["cached", "ecma_ast", "ecma_visit"] } swc_core = { version = "0.27.4", features = ["cached", "ecma_ast", "ecma_visit"] }
[dev-dependencies] [dev-dependencies]
swc_core = { version = "0.28.4", features = ["testing_transform"] } swc_core = { version = "0.27.4", features = ["testing_transform"] }
testing = "0.31.3" testing = "0.31.1"
...@@ -30,7 +30,7 @@ next-swc = {version = "0.0.0", path = "../core"} ...@@ -30,7 +30,7 @@ next-swc = {version = "0.0.0", path = "../core"}
once_cell = "1.13.0" once_cell = "1.13.0"
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"allocator_node", "allocator_node",
"base_concurrent", # concurrent? "base_concurrent", # concurrent?
"common_concurrent", "common_concurrent",
......
...@@ -13,7 +13,7 @@ use swc_core::{ ...@@ -13,7 +13,7 @@ use swc_core::{
common::{ common::{
collections::AHashMap, collections::AHashMap,
errors::{ColorConfig, Handler}, errors::{ColorConfig, Handler},
BytePos, FileName, Globals, SourceMap, Span, GLOBALS, BytePos, FileName, SourceMap, Span,
}, },
ecma::ast::*, ecma::ast::*,
ecma::atoms::JsWord, ecma::atoms::JsWord,
...@@ -69,11 +69,10 @@ impl Task for BundleTask { ...@@ -69,11 +69,10 @@ impl Task for BundleTask {
.map(JsWord::from) .map(JsWord::from)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let globals = Globals::default();
let comments = self.c.comments().clone(); let comments = self.c.comments().clone();
// //
let mut bundler = Bundler::new( let mut bundler = Bundler::new(
&globals, self.c.globals(),
self.c.cm.clone(), self.c.cm.clone(),
CustomLoader { CustomLoader {
cm: self.c.cm.clone(), cm: self.c.cm.clone(),
...@@ -89,7 +88,7 @@ impl Task for BundleTask { ...@@ -89,7 +88,7 @@ impl Task for BundleTask {
}, },
Box::new(CustomHook), Box::new(CustomHook),
); );
GLOBALS.set(&globals, || {
let mut entries = HashMap::default(); let mut entries = HashMap::default();
let path: PathBuf = option.entry; let path: PathBuf = option.entry;
let path = path let path = path
...@@ -98,9 +97,10 @@ impl Task for BundleTask { ...@@ -98,9 +97,10 @@ impl Task for BundleTask {
entries.insert("main".to_string(), FileName::Real(path)); entries.insert("main".to_string(), FileName::Real(path));
let outputs = bundler.bundle(entries)?; let outputs = bundler.bundle(entries)?;
let output = outputs.into_iter().next().ok_or_else(|| { let output = outputs
anyhow!("swc_bundler::Bundle::bundle returned empty result") .into_iter()
})?; .next()
.ok_or_else(|| anyhow!("swc_bundler::Bundle::bundle returned empty result"))?;
let source_map_names = { let source_map_names = {
let mut v = SourceMapIdentCollector { let mut v = SourceMapIdentCollector {
...@@ -128,7 +128,6 @@ impl Task for BundleTask { ...@@ -128,7 +128,6 @@ impl Task for BundleTask {
)?; )?;
Ok(code) Ok(code)
})
}, },
) )
.convert_err() .convert_err()
......
...@@ -35,7 +35,7 @@ use serde::Deserialize; ...@@ -35,7 +35,7 @@ use serde::Deserialize;
use std::sync::Arc; use std::sync::Arc;
use swc_core::{ use swc_core::{
base::{config::JsMinifyOptions, try_with_handler, TransformOutput}, base::{config::JsMinifyOptions, try_with_handler, TransformOutput},
common::{errors::ColorConfig, sync::Lrc, FileName, SourceFile, SourceMap, GLOBALS}, common::{errors::ColorConfig, sync::Lrc, FileName, SourceFile, SourceMap},
}; };
struct MinifyTask { struct MinifyTask {
...@@ -85,7 +85,6 @@ impl Task for MinifyTask { ...@@ -85,7 +85,6 @@ impl Task for MinifyTask {
skip_filename: true, skip_filename: true,
}, },
|handler| { |handler| {
GLOBALS.set(&Default::default(), || {
let fm = self.code.to_file(self.c.cm.clone()); let fm = self.code.to_file(self.c.cm.clone());
self.c.minify( self.c.minify(
...@@ -95,7 +94,6 @@ impl Task for MinifyTask { ...@@ -95,7 +94,6 @@ impl Task for MinifyTask {
..self.opts.clone() ..self.opts.clone()
}, },
) )
})
}, },
) )
.convert_err() .convert_err()
...@@ -133,7 +131,7 @@ pub fn minify_sync(cx: CallContext) -> napi::Result<JsObject> { ...@@ -133,7 +131,7 @@ pub fn minify_sync(cx: CallContext) -> napi::Result<JsObject> {
color: ColorConfig::Never, color: ColorConfig::Never,
skip_filename: true, skip_filename: true,
}, },
|handler| GLOBALS.set(&Default::default(), || c.minify(fm, handler, &opts)), |handler| c.minify(fm, handler, &opts),
) )
.convert_err()?; .convert_err()?;
......
...@@ -4,9 +4,7 @@ use napi::{CallContext, Either, Env, JsObject, JsString, JsUndefined, Task}; ...@@ -4,9 +4,7 @@ use napi::{CallContext, Either, Env, JsObject, JsString, JsUndefined, Task};
use std::sync::Arc; use std::sync::Arc;
use swc_core::{ use swc_core::{
base::{config::ParseOptions, try_with_handler}, base::{config::ParseOptions, try_with_handler},
common::{ common::{comments::Comments, errors::ColorConfig, FileName, FilePathMapping, SourceMap},
comments::Comments, errors::ColorConfig, FileName, FilePathMapping, SourceMap, GLOBALS,
},
}; };
pub struct ParseTask { pub struct ParseTask {
...@@ -24,9 +22,7 @@ impl Task for ParseTask { ...@@ -24,9 +22,7 @@ impl Task for ParseTask {
type JsValue = JsString; type JsValue = JsString;
fn compute(&mut self) -> napi::Result<Self::Output> { fn compute(&mut self) -> napi::Result<Self::Output> {
GLOBALS.set(&Default::default(), || { let c = swc_core::base::Compiler::new(Arc::new(SourceMap::new(FilePathMapping::empty())));
let c =
swc_core::base::Compiler::new(Arc::new(SourceMap::new(FilePathMapping::empty())));
let options: ParseOptions = deserialize_json(&self.options).convert_err()?; let options: ParseOptions = deserialize_json(&self.options).convert_err()?;
let comments = c.comments().clone(); let comments = c.comments().clone();
...@@ -61,7 +57,6 @@ impl Task for ParseTask { ...@@ -61,7 +57,6 @@ impl Task for ParseTask {
.convert_err()?; .convert_err()?;
Ok(ast_json) Ok(ast_json)
})
} }
fn resolve(self, env: Env, result: Self::Output) -> napi::Result<Self::JsValue> { fn resolve(self, env: Env, result: Self::Output) -> napi::Result<Self::JsValue> {
......
...@@ -44,7 +44,7 @@ use std::{ ...@@ -44,7 +44,7 @@ use std::{
}; };
use swc_core::{ use swc_core::{
base::{try_with_handler, Compiler, TransformOutput}, base::{try_with_handler, Compiler, TransformOutput},
common::{errors::ColorConfig, FileName, GLOBALS}, common::{errors::ColorConfig, FileName},
ecma::transforms::base::pass::noop, ecma::transforms::base::pass::noop,
}; };
...@@ -68,7 +68,6 @@ impl Task for TransformTask { ...@@ -68,7 +68,6 @@ impl Task for TransformTask {
type JsValue = JsObject; type JsValue = JsObject;
fn compute(&mut self) -> napi::Result<Self::Output> { fn compute(&mut self) -> napi::Result<Self::Output> {
GLOBALS.set(&Default::default(), || {
let eliminated_packages: Rc<RefCell<fxhash::FxHashSet<String>>> = Default::default(); let eliminated_packages: Rc<RefCell<fxhash::FxHashSet<String>>> = Default::default();
let res = catch_unwind(AssertUnwindSafe(|| { let res = catch_unwind(AssertUnwindSafe(|| {
try_with_handler( try_with_handler(
...@@ -146,7 +145,6 @@ impl Task for TransformTask { ...@@ -146,7 +145,6 @@ impl Task for TransformTask {
format!("{:?}", err), format!("{:?}", err),
)), )),
} }
})
} }
fn resolve( fn resolve(
......
...@@ -16,7 +16,7 @@ once_cell = "1.13.0" ...@@ -16,7 +16,7 @@ once_cell = "1.13.0"
regex = {version = "1.5.4", features = ["std", "perf"], default-features = false} regex = {version = "1.5.4", features = ["std", "perf"], default-features = false}
serde = {version = "1.0.130", features = ["derive"]} serde = {version = "1.0.130", features = ["derive"]}
tracing = "0.1.32" tracing = "0.1.32"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"common", "common",
"ecma_ast", "ecma_ast",
"ecma_utils", "ecma_utils",
...@@ -25,8 +25,8 @@ swc_core = { version = "0.28.4", features = [ ...@@ -25,8 +25,8 @@ swc_core = { version = "0.28.4", features = [
[dev-dependencies] [dev-dependencies]
serde_json = "1" serde_json = "1"
testing = "0.31.3" testing = "0.31.1"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"ecma_parser", "ecma_parser",
"ecma_transforms", "ecma_transforms",
"testing_transform" "testing_transform"
......
...@@ -13,7 +13,7 @@ version = "0.20.0" ...@@ -13,7 +13,7 @@ version = "0.20.0"
easy-error = "1.0.0" easy-error = "1.0.0"
tracing = "0.1.32" tracing = "0.1.32"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"common", "common",
"css_ast", "css_ast",
"css_codegen", "css_codegen",
...@@ -27,7 +27,7 @@ swc_core = { version = "0.28.4", features = [ ...@@ -27,7 +27,7 @@ swc_core = { version = "0.28.4", features = [
] } ] }
[dev-dependencies] [dev-dependencies]
testing = "0.31.3" testing = "0.31.1"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"testing_transform" "testing_transform"
] } ] }
...@@ -31,7 +31,7 @@ wasm-bindgen-futures = "0.4.8" ...@@ -31,7 +31,7 @@ wasm-bindgen-futures = "0.4.8"
getrandom = { version = "0.2.5", optional = true, default-features = false } getrandom = { version = "0.2.5", optional = true, default-features = false }
js-sys = "0.3.59" js-sys = "0.3.59"
swc_core = { version = "0.28.4", features = [ swc_core = { version = "0.27.4", features = [
"common_concurrent", "common_concurrent",
"binding_macro_wasm", "binding_macro_wasm",
"ecma_codegen", "ecma_codegen",
......
...@@ -8,9 +8,7 @@ use wasm_bindgen_futures::future_to_promise; ...@@ -8,9 +8,7 @@ use wasm_bindgen_futures::future_to_promise;
use swc_core::{ use swc_core::{
base::{config::JsMinifyOptions, config::ParseOptions, try_with_handler, Compiler}, base::{config::JsMinifyOptions, config::ParseOptions, try_with_handler, Compiler},
common::{ common::{comments::Comments, errors::ColorConfig, FileName, FilePathMapping, SourceMap},
comments::Comments, errors::ColorConfig, FileName, FilePathMapping, SourceMap, GLOBALS,
},
ecma::transforms::base::pass::noop, ecma::transforms::base::pass::noop,
}; };
...@@ -31,7 +29,6 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -31,7 +29,6 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
skip_filename: false, skip_filename: false,
}, },
|handler| { |handler| {
GLOBALS.set(&Default::default(), || {
let opts: JsMinifyOptions = opts.into_serde().context("failed to parse options")?; let opts: JsMinifyOptions = opts.into_serde().context("failed to parse options")?;
let fm = c.cm.new_source_file(FileName::Anon, s.into()); let fm = c.cm.new_source_file(FileName::Anon, s.into());
...@@ -40,7 +37,6 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -40,7 +37,6 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
.context("failed to minify file")?; .context("failed to minify file")?;
JsValue::from_serde(&program).context("failed to serialize json") JsValue::from_serde(&program).context("failed to serialize json")
})
}, },
) )
.map_err(convert_err) .map_err(convert_err)
...@@ -66,9 +62,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -66,9 +62,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
skip_filename: false, skip_filename: false,
}, },
|handler| { |handler| {
GLOBALS.set(&Default::default(), || { let opts: TransformOptions = opts.into_serde().context("failed to parse options")?;
let opts: TransformOptions =
opts.into_serde().context("failed to parse options")?;
let s = s.dyn_into::<js_sys::JsString>(); let s = s.dyn_into::<js_sys::JsString>();
let out = match s { let out = match s {
...@@ -105,7 +99,6 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -105,7 +99,6 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
}; };
JsValue::from_serde(&out).context("failed to serialize json") JsValue::from_serde(&out).context("failed to serialize json")
})
}, },
) )
.map_err(convert_err) .map_err(convert_err)
...@@ -131,9 +124,7 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -131,9 +124,7 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
}, },
|handler| { |handler| {
c.run(|| { c.run(|| {
GLOBALS.set(&Default::default(), || { let opts: ParseOptions = opts.into_serde().context("failed to parse options")?;
let opts: ParseOptions =
opts.into_serde().context("failed to parse options")?;
let fm = c.cm.new_source_file(FileName::Anon, s.into()); let fm = c.cm.new_source_file(FileName::Anon, s.into());
...@@ -158,7 +149,6 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> { ...@@ -158,7 +149,6 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
let s = serde_json::to_string(&program).unwrap(); let s = serde_json::to_string(&program).unwrap();
Ok(JsValue::from_str(&s)) Ok(JsValue::from_str(&s))
}) })
})
}, },
) )
.map_err(convert_err) .map_err(convert_err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment