From 4da690bbf9b742e865e56099cafb9ebc621e1d5e Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Fri, 12 May 2023 05:20:15 +0000 Subject: [PATCH 1/3] feat(plugin): add versioned wrapper struct --- crates/swc/src/plugin.rs | 18 ++++--- crates/swc_common/src/plugin/serialized.rs | 50 ++++++++----------- crates/swc_common/src/syntax_pos/hygiene.rs | 15 ++++-- crates/swc_plugin_macro/src/lib.rs | 10 ++-- .../src/comments/plugin_comments_proxy.rs | 7 +-- .../read_returned_result_from_host.rs | 5 +- .../src/metadata/transform_plugin_metadata.rs | 2 +- .../src/source_map/plugin_source_map_proxy.rs | 7 +-- .../swc_plugin_runner/benches/ecma_invoke.rs | 6 ++- .../src/imported_fn/comments.rs | 42 +++++++++------- .../src/imported_fn/handler.rs | 6 ++- .../src/imported_fn/hygiene.rs | 19 +++++-- .../src/imported_fn/metadata_context.rs | 24 +++++---- .../src/imported_fn/source_map.rs | 22 +++++--- crates/swc_plugin_runner/src/load_plugin.rs | 3 +- .../swc_plugin_runner/src/memory_interop.rs | 5 +- .../src/transform_executor.rs | 2 +- crates/swc_plugin_runner/tests/css_rkyv.rs | 17 +++++-- .../tests/ecma_integration.rs | 17 +++++-- crates/swc_plugin_runner/tests/ecma_rkyv.rs | 17 +++++-- crates/swc_plugin_runner/tests/issues.rs | 8 ++- 21 files changed, 185 insertions(+), 117 deletions(-) diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index cc69280fba7a..319d8e1664de 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -94,7 +94,8 @@ impl RustPlugins { }, || { let span = tracing::span!(tracing::Level::INFO, "serialize_program").entered(); - let mut serialized_program = PluginSerializedBytes::try_serialize(&n)?; + let program = swc_common::plugin::serialized::VersionedSerializable::new(n); + let mut serialized = PluginSerializedBytes::try_serialize(&program)?; drop(span); // Run plugin transformation against current program. @@ -137,9 +138,9 @@ impl RustPlugins { ) .entered(); - serialized_program = transform_plugin_executor + serialized = transform_plugin_executor .transform( - &serialized_program, + &serialized, self.unresolved_mark, should_enable_comments_proxy, ) @@ -156,7 +157,7 @@ impl RustPlugins { // Plugin transformation is done. Deserialize transformed bytes back // into Program - serialized_program.deserialize() + serialized.deserialize().map(|v| v.into_inner()) }, ) } @@ -179,7 +180,8 @@ impl RustPlugins { inner: self.comments.clone(), }, || { - let mut serialized_program = PluginSerializedBytes::try_serialize(&n)?; + let program = swc_common::plugin::serialized::VersionedSerializable::new(n); + let mut serialized = PluginSerializedBytes::try_serialize(&program)?; if let Some(plugins) = &mut self.plugins { for p in plugins.drain(..) { @@ -192,9 +194,9 @@ impl RustPlugins { Some(p.1), )?; - serialized_program = transform_plugin_executor + serialized = transform_plugin_executor .transform( - &serialized_program, + &serialized, self.unresolved_mark, should_enable_comments_proxy, ) @@ -204,7 +206,7 @@ impl RustPlugins { } } - serialized_program.deserialize() + serialized_program.deserialize().map(|v| v.into_inner()) }, ) } diff --git a/crates/swc_common/src/plugin/serialized.rs b/crates/swc_common/src/plugin/serialized.rs index 7b905092161c..50587218003c 100644 --- a/crates/swc_common/src/plugin/serialized.rs +++ b/crates/swc_common/src/plugin/serialized.rs @@ -59,7 +59,7 @@ impl PluginSerializedBytes { * to implement TryFrom trait */ #[tracing::instrument(level = "info", skip_all)] - pub fn try_serialize(t: &W) -> Result + pub fn try_serialize(t: &VersionedSerializable) -> Result where W: rkyv::Serialize>, { @@ -99,14 +99,14 @@ impl PluginSerializedBytes { } #[tracing::instrument(level = "info", skip_all)] - pub fn deserialize(&self) -> Result + pub fn deserialize(&self) -> Result, Error> where W: rkyv::Archive, W::Archived: rkyv::Deserialize, { use anyhow::Context; - let archived = unsafe { rkyv::archived_root::(&self.field[..]) }; + let archived = unsafe { rkyv::archived_root::>(&self.field[..]) }; archived .deserialize(&mut rkyv::de::deserializers::SharedDeserializeMap::new()) @@ -124,7 +124,7 @@ impl PluginSerializedBytes { pub unsafe fn deserialize_from_ptr( raw_allocated_ptr: *const u8, raw_allocated_ptr_len: u32, -) -> Result +) -> Result, Error> where W: rkyv::Archive, W::Archived: rkyv::Deserialize, @@ -135,37 +135,30 @@ where serialized.deserialize() } -/// Deserialize `Fallible` struct from raw ptr. This is similar to -/// `deserialize_from_ptr` but for the struct requires bounds to the -/// SharedSerializeRegistry which cannot be Infallible. Internally this does -/// not call deserialize with Infallible deserializer, use -/// SharedDeserializeMap instead. -#[tracing::instrument(level = "info", skip_all)] -pub fn deserialize_from_ptr_into_fallible( - raw_allocated_ptr: *const u8, - raw_allocated_ptr_len: u32, -) -> Result -where - W: rkyv::Archive, - W::Archived: rkyv::Deserialize, -{ - let serialized = - PluginSerializedBytes::from_raw_ptr(raw_allocated_ptr, raw_allocated_ptr_len as usize); - - serialized.deserialize() -} - -/* /// A wrapper type for the structures to be passed into plugins /// serializes the contained value out-of-line so that newer /// versions can be viewed as the older version. /// -#[derive(Archive, Deserialize, Serialize)] -pub struct VersionedSerializable(#[with(AsBox)] T); +/// First field indicate version of struct type (schema). Any consumers like +/// swc_plugin_macro can use this to validate compatiblility before attempt to +/// serialize. +#[cfg_attr( + feature = "__plugin", + derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) +)] +#[repr(transparent)] +#[cfg_attr(feature = "__plugin", archive(check_bytes))] +#[cfg_attr(feature = "__plugin", archive_attr(repr(transparent)))] +#[derive(Debug)] +pub struct VersionedSerializable( + // [NOTE]: https://github.com/rkyv/rkyv/issues/373#issuecomment-1546360897 + //#[cfg_attr(feature = "__plugin", with(rkyv::with::AsBox))] + pub T, +); impl VersionedSerializable { pub fn new(value: T) -> Self { - VersionedSerializable(value) + Self(value) } pub fn inner(&self) -> &T { @@ -176,4 +169,3 @@ impl VersionedSerializable { self.0 } } - */ diff --git a/crates/swc_common/src/syntax_pos/hygiene.rs b/crates/swc_common/src/syntax_pos/hygiene.rs index 2b637b35ad9c..78b350a88897 100644 --- a/crates/swc_common/src/syntax_pos/hygiene.rs +++ b/crates/swc_common/src/syntax_pos/hygiene.rs @@ -181,8 +181,10 @@ impl Mark { pub fn is_descendant_of(mut self, ancestor: Mark) -> bool { // This code path executed inside of the guest memory context. // In here, preallocate memory for the context. + + use crate::plugin::serialized::VersionedSerializable; let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize( - &MutableMarkContext(0, 0, 0), + &VersionedSerializable::new(MutableMarkContext(0, 0, 0)), ) .expect("Should be serializable"); let (ptr, len) = serialized.as_ptr(); @@ -200,6 +202,7 @@ impl Mark { len.try_into().expect("Should able to convert ptr length"), ) .expect("Should able to deserialize") + .into_inner() }; self = Mark::from_u32(context.0); @@ -222,8 +225,10 @@ impl Mark { #[allow(unused_mut, unused_assignments)] #[cfg(all(feature = "__plugin_mode", target_arch = "wasm32"))] pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark { + use crate::plugin::serialized::VersionedSerializable; + let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize( - &MutableMarkContext(0, 0, 0), + &VersionedSerializable::new(MutableMarkContext(0, 0, 0)), ) .expect("Should be serializable"); let (ptr, len) = serialized.as_ptr(); @@ -238,6 +243,7 @@ impl Mark { len.try_into().expect("Should able to convert ptr length"), ) .expect("Should able to deserialize") + .into_inner() }; a = Mark::from_u32(context.0); b = Mark::from_u32(context.1); @@ -418,7 +424,9 @@ impl SyntaxContext { #[cfg(all(feature = "__plugin_mode", target_arch = "wasm32"))] pub fn remove_mark(&mut self) -> Mark { - let context = MutableMarkContext(0, 0, 0); + use crate::plugin::serialized::VersionedSerializable; + + let context = VersionedSerializable::new(MutableMarkContext(0, 0, 0)); let serialized = crate::plugin::serialized::PluginSerializedBytes::try_serialize(&context) .expect("Should be serializable"); let (ptr, len) = serialized.as_ptr(); @@ -433,6 +441,7 @@ impl SyntaxContext { len.try_into().expect("Should able to convert ptr length"), ) .expect("Should able to deserialize") + .into_inner() }; *self = SyntaxContext(context.0); diff --git a/crates/swc_plugin_macro/src/lib.rs b/crates/swc_plugin_macro/src/lib.rs index 2965f2b65137..ea96065346c3 100644 --- a/crates/swc_plugin_macro/src/lib.rs +++ b/crates/swc_plugin_macro/src/lib.rs @@ -60,7 +60,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream { impl swc_core::common::errors::Emitter for PluginDiagnosticsEmitter { #[cfg_attr(not(target_arch = "wasm32"), allow(unused))] fn emit(&mut self, db: &swc_core::common::errors::DiagnosticBuilder<'_>) { - let diag = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&*db.diagnostic) + let diag = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&swc_core::common::plugin::serialized::VersionedSerializable::new(*db.diagnostic.clone())) .expect("Should able to serialize Diagnostic"); let (ptr, len) = diag.as_ptr(); @@ -83,7 +83,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream { /// Internal function plugin_macro uses to create ptr to PluginError. fn construct_error_ptr(plugin_error: swc_core::common::plugin::serialized::PluginError) -> u32 { - let ret = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize(&plugin_error).expect("Should able to serialize PluginError"); + 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"); let (ptr, len) = ret.as_ptr(); send_transform_result_to_host( @@ -107,7 +107,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream { }; let serialized_result = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize( - &result + &swc_core::common::plugin::serialized::VersionedSerializable::new(result) ).expect("Diagnostics should be always serializable"); 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 { let err = swc_core::common::plugin::serialized::PluginError::Deserialize("Failed to deserialize program received from host".to_string()); return construct_error_ptr(err); } - let program: #ast_type = program.expect("Should be a program"); + let program: #ast_type = program.expect("Should be a program").into_inner(); // Create a handler wired with plugin's diagnostic emitter, set it for global context. let handler = swc_core::common::errors::Handler::with_emitter( @@ -161,7 +161,7 @@ fn handle_func(func: ItemFn, ast_type: Ident) -> TokenStream { }; // Take original plugin fn ident, then call it with interop'ed args - let transformed_program = #ident(program, metadata); + let transformed_program = swc_core::common::plugin::serialized::VersionedSerializable::new(#ident(program, metadata)); // Serialize transformed result, return back to the host. let serialized_result = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize( diff --git a/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs b/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs index acf7587485a5..7a04be42881c 100644 --- a/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs +++ b/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs @@ -52,9 +52,10 @@ impl PluginCommentsProxy { { #[cfg(target_arch = "wasm32")] { - let serialized = - swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(&value) - .expect("Should able to serialize value"); + let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(value), + ) + .expect("Should able to serialize value"); let (serialized_comment_ptr, serialized_comment_ptr_len) = serialized.as_ptr(); unsafe { // We need to copy PluginCommentProxy's param for add_leading (Comment, or diff --git a/crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs b/crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs index b34f35347c6e..a8a1e1900f1b 100644 --- a/crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs +++ b/crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs @@ -44,7 +44,8 @@ where F: FnOnce(u32) -> u32, { // Allocate AllocatedBytesPtr to get return value from the host - let allocated_bytes_ptr = AllocatedBytesPtr(0, 0); + let allocated_bytes_ptr = + swc_common::plugin::serialized::VersionedSerializable::new(AllocatedBytesPtr(0, 0)); let serialized_allocated_bytes_ptr = PluginSerializedBytes::try_serialize(&allocated_bytes_ptr) .expect("Should able to serialize AllocatedBytesPtr"); let (serialized_allocated_bytes_raw_ptr, serialized_allocated_bytes_raw_ptr_size) = @@ -69,6 +70,7 @@ where .expect("Should able to convert ptr length"), ) .expect("Should able to deserialize AllocatedBytesPtr") + .into_inner() }) } @@ -98,5 +100,6 @@ where allocated_returned_value_ptr.1, ) .expect("Returned value should be serializable") + .into_inner() }) } diff --git a/crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs b/crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs index 016e9d186b4c..b0d48230ac0c 100644 --- a/crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs +++ b/crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs @@ -79,7 +79,7 @@ impl TransformPluginProgramMetadata { #[cfg(target_arch = "wasm32")] return read_returned_result_from_host(|serialized_ptr| unsafe { let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize( - &key.to_string(), + &swc_common::plugin::serialized::VersionedSerializable::new(key.to_string()), ) .expect("Should be serializable"); let (key_ptr, key_ptr_len) = serialized.as_ptr(); diff --git a/crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs b/crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs index 9781fdd8dad0..91db21eb6546 100644 --- a/crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs +++ b/crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs @@ -230,9 +230,10 @@ impl SourceMapper for PluginSourceMapProxy { ctxt: swc_common::SyntaxContext::empty(), }; - let serialized = - swc_common::plugin::serialized::PluginSerializedBytes::try_serialize(&span) - .expect("Should be serializable"); + let serialized = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(span), + ) + .expect("Should be serializable"); let (ptr, len) = serialized.as_ptr(); let ret = __merge_spans_proxy( diff --git a/crates/swc_plugin_runner/benches/ecma_invoke.rs b/crates/swc_plugin_runner/benches/ecma_invoke.rs index cca63b9ebeff..4a983b0519da 100644 --- a/crates/swc_plugin_runner/benches/ecma_invoke.rs +++ b/crates/swc_plugin_runner/benches/ecma_invoke.rs @@ -11,7 +11,7 @@ use std::{ use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion}; #[cfg(feature = "__rkyv")] -use swc_common::plugin::serialized::PluginSerializedBytes; +use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable}; use swc_common::{ collections::AHashMap, plugin::metadata::TransformPluginMetadataContext, FileName, FilePathMapping, Globals, Mark, SourceMap, GLOBALS, @@ -62,6 +62,7 @@ fn bench_transform(b: &mut Bencher, plugin_dir: &Path) { ) .unwrap(); + let program = VersionedSerializable::new(program); let program_ser = PluginSerializedBytes::try_serialize(&program).unwrap(); let mut transform_plugin_executor = @@ -82,7 +83,8 @@ fn bench_transform(b: &mut Bencher, plugin_dir: &Path) { ) .unwrap(); - let experimental_metadata: AHashMap = AHashMap::default(); + let experimental_metadata: VersionedSerializable> = + VersionedSerializable::new(AHashMap::default()); let _experimental_metadata = PluginSerializedBytes::try_serialize(&experimental_metadata) .expect("Should be a hashmap"); diff --git a/crates/swc_plugin_runner/src/imported_fn/comments.rs b/crates/swc_plugin_runner/src/imported_fn/comments.rs index 27d985437be7..9b60d55a7591 100644 --- a/crates/swc_plugin_runner/src/imported_fn/comments.rs +++ b/crates/swc_plugin_runner/src/imported_fn/comments.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use parking_lot::Mutex; use swc_common::{ comments::{Comments, SingleThreadedComments}, - plugin::serialized::PluginSerializedBytes, + plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, BytePos, }; use swc_plugin_proxy::COMMENTS; @@ -142,7 +142,8 @@ pub fn add_leading_comment_proxy(env: FunctionEnvMut, by byte_pos, serialized .deserialize() - .expect("Should be able to deserialize"), + .expect("Should be able to deserialize") + .into_inner(), ); }); } @@ -154,7 +155,8 @@ pub fn add_leading_comments_proxy(env: FunctionEnvMut, b byte_pos, serialized .deserialize() - .expect("Should be able to deserialize"), + .expect("Should be able to deserialize") + .into_inner(), ); }); } @@ -191,9 +193,10 @@ pub fn take_leading_comments_proxy( |comments| { let leading_comments = comments.take_leading(BytePos(byte_pos)); if let Some(leading_comments) = leading_comments { - let serialized_leading_comments_vec_bytes = - PluginSerializedBytes::try_serialize(&leading_comments) - .expect("Should be serializable"); + let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize( + &VersionedSerializable::new(leading_comments), + ) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -236,9 +239,10 @@ pub fn get_leading_comments_proxy( |comments| { let leading_comments = comments.get_leading(BytePos(byte_pos)); if let Some(leading_comments) = leading_comments { - let serialized_leading_comments_vec_bytes = - PluginSerializedBytes::try_serialize(&leading_comments) - .expect("Should be serializable"); + let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize( + &VersionedSerializable::new(leading_comments), + ) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -263,7 +267,8 @@ pub fn add_trailing_comment_proxy(env: FunctionEnvMut, b byte_pos, serialized .deserialize() - .expect("Should be able to deserialize"), + .expect("Should be able to deserialize") + .into_inner(), ); }); } @@ -275,7 +280,8 @@ pub fn add_trailing_comments_proxy(env: FunctionEnvMut, byte_pos, serialized .deserialize() - .expect("Should be able to deserialize"), + .expect("Should be able to deserialize") + .into_inner(), ); }); } @@ -315,9 +321,10 @@ pub fn take_trailing_comments_proxy( |comments| { let trailing_comments = comments.take_trailing(BytePos(byte_pos)); if let Some(leading_comments) = trailing_comments { - let serialized_leading_comments_vec_bytes = - PluginSerializedBytes::try_serialize(&leading_comments) - .expect("Should be serializable"); + let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize( + &VersionedSerializable::new(leading_comments), + ) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -355,9 +362,10 @@ pub fn get_trailing_comments_proxy( |comments| { let trailing_comments = comments.get_trailing(BytePos(byte_pos)); if let Some(leading_comments) = trailing_comments { - let serialized_leading_comments_vec_bytes = - PluginSerializedBytes::try_serialize(&leading_comments) - .expect("Should be serializable"); + let serialized_leading_comments_vec_bytes = PluginSerializedBytes::try_serialize( + &VersionedSerializable::new(leading_comments), + ) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, diff --git a/crates/swc_plugin_runner/src/imported_fn/handler.rs b/crates/swc_plugin_runner/src/imported_fn/handler.rs index 969382ec3001..c4836c6490af 100644 --- a/crates/swc_plugin_runner/src/imported_fn/handler.rs +++ b/crates/swc_plugin_runner/src/imported_fn/handler.rs @@ -26,8 +26,10 @@ pub fn emit_diagnostics( let diagnostic = PluginSerializedBytes::deserialize::(&serialized) .expect("Should able to be deserialized into diagnostic"); - let mut builder = - swc_common::errors::DiagnosticBuilder::new_diagnostic(handler, diagnostic); + let mut builder = swc_common::errors::DiagnosticBuilder::new_diagnostic( + handler, + diagnostic.into_inner(), + ); builder.emit(); }) } diff --git a/crates/swc_plugin_runner/src/imported_fn/hygiene.rs b/crates/swc_plugin_runner/src/imported_fn/hygiene.rs index b57a6513405e..2b17616d58c2 100644 --- a/crates/swc_plugin_runner/src/imported_fn/hygiene.rs +++ b/crates/swc_plugin_runner/src/imported_fn/hygiene.rs @@ -1,5 +1,7 @@ use swc_common::{ - hygiene::MutableMarkContext, plugin::serialized::PluginSerializedBytes, Mark, SyntaxContext, + hygiene::MutableMarkContext, + plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, + Mark, SyntaxContext, }; use wasmer::{AsStoreMut, FunctionEnvMut}; @@ -46,7 +48,11 @@ pub fn mark_is_descendant_of_proxy( let return_value = self_mark.is_descendant_of(ancestor); - let context = MutableMarkContext(self_mark.as_u32(), 0, return_value as u32); + let context = VersionedSerializable::new(MutableMarkContext( + self_mark.as_u32(), + 0, + return_value as u32, + )); let serialized_bytes = PluginSerializedBytes::try_serialize(&context).expect("Should be serializable"); @@ -75,7 +81,8 @@ pub fn mark_least_ancestor_proxy( let return_value = Mark::least_ancestor(a, b).as_u32(); - let context = MutableMarkContext(a.as_u32(), b.as_u32(), return_value); + let context = + VersionedSerializable::new(MutableMarkContext(a.as_u32(), b.as_u32(), return_value)); let serialized_bytes = PluginSerializedBytes::try_serialize(&context).expect("Should be serializable"); @@ -109,7 +116,11 @@ pub fn syntax_context_remove_mark_proxy( let return_value = self_mark.remove_mark(); - let context = MutableMarkContext(self_mark.as_u32(), 0, return_value.as_u32()); + let context = VersionedSerializable::new(MutableMarkContext( + self_mark.as_u32(), + 0, + return_value.as_u32(), + )); let serialized_bytes = PluginSerializedBytes::try_serialize(&context).expect("Should be serializable"); diff --git a/crates/swc_plugin_runner/src/imported_fn/metadata_context.rs b/crates/swc_plugin_runner/src/imported_fn/metadata_context.rs index e192fbf68a2e..3d19969d2dca 100644 --- a/crates/swc_plugin_runner/src/imported_fn/metadata_context.rs +++ b/crates/swc_plugin_runner/src/imported_fn/metadata_context.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use parking_lot::Mutex; use swc_common::plugin::{ metadata::{TransformPluginMetadataContext, TransformPluginMetadataContextKind}, - serialized::PluginSerializedBytes, + serialized::{PluginSerializedBytes, VersionedSerializable}, }; use wasmer::{AsStoreMut, FunctionEnvMut, Memory, TypedFunction}; @@ -77,7 +77,8 @@ pub fn get_transform_plugin_config( let config = serde_json::to_string(config_value).ok(); if let Some(config) = config { let serialized = - PluginSerializedBytes::try_serialize(&config).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(config)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -109,10 +110,11 @@ pub fn get_transform_context( .as_ref() .expect("Alloc guest memory fn should be available, check initialization"); - let value = env - .data() - .metadata_context - .get(&TransformPluginMetadataContextKind::from(key)); + let value = VersionedSerializable::new( + env.data() + .metadata_context + .get(&TransformPluginMetadataContextKind::from(key)), + ); let serialized = PluginSerializedBytes::try_serialize(&value).expect("Should be serializable"); @@ -145,7 +147,8 @@ pub fn get_experimental_transform_context( let context_key_buffer = env.data().mutable_context_key_buffer.lock().clone(); let key: String = PluginSerializedBytes::from_slice(&context_key_buffer[..]) .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); let value = env .data() @@ -155,8 +158,8 @@ pub fn get_experimental_transform_context( .map(|v| v.to_string()); if let Some(value) = value { - let serialized = - PluginSerializedBytes::try_serialize(&value).expect("Should be serializable"); + let serialized = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(value)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -187,7 +190,8 @@ pub fn get_raw_experiemtal_transform_context( .as_ref() .expect("Alloc guest memory fn should be available, check initialization"); - let experimental_context = env.data().metadata_context.experimental.clone(); + let experimental_context = + VersionedSerializable::new(env.data().metadata_context.experimental.clone()); let serialized_experimental_context_bytes = PluginSerializedBytes::try_serialize(&experimental_context) .expect("Should be serializable"); diff --git a/crates/swc_plugin_runner/src/imported_fn/source_map.rs b/crates/swc_plugin_runner/src/imported_fn/source_map.rs index cb98b4ff9d85..3b6daa11e350 100644 --- a/crates/swc_plugin_runner/src/imported_fn/source_map.rs +++ b/crates/swc_plugin_runner/src/imported_fn/source_map.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use parking_lot::Mutex; use swc_common::{ - plugin::serialized::PluginSerializedBytes, + plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, source_map::{PartialFileLines, PartialLoc}, BytePos, SourceMap, SourceMapper, Span, SyntaxContext, }; @@ -58,7 +58,7 @@ pub fn lookup_char_pos_proxy( .expect("Alloc guest memory fn should be available, check initialization"); let original_loc = (env.data().source_map.lock()).lookup_char_pos(BytePos(byte_pos)); - let ret = PartialLoc { + let ret = VersionedSerializable::new(PartialLoc { source_file: if should_include_source_file == 0 { None } else { @@ -67,7 +67,7 @@ pub fn lookup_char_pos_proxy( line: original_loc.line, col: original_loc.col.0, col_display: original_loc.col_display, - }; + }); let serialized_loc_bytes = PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); @@ -118,6 +118,7 @@ pub fn merge_spans_proxy( let ret = (env.data().source_map.lock()).merge_spans(sp_lhs, sp_rhs); if let Some(span) = ret { + let span = VersionedSerializable::new(span); let serialized_bytes = PluginSerializedBytes::try_serialize(&span).expect("Should be serializable"); write_into_memory_view( @@ -169,7 +170,8 @@ pub fn span_to_lines_proxy( }); let serialized_loc_bytes = - PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -201,7 +203,8 @@ pub fn lookup_byte_offset_proxy( let ret = (env.data().source_map.lock()).lookup_byte_offset(byte_pos); let serialized_loc_bytes = - PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -238,7 +241,8 @@ pub fn span_to_string_proxy( }; let ret = (env.data().source_map.lock()).span_to_string(span); let serialized_loc_bytes = - PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -275,7 +279,8 @@ pub fn span_to_filename_proxy( }; let ret = (env.data().source_map.lock()).span_to_filename(span); let serialized_loc_bytes = - PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, @@ -312,7 +317,8 @@ pub fn span_to_source_proxy( }; let ret = (*env.data().source_map.lock()).span_to_snippet(span); let serialized_loc_bytes = - PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(ret)) + .expect("Should be serializable"); allocate_return_values_into_guest( memory, diff --git a/crates/swc_plugin_runner/src/load_plugin.rs b/crates/swc_plugin_runner/src/load_plugin.rs index e9036f5c387d..cb467e288a8d 100644 --- a/crates/swc_plugin_runner/src/load_plugin.rs +++ b/crates/swc_plugin_runner/src/load_plugin.rs @@ -175,7 +175,8 @@ pub fn load_plugin( let diag_result: PluginCorePkgDiagnostics = PluginSerializedBytes::from_slice(&(&(*diagnostics_buffer.lock()))[..]) - .deserialize()?; + .deserialize()? + .into_inner(); Ok((instance, transform_result, diag_result, wasi_env)) } diff --git a/crates/swc_plugin_runner/src/memory_interop.rs b/crates/swc_plugin_runner/src/memory_interop.rs index 0ecebeea0180..a496fe9c35d3 100644 --- a/crates/swc_plugin_runner/src/memory_interop.rs +++ b/crates/swc_plugin_runner/src/memory_interop.rs @@ -1,4 +1,4 @@ -use swc_common::plugin::serialized::PluginSerializedBytes; +use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable}; use swc_plugin_proxy::AllocatedBytesPtr; use wasmer::{Memory, MemoryView, StoreMut, TypedFunction, WasmPtr}; @@ -78,7 +78,8 @@ pub fn allocate_return_values_into_guest( let (allocated_ptr, allocated_ptr_len) = write_into_memory_view(memory, store, serialized_bytes, |_, _| guest_memory_ptr); - let allocated_bytes = AllocatedBytesPtr(allocated_ptr, allocated_ptr_len); + let allocated_bytes = + VersionedSerializable::new(AllocatedBytesPtr(allocated_ptr, allocated_ptr_len)); // Retuning (allocated_ptr, len) into caller (plugin) let comment_ptr_serialized = PluginSerializedBytes::try_serialize(&allocated_bytes).expect("Should be serializable"); diff --git a/crates/swc_plugin_runner/src/transform_executor.rs b/crates/swc_plugin_runner/src/transform_executor.rs index 7270707349b8..e46d19527658 100644 --- a/crates/swc_plugin_runner/src/transform_executor.rs +++ b/crates/swc_plugin_runner/src/transform_executor.rs @@ -153,7 +153,7 @@ impl TransformExecutor { if returned_ptr_result == 0 { Ok(ret) } else { - let err: PluginError = ret.deserialize()?; + let err: PluginError = ret.deserialize()?.into_inner(); match err { PluginError::SizeInteropFailure(msg) => Err(anyhow!( "Failed to convert pointer size to calculate: {}", diff --git a/crates/swc_plugin_runner/tests/css_rkyv.rs b/crates/swc_plugin_runner/tests/css_rkyv.rs index 2255a297965f..5d91bacdf8ed 100644 --- a/crates/swc_plugin_runner/tests/css_rkyv.rs +++ b/crates/swc_plugin_runner/tests/css_rkyv.rs @@ -73,7 +73,10 @@ fn invoke(input: PathBuf) -> Result<(), Error> { let parsed: Stylesheet = swc_css_parser::parse_file(&fm, Default::default(), &mut vec![]).unwrap(); - let program = PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable"); + let program = PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()), + ) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( "TestExperimental".to_string(), @@ -105,7 +108,8 @@ fn invoke(input: PathBuf) -> Result<(), Error> { let program: Stylesheet = program_bytes .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); assert_eq!(parsed, program); @@ -120,8 +124,10 @@ fn invoke(input: PathBuf) -> Result<(), Error> { let parsed: Stylesheet = swc_css_parser::parse_file(&fm, Default::default(), &mut vec![]).unwrap(); - let mut serialized_program = - PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable"); + let mut serialized_program = PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()), + ) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( @@ -170,7 +176,8 @@ fn invoke(input: PathBuf) -> Result<(), Error> { let program: Stylesheet = serialized_program .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); assert_eq!(parsed, program); diff --git a/crates/swc_plugin_runner/tests/ecma_integration.rs b/crates/swc_plugin_runner/tests/ecma_integration.rs index dc293fa88ff1..27c0c95b3899 100644 --- a/crates/swc_plugin_runner/tests/ecma_integration.rs +++ b/crates/swc_plugin_runner/tests/ecma_integration.rs @@ -74,6 +74,8 @@ impl Visit for TestVisitor { #[cfg(feature = "__rkyv")] #[test] fn internal() -> Result<(), Error> { + use swc_common::plugin::serialized::VersionedSerializable; + let path = build_plugin( &PathBuf::from(env::var("CARGO_MANIFEST_DIR")?) .join("tests") @@ -94,7 +96,8 @@ fn internal() -> Result<(), Error> { ) .unwrap(); - let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable"); + let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program)) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( "TestExperimental".to_string(), @@ -130,7 +133,8 @@ fn internal() -> Result<(), Error> { let program: Program = program_bytes .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); let mut visitor = TestVisitor { plugin_transform_found: false, }; @@ -156,7 +160,8 @@ fn internal() -> Result<(), Error> { ) .unwrap(); - let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable"); + let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program)) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( "TestExperimental".to_string(), @@ -207,7 +212,8 @@ fn internal() -> Result<(), Error> { .unwrap(); let mut serialized_program = - PluginSerializedBytes::try_serialize(&program).expect("Should serializable"); + PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program)) + .expect("Should serializable"); let cache: Lazy = Lazy::new(PluginModuleCache::new); let experimental_metadata: AHashMap = [ @@ -257,7 +263,8 @@ fn internal() -> Result<(), Error> { let program: Program = serialized_program .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); let mut visitor = TestVisitor { plugin_transform_found: false, }; diff --git a/crates/swc_plugin_runner/tests/ecma_rkyv.rs b/crates/swc_plugin_runner/tests/ecma_rkyv.rs index 70d117ecf319..397513916a7b 100644 --- a/crates/swc_plugin_runner/tests/ecma_rkyv.rs +++ b/crates/swc_plugin_runner/tests/ecma_rkyv.rs @@ -83,7 +83,10 @@ fn internal(input: PathBuf) -> Result<(), Error> { ) .unwrap(); - let program = PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable"); + let program = PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()), + ) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( "TestExperimental".to_string(), @@ -117,7 +120,8 @@ fn internal(input: PathBuf) -> Result<(), Error> { let program: Program = program_bytes .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); assert_eq!(parsed, program); @@ -138,8 +142,10 @@ fn internal(input: PathBuf) -> Result<(), Error> { ) .unwrap(); - let mut serialized_program = - PluginSerializedBytes::try_serialize(&parsed).expect("Should serializable"); + let mut serialized_program = PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(parsed.clone()), + ) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( @@ -188,7 +194,8 @@ fn internal(input: PathBuf) -> Result<(), Error> { let program: Program = serialized_program .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); assert_eq!(parsed, program); diff --git a/crates/swc_plugin_runner/tests/issues.rs b/crates/swc_plugin_runner/tests/issues.rs index e145dde19f57..ae1f8089e78b 100644 --- a/crates/swc_plugin_runner/tests/issues.rs +++ b/crates/swc_plugin_runner/tests/issues.rs @@ -73,6 +73,8 @@ impl Visit for TestVisitor { #[cfg(feature = "__rkyv")] #[test] fn issue_6404() -> Result<(), Error> { + use swc_common::plugin::serialized::VersionedSerializable; + let plugin_path = build_plugin( &PathBuf::from(env::var("CARGO_MANIFEST_DIR")?) .join("tests") @@ -98,7 +100,8 @@ fn issue_6404() -> Result<(), Error> { ) .unwrap(); - let program = PluginSerializedBytes::try_serialize(&program).expect("Should serializable"); + let program = PluginSerializedBytes::try_serialize(&VersionedSerializable::new(program)) + .expect("Should serializable"); let experimental_metadata: AHashMap = [ ( "TestExperimental".to_string(), @@ -134,7 +137,8 @@ fn issue_6404() -> Result<(), Error> { let _: Program = program_bytes .deserialize() - .expect("Should able to deserialize"); + .expect("Should able to deserialize") + .into_inner(); Ok(()) }) From 3bd99af6c9bdf2efa155650c4f64a39d90b0066c Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Fri, 12 May 2023 05:34:38 +0000 Subject: [PATCH 2/3] build(cargo): bump up swc_core for patch CI --- bindings/Cargo.lock | 136 +++++++++++++------------- bindings/binding_core_node/Cargo.toml | 2 +- bindings/binding_core_wasm/Cargo.toml | 2 +- bindings/swc_cli/Cargo.toml | 2 +- 4 files changed, 71 insertions(+), 71 deletions(-) diff --git a/bindings/Cargo.lock b/bindings/Cargo.lock index 8c9f4d1ccf95..3e0a8bf6835f 100644 --- a/bindings/Cargo.lock +++ b/bindings/Cargo.lock @@ -229,9 +229,9 @@ dependencies = [ [[package]] name = "binding_macros" -version = "0.49.46" +version = "0.50.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e91cf028335b07553ac9236e1b8be00b17710504500de81b0cfaa4e05b5540a" +checksum = "88195712102da9c3d1564fcdf2c87a24188a494ae0bd216bfb29bc16e99131eb" dependencies = [ "anyhow", "console_error_panic_hook", @@ -2772,9 +2772,9 @@ dependencies = [ [[package]] name = "swc" -version = "0.260.46" +version = "0.261.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d464fcbe2475d2c9e82ef2c12c50d115ec08cdf58e47ca0293b812b371fefb13" +checksum = "03416dba6f7f137e513fd25eba6a4bf6e6fe4562d37d1bdce4056d4401f42434" dependencies = [ "ahash", "anyhow", @@ -2824,9 +2824,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4a2900a3da67c8759564b4defcd47e35f14cee65952015a5122ba7cbba927f" +checksum = "5c17c2810ab8281e81fd88e7a4356efbf56481087bf801baa84e757316a4564d" dependencies = [ "bytecheck", "once_cell", @@ -2840,9 +2840,9 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.213.34" +version = "0.214.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5731b18f9965e0c07fb6ded194df2667b69d7dc540d6cce9265afa8ceeb699" +checksum = "cb81914c99906a0a7deb8686f38ede0f027a034eb6dcbfa17ec6b890234cf748" dependencies = [ "ahash", "anyhow", @@ -2909,9 +2909,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.31.6" +version = "0.31.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7efdfff3bc0297c74b7ce0489a15a49a49c17a99261e2a0c5cb70fc15dca2392" +checksum = "bab852020b59b20d7aecbdee76db489c2d5c73ea3a7f832f06e02aca3cc6fe3b" dependencies = [ "ahash", "anyhow", @@ -2966,9 +2966,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.75.46" +version = "0.76.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a3e03a4add53814460ff437513d35717fccb26788bb43046780c606d442e01" +checksum = "e0f9b4a9c5a2eaf282e527f9279b81cf926f2103e156ecacb99795f00b9345a5" dependencies = [ "binding_macros", "swc", @@ -2990,9 +2990,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.103.7" +version = "0.104.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf9a2bea4d019564781b64ad9038a859b829f58ddb6e3ba5571292f5b5e0145" +checksum = "1b9a3b45f580f3d9655fcf17a85ef60eb1f9cb47190a22a1ba57db810abbd868" dependencies = [ "bitflags 2.2.1", "bytecheck", @@ -3009,9 +3009,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.138.17" +version = "0.139.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80be2cea85be7cf00d7c82b7238845c916168917ebfbffee41a42d8f59249a82" +checksum = "003783e7ca1f8eb95b69ce666a2087d71e631cca80519c9dd53ff9ea3eadb390" dependencies = [ "memchr", "num-bigint", @@ -3041,9 +3041,9 @@ dependencies = [ [[package]] name = "swc_ecma_ext_transforms" -version = "0.102.14" +version = "0.103.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b92027e0033fa9af45779d8765b872599d45617fadf1f28d318caf9180f423e" +checksum = "47919af8a7a40157f5e1dbbb31c5f39c69e1d146e8bb4ced938567bb24708ecd" dependencies = [ "phf", "swc_atoms", @@ -3055,9 +3055,9 @@ dependencies = [ [[package]] name = "swc_ecma_lints" -version = "0.81.20" +version = "0.82.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36d25a81aaf4354a153dafdd32c5e7e7c4214ca85962f3ae7a1271e219e4c9d1" +checksum = "5591e056c686fb1e54d12e6ddeea0bbbf22c55155395775c84cc20403ce0e837" dependencies = [ "ahash", "auto_impl", @@ -3076,9 +3076,9 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.43.8" +version = "0.43.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d000718304b9c3efa920a72614739ce15580d5d8ff86d6fabf1abcde474decbf" +checksum = "acf9887fb7bc0f0ee13df7a010010ff339f6aa25701399cf4837131d821b5411" dependencies = [ "ahash", "anyhow", @@ -3098,9 +3098,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.180.34" +version = "0.181.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e44bd7029599f7c2a1963d6d9532501c76dd5c8399abe1bf93134e010b4b09" +checksum = "d7e7724abfbb81b1d4649191667f5cd41bcc9453c7245797c12e789f44defa16" dependencies = [ "ahash", "arrayvec", @@ -3134,9 +3134,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.133.14" +version = "0.134.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1265e024029484ecc950bbb8ef347e0a874e3165c52ab64bfda1052d3e53c8e5" +checksum = "327eb456e1bb27a20cd4ddde77232504a3ba7da46bfbab8b102fd277f17fb7dc" dependencies = [ "either", "lexical", @@ -3154,9 +3154,9 @@ dependencies = [ [[package]] name = "swc_ecma_preset_env" -version = "0.194.31" +version = "0.195.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db0c1ce96219a22f12f69efc7f4b1606edadb0ef4f70046fdbb0e4fa6eb196d" +checksum = "3ab0bddaedf47548cd4222b5fe700895e53b261937ff8468d58f5335f30cdeb6" dependencies = [ "ahash", "anyhow", @@ -3179,9 +3179,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.217.30" +version = "0.218.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0812b9b66c0f0f5f9654a7ebd758edacad109453bebe24d84a16d2283b2283f" +checksum = "75e3ec66a8c72dec8d1670cc4dbbe8e804609778aa860b646cd5b776b1cdd278" dependencies = [ "swc_atoms", "swc_common", @@ -3199,9 +3199,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.126.20" +version = "0.127.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d3d99910583edf07db0b22b4cd3517abe86729f7dd219db29961e327d8519" +checksum = "059a3a8040f018a63b3c2db9926edabf4080635727c6c1889c48884eddda4040" dependencies = [ "better_scoped_tls", "bitflags 2.2.1", @@ -3223,9 +3223,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "0.115.20" +version = "0.116.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3099f594b34a1259f0a3d271fd0a94e78d4b7845ea77d6a34dd60cc7f3d7c88" +checksum = "bdb123ada9f274674ee389073f9825ae1730462a3bc4e4e1d8803816e06f732c" dependencies = [ "swc_atoms", "swc_common", @@ -3237,9 +3237,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.152.22" +version = "0.153.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1649ede69ead264378145d7c79c2864bf7aa159f4f5ecc00b7df1b06f66ee17c" +checksum = "ebc2266e853a9d67d05ac442ca490b4498505fdc635981cb0cd7e864c4e57c3f" dependencies = [ "ahash", "arrayvec", @@ -3277,9 +3277,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.169.26" +version = "0.170.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2b477af0a9b4937b2fa9f8b5cd0371aecb3993dfe3f115dc4de5d190ee3ab8" +checksum = "c786fc8441dbb9a2c9a185302850d52fd815c3efafadcc2c4b452ab1f916039d" dependencies = [ "Inflector", "ahash", @@ -3305,9 +3305,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.186.30" +version = "0.187.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a60a69736b4cee73085bb1057ec7cdca34d83fda34a11e003186bd795f97f1ee" +checksum = "f70df5dc8473bbf95a7babe019173d2c407319d77b2e94ffe32013576fcb88eb" dependencies = [ "ahash", "dashmap", @@ -3331,9 +3331,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_proposal" -version = "0.160.24" +version = "0.161.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b771acb5a35bb4ce27a353daf0ab92ff99300746238ddb0d7f59b06e7baeb1e" +checksum = "ba6e893986e673ae4a0e338b2602871560eed645d277c0d27b526dad2ff0a090" dependencies = [ "either", "rustc-hash", @@ -3351,9 +3351,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "0.172.28" +version = "0.173.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac590418ef63cf8ea3ae5bd42101a3009f0195eab277115e8d98fa343cba8abc" +checksum = "d3151be69096f575281db808da2293a56729ccab8b9fc5649179172611d29d5d" dependencies = [ "ahash", "base64 0.13.1", @@ -3377,9 +3377,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.176.29" +version = "0.177.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f420a2ece993725e0e705c341c518eed28aecf5738b91bc3ef655c3640227c" +checksum = "7b067ff53c2adf2cd778f95531806b03e64fc2b82cdb0d8329b748911c37e28a" dependencies = [ "serde", "swc_atoms", @@ -3393,9 +3393,9 @@ dependencies = [ [[package]] name = "swc_ecma_usage_analyzer" -version = "0.12.14" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c01b218026bd01c6f1242686b6aa3b24a8f3748626a113e5cece1cf49fd2f7" +checksum = "0f264aab5eca8f8ac2cf6b51816679611eabdf31807fece0a06197bf1c9c16d9" dependencies = [ "ahash", "indexmap", @@ -3411,9 +3411,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.116.14" +version = "0.117.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0d9e6c2c4cdb90eb2d9a1b0963d190e706b8846dcb54bb66d06be6c669c256" +checksum = "9c9bbff7a2f87308ab7ad3eda7985c6b2b5640cffe5e498a4d587718e02b6d60" dependencies = [ "indexmap", "num_cpus", @@ -3430,9 +3430,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.89.7" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d212dd6c58b496ecd880b0c1bd2de65a6c4004cb891423bfffa0068fcf5be9de" +checksum = "1adc0fa542cd90e3f2e1a0ad5e68be6b88973a68f8107bf3a322354e78d7ecc2" dependencies = [ "num-bigint", "swc_atoms", @@ -3456,9 +3456,9 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "0.15.6" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b756b002d2ea08c16946161394c581ec04379c71bc7b9e831603b9275a0515a" +checksum = "f10f67c32660d4573ff300040fdf7c0e63acb34ae92ffbca9c49d7c0d5ccd32b" dependencies = [ "anyhow", "miette", @@ -3469,9 +3469,9 @@ dependencies = [ [[package]] name = "swc_fast_graph" -version = "0.19.6" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b97bf458e63d402c54613f10f5348d2ba7c5bc06cd04fc093dc33e2f50f0fb0" +checksum = "b1f7be49335c25e55418468fc01b2fce2a7d0f33fe625367f68c4412363a79ce" dependencies = [ "indexmap", "petgraph", @@ -3481,9 +3481,9 @@ dependencies = [ [[package]] name = "swc_graph_analyzer" -version = "0.20.7" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9c7874184694339a65f2ec76a4343bc2cc3af6d6a5ca3f7479205c2a71952b" +checksum = "c4e730c7eb669e3b5f715bd0508b3bc6d9d9790fca206e8cfa8b8c14c39be66e" dependencies = [ "ahash", "auto_impl", @@ -3516,9 +3516,9 @@ dependencies = [ [[package]] name = "swc_node_bundler" -version = "0.47.46" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6930d8d389ba47de0028f126de7081ee127688f73fa10c6e9d236075a812017" +checksum = "7d64d18bd730dab20f17adb85882b3e01738985a4ecb763acd64aa3c4e4ce311" dependencies = [ "anyhow", "dashmap", @@ -3545,9 +3545,9 @@ dependencies = [ [[package]] name = "swc_node_comments" -version = "0.18.6" +version = "0.18.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bd9a00855116dfd865430999a4bcbcab9c4d18106957280d1cb2ea44c8f15c" +checksum = "a4ff2d25e5d902524df8ddb42f8bc67c46c7a10dc8fb00b52504371235522b17" dependencies = [ "ahash", "dashmap", @@ -3571,9 +3571,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "0.32.7" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfbe89b626e8ef1554a948c8596891ba44c8dafd8a3c37e8a6a456b701566a9" +checksum = "fadeab239b981b23a40ca718cdd93c52d8aef41ef79fe69c50d298567041e4cd" dependencies = [ "better_scoped_tls", "rkyv", @@ -3585,9 +3585,9 @@ dependencies = [ [[package]] name = "swc_plugin_runner" -version = "0.94.23" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4643964a9bb5a708a2765abf3ef4b331490db724535282c4b5eb17cf43cc89b3" +checksum = "d42b168ee603b45e4e8712d41bd429d58aa8df4e70f0bfea6e70425798c350c6" dependencies = [ "anyhow", "enumset", @@ -3607,9 +3607,9 @@ dependencies = [ [[package]] name = "swc_timer" -version = "0.19.7" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7eb2c0fe1ef3e7e50f4439079046c3b15ac1b4c142b4a18f830b4754fa04285" +checksum = "ecc46b07c1080b9bf423f30f3971378420252ae098d11fcc0a18a7b4f6c0d14f" dependencies = [ "tracing", ] diff --git a/bindings/binding_core_node/Cargo.toml b/bindings/binding_core_node/Cargo.toml index 1b2667b606a9..e560955de968 100644 --- a/bindings/binding_core_node/Cargo.toml +++ b/bindings/binding_core_node/Cargo.toml @@ -48,7 +48,7 @@ tracing-chrome = "0.5.0" tracing-futures = "0.2.5" tracing-subscriber = { version = "0.3.9", features = ["env-filter"] } -swc_core = { version = "0.75.46", features = [ +swc_core = { version = "0.76.2", features = [ "allocator_node", "ecma_ast", "ecma_ast_serde", diff --git a/bindings/binding_core_wasm/Cargo.toml b/bindings/binding_core_wasm/Cargo.toml index 123ed8bae268..3fa2982d610b 100644 --- a/bindings/binding_core_wasm/Cargo.toml +++ b/bindings/binding_core_wasm/Cargo.toml @@ -34,7 +34,7 @@ plugin = [] anyhow = "1.0.66" serde = { version = "1", features = ["derive"] } serde-wasm-bindgen = "0.4.5" -swc_core = { version = "0.75.46", features = [ +swc_core = { version = "0.76.2", features = [ "ecma_ast_serde", "common_perf", "binding_macro_wasm", diff --git a/bindings/swc_cli/Cargo.toml b/bindings/swc_cli/Cargo.toml index 1806d7557c46..3062da056821 100644 --- a/bindings/swc_cli/Cargo.toml +++ b/bindings/swc_cli/Cargo.toml @@ -27,7 +27,7 @@ relative-path = "1.6.1" serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = ["unbounded_depth"] } sourcemap = "6.2.2" -swc_core = { version = "0.75.46", features = [ +swc_core = { version = "0.76.2", features = [ "trace_macro", "common_concurrent", "base_concurrent", From b5e6e4b438e0c5ad8adbf75fefe88ec8d26ee30d Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Fri, 12 May 2023 06:07:45 +0000 Subject: [PATCH 3/3] build(package): update deps --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a0861b41bc25..748a5904c427 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "@napi-rs/cli": "^2.14.1", "@swc/core": "=1.2.220", "@swc/helpers": "^0.5.0", - "@swc/plugin-jest": "1.5.59", + "@swc/plugin-jest": "latest", "@taplo/cli": "^0.3.2", "@types/jest": "^28.1.4", "@types/node": "^14.14.41", diff --git a/yarn.lock b/yarn.lock index 58ae7f39513a..45ca9b6c1550 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2465,7 +2465,7 @@ __metadata: "@swc/core-win32-ia32-msvc": 1.2.146 "@swc/core-win32-x64-msvc": 1.2.146 "@swc/helpers": ^0.5.0 - "@swc/plugin-jest": 1.5.59 + "@swc/plugin-jest": latest "@taplo/cli": ^0.3.2 "@types/jest": ^28.1.4 "@types/node": ^14.14.41 @@ -2541,10 +2541,10 @@ __metadata: languageName: node linkType: hard -"@swc/plugin-jest@npm:1.5.59": - version: 1.5.59 - resolution: "@swc/plugin-jest@npm:1.5.59" - checksum: cc94723c12a6c9122a1ee3367fc55623858001435e3efaac009b8c0e1a125f97a9ac0ec773eaeb20e65a6b877204f4ea865f5fa70af1820d1ca869203f6e7561 +"@swc/plugin-jest@npm:latest": + version: 1.5.62 + resolution: "@swc/plugin-jest@npm:1.5.62" + checksum: 722a44b0c83ab89d355781bebb987f200e503c960733c62fae5f91b6bd717b25330819d93507df8cf87695d71f318f83e566f102aec9c23f41794498e902b817 languageName: node linkType: hard