chore: Update swc_core to v0.40.40
(#42326)
This PR updates swc crates to
5784ae24a5
Applies
- https://github.com/swc-project/swc/pull/6300
Closes https://github.com/vercel/next.js/issues/42171.
- https://github.com/swc-project/swc/pull/6293
- https://github.com/swc-project/swc/pull/6272
Closes https://github.com/vercel/next.js/issues/41992.
This commit is contained in:
parent
00df9f3533
commit
670f2a8a6d
10 changed files with 231 additions and 223 deletions
381
packages/next-swc/Cargo.lock
generated
381
packages/next-swc/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -19,11 +19,11 @@ pathdiff = "0.2.0"
|
|||
regex = "1.5"
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
swc_emotion = "0.28.1"
|
||||
styled_components = "0.52.1"
|
||||
styled_jsx = "0.29.1"
|
||||
modularize_imports = "0.25.1"
|
||||
tracing = { version = "0.1.32", features = ["release_max_level_info"] }
|
||||
swc_emotion = "0.28.2"
|
||||
styled_components = "0.52.2"
|
||||
styled_jsx = "0.29.2"
|
||||
modularize_imports = "0.25.2"
|
||||
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
|
||||
|
||||
swc_core = { features = [
|
||||
"common_concurrent",
|
||||
|
@ -42,9 +42,9 @@ swc_core = { features = [
|
|||
"ecma_parser_typescript",
|
||||
"cached",
|
||||
"base"
|
||||
], version = "0.40.16" }
|
||||
], version = "0.40.40" }
|
||||
|
||||
[dev-dependencies]
|
||||
swc_core = { features = ["testing_transform"], version = "0.40.16" }
|
||||
testing = "0.31.10"
|
||||
swc_core = { features = ["testing_transform"], version = "0.40.40" }
|
||||
testing = "0.31.13"
|
||||
walkdir = "2.3.2"
|
||||
|
|
|
@ -3,6 +3,7 @@ use serde::de::DeserializeOwned;
|
|||
use std::path::{Path, PathBuf};
|
||||
use swc_core::{
|
||||
base::Compiler,
|
||||
common::comments::SingleThreadedComments,
|
||||
ecma::parser::{Syntax, TsConfig},
|
||||
ecma::transforms::base::pass::noop,
|
||||
};
|
||||
|
@ -71,12 +72,14 @@ fn test(input: &Path, minify: bool) {
|
|||
|
||||
let options = options.patch(&fm);
|
||||
|
||||
let comments = SingleThreadedComments::default();
|
||||
match c.process_js_with_custom_pass(
|
||||
fm.clone(),
|
||||
None,
|
||||
&handler,
|
||||
&options.swc,
|
||||
|_, comments| {
|
||||
comments.clone(),
|
||||
|_| {
|
||||
custom_before_pass(
|
||||
cm.clone(),
|
||||
fm.clone(),
|
||||
|
@ -85,7 +88,7 @@ fn test(input: &Path, minify: bool) {
|
|||
Default::default(),
|
||||
)
|
||||
},
|
||||
|_, _| noop(),
|
||||
|_| noop(),
|
||||
) {
|
||||
Ok(v) => {
|
||||
NormalizedOutput::from(v.code)
|
||||
|
|
|
@ -8,7 +8,7 @@ use once_cell::sync::Lazy;
|
|||
|
||||
use swc_core::{
|
||||
base::{try_with_handler, Compiler},
|
||||
common::{FileName, FilePathMapping, SourceMap, GLOBALS},
|
||||
common::{comments::SingleThreadedComments, FileName, FilePathMapping, SourceMap, GLOBALS},
|
||||
ecma::transforms::base::pass::noop,
|
||||
};
|
||||
|
||||
|
@ -42,13 +42,15 @@ export function getServerSideProps() {
|
|||
assert!(
|
||||
try_with_handler(COMPILER.cm.clone(), Default::default(), |handler| {
|
||||
GLOBALS.set(&Default::default(), || {
|
||||
let comments = SingleThreadedComments::default();
|
||||
COMPILER.process_js_with_custom_pass(
|
||||
fm,
|
||||
None,
|
||||
handler,
|
||||
&Default::default(),
|
||||
|_, _| next_ssg(eliminated_packages.clone()),
|
||||
|_, _| noop(),
|
||||
comments.clone(),
|
||||
|_| next_ssg(eliminated_packages.clone()),
|
||||
|_| noop(),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -21,7 +21,7 @@ sentry_native_tls = ["_sentry_native_tls"]
|
|||
sentry_rustls = ["_sentry_rustls"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
anyhow = "1.0.66"
|
||||
backtrace = "0.3"
|
||||
fxhash = "0.2.1"
|
||||
napi = { version = "2", default-features = false, features = ["napi3", "serde-json", "tokio_rt", "error_anyhow"] }
|
||||
|
@ -50,8 +50,8 @@ swc_core = { features = [
|
|||
"ecma_transforms_typescript",
|
||||
"ecma_utils",
|
||||
"ecma_visit",
|
||||
], version = "0.40.16" }
|
||||
tracing = { version = "0.1.32", features = ["release_max_level_info"] }
|
||||
], version = "0.40.40" }
|
||||
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-subscriber = "0.3.9"
|
||||
tracing-chrome = "0.5.0"
|
||||
|
|
|
@ -31,8 +31,9 @@ use fxhash::FxHashMap;
|
|||
use napi::bindgen_prelude::*;
|
||||
use serde::Deserialize;
|
||||
use swc_core::{
|
||||
base::{config::JsMinifyOptions, try_with_handler, TransformOutput},
|
||||
base::{config::JsMinifyOptions, try_with_handler, BoolOrDataConfig, TransformOutput},
|
||||
common::{errors::ColorConfig, sync::Lrc, FileName, SourceFile, SourceMap, GLOBALS},
|
||||
ecma::minifier::option::terser::TerserCompressorOptions,
|
||||
};
|
||||
|
||||
use crate::{get_compiler, util::MapErr};
|
||||
|
@ -92,6 +93,12 @@ impl Task for MinifyTask {
|
|||
fm,
|
||||
handler,
|
||||
&JsMinifyOptions {
|
||||
compress: TerserCompressorOptions {
|
||||
// inline: TerserInlineOption::Num(0).into(),
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
mangle: BoolOrDataConfig::from_bool(false),
|
||||
..self.opts.clone()
|
||||
},
|
||||
)
|
||||
|
|
|
@ -38,6 +38,7 @@ use anyhow::{anyhow, bail, Context as _};
|
|||
use fxhash::FxHashSet;
|
||||
use napi::bindgen_prelude::*;
|
||||
use next_swc::{custom_before_pass, TransformOptions};
|
||||
use swc_core::common::comments::SingleThreadedComments;
|
||||
use swc_core::{
|
||||
base::{try_with_handler, Compiler, TransformOutput},
|
||||
common::{errors::ColorConfig, FileName, GLOBALS},
|
||||
|
@ -107,12 +108,14 @@ impl Task for TransformTask {
|
|||
let cm = self.c.cm.clone();
|
||||
let file = fm.clone();
|
||||
|
||||
let comments = SingleThreadedComments::default();
|
||||
self.c.process_js_with_custom_pass(
|
||||
fm,
|
||||
None,
|
||||
handler,
|
||||
&options.swc,
|
||||
|_, comments| {
|
||||
comments.clone(),
|
||||
|_| {
|
||||
custom_before_pass(
|
||||
cm,
|
||||
file,
|
||||
|
@ -121,7 +124,7 @@ impl Task for TransformTask {
|
|||
eliminated_packages.clone(),
|
||||
)
|
||||
},
|
||||
|_, _| noop(),
|
||||
|_| noop(),
|
||||
)
|
||||
})
|
||||
},
|
||||
|
|
|
@ -17,7 +17,7 @@ plugin = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.42"
|
||||
anyhow = "1.0.66"
|
||||
console_error_panic_hook = "0.1.6"
|
||||
next-swc = {version = "0.0.0", path = "../core"}
|
||||
once_cell = "1.13.0"
|
||||
|
@ -25,7 +25,7 @@ parking_lot_core = "=0.8.0"
|
|||
path-clean = "0.1"
|
||||
serde = {version = "1", features = ["derive"]}
|
||||
serde_json = "1"
|
||||
tracing = { version = "0.1.32", features = ["release_max_level_off","max_level_off"] }
|
||||
tracing = { version = "0.1.37", features = ["release_max_level_off","max_level_off"] }
|
||||
wasm-bindgen = {version = "0.2", features = ["enable-interning"]}
|
||||
wasm-bindgen-futures = "0.4.8"
|
||||
getrandom = { version = "0.2.5", optional = true, default-features = false }
|
||||
|
@ -46,7 +46,7 @@ swc_core = { features = [
|
|||
"ecma_parser_typescript",
|
||||
"ecma_utils",
|
||||
"ecma_visit"
|
||||
], version = "0.40.16" }
|
||||
], version = "0.40.40" }
|
||||
|
||||
|
||||
# Workaround a bug
|
||||
|
|
|
@ -8,7 +8,9 @@ use wasm_bindgen_futures::future_to_promise;
|
|||
use swc_core::{
|
||||
base::{config::JsMinifyOptions, config::ParseOptions, try_with_handler, Compiler},
|
||||
common::{
|
||||
comments::Comments, errors::ColorConfig, FileName, FilePathMapping, SourceMap, GLOBALS,
|
||||
comments::{Comments, SingleThreadedComments},
|
||||
errors::ColorConfig,
|
||||
FileName, FilePathMapping, SourceMap, GLOBALS,
|
||||
},
|
||||
ecma::transforms::base::pass::noop,
|
||||
};
|
||||
|
@ -84,12 +86,14 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
|
|||
);
|
||||
let cm = c.cm.clone();
|
||||
let file = fm.clone();
|
||||
let comments = SingleThreadedComments::default();
|
||||
c.process_js_with_custom_pass(
|
||||
fm,
|
||||
None,
|
||||
handler,
|
||||
&opts.swc,
|
||||
|_, comments| {
|
||||
comments.clone(),
|
||||
|_| {
|
||||
custom_before_pass(
|
||||
cm,
|
||||
file,
|
||||
|
@ -98,7 +102,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
|
|||
Default::default(),
|
||||
)
|
||||
},
|
||||
|_, _| noop(),
|
||||
|_| noop(),
|
||||
)
|
||||
.context("failed to process js file")?
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ var ref = _slicedToArray(useState(0), 2), count = ref[0], setCount = ref[1];
|
|||
expect(output).toMatchInlineSnapshot(`
|
||||
"function _arrayLikeToArray(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
for(var i1 = 0, arr2 = new Array(len); i1 < len; i1++)arr2[i1] = arr[i1];
|
||||
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
||||
return arr2;
|
||||
}
|
||||
function _arrayWithHoles(arr) {
|
||||
|
@ -95,7 +95,7 @@ function _nonIterableRest() {
|
|||
throw new TypeError(\\"Invalid attempt to destructure non-iterable instance.\\\\\\\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\\");
|
||||
}
|
||||
function _toArray(arr) {
|
||||
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
||||
}
|
||||
function _unsupportedIterableToArray(o, minLen) {
|
||||
if (!o) return;
|
||||
|
|
Loading…
Reference in a new issue