Update swc (#30127)
Co-authored-by: kdy1 <kdy1@users.noreply.github.com>
This commit is contained in:
parent
282c1c9d7c
commit
5f73633d4d
10 changed files with 75 additions and 74 deletions
29
packages/next/build/swc/Cargo.lock
generated
29
packages/next/build/swc/Cargo.lock
generated
|
@ -119,9 +119,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
|||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.61"
|
||||
version = "0.3.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01"
|
||||
checksum = "091bcdf2da9950f96aa522681ce805e6857f6ca8df73833d35736ab2dc78e152"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
|
@ -793,9 +793,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.26.2"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
|
||||
checksum = "c821014c18301591b89b843809ef953af9e3df0496c232d5c0611b0a52aac363"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
@ -1576,9 +1576,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
|||
|
||||
[[package]]
|
||||
name = "swc"
|
||||
version = "0.76.1"
|
||||
version = "0.77.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fea3932ebdcad1f5c6507858af1cf8fe53a905761194c9bcaf268c4c308edf69"
|
||||
checksum = "fe683a5da5b4930cdcf47a5002127d5db24a583ec20f3d98b7321d2f34bc0f4b"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
|
@ -1625,9 +1625,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_common"
|
||||
version = "0.14.1"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de8be830f71f62908dae13fd9db66522e77dbf9188bd07d0b86d15f48557b219"
|
||||
checksum = "7d0ebf30bbbc54bd2e2115f9bf9f3226b8e6039ed1a076992af4c09c49de7947"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"ast_node",
|
||||
|
@ -1759,9 +1759,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_codegen"
|
||||
version = "0.77.0"
|
||||
version = "0.77.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9679c138f4cfe98c86e0947bdc089c4402b372db064f6aca2636a86c93898052"
|
||||
checksum = "84bc14c5b5ba303bf0bcb6ace52d7ae321bf7e1ead9e90a1dc9f90e0e7f5eeb7"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"memchr",
|
||||
|
@ -1923,9 +1923,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_base"
|
||||
version = "0.40.0"
|
||||
version = "0.40.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1ce842ee29a2e96647950dba48dddd757ad7e5b392b1902191a16c3e8be22ae"
|
||||
checksum = "9c6eddb77633192d66e77eba1adc6ee27f8624f5d175360d323b02e2ebee7133"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"phf",
|
||||
|
@ -1937,6 +1937,7 @@ dependencies = [
|
|||
"swc_ecma_parser",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2120,9 +2121,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_utils"
|
||||
version = "0.48.0"
|
||||
version = "0.48.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc932d46dabd2250f4bb690cf5eb14a672c6c054caee1a1a9ff3ecf77b472606"
|
||||
checksum = "7da7efcb8e643863ab3588b515c6290f8a7a6538ee3a1ac856820cf43aada4ba"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"scoped-tls",
|
||||
|
|
|
@ -16,9 +16,9 @@ path-clean = "0.1"
|
|||
regex = "1.5"
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
swc = "0.76.0"
|
||||
swc = "0.77.0"
|
||||
swc_atoms = "0.2.7"
|
||||
swc_common = { version = "0.14.1", features = ["concurrent", "sourcemap"] }
|
||||
swc_common = { version = "0.14.2", features = ["concurrent", "sourcemap"] }
|
||||
swc_css = "0.20.0"
|
||||
swc_ecmascript = { version = "0.80.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
|
||||
swc_ecma_preset_env = "0.59.0"
|
||||
|
|
|
@ -26,8 +26,8 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
use crate::{
|
||||
complete_output, get_compiler,
|
||||
util::{CtxtExt, MapErr},
|
||||
complete_output, get_compiler,
|
||||
util::{CtxtExt, MapErr},
|
||||
};
|
||||
use fxhash::FxHashMap;
|
||||
use napi::{CallContext, JsObject, Task};
|
||||
|
@ -37,81 +37,81 @@ use swc::{try_with_handler, TransformOutput};
|
|||
use swc_common::{sync::Lrc, FileName, SourceFile, SourceMap};
|
||||
|
||||
struct MinifyTask {
|
||||
c: Arc<swc::Compiler>,
|
||||
code: MinifyTarget,
|
||||
opts: swc::config::JsMinifyOptions,
|
||||
c: Arc<swc::Compiler>,
|
||||
code: MinifyTarget,
|
||||
opts: swc::config::JsMinifyOptions,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum MinifyTarget {
|
||||
/// Code to minify.
|
||||
Single(String),
|
||||
/// `{ filename: code }`
|
||||
Map(FxHashMap<String, String>),
|
||||
/// Code to minify.
|
||||
Single(String),
|
||||
/// `{ filename: code }`
|
||||
Map(FxHashMap<String, String>),
|
||||
}
|
||||
|
||||
impl MinifyTarget {
|
||||
fn to_file(&self, cm: Lrc<SourceMap>) -> Lrc<SourceFile> {
|
||||
match self {
|
||||
MinifyTarget::Single(code) => cm.new_source_file(FileName::Anon, code.clone()),
|
||||
MinifyTarget::Map(codes) => {
|
||||
assert_eq!(
|
||||
codes.len(),
|
||||
1,
|
||||
"swc.minify does not support concatenating multiple files yet"
|
||||
);
|
||||
fn to_file(&self, cm: Lrc<SourceMap>) -> Lrc<SourceFile> {
|
||||
match self {
|
||||
MinifyTarget::Single(code) => cm.new_source_file(FileName::Anon, code.clone()),
|
||||
MinifyTarget::Map(codes) => {
|
||||
assert_eq!(
|
||||
codes.len(),
|
||||
1,
|
||||
"swc.minify does not support concatenating multiple files yet"
|
||||
);
|
||||
|
||||
let (filename, code) = codes.iter().next().unwrap();
|
||||
let (filename, code) = codes.iter().next().unwrap();
|
||||
|
||||
cm.new_source_file(FileName::Real(filename.clone().into()), code.clone())
|
||||
}
|
||||
cm.new_source_file(FileName::Real(filename.clone().into()), code.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Task for MinifyTask {
|
||||
type Output = TransformOutput;
|
||||
type Output = TransformOutput;
|
||||
|
||||
type JsValue = JsObject;
|
||||
type JsValue = JsObject;
|
||||
|
||||
fn compute(&mut self) -> napi::Result<Self::Output> {
|
||||
try_with_handler(self.c.cm.clone(), |handler| {
|
||||
let fm = self.code.to_file(self.c.cm.clone());
|
||||
fn compute(&mut self) -> napi::Result<Self::Output> {
|
||||
try_with_handler(self.c.cm.clone(), true, |handler| {
|
||||
let fm = self.code.to_file(self.c.cm.clone());
|
||||
|
||||
self.c.minify(fm, &handler, &self.opts)
|
||||
})
|
||||
.convert_err()
|
||||
}
|
||||
self.c.minify(fm, &handler, &self.opts)
|
||||
})
|
||||
.convert_err()
|
||||
}
|
||||
|
||||
fn resolve(self, env: napi::Env, output: Self::Output) -> napi::Result<Self::JsValue> {
|
||||
complete_output(&env, output)
|
||||
}
|
||||
fn resolve(self, env: napi::Env, output: Self::Output) -> napi::Result<Self::JsValue> {
|
||||
complete_output(&env, output)
|
||||
}
|
||||
}
|
||||
|
||||
#[js_function(2)]
|
||||
pub fn minify(cx: CallContext) -> napi::Result<JsObject> {
|
||||
let code = cx.get_deserialized(0)?;
|
||||
let opts = cx.get_deserialized(1)?;
|
||||
let code = cx.get_deserialized(0)?;
|
||||
let opts = cx.get_deserialized(1)?;
|
||||
|
||||
let c = get_compiler(&cx);
|
||||
let c = get_compiler(&cx);
|
||||
|
||||
let task = MinifyTask { c, code, opts };
|
||||
let task = MinifyTask { c, code, opts };
|
||||
|
||||
cx.env.spawn(task).map(|t| t.promise_object())
|
||||
cx.env.spawn(task).map(|t| t.promise_object())
|
||||
}
|
||||
|
||||
#[js_function(2)]
|
||||
pub fn minify_sync(cx: CallContext) -> napi::Result<JsObject> {
|
||||
let code: MinifyTarget = cx.get_deserialized(0)?;
|
||||
let opts = cx.get_deserialized(1)?;
|
||||
let code: MinifyTarget = cx.get_deserialized(0)?;
|
||||
let opts = cx.get_deserialized(1)?;
|
||||
|
||||
let c = get_compiler(&cx);
|
||||
let c = get_compiler(&cx);
|
||||
|
||||
let fm = code.to_file(c.cm.clone());
|
||||
let fm = code.to_file(c.cm.clone());
|
||||
|
||||
let output =
|
||||
try_with_handler(c.cm.clone(), |handler| c.minify(fm, &handler, &opts)).convert_err()?;
|
||||
let output = try_with_handler(c.cm.clone(), true, |handler| c.minify(fm, &handler, &opts))
|
||||
.convert_err()?;
|
||||
|
||||
complete_output(&cx.env, output)
|
||||
complete_output(&cx.env, output)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ impl Task for TransformTask {
|
|||
|
||||
fn compute(&mut self) -> napi::Result<Self::Output> {
|
||||
let res = catch_unwind(AssertUnwindSafe(|| {
|
||||
try_with_handler(self.c.cm.clone(), |handler| {
|
||||
try_with_handler(self.c.cm.clone(), true, |handler| {
|
||||
self.c.run(|| match self.input {
|
||||
Input::Source(ref s) => {
|
||||
let before_pass = custom_before_pass(&s.name, &self.options);
|
||||
|
@ -124,7 +124,7 @@ where
|
|||
let is_module = cx.get::<JsBoolean>(1)?;
|
||||
let options: TransformOptions = cx.get_deserialized(2)?;
|
||||
|
||||
let output = try_with_handler(c.cm.clone(), |handler| {
|
||||
let output = try_with_handler(c.cm.clone(), true, |handler| {
|
||||
c.run(|| {
|
||||
if is_module.get_value()? {
|
||||
let program: Program =
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import _JSXStyle from "styled-jsx/style";
|
||||
function NavigationItem({ active , className: className1 }) {
|
||||
function NavigationItem({ active , className }) {
|
||||
return <span className={"jsx-2342aae4628612c6" + " " + (cn({
|
||||
active
|
||||
}, className1, "navigation-item") || "")}>
|
||||
}, className, "navigation-item") || "")}>
|
||||
|
||||
<_JSXStyle id={"2342aae4628612c6"}>{".navigation-item.jsx-2342aae4628612c6 a::after {content:attr(data-text);\ncontent: attr(data-text) / ''}"}</_JSXStyle>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _JSXStyle from "styled-jsx/style";
|
||||
import colors, { size } from "./constants";
|
||||
import colors1, { size } from "./constants";
|
||||
const color = "red";
|
||||
const bar = new String("div.jsx-aaed0341accea8f {font-size:3em}");
|
||||
bar.__hash = "aaed0341accea8f";
|
||||
|
@ -12,33 +12,33 @@ export const foo = new String(`div.jsx-a0d126276b085021 {color:${color}}`);
|
|||
foo.__hash = "a0d126276b085021";
|
||||
({
|
||||
styles: <_JSXStyle id={"47e08c293b53f262"} dynamic={[
|
||||
colors.green.light
|
||||
]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}}
|
||||
colors1.green.light
|
||||
]}>{`div.__jsx-style-dynamic-selector {color:${colors1.green.light}}
|
||||
a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
|
||||
className: _JSXStyle.dynamic([
|
||||
[
|
||||
"47e08c293b53f262",
|
||||
[
|
||||
colors.green.light
|
||||
colors1.green.light
|
||||
]
|
||||
]
|
||||
])
|
||||
});
|
||||
const b = {
|
||||
styles: <_JSXStyle id={"47e08c293b53f262"} dynamic={[
|
||||
colors.green.light
|
||||
]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}}
|
||||
colors1.green.light
|
||||
]}>{`div.__jsx-style-dynamic-selector {color:${colors1.green.light}}
|
||||
a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
|
||||
className: _JSXStyle.dynamic([
|
||||
[
|
||||
"47e08c293b53f262",
|
||||
[
|
||||
colors.green.light
|
||||
colors1.green.light
|
||||
]
|
||||
]
|
||||
])
|
||||
};
|
||||
const dynamic1 = (colors)=>{
|
||||
const dynamic = (colors)=>{
|
||||
const b = {
|
||||
styles: <_JSXStyle id={"79d79305fa1611e"} dynamic={[
|
||||
colors.green.light
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue