Skip to content

Commit bba1fad

Browse files
authoredMay 15, 2023
feat(plugin): Add versioned wrapper struct (#7382)
1 parent 5d30437 commit bba1fad

File tree

27 files changed

+262
-194
lines changed

27 files changed

+262
-194
lines changed
 

‎bindings/Cargo.lock

+68-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bindings/binding_core_node/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ tracing-chrome = "0.5.0"
4848
tracing-futures = "0.2.5"
4949
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }
5050

51-
swc_core = { version = "0.75.46", features = [
51+
swc_core = { version = "0.76.2", features = [
5252
"allocator_node",
5353
"ecma_ast",
5454
"ecma_ast_serde",

‎bindings/binding_core_wasm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ plugin = []
3434
anyhow = "1.0.66"
3535
serde = { version = "1", features = ["derive"] }
3636
serde-wasm-bindgen = "0.4.5"
37-
swc_core = { version = "0.75.46", features = [
37+
swc_core = { version = "0.76.2", features = [
3838
"ecma_ast_serde",
3939
"common_perf",
4040
"binding_macro_wasm",

‎bindings/swc_cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ relative-path = "1.6.1"
2727
serde = { version = "1", features = ["derive"] }
2828
serde_json = { version = "1", features = ["unbounded_depth"] }
2929
sourcemap = "6.2.2"
30-
swc_core = { version = "0.75.46", features = [
30+
swc_core = { version = "0.76.2", features = [
3131
"trace_macro",
3232
"common_concurrent",
3333
"base_concurrent",

‎crates/swc/src/plugin.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ impl RustPlugins {
9494
},
9595
|| {
9696
let span = tracing::span!(tracing::Level::INFO, "serialize_program").entered();
97-
let mut serialized_program = PluginSerializedBytes::try_serialize(&n)?;
97+
let program = swc_common::plugin::serialized::VersionedSerializable::new(n);
98+
let mut serialized = PluginSerializedBytes::try_serialize(&program)?;
9899
drop(span);
99100

100101
// Run plugin transformation against current program.
@@ -137,9 +138,9 @@ impl RustPlugins {
137138
)
138139
.entered();
139140

140-
serialized_program = transform_plugin_executor
141+
serialized = transform_plugin_executor
141142
.transform(
142-
&serialized_program,
143+
&serialized,
143144
self.unresolved_mark,
144145
should_enable_comments_proxy,
145146
)
@@ -156,7 +157,7 @@ impl RustPlugins {
156157

157158
// Plugin transformation is done. Deserialize transformed bytes back
158159
// into Program
159-
serialized_program.deserialize()
160+
serialized.deserialize().map(|v| v.into_inner())
160161
},
161162
)
162163
}
@@ -179,7 +180,8 @@ impl RustPlugins {
179180
inner: self.comments.clone(),
180181
},
181182
|| {
182-
let mut serialized_program = PluginSerializedBytes::try_serialize(&n)?;
183+
let program = swc_common::plugin::serialized::VersionedSerializable::new(n);
184+
let mut serialized = PluginSerializedBytes::try_serialize(&program)?;
183185

184186
if let Some(plugins) = &mut self.plugins {
185187
for p in plugins.drain(..) {
@@ -192,9 +194,9 @@ impl RustPlugins {
192194
Some(p.1),
193195
)?;
194196

195-
serialized_program = transform_plugin_executor
197+
serialized = transform_plugin_executor
196198
.transform(
197-
&serialized_program,
199+
&serialized,
198200
self.unresolved_mark,
199201
should_enable_comments_proxy,
200202
)
@@ -204,7 +206,7 @@ impl RustPlugins {
204206
}
205207
}
206208

207-
serialized_program.deserialize()
209+
serialized_program.deserialize().map(|v| v.into_inner())
208210
},
209211
)
210212
}

‎crates/swc_common/src/plugin/serialized.rs

+21-29
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl PluginSerializedBytes {
5959
* to implement TryFrom trait
6060
*/
6161
#[tracing::instrument(level = "info", skip_all)]
62-
pub fn try_serialize<W>(t: &W) -> Result<Self, Error>
62+
pub fn try_serialize<W>(t: &VersionedSerializable<W>) -> Result<Self, Error>
6363
where
6464
W: rkyv::Serialize<rkyv::ser::serializers::AllocSerializer<512>>,
6565
{
@@ -99,14 +99,14 @@ impl PluginSerializedBytes {
9999
}
100100

101101
#[tracing::instrument(level = "info", skip_all)]
102-
pub fn deserialize<W>(&self) -> Result<W, Error>
102+
pub fn deserialize<W>(&self) -> Result<VersionedSerializable<W>, Error>
103103
where
104104
W: rkyv::Archive,
105105
W::Archived: rkyv::Deserialize<W, rkyv::de::deserializers::SharedDeserializeMap>,
106106
{
107107
use anyhow::Context;
108108

109-
let archived = unsafe { rkyv::archived_root::<W>(&self.field[..]) };
109+
let archived = unsafe { rkyv::archived_root::<VersionedSerializable<W>>(&self.field[..]) };
110110

111111
archived
112112
.deserialize(&mut rkyv::de::deserializers::SharedDeserializeMap::new())
@@ -124,7 +124,7 @@ impl PluginSerializedBytes {
124124
pub unsafe fn deserialize_from_ptr<W>(
125125
raw_allocated_ptr: *const u8,
126126
raw_allocated_ptr_len: u32,
127-
) -> Result<W, Error>
127+
) -> Result<VersionedSerializable<W>, Error>
128128
where
129129
W: rkyv::Archive,
130130
W::Archived: rkyv::Deserialize<W, rkyv::de::deserializers::SharedDeserializeMap>,
@@ -135,37 +135,30 @@ where
135135
serialized.deserialize()
136136
}
137137

138-
/// Deserialize `Fallible` struct from raw ptr. This is similar to
139-
/// `deserialize_from_ptr` but for the struct requires bounds to the
140-
/// SharedSerializeRegistry which cannot be Infallible. Internally this does
141-
/// not call deserialize with Infallible deserializer, use
142-
/// SharedDeserializeMap instead.
143-
#[tracing::instrument(level = "info", skip_all)]
144-
pub fn deserialize_from_ptr_into_fallible<W>(
145-
raw_allocated_ptr: *const u8,
146-
raw_allocated_ptr_len: u32,
147-
) -> Result<W, Error>
148-
where
149-
W: rkyv::Archive,
150-
W::Archived: rkyv::Deserialize<W, rkyv::de::deserializers::SharedDeserializeMap>,
151-
{
152-
let serialized =
153-
PluginSerializedBytes::from_raw_ptr(raw_allocated_ptr, raw_allocated_ptr_len as usize);
154-
155-
serialized.deserialize()
156-
}
157-
158-
/*
159138
/// A wrapper type for the structures to be passed into plugins
160139
/// serializes the contained value out-of-line so that newer
161140
/// versions can be viewed as the older version.
162141
///
163-
#[derive(Archive, Deserialize, Serialize)]
164-
pub struct VersionedSerializable<T>(#[with(AsBox)] T);
142+
/// First field indicate version of struct type (schema). Any consumers like
143+
/// swc_plugin_macro can use this to validate compatiblility before attempt to
144+
/// serialize.
145+
#[cfg_attr(
146+
feature = "__plugin",
147+
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
148+
)]
149+
#[repr(transparent)]
150+
#[cfg_attr(feature = "__plugin", archive(check_bytes))]
151+
#[cfg_attr(feature = "__plugin", archive_attr(repr(transparent)))]
152+
#[derive(Debug)]
153+
pub struct VersionedSerializable<T>(
154+
// [NOTE]: https://github.com/rkyv/rkyv/issues/373#issuecomment-1546360897
155+
//#[cfg_attr(feature = "__plugin", with(rkyv::with::AsBox))]
156+
pub T,
157+
);
165158

166159
impl<T> VersionedSerializable<T> {
167160
pub fn new(value: T) -> Self {
168-
VersionedSerializable(value)
161+
Self(value)
169162
}
170163

171164
pub fn inner(&self) -> &T {
@@ -176,4 +169,3 @@ impl<T> VersionedSerializable<T> {
176169
self.0
177170
}
178171
}
179-
*/

‎crates/swc_common/src/syntax_pos/hygiene.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ impl Mark {
181181
pub fn is_descendant_of(mut self, ancestor: Mark) -> bool {
182182
// This code path executed inside of the guest memory context.
183183
// In here, preallocate memory for the context.
184+
185+
use crate::plugin::serialized::VersionedSerializable;
184186
let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize(
185-
&MutableMarkContext(0, 0, 0),
187+
&VersionedSerializable::new(MutableMarkContext(0, 0, 0)),
186188
)
187189
.expect("Should be serializable");
188190
let (ptr, len) = serialized.as_ptr();
@@ -200,6 +202,7 @@ impl Mark {
200202
len.try_into().expect("Should able to convert ptr length"),
201203
)
202204
.expect("Should able to deserialize")
205+
.into_inner()
203206
};
204207
self = Mark::from_u32(context.0);
205208

@@ -222,8 +225,10 @@ impl Mark {
222225
#[allow(unused_mut, unused_assignments)]
223226
#[cfg(all(feature = "__plugin_mode", target_arch = "wasm32"))]
224227
pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark {
228+
use crate::plugin::serialized::VersionedSerializable;
229+
225230
let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize(
226-
&MutableMarkContext(0, 0, 0),
231+
&VersionedSerializable::new(MutableMarkContext(0, 0, 0)),
227232
)
228233
.expect("Should be serializable");
229234
let (ptr, len) = serialized.as_ptr();
@@ -238,6 +243,7 @@ impl Mark {
238243
len.try_into().expect("Should able to convert ptr length"),
239244
)
240245
.expect("Should able to deserialize")
246+
.into_inner()
241247
};
242248
a = Mark::from_u32(context.0);
243249
b = Mark::from_u32(context.1);
@@ -418,7 +424,9 @@ impl SyntaxContext {
418424

419425
#[cfg(all(feature = "__plugin_mode", target_arch = "wasm32"))]
420426
pub fn remove_mark(&mut self) -> Mark {
421-
let context = MutableMarkContext(0, 0, 0);
427+
use crate::plugin::serialized::VersionedSerializable;
428+
429+
let context = VersionedSerializable::new(MutableMarkContext(0, 0, 0));
422430
let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize(&context)
423431
.expect("Should be serializable");
424432
let (ptr, len) = serialized.as_ptr();
@@ -433,6 +441,7 @@ impl SyntaxContext {
433441
len.try_into().expect("Should able to convert ptr length"),
434442
)
435443
.expect("Should able to deserialize")
444+
.into_inner()
436445
};
437446

438447
*self = SyntaxContext(context.0);

‎crates/swc_plugin_macro/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream {
6060
impl swc_core::common::errors::Emitter for PluginDiagnosticsEmitter {
6161
#[cfg_attr(not(target_arch = "wasm32"), allow(unused))]
6262
fn emit(&mut self, db: &swc_core::common::errors::DiagnosticBuilder<'_>) {
63-
let diag = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&*db.diagnostic)
63+
let diag = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&swc_core::common::plugin::serialized::VersionedSerializable::new(*db.diagnostic.clone()))
6464
.expect("Should able to serialize Diagnostic");
6565
let (ptr, len) = diag.as_ptr();
6666

@@ -83,7 +83,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream {
8383

8484
/// Internal function plugin_macro uses to create ptr to PluginError.
8585
fn construct_error_ptr(plugin_error: swc_core::common::plugin::serialized::PluginError) -> u32 {
86-
let ret = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&plugin_error).expect("Should able to serialize PluginError");
86+
let ret = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&swc_core::common::plugin::serialized::VersionedSerializable::new(plugin_error)).expect("Should able to serialize PluginError");
8787
let (ptr, len) = ret.as_ptr();
8888

8989
send_transform_result_to_host(
@@ -107,7 +107,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream {
107107
};
108108

109109
let serialized_result = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(
110-
&result
110+
&swc_core::common::plugin::serialized::VersionedSerializable::new(result)
111111
).expect("Diagnostics should be always serializable");
112112

113113
let (serialized_result_ptr, serialized_result_ptr_len) = serialized_result.as_ptr();
@@ -135,7 +135,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream {
135135
let err = swc_core::common::plugin::serialized::PluginError::Deserialize("Failed to deserialize program received from host".to_string());
136136
return construct_error_ptr(err);
137137
}
138-
let program: #ast_type = program.expect("Should be a program");
138+
let program: #ast_type = program.expect("Should be a program").into_inner();
139139

140140
// Create a handler wired with plugin's diagnostic emitter, set it for global context.
141141
let handler = swc_core::common::errors::Handler::with_emitter(
@@ -161,7 +161,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream {
161161
};
162162

163163
// Take original plugin fn ident, then call it with interop'ed args
164-
let transformed_program = #ident(program, metadata);
164+
let transformed_program = swc_core::common::plugin::serialized::VersionedSerializable::new(#ident(program, metadata));
165165

166166
// Serialize transformed result, return back to the host.
167167
let serialized_result = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(

‎crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ impl PluginCommentsProxy {
5252
{
5353
#[cfg(target_arch = "wasm32")]
5454
{
55-
let serialized =
56-
swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(&value)
57-
.expect("Should able to serialize value");
55+
let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(
56+
&swc_common::plugin::serialized::VersionedSerializable::new(value),
57+
)
58+
.expect("Should able to serialize value");
5859
let (serialized_comment_ptr, serialized_comment_ptr_len) = serialized.as_ptr();
5960
unsafe {
6061
// We need to copy PluginCommentProxy's param for add_leading (Comment, or

‎crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ where
4444
F: FnOnce(u32) -> u32,
4545
{
4646
// Allocate AllocatedBytesPtr to get return value from the host
47-
let allocated_bytes_ptr = AllocatedBytesPtr(0, 0);
47+
let allocated_bytes_ptr =
48+
swc_common::plugin::serialized::VersionedSerializable::new(AllocatedBytesPtr(0, 0));
4849
let serialized_allocated_bytes_ptr = PluginSerializedBytes::try_serialize(&allocated_bytes_ptr)
4950
.expect("Should able to serialize AllocatedBytesPtr");
5051
let (serialized_allocated_bytes_raw_ptr, serialized_allocated_bytes_raw_ptr_size) =
@@ -69,6 +70,7 @@ where
6970
.expect("Should able to convert ptr length"),
7071
)
7172
.expect("Should able to deserialize AllocatedBytesPtr")
73+
.into_inner()
7274
})
7375
}
7476

@@ -98,5 +100,6 @@ where
98100
allocated_returned_value_ptr.1,
99101
)
100102
.expect("Returned value should be serializable")
103+
.into_inner()
101104
})
102105
}

‎crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl TransformPluginProgramMetadata {
7979
#[cfg(target_arch = "wasm32")]
8080
return read_returned_result_from_host(|serialized_ptr| unsafe {
8181
let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(
82-
&key.to_string(),
82+
&swc_common::plugin::serialized::VersionedSerializable::new(key.to_string()),
8383
)
8484
.expect("Should be serializable");
8585
let (key_ptr, key_ptr_len) = serialized.as_ptr();

‎crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ impl SourceMapper for PluginSourceMapProxy {
230230
ctxt: swc_common::SyntaxContext::empty(),
231231
};
232232

233-
let serialized =
234-
swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(&span)
235-
.expect("Should be serializable");
233+
let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(
234+
&swc_common::plugin::serialized::VersionedSerializable::new(span),
235+
)
236+
.expect("Should be serializable");
236237
let (ptr, len) = serialized.as_ptr();
237238

238239
let ret = __merge_spans_proxy(

‎crates/swc_plugin_runner/benches/ecma_invoke.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111

1212
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
1313
#[cfg(feature = "__rkyv")]
14-
use swc_common::plugin::serialized::PluginSerializedBytes;
14+
use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable};
1515
use swc_common::{
1616
collections::AHashMap, plugin::metadata::TransformPluginMetadataContext, FileName,
1717
FilePathMapping, Globals, Mark, SourceMap, GLOBALS,
@@ -62,6 +62,7 @@ fn bench_transform(b: &mut Bencher, plugin_dir: &Path) {
6262
)
6363
.unwrap();
6464

65+
let program = VersionedSerializable::new(program);
6566
let program_ser = PluginSerializedBytes::try_serialize(&program).unwrap();
6667

6768
let mut transform_plugin_executor =
@@ -82,7 +83,8 @@ fn bench_transform(b: &mut Bencher, plugin_dir: &Path) {
8283
)
8384
.unwrap();
8485

85-
let experimental_metadata: AHashMap<String, String> = AHashMap::default();
86+
let experimental_metadata: VersionedSerializable<AHashMap<String, String>> =
87+
VersionedSerializable::new(AHashMap::default());
8688
let _experimental_metadata =
8789
PluginSerializedBytes::try_serialize(&experimental_metadata)
8890
.expect("Should be a hashmap");

‎crates/swc_plugin_runner/src/imported_fn/comments.rs

+25-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use parking_lot::Mutex;
44
use swc_common::{
55
comments::{Comments, SingleThreadedComments},
6-
plugin::serialized::PluginSerializedBytes,
6+
plugin::serialized::{PluginSerializedBytes, VersionedSerializable},
77
BytePos,
88
};
99
use swc_plugin_proxy::COMMENTS;
@@ -142,7 +142,8 @@ pub fn add_leading_comment_proxy(env: FunctionEnvMut<CommentHostEnvironment>, by
142142
byte_pos,
143143
serialized
144144
.deserialize()
145-
.expect("Should be able to deserialize"),
145+
.expect("Should be able to deserialize")
146+
.into_inner(),
146147
);
147148
});
148149
}
@@ -154,7 +155,8 @@ pub fn add_leading_comments_proxy(env: FunctionEnvMut<CommentHostEnvironment>, b
154155
byte_pos,
155156
serialized
156157
.deserialize()
157-
.expect("Should be able to deserialize"),
158+
.expect("Should be able to deserialize")
159+
.into_inner(),
158160
);
159161
});
160162
}
@@ -191,9 +193,10 @@ pub fn take_leading_comments_proxy(
191193
|comments| {
192194
let leading_comments = comments.take_leading(BytePos(byte_pos));
193195
if let Some(leading_comments) = leading_comments {
194-
let serialized_leading_comments_vec_bytes =
195-
PluginSerializedBytes::try_serialize(&leading_comments)
196-
.expect("Should be serializable");
196+
let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize(
197+
&VersionedSerializable::new(leading_comments),
198+
)
199+
.expect("Should be serializable");
197200

198201
allocate_return_values_into_guest(
199202
memory,
@@ -236,9 +239,10 @@ pub fn get_leading_comments_proxy(
236239
|comments| {
237240
let leading_comments = comments.get_leading(BytePos(byte_pos));
238241
if let Some(leading_comments) = leading_comments {
239-
let serialized_leading_comments_vec_bytes =
240-
PluginSerializedBytes::try_serialize(&leading_comments)
241-
.expect("Should be serializable");
242+
let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize(
243+
&VersionedSerializable::new(leading_comments),
244+
)
245+
.expect("Should be serializable");
242246

243247
allocate_return_values_into_guest(
244248
memory,
@@ -263,7 +267,8 @@ pub fn add_trailing_comment_proxy(env: FunctionEnvMut<CommentHostEnvironment>, b
263267
byte_pos,
264268
serialized
265269
.deserialize()
266-
.expect("Should be able to deserialize"),
270+
.expect("Should be able to deserialize")
271+
.into_inner(),
267272
);
268273
});
269274
}
@@ -275,7 +280,8 @@ pub fn add_trailing_comments_proxy(env: FunctionEnvMut<CommentHostEnvironment>,
275280
byte_pos,
276281
serialized
277282
.deserialize()
278-
.expect("Should be able to deserialize"),
283+
.expect("Should be able to deserialize")
284+
.into_inner(),
279285
);
280286
});
281287
}
@@ -315,9 +321,10 @@ pub fn take_trailing_comments_proxy(
315321
|comments| {
316322
let trailing_comments = comments.take_trailing(BytePos(byte_pos));
317323
if let Some(leading_comments) = trailing_comments {
318-
let serialized_leading_comments_vec_bytes =
319-
PluginSerializedBytes::try_serialize(&leading_comments)
320-
.expect("Should be serializable");
324+
let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize(
325+
&VersionedSerializable::new(leading_comments),
326+
)
327+
.expect("Should be serializable");
321328

322329
allocate_return_values_into_guest(
323330
memory,
@@ -355,9 +362,10 @@ pub fn get_trailing_comments_proxy(
355362
|comments| {
356363
let trailing_comments = comments.get_trailing(BytePos(byte_pos));
357364
if let Some(leading_comments) = trailing_comments {
358-
let serialized_leading_comments_vec_bytes =
359-
PluginSerializedBytes::try_serialize(&leading_comments)
360-
.expect("Should be serializable");
365+
let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize(
366+
&VersionedSerializable::new(leading_comments),
367+
)
368+
.expect("Should be serializable");
361369

362370
allocate_return_values_into_guest(
363371
memory,

‎crates/swc_plugin_runner/src/imported_fn/handler.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ pub fn emit_diagnostics(
2626
let diagnostic = PluginSerializedBytes::deserialize::<Diagnostic>(&serialized)
2727
.expect("Should able to be deserialized into diagnostic");
2828

29-
let mut builder =
30-
swc_common::errors::DiagnosticBuilder::new_diagnostic(handler, diagnostic);
29+
let mut builder = swc_common::errors::DiagnosticBuilder::new_diagnostic(
30+
handler,
31+
diagnostic.into_inner(),
32+
);
3133
builder.emit();
3234
})
3335
}

‎crates/swc_plugin_runner/src/imported_fn/hygiene.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use swc_common::{
2-
hygiene::MutableMarkContext, plugin::serialized::PluginSerializedBytes, Mark, SyntaxContext,
2+
hygiene::MutableMarkContext,
3+
plugin::serialized::{PluginSerializedBytes, VersionedSerializable},
4+
Mark, SyntaxContext,
35
};
46
use wasmer::{AsStoreMut, FunctionEnvMut};
57

@@ -46,7 +48,11 @@ pub fn mark_is_descendant_of_proxy(
4648

4749
let return_value = self_mark.is_descendant_of(ancestor);
4850

49-
let context = MutableMarkContext(self_mark.as_u32(), 0, return_value as u32);
51+
let context = VersionedSerializable::new(MutableMarkContext(
52+
self_mark.as_u32(),
53+
0,
54+
return_value as u32,
55+
));
5056
let serialized_bytes =
5157
PluginSerializedBytes::try_serialize(&context).expect("Should be serializable");
5258

@@ -75,7 +81,8 @@ pub fn mark_least_ancestor_proxy(
7581

7682
let return_value = Mark::least_ancestor(a, b).as_u32();
7783

78-
let context = MutableMarkContext(a.as_u32(), b.as_u32(), return_value);
84+
let context =
85+
VersionedSerializable::new(MutableMarkContext(a.as_u32(), b.as_u32(), return_value));
7986
let serialized_bytes =
8087
PluginSerializedBytes::try_serialize(&context).expect("Should be serializable");
8188

@@ -109,7 +116,11 @@ pub fn syntax_context_remove_mark_proxy(
109116

110117
let return_value = self_mark.remove_mark();
111118

112-
let context = MutableMarkContext(self_mark.as_u32(), 0, return_value.as_u32());
119+
let context = VersionedSerializable::new(MutableMarkContext(
120+
self_mark.as_u32(),
121+
0,
122+
return_value.as_u32(),
123+
));
113124
let serialized_bytes =
114125
PluginSerializedBytes::try_serialize(&context).expect("Should be serializable");
115126

‎crates/swc_plugin_runner/src/imported_fn/metadata_context.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use parking_lot::Mutex;
44
use swc_common::plugin::{
55
metadata::{TransformPluginMetadataContext, TransformPluginMetadataContextKind},
6-
serialized::PluginSerializedBytes,
6+
serialized::{PluginSerializedBytes, VersionedSerializable},
77
};
88
use wasmer::{AsStoreMut, FunctionEnvMut, Memory, TypedFunction};
99

@@ -77,7 +77,8 @@ pub fn get_transform_plugin_config(
7777
let config = serde_json::to_string(config_value).ok();
7878
if let Some(config) = config {
7979
let serialized =
80-
PluginSerializedBytes::try_serialize(&config).expect("Should be serializable");
80+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(config))
81+
.expect("Should be serializable");
8182

8283
allocate_return_values_into_guest(
8384
memory,
@@ -109,10 +110,11 @@ pub fn get_transform_context(
109110
.as_ref()
110111
.expect("Alloc guest memory fn should be available, check initialization");
111112

112-
let value = env
113-
.data()
114-
.metadata_context
115-
.get(&TransformPluginMetadataContextKind::from(key));
113+
let value = VersionedSerializable::new(
114+
env.data()
115+
.metadata_context
116+
.get(&TransformPluginMetadataContextKind::from(key)),
117+
);
116118

117119
let serialized = PluginSerializedBytes::try_serialize(&value).expect("Should be serializable");
118120

@@ -145,7 +147,8 @@ pub fn get_experimental_transform_context(
145147
let context_key_buffer = env.data().mutable_context_key_buffer.lock().clone();
146148
let key: String = PluginSerializedBytes::from_slice(&context_key_buffer[..])
147149
.deserialize()
148-
.expect("Should able to deserialize");
150+
.expect("Should able to deserialize")
151+
.into_inner();
149152

150153
let value = env
151154
.data()
@@ -155,8 +158,8 @@ pub fn get_experimental_transform_context(
155158
.map(|v| v.to_string());
156159

157160
if let Some(value) = value {
158-
let serialized =
159-
PluginSerializedBytes::try_serialize(&value).expect("Should be serializable");
161+
let serialized = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(value))
162+
.expect("Should be serializable");
160163

161164
allocate_return_values_into_guest(
162165
memory,
@@ -187,7 +190,8 @@ pub fn get_raw_experiemtal_transform_context(
187190
.as_ref()
188191
.expect("Alloc guest memory fn should be available, check initialization");
189192

190-
let experimental_context = env.data().metadata_context.experimental.clone();
193+
let experimental_context =
194+
VersionedSerializable::new(env.data().metadata_context.experimental.clone());
191195
let serialized_experimental_context_bytes =
192196
PluginSerializedBytes::try_serialize(&experimental_context)
193197
.expect("Should be serializable");

‎crates/swc_plugin_runner/src/imported_fn/source_map.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::Arc;
22

33
use parking_lot::Mutex;
44
use swc_common::{
5-
plugin::serialized::PluginSerializedBytes,
5+
plugin::serialized::{PluginSerializedBytes, VersionedSerializable},
66
source_map::{PartialFileLines, PartialLoc},
77
BytePos, SourceMap, SourceMapper, Span, SyntaxContext,
88
};
@@ -58,7 +58,7 @@ pub fn lookup_char_pos_proxy(
5858
.expect("Alloc guest memory fn should be available, check initialization");
5959

6060
let original_loc = (env.data().source_map.lock()).lookup_char_pos(BytePos(byte_pos));
61-
let ret = PartialLoc {
61+
let ret = VersionedSerializable::new(PartialLoc {
6262
source_file: if should_include_source_file == 0 {
6363
None
6464
} else {
@@ -67,7 +67,7 @@ pub fn lookup_char_pos_proxy(
6767
line: original_loc.line,
6868
col: original_loc.col.0,
6969
col_display: original_loc.col_display,
70-
};
70+
});
7171

7272
let serialized_loc_bytes =
7373
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
@@ -118,6 +118,7 @@ pub fn merge_spans_proxy(
118118

119119
let ret = (env.data().source_map.lock()).merge_spans(sp_lhs, sp_rhs);
120120
if let Some(span) = ret {
121+
let span = VersionedSerializable::new(span);
121122
let serialized_bytes =
122123
PluginSerializedBytes::try_serialize(&span).expect("Should be serializable");
123124
write_into_memory_view(
@@ -169,7 +170,8 @@ pub fn span_to_lines_proxy(
169170
});
170171

171172
let serialized_loc_bytes =
172-
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
173+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret))
174+
.expect("Should be serializable");
173175

174176
allocate_return_values_into_guest(
175177
memory,
@@ -201,7 +203,8 @@ pub fn lookup_byte_offset_proxy(
201203
let ret = (env.data().source_map.lock()).lookup_byte_offset(byte_pos);
202204

203205
let serialized_loc_bytes =
204-
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
206+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret))
207+
.expect("Should be serializable");
205208

206209
allocate_return_values_into_guest(
207210
memory,
@@ -238,7 +241,8 @@ pub fn span_to_string_proxy(
238241
};
239242
let ret = (env.data().source_map.lock()).span_to_string(span);
240243
let serialized_loc_bytes =
241-
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
244+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret))
245+
.expect("Should be serializable");
242246

243247
allocate_return_values_into_guest(
244248
memory,
@@ -275,7 +279,8 @@ pub fn span_to_filename_proxy(
275279
};
276280
let ret = (env.data().source_map.lock()).span_to_filename(span);
277281
let serialized_loc_bytes =
278-
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
282+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret))
283+
.expect("Should be serializable");
279284

280285
allocate_return_values_into_guest(
281286
memory,
@@ -312,7 +317,8 @@ pub fn span_to_source_proxy(
312317
};
313318
let ret = (*env.data().source_map.lock()).span_to_snippet(span);
314319
let serialized_loc_bytes =
315-
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
320+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret))
321+
.expect("Should be serializable");
316322

317323
allocate_return_values_into_guest(
318324
memory,

‎crates/swc_plugin_runner/src/load_plugin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ pub fn load_plugin(
175175

176176
let diag_result: PluginCorePkgDiagnostics =
177177
PluginSerializedBytes::from_slice(&(&(*diagnostics_buffer.lock()))[..])
178-
.deserialize()?;
178+
.deserialize()?
179+
.into_inner();
179180

180181
Ok((instance, transform_result, diag_result, wasi_env))
181182
}

‎crates/swc_plugin_runner/src/memory_interop.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use swc_common::plugin::serialized::PluginSerializedBytes;
1+
use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable};
22
use swc_plugin_proxy::AllocatedBytesPtr;
33
use wasmer::{Memory, MemoryView, StoreMut, TypedFunction, WasmPtr};
44

@@ -78,7 +78,8 @@ pub fn allocate_return_values_into_guest(
7878
let (allocated_ptr, allocated_ptr_len) =
7979
write_into_memory_view(memory, store, serialized_bytes, |_, _| guest_memory_ptr);
8080

81-
let allocated_bytes = AllocatedBytesPtr(allocated_ptr, allocated_ptr_len);
81+
let allocated_bytes =
82+
VersionedSerializable::new(AllocatedBytesPtr(allocated_ptr, allocated_ptr_len));
8283
// Retuning (allocated_ptr, len) into caller (plugin)
8384
let comment_ptr_serialized =
8485
PluginSerializedBytes::try_serialize(&allocated_bytes).expect("Should be serializable");

‎crates/swc_plugin_runner/src/transform_executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl TransformExecutor {
153153
if returned_ptr_result == 0 {
154154
Ok(ret)
155155
} else {
156-
let err: PluginError = ret.deserialize()?;
156+
let err: PluginError = ret.deserialize()?.into_inner();
157157
match err {
158158
PluginError::SizeInteropFailure(msg) => Err(anyhow!(
159159
"Failed to convert pointer size to calculate: {}",

‎crates/swc_plugin_runner/tests/css_rkyv.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ fn invoke(input: PathBuf) -> Result<(), Error> {
7373
let parsed: Stylesheet =
7474
swc_css_parser::parse_file(&fm, Default::default(), &mut vec![]).unwrap();
7575

76-
let program = PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable");
76+
let program = PluginSerializedBytes::try_serialize(
77+
&swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()),
78+
)
79+
.expect("Should serializable");
7780
let experimental_metadata: AHashMap<String, String> = [
7881
(
7982
"TestExperimental".to_string(),
@@ -105,7 +108,8 @@ fn invoke(input: PathBuf) -> Result<(), Error> {
105108

106109
let program: Stylesheet = program_bytes
107110
.deserialize()
108-
.expect("Should able to deserialize");
111+
.expect("Should able to deserialize")
112+
.into_inner();
109113

110114
assert_eq!(parsed, program);
111115

@@ -120,8 +124,10 @@ fn invoke(input: PathBuf) -> Result<(), Error> {
120124
let parsed: Stylesheet =
121125
swc_css_parser::parse_file(&fm, Default::default(), &mut vec![]).unwrap();
122126

123-
let mut serialized_program =
124-
PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable");
127+
let mut serialized_program = PluginSerializedBytes::try_serialize(
128+
&swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()),
129+
)
130+
.expect("Should serializable");
125131

126132
let experimental_metadata: AHashMap<String, String> = [
127133
(
@@ -170,7 +176,8 @@ fn invoke(input: PathBuf) -> Result<(), Error> {
170176

171177
let program: Stylesheet = serialized_program
172178
.deserialize()
173-
.expect("Should able to deserialize");
179+
.expect("Should able to deserialize")
180+
.into_inner();
174181

175182
assert_eq!(parsed, program);
176183

‎crates/swc_plugin_runner/tests/ecma_integration.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ impl Visit for TestVisitor {
7474
#[cfg(feature = "__rkyv")]
7575
#[test]
7676
fn internal() -> Result<(), Error> {
77+
use swc_common::plugin::serialized::VersionedSerializable;
78+
7779
let path = build_plugin(
7880
&PathBuf::from(env::var("CARGO_MANIFEST_DIR")?)
7981
.join("tests")
@@ -94,7 +96,8 @@ fn internal() -> Result<(), Error> {
9496
)
9597
.unwrap();
9698

97-
let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable");
99+
let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program))
100+
.expect("Should serializable");
98101
let experimental_metadata: AHashMap<String, String> = [
99102
(
100103
"TestExperimental".to_string(),
@@ -130,7 +133,8 @@ fn internal() -> Result<(), Error> {
130133

131134
let program: Program = program_bytes
132135
.deserialize()
133-
.expect("Should able to deserialize");
136+
.expect("Should able to deserialize")
137+
.into_inner();
134138
let mut visitor = TestVisitor {
135139
plugin_transform_found: false,
136140
};
@@ -156,7 +160,8 @@ fn internal() -> Result<(), Error> {
156160
)
157161
.unwrap();
158162

159-
let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable");
163+
let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program))
164+
.expect("Should serializable");
160165
let experimental_metadata: AHashMap<String, String> = [
161166
(
162167
"TestExperimental".to_string(),
@@ -207,7 +212,8 @@ fn internal() -> Result<(), Error> {
207212
.unwrap();
208213

209214
let mut serialized_program =
210-
PluginSerializedBytes::try_serialize(&program).expect("Should serializable");
215+
PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program))
216+
.expect("Should serializable");
211217
let cache: Lazy<PluginModuleCache> = Lazy::new(PluginModuleCache::new);
212218

213219
let experimental_metadata: AHashMap<String, String> = [
@@ -257,7 +263,8 @@ fn internal() -> Result<(), Error> {
257263

258264
let program: Program = serialized_program
259265
.deserialize()
260-
.expect("Should able to deserialize");
266+
.expect("Should able to deserialize")
267+
.into_inner();
261268
let mut visitor = TestVisitor {
262269
plugin_transform_found: false,
263270
};

‎crates/swc_plugin_runner/tests/ecma_rkyv.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ fn internal(input: PathBuf) -> Result<(), Error> {
8383
)
8484
.unwrap();
8585

86-
let program = PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable");
86+
let program = PluginSerializedBytes::try_serialize(
87+
&swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()),
88+
)
89+
.expect("Should serializable");
8790
let experimental_metadata: AHashMap<String, String> = [
8891
(
8992
"TestExperimental".to_string(),
@@ -117,7 +120,8 @@ fn internal(input: PathBuf) -> Result<(), Error> {
117120

118121
let program: Program = program_bytes
119122
.deserialize()
120-
.expect("Should able to deserialize");
123+
.expect("Should able to deserialize")
124+
.into_inner();
121125

122126
assert_eq!(parsed, program);
123127

@@ -138,8 +142,10 @@ fn internal(input: PathBuf) -> Result<(), Error> {
138142
)
139143
.unwrap();
140144

141-
let mut serialized_program =
142-
PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable");
145+
let mut serialized_program = PluginSerializedBytes::try_serialize(
146+
&swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()),
147+
)
148+
.expect("Should serializable");
143149

144150
let experimental_metadata: AHashMap<String, String> = [
145151
(
@@ -188,7 +194,8 @@ fn internal(input: PathBuf) -> Result<(), Error> {
188194

189195
let program: Program = serialized_program
190196
.deserialize()
191-
.expect("Should able to deserialize");
197+
.expect("Should able to deserialize")
198+
.into_inner();
192199

193200
assert_eq!(parsed, program);
194201

‎crates/swc_plugin_runner/tests/issues.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ impl Visit for TestVisitor {
7373
#[cfg(feature = "__rkyv")]
7474
#[test]
7575
fn issue_6404() -> Result<(), Error> {
76+
use swc_common::plugin::serialized::VersionedSerializable;
77+
7678
let plugin_path = build_plugin(
7779
&PathBuf::from(env::var("CARGO_MANIFEST_DIR")?)
7880
.join("tests")
@@ -98,7 +100,8 @@ fn issue_6404() -> Result<(), Error> {
98100
)
99101
.unwrap();
100102

101-
let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable");
103+
let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program))
104+
.expect("Should serializable");
102105
let experimental_metadata: AHashMap<String, String> = [
103106
(
104107
"TestExperimental".to_string(),
@@ -134,7 +137,8 @@ fn issue_6404() -> Result<(), Error> {
134137

135138
let _: Program = program_bytes
136139
.deserialize()
137-
.expect("Should able to deserialize");
140+
.expect("Should able to deserialize")
141+
.into_inner();
138142

139143
Ok(())
140144
})

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@napi-rs/cli": "^2.14.1",
9494
"@swc/core": "=1.2.220",
9595
"@swc/helpers": "^0.5.0",
96-
"@swc/plugin-jest": "1.5.59",
96+
"@swc/plugin-jest": "latest",
9797
"@taplo/cli": "^0.3.2",
9898
"@types/jest": "^28.1.4",
9999
"@types/node": "^14.14.41",

‎yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,7 @@ __metadata:
24652465
"@swc/core-win32-ia32-msvc": 1.2.146
24662466
"@swc/core-win32-x64-msvc": 1.2.146
24672467
"@swc/helpers": ^0.5.0
2468-
"@swc/plugin-jest": 1.5.59
2468+
"@swc/plugin-jest": latest
24692469
"@taplo/cli": ^0.3.2
24702470
"@types/jest": ^28.1.4
24712471
"@types/node": ^14.14.41
@@ -2541,10 +2541,10 @@ __metadata:
25412541
languageName: node
25422542
linkType: hard
25432543

2544-
"@swc/plugin-jest@npm:1.5.59":
2545-
version: 1.5.59
2546-
resolution: "@swc/plugin-jest@npm:1.5.59"
2547-
checksum: cc94723c12a6c9122a1ee3367fc55623858001435e3efaac009b8c0e1a125f97a9ac0ec773eaeb20e65a6b877204f4ea865f5fa70af1820d1ca869203f6e7561
2544+
"@swc/plugin-jest@npm:latest":
2545+
version: 1.5.62
2546+
resolution: "@swc/plugin-jest@npm:1.5.62"
2547+
checksum: 722a44b0c83ab89d355781bebb987f200e503c960733c62fae5f91b6bd717b25330819d93507df8cf87695d71f318f83e566f102aec9c23f41794498e902b817
25482548
languageName: node
25492549
linkType: hard
25502550

1 commit comments

Comments
 (1)

github-actions[bot] commented on May 15, 2023

@github-actions[bot]

Benchmark

Benchmark suite Current: bba1fad Previous: cad18fa Ratio
es/full/bugs-1 255070 ns/iter (± 5126) 304392 ns/iter (± 10984) 0.84
es/full/minify/libraries/antd 1284193998 ns/iter (± 20913473) 1676505868 ns/iter (± 25119076) 0.77
es/full/minify/libraries/d3 259174361 ns/iter (± 7593848) 315208200 ns/iter (± 5180031) 0.82
es/full/minify/libraries/echarts 1023820184 ns/iter (± 16726767) 1268978308 ns/iter (± 10157127) 0.81
es/full/minify/libraries/jquery 78514084 ns/iter (± 278090) 92848319 ns/iter (± 813778) 0.85
es/full/minify/libraries/lodash 88771556 ns/iter (± 710417) 107466006 ns/iter (± 1243746) 0.83
es/full/minify/libraries/moment 46123745 ns/iter (± 416089) 53626932 ns/iter (± 275866) 0.86
es/full/minify/libraries/react 16497023 ns/iter (± 72838) 19495309 ns/iter (± 160935) 0.85
es/full/minify/libraries/terser 207858862 ns/iter (± 2908454) 250549052 ns/iter (± 2849593) 0.83
es/full/minify/libraries/three 365030575 ns/iter (± 3352985) 468960328 ns/iter (± 11320174) 0.78
es/full/minify/libraries/typescript 2550999489 ns/iter (± 24026023) 3146500634 ns/iter (± 21885989) 0.81
es/full/minify/libraries/victory 553006804 ns/iter (± 11172866) 708322675 ns/iter (± 15186115) 0.78
es/full/minify/libraries/vue 110412705 ns/iter (± 802921) 134103914 ns/iter (± 1015625) 0.82
es/full/codegen/es3 31172 ns/iter (± 66) 33780 ns/iter (± 105) 0.92
es/full/codegen/es5 31258 ns/iter (± 55) 33920 ns/iter (± 68) 0.92
es/full/codegen/es2015 31150 ns/iter (± 82) 33867 ns/iter (± 63) 0.92
es/full/codegen/es2016 31188 ns/iter (± 83) 33855 ns/iter (± 47) 0.92
es/full/codegen/es2017 31147 ns/iter (± 73) 33906 ns/iter (± 52) 0.92
es/full/codegen/es2018 31169 ns/iter (± 84) 33906 ns/iter (± 81) 0.92
es/full/codegen/es2019 31126 ns/iter (± 80) 33827 ns/iter (± 96) 0.92
es/full/codegen/es2020 31286 ns/iter (± 120) 33794 ns/iter (± 368) 0.93
es/full/all/es3 155084214 ns/iter (± 634133) 184333000 ns/iter (± 3246168) 0.84
es/full/all/es5 147847699 ns/iter (± 707731) 178810255 ns/iter (± 3376832) 0.83
es/full/all/es2015 110344074 ns/iter (± 785617) 139519704 ns/iter (± 2903594) 0.79
es/full/all/es2016 109567495 ns/iter (± 509145) 136987240 ns/iter (± 1676126) 0.80
es/full/all/es2017 108893523 ns/iter (± 557906) 132956349 ns/iter (± 2401595) 0.82
es/full/all/es2018 106573752 ns/iter (± 707219) 130416593 ns/iter (± 2272206) 0.82
es/full/all/es2019 106187291 ns/iter (± 1002460) 129184745 ns/iter (± 1747641) 0.82
es/full/all/es2020 102292956 ns/iter (± 1795840) 118431299 ns/iter (± 1670536) 0.86
es/full/parser 454295 ns/iter (± 5987) 508813 ns/iter (± 8509) 0.89
es/full/base/fixer 18060 ns/iter (± 103) 22818 ns/iter (± 83) 0.79
es/full/base/resolver_and_hygiene 76425 ns/iter (± 154) 86186 ns/iter (± 123) 0.89
serialization of serde 118 ns/iter (± 0) 121 ns/iter (± 0) 0.98
css/minify/libraries/bootstrap 23646279 ns/iter (± 176018) 27533558 ns/iter (± 105366) 0.86
css/visitor/compare/clone 1658924 ns/iter (± 5832) 2149047 ns/iter (± 5997) 0.77
css/visitor/compare/visit_mut_span 1799448 ns/iter (± 5802) 2334896 ns/iter (± 6946) 0.77
css/visitor/compare/visit_mut_span_panic 1863438 ns/iter (± 11411) 2398876 ns/iter (± 6095) 0.78
css/visitor/compare/fold_span 2573728 ns/iter (± 9088) 3123687 ns/iter (± 16481) 0.82
css/visitor/compare/fold_span_panic 2757838 ns/iter (± 12625) 3273450 ns/iter (± 14305) 0.84
css/lexer/bootstrap_5_1_3 4510585 ns/iter (± 4479) 5220225 ns/iter (± 23808) 0.86
css/lexer/foundation_6_7_4 3845095 ns/iter (± 3337) 4395261 ns/iter (± 11074) 0.87
css/lexer/tailwind_3_1_1 719140 ns/iter (± 725) 835463 ns/iter (± 2106) 0.86
css/parser/bootstrap_5_1_3 18385166 ns/iter (± 91426) 21057314 ns/iter (± 149916) 0.87
css/parser/foundation_6_7_4 14753848 ns/iter (± 61169) 16693119 ns/iter (± 81825) 0.88
css/parser/tailwind_3_1_1 2802331 ns/iter (± 2098) 3223065 ns/iter (± 5499) 0.87
es/codegen/colors 329705 ns/iter (± 185743) 327552 ns/iter (± 184975) 1.01
es/codegen/large 1340625 ns/iter (± 736180) 1112312 ns/iter (± 558802) 1.21
es/codegen/with-parser/colors 42535 ns/iter (± 567) 49046 ns/iter (± 178) 0.87
es/codegen/with-parser/large 474349 ns/iter (± 750) 531607 ns/iter (± 1928) 0.89
es/minify/libraries/antd 1146526335 ns/iter (± 20048746) 1473285597 ns/iter (± 22272627) 0.78
es/minify/libraries/d3 225041611 ns/iter (± 3265842) 263110840 ns/iter (± 3871647) 0.86
es/minify/libraries/echarts 909950484 ns/iter (± 11956656) 1124520478 ns/iter (± 25651679) 0.81
es/minify/libraries/jquery 70035095 ns/iter (± 143569) 83842950 ns/iter (± 1603526) 0.84
es/minify/libraries/lodash 80869733 ns/iter (± 515472) 99631817 ns/iter (± 851420) 0.81
es/minify/libraries/moment 40528753 ns/iter (± 155287) 47595528 ns/iter (± 581206) 0.85
es/minify/libraries/react 14966169 ns/iter (± 103416) 17710603 ns/iter (± 215552) 0.85
es/minify/libraries/terser 184831155 ns/iter (± 2045394) 221339513 ns/iter (± 4835437) 0.84
es/minify/libraries/three 315877511 ns/iter (± 7844865) 380403194 ns/iter (± 7878812) 0.83
es/minify/libraries/typescript 2221320827 ns/iter (± 13225107) 2716428880 ns/iter (± 27322095) 0.82
es/minify/libraries/victory 481254983 ns/iter (± 5674515) 589953685 ns/iter (± 13027471) 0.82
es/minify/libraries/vue 101043538 ns/iter (± 2008629) 119791364 ns/iter (± 1175509) 0.84
es/visitor/compare/clone 2000101 ns/iter (± 11474) 2336688 ns/iter (± 19047) 0.86
es/visitor/compare/visit_mut_span 2349314 ns/iter (± 4633) 2720546 ns/iter (± 4356) 0.86
es/visitor/compare/visit_mut_span_panic 2376198 ns/iter (± 9690) 2768894 ns/iter (± 11391) 0.86
es/visitor/compare/fold_span 3416955 ns/iter (± 6575) 3820787 ns/iter (± 7332) 0.89
es/visitor/compare/fold_span_panic 3557127 ns/iter (± 20651) 3942338 ns/iter (± 16054) 0.90
es/lexer/colors 11481 ns/iter (± 34) 12996 ns/iter (± 48) 0.88
es/lexer/angular 5611008 ns/iter (± 2410) 6368000 ns/iter (± 14538) 0.88
es/lexer/backbone 726955 ns/iter (± 370) 784772 ns/iter (± 1114) 0.93
es/lexer/jquery 4093159 ns/iter (± 2514) 4419205 ns/iter (± 3651) 0.93
es/lexer/jquery mobile 6344132 ns/iter (± 26027) 6912720 ns/iter (± 9315) 0.92
es/lexer/mootools 3259476 ns/iter (± 3123) 3470338 ns/iter (± 2237) 0.94
es/lexer/underscore 608199 ns/iter (± 2133) 648943 ns/iter (± 908) 0.94
es/lexer/three 19577265 ns/iter (± 22384) 20938750 ns/iter (± 16924) 0.93
es/lexer/yui 3590398 ns/iter (± 3895) 3869349 ns/iter (± 7133) 0.93
es/parser/colors 25312 ns/iter (± 33) 28657 ns/iter (± 73) 0.88
es/parser/angular 13280711 ns/iter (± 139078) 14876409 ns/iter (± 131776) 0.89
es/parser/backbone 1933982 ns/iter (± 8120) 2153551 ns/iter (± 11796) 0.90
es/parser/jquery 10690869 ns/iter (± 158439) 11733237 ns/iter (± 88948) 0.91
es/parser/jquery mobile 16634100 ns/iter (± 194104) 18596734 ns/iter (± 327318) 0.89
es/parser/mootools 8131956 ns/iter (± 40163) 8856553 ns/iter (± 30884) 0.92
es/parser/underscore 1660243 ns/iter (± 10207) 1819625 ns/iter (± 9251) 0.91
es/parser/three 48044537 ns/iter (± 245441) 53861043 ns/iter (± 862547) 0.89
es/parser/yui 8080525 ns/iter (± 63652) 9059696 ns/iter (± 42716) 0.89
es/preset-env/usage/builtin_type 148356 ns/iter (± 39660) 140398 ns/iter (± 34122) 1.06
es/preset-env/usage/property 15929 ns/iter (± 85) 20172 ns/iter (± 159) 0.79
es/resolver/typescript 92581401 ns/iter (± 1151625) 122249862 ns/iter (± 2960412) 0.76
es/fixer/typescript 67740210 ns/iter (± 646551) 86582820 ns/iter (± 2309090) 0.78
es/hygiene/typescript 137156382 ns/iter (± 1551353) 187281886 ns/iter (± 1438417) 0.73
es/resolver_with_hygiene/typescript 243180807 ns/iter (± 3138938) 339308290 ns/iter (± 1980154) 0.72
es/visitor/base-perf/module_clone 61862 ns/iter (± 277) 81310 ns/iter (± 510) 0.76
es/visitor/base-perf/fold_empty 65123 ns/iter (± 365) 91575 ns/iter (± 300) 0.71
es/visitor/base-perf/fold_noop_impl_all 65874 ns/iter (± 413) 92022 ns/iter (± 432) 0.72
es/visitor/base-perf/fold_noop_impl_vec 65545 ns/iter (± 103) 92481 ns/iter (± 643) 0.71
es/visitor/base-perf/boxing_boxed_clone 51 ns/iter (± 0) 56 ns/iter (± 0) 0.91
es/visitor/base-perf/boxing_unboxed_clone 36 ns/iter (± 0) 41 ns/iter (± 0) 0.88
es/visitor/base-perf/boxing_boxed 107 ns/iter (± 0) 101 ns/iter (± 0) 1.06
es/visitor/base-perf/boxing_unboxed 77 ns/iter (± 0) 78 ns/iter (± 0) 0.99
es/visitor/base-perf/visit_empty 0 ns/iter (± 0)
es/visitor/base-perf/visit_contains_this 2679 ns/iter (± 8) 3510 ns/iter (± 37) 0.76
es/base/parallel/resolver/typescript 3896203858 ns/iter (± 327007318) 6367920777 ns/iter (± 665384861) 0.61
es/base/parallel/hygiene/typescript 1466634410 ns/iter (± 18423068) 2192405186 ns/iter (± 26225131) 0.67
misc/visitors/time-complexity/time 5 108 ns/iter (± 1) 105 ns/iter (± 0) 1.03
misc/visitors/time-complexity/time 10 284 ns/iter (± 0) 321 ns/iter (± 0) 0.88
misc/visitors/time-complexity/time 15 539 ns/iter (± 0) 651 ns/iter (± 4) 0.83
misc/visitors/time-complexity/time 20 1140 ns/iter (± 2) 1185 ns/iter (± 1) 0.96
misc/visitors/time-complexity/time 40 3912 ns/iter (± 326) 6286 ns/iter (± 14) 0.62
misc/visitors/time-complexity/time 60 7731 ns/iter (± 8) 15525 ns/iter (± 39) 0.50
es/full-target/es2016 227624 ns/iter (± 676) 253067 ns/iter (± 1822) 0.90
es/full-target/es2017 217412 ns/iter (± 832) 246683 ns/iter (± 1024) 0.88
es/full-target/es2018 207108 ns/iter (± 764) 235408 ns/iter (± 521) 0.88
es2020_nullish_coalescing 70026 ns/iter (± 450) 93821 ns/iter (± 659) 0.75
es2020_optional_chaining 96962 ns/iter (± 908) 125099 ns/iter (± 432) 0.78
es2022_class_properties 118369 ns/iter (± 292) 149451 ns/iter (± 466) 0.79
es2018_object_rest_spread 74908 ns/iter (± 204) 96624 ns/iter (± 397) 0.78
es2019_optional_catch_binding 64439 ns/iter (± 505) 86632 ns/iter (± 419) 0.74
es2017_async_to_generator 64800 ns/iter (± 471) 86800 ns/iter (± 183) 0.75
es2016_exponentiation 68879 ns/iter (± 185) 91063 ns/iter (± 268) 0.76
es2015_arrow 68589 ns/iter (± 211) 94605 ns/iter (± 254) 0.73
es2015_block_scoped_fn 68224 ns/iter (± 190) 93204 ns/iter (± 372) 0.73
es2015_block_scoping 120184 ns/iter (± 454) 170811 ns/iter (± 510) 0.70

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.