diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6cf42bc7fc9..140fb45af6c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -232,7 +232,7 @@ jobs: os: ubuntu-latest runner: ubuntu-latest check: | - cargo hack check --feature-powerset --no-dev-deps --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest --exclude-features plugin-bytecheck --exclude-features plugin_transform_host_js --exclude-features plugin_transform_host_native + cargo hack check --feature-powerset --no-dev-deps --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest --exclude-features plugin_transform_host_js --exclude-features plugin_transform_host_native - crate: swc os: windows-latest runner: windows-latest @@ -251,7 +251,7 @@ jobs: os: ubuntu-latest runner: ubuntu-latest check: | - cargo hack check --feature-powerset --no-dev-deps --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features plugin-bytecheck-base --exclude-features plugin-bytecheck-mode --exclude-features plugin-bytecheck-rt --exclude-features rkyv-bytecheck-impl --exclude-features rkyv-impl + cargo hack check --feature-powerset --no-dev-deps --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features rkyv-impl - crate: swc_common os: windows-latest runner: windows-latest @@ -310,7 +310,7 @@ jobs: os: ubuntu-latest runner: ubuntu-latest check: | - cargo hack check --feature-powerset --no-dev-deps --exclude-features __rkyv --exclude-features rkyv-bytecheck-impl + cargo hack check --feature-powerset --no-dev-deps --exclude-features __rkyv - crate: swc_ecma_codegen os: ubuntu-latest runner: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index e5f75073651..15d04d5bcd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3451,10 +3451,8 @@ dependencies = [ name = "swc_atoms" version = "0.5.1" dependencies = [ - "bytecheck", "once_cell", "rkyv", - "rkyv-test", "rustc-hash", "serde", "string_cache", @@ -3528,7 +3526,6 @@ dependencies = [ "ast_node", "atty", "better_scoped_tls", - "bytecheck", "cfg-if", "criterion", "either", @@ -3646,7 +3643,6 @@ dependencies = [ name = "swc_css_ast" version = "0.137.1" dependencies = [ - "bytecheck", "is-macro", "rkyv", "serde", @@ -3820,11 +3816,9 @@ version = "0.103.1" dependencies = [ "arbitrary", "bitflags", - "bytecheck", "is-macro", "num-bigint", "rkyv", - "rkyv-test", "scoped-tls", "serde", "serde_json", @@ -4494,7 +4488,6 @@ dependencies = [ name = "swc_html_ast" version = "0.31.1" dependencies = [ - "bytecheck", "is-macro", "rkyv", "serde", @@ -4690,7 +4683,6 @@ version = "0.32.1" dependencies = [ "better_scoped_tls", "rkyv", - "rkyv-test", "swc_common", "swc_ecma_ast", "swc_trace_macro", diff --git a/bindings/binding_core_node/Cargo.toml b/bindings/binding_core_node/Cargo.toml index d08f0c7b77e..45cef2bd56f 100644 --- a/bindings/binding_core_node/Cargo.toml +++ b/bindings/binding_core_node/Cargo.toml @@ -18,14 +18,6 @@ plugin = ["swc_core/plugin_transform_host_native"] swc_v1 = ["swc_core/bundler_node_v1"] swc_v2 = ["swc_core/bundler_node_v2"] -# Experiemntal bytechecked plugin serialization / deserialization. -plugin_bytecheck = [ - # We know what we're doing - enable internal features for the host plugin setup. - # "swc_core/__plugin_transform_host_bytecheck", - "swc_core/__plugin_transform_host_schema_v1", - "swc_core/__plugin_transform_env_native", -] - # Internal flag for testing purpose only. __plugin_transform_vtest = [ # We know what we're doing - enable internal features for testing fixture setup. diff --git a/crates/ast_node/src/lib.rs b/crates/ast_node/src/lib.rs index 26f837d1a66..2d9b08a13ad 100644 --- a/crates/ast_node/src/lib.rs +++ b/crates/ast_node/src/lib.rs @@ -207,10 +207,6 @@ pub fn ast_node( feature = "rkyv-impl", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] - #[cfg_attr( - feature = "rkyv-bytecheck-impl", - derive(rkyv_latest::Archive, rkyv_latest::Serialize, rkyv_latest::Deserialize) - )] #[cfg_attr( feature = "rkyv-impl", archive(bound( @@ -218,13 +214,6 @@ pub fn ast_node( deserialize = "__D: rkyv::de::SharedDeserializeRegistry" )) )] - #[cfg_attr( - feature = "rkyv-bytecheck-impl", - archive(bound( - serialize = "__S: rkyv_latest::ser::Serializer + rkyv_latest::ser::ScratchSpace + rkyv_latest::ser::SharedSerializeRegistry", - deserialize = "__D: rkyv_latest::de::SharedDeserializeRegistry" - )) - )] #[cfg_attr( feature = "serde-impl", serde(untagged) @@ -283,10 +272,6 @@ pub fn ast_node( feature = "rkyv-impl", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] - #[cfg_attr( - feature = "rkyv-bytecheck-impl", - derive(rkyv_latest::Archive, rkyv_latest::Serialize, rkyv_latest::Deserialize) - )] #[cfg_attr( feature = "rkyv-impl", archive( @@ -296,15 +281,6 @@ pub fn ast_node( ) ) )] - #[cfg_attr( - feature = "rkyv-bytecheck-impl", - archive( - bound( - serialize = "__S: rkyv_latest::ser::Serializer + rkyv_latest::ser::ScratchSpace + rkyv_latest::ser::SharedSerializeRegistry", - deserialize = "__D: rkyv_latest::de::SharedDeserializeRegistry" - ) - ) - )] serde_tag #[cfg_attr( feature = "serde-impl", diff --git a/crates/swc/Cargo.toml b/crates/swc/Cargo.toml index 8db4429e551..92c7ba51a90 100644 --- a/crates/swc/Cargo.toml +++ b/crates/swc/Cargo.toml @@ -33,10 +33,6 @@ plugin = [ "swc_plugin_runner/rkyv-impl", "swc_plugin_proxy/plugin-rt", ] -plugin-bytecheck = [ - "swc_plugin_runner/rkyv-bytecheck-impl", - "swc_plugin_proxy/plugin-bytecheck-rt", -] plugin_transform_schema_v1 = [ "swc_common/plugin_transform_schema_v1", "swc_plugin_runner/plugin_transform_schema_v1", diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index f944bcf52ed..9b1dbae148a 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -1,8 +1,5 @@ #![cfg_attr( - any( - not(any(feature = "plugin", feature = "plugin-bytecheck")), - target_arch = "wasm32" - ), + any(not(any(feature = "plugin")), target_arch = "wasm32"), allow(unused) )] use std::{ @@ -617,10 +614,7 @@ impl Options { // Embedded runtime plugin target, based on assumption we have // 1. filesystem access for the cache // 2. embedded runtime can compiles & execute wasm - #[cfg(all( - any(feature = "plugin", feature = "plugin-bytecheck"), - not(target_arch = "wasm32") - ))] + #[cfg(all(any(feature = "plugin"), not(target_arch = "wasm32")))] let plugins = { let plugin_resolver = CachingResolver::new( 40, @@ -659,10 +653,7 @@ impl Options { // 1. no filesystem access, loading binary / cache management should be // performed externally // 2. native runtime compiles & execute wasm (i.e v8 on node, chrome) - #[cfg(all( - any(feature = "plugin", feature = "plugin-bytecheck"), - target_arch = "wasm32" - ))] + #[cfg(all(any(feature = "plugin"), target_arch = "wasm32"))] let plugins = { let transform_filename = match base { FileName::Real(path) => path.as_os_str().to_str().map(String::from), @@ -689,7 +680,7 @@ impl Options { ) }; - #[cfg(not(any(feature = "plugin", feature = "plugin-bytecheck")))] + #[cfg(not(any(feature = "plugin")))] let plugins = crate::plugin::plugins(); let pass = chain!( diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index 0e90f81f49a..cc69280fba7 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -2,18 +2,15 @@ //! expressions at the moment. #![cfg_attr( - any( - not(any(feature = "plugin", feature = "plugin-bytecheck")), - target_arch = "wasm32" - ), + any(not(any(feature = "plugin")), target_arch = "wasm32"), allow(unused) )] use serde::{Deserialize, Serialize}; -#[cfg(any(feature = "plugin", feature = "plugin-bytecheck"))] +#[cfg(any(feature = "plugin"))] use swc_ecma_ast::*; use swc_ecma_loader::resolvers::{lru::CachingResolver, node::NodeModulesResolver}; -#[cfg(not(any(feature = "plugin", feature = "plugin-bytecheck")))] +#[cfg(not(any(feature = "plugin")))] use swc_ecma_transforms::pass::noop; use swc_ecma_visit::{noop_fold_type, Fold}; @@ -27,7 +24,7 @@ use swc_ecma_visit::{noop_fold_type, Fold}; #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct PluginConfig(pub String, pub serde_json::Value); -#[cfg(any(feature = "plugin", feature = "plugin-bytecheck"))] +#[cfg(any(feature = "plugin"))] pub fn plugins( configured_plugins: Option>, metadata_context: std::sync::Arc, @@ -48,7 +45,7 @@ pub fn plugins( } } -#[cfg(not(any(feature = "plugin", feature = "plugin-bytecheck")))] +#[cfg(not(any(feature = "plugin")))] pub fn plugins() -> impl Fold { noop() } @@ -63,7 +60,7 @@ struct RustPlugins { } impl RustPlugins { - #[cfg(any(feature = "plugin", feature = "plugin-bytecheck"))] + #[cfg(any(feature = "plugin"))] fn apply(&mut self, n: Program) -> Result { use anyhow::Context; if self.plugins.is_none() || self.plugins.as_ref().unwrap().is_empty() { @@ -79,10 +76,7 @@ impl RustPlugins { } #[tracing::instrument(level = "info", skip_all, name = "apply_plugins")] - #[cfg(all( - any(feature = "plugin", feature = "plugin-bytecheck"), - not(target_arch = "wasm32") - ))] + #[cfg(all(any(feature = "plugin"), not(target_arch = "wasm32")))] fn apply_inner(&mut self, n: Program) -> Result { use std::{path::PathBuf, sync::Arc}; @@ -167,10 +161,7 @@ impl RustPlugins { ) } - #[cfg(all( - any(feature = "plugin", feature = "plugin-bytecheck"), - target_arch = "wasm32" - ))] + #[cfg(all(any(feature = "plugin"), target_arch = "wasm32"))] #[tracing::instrument(level = "info", skip_all)] fn apply_inner(&mut self, n: Program) -> Result { use std::{path::PathBuf, sync::Arc}; @@ -222,14 +213,14 @@ impl RustPlugins { impl Fold for RustPlugins { noop_fold_type!(); - #[cfg(any(feature = "plugin", feature = "plugin-bytecheck"))] + #[cfg(any(feature = "plugin"))] fn fold_module(&mut self, n: Module) -> Module { self.apply(Program::Module(n)) .expect("failed to invoke plugin") .expect_module() } - #[cfg(any(feature = "plugin", feature = "plugin-bytecheck"))] + #[cfg(any(feature = "plugin"))] fn fold_script(&mut self, n: Script) -> Script { self.apply(Program::Script(n)) .expect("failed to invoke plugin") diff --git a/crates/swc_atoms/Cargo.toml b/crates/swc_atoms/Cargo.toml index 6ee8e43bf26..e808ed3e1b8 100644 --- a/crates/swc_atoms/Cargo.toml +++ b/crates/swc_atoms/Cargo.toml @@ -13,24 +13,15 @@ version = "0.5.1" bench = false [features] -__rkyv = [] -# Enably rkyv serialization with stable version of rkyv. +__rkyv = [] rkyv-impl = ["__rkyv", "rkyv"] -# Enable rkyv serialization with updated version of rkyv, along with bytecheck. -rkyv-bytecheck-impl = ["__rkyv", "rkyv-latest"] [dependencies] -bytecheck = { version = "0.6.9", optional = true } once_cell = "1" rkyv = { package = "rkyv", version = "=0.7.40", optional = true, features = [ "strict", "validation", ] } -# This is to avoid cargo version selection conflict between rkyv=0.7.40 and other versions, as it is strictly pinned -# cannot be merged. -rkyv-latest = { package = "rkyv-test", version = "=0.7.38-test.2", optional = true, features = [ - "strict", -] } rustc-hash = "1.1.0" serde = "1" string_cache = "0.8.7" diff --git a/crates/swc_atoms/build.rs b/crates/swc_atoms/build.rs index 029e979396e..fca64c8c130 100644 --- a/crates/swc_atoms/build.rs +++ b/crates/swc_atoms/build.rs @@ -1,8 +1,5 @@ use std::{env, path::Path}; -#[cfg(all(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] -compile_error!("Cannot enable bytechcked, non-bytechecked rkyv both"); - fn main() { let strs = include_str!("words.txt") .lines() diff --git a/crates/swc_atoms/src/lib.rs b/crates/swc_atoms/src/lib.rs index 19038c3493b..40019b7565c 100644 --- a/crates/swc_atoms/src/lib.rs +++ b/crates/swc_atoms/src/lib.rs @@ -14,8 +14,6 @@ use std::{ rc::Rc, }; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use rustc_hash::FxHashSet; use serde::Serializer; use triomphe::{Arc, HeaderWithLength, ThinArc}; diff --git a/crates/swc_common/Cargo.toml b/crates/swc_common/Cargo.toml index 1caae3fb40f..a8b3908a719 100644 --- a/crates/swc_common/Cargo.toml +++ b/crates/swc_common/Cargo.toml @@ -28,32 +28,19 @@ plugin-base = ["__plugin", "anyhow", "rkyv-impl", "diagnostic-serde"] plugin-mode = ["__plugin_mode", "plugin-base"] plugin-rt = ["__plugin_rt", "plugin-base"] -plugin-bytecheck-base = [ - "__plugin", - "anyhow", - "rkyv-bytecheck-impl", - "diagnostic-serde", -] -plugin-bytecheck-mode = ["__plugin_mode", "plugin-bytecheck-base"] -plugin-bytecheck-rt = ["__plugin_rt", "plugin-bytecheck-base"] - plugin_transform_schema_v1 = [] plugin_transform_schema_vtest = [] tty-emitter = ["atty", "termcolor"] -__rkyv = [] -# Enably rkyv serialization with stable version of rkyv. +__rkyv = [] rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl"] -# Enable rkyv serialization with updated version of rkyv, along with bytecheck. -rkyv-bytecheck-impl = ["__rkyv", "rkyv-latest", "swc_atoms/rkyv-bytecheck-impl"] [dependencies] ahash = "0.7.4" anyhow = { version = "1.0.45", optional = true } arbitrary = { version = "1", optional = true, features = ["derive"] } atty = { version = "0.2", optional = true } -bytecheck = { version = "0.6.9", optional = true } cfg-if = "1.0.0" either = "1.5" new_debug_unreachable = "1.0.4" diff --git a/crates/swc_common/src/comments.rs b/crates/swc_common/src/comments.rs index 894d8ca90ae..e3f5760c999 100644 --- a/crates/swc_common/src/comments.rs +++ b/crates/swc_common/src/comments.rs @@ -4,8 +4,6 @@ use std::{ sync::Arc, }; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use rustc_hash::FxHashMap; use swc_atoms::{atom, Atom}; @@ -545,7 +543,7 @@ impl SingleThreadedComments { #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct Comment { @@ -563,7 +561,7 @@ impl Spanned for Comment { #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum CommentKind { diff --git a/crates/swc_common/src/errors/diagnostic.rs b/crates/swc_common/src/errors/diagnostic.rs index c193f0c4c86..f6da23d5620 100644 --- a/crates/swc_common/src/errors/diagnostic.rs +++ b/crates/swc_common/src/errors/diagnostic.rs @@ -10,9 +10,6 @@ use std::fmt; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; - use super::{snippet::Style, Applicability, CodeSuggestion, Level, Substitution, SubstitutionPart}; use crate::syntax_pos::{MultiSpan, Span}; @@ -22,7 +19,7 @@ use crate::syntax_pos::{MultiSpan, Span}; derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct Message(pub String, pub Style); @@ -34,7 +31,7 @@ pub struct Message(pub String, pub Style); derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct Diagnostic { @@ -52,7 +49,7 @@ pub struct Diagnostic { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum DiagnosticId { @@ -67,7 +64,7 @@ pub enum DiagnosticId { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct SubDiagnostic { diff --git a/crates/swc_common/src/errors/mod.rs b/crates/swc_common/src/errors/mod.rs index c908bac52ae..c8934f03ac9 100644 --- a/crates/swc_common/src/errors/mod.rs +++ b/crates/swc_common/src/errors/mod.rs @@ -17,8 +17,6 @@ use std::{ sync::atomic::{AtomicUsize, Ordering::SeqCst}, }; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[cfg(feature = "tty-emitter")] use termcolor::{Color, ColorSpec}; @@ -49,7 +47,7 @@ mod styled_buffer; derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum Applicability { @@ -65,7 +63,7 @@ pub enum Applicability { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct CodeSuggestion { @@ -116,7 +114,7 @@ pub struct CodeSuggestion { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct Substitution { @@ -129,7 +127,7 @@ pub struct Substitution { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct SubstitutionPart { @@ -876,7 +874,7 @@ impl Handler { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum Level { diff --git a/crates/swc_common/src/errors/snippet.rs b/crates/swc_common/src/errors/snippet.rs index bc744e42400..f1447733e3d 100644 --- a/crates/swc_common/src/errors/snippet.rs +++ b/crates/swc_common/src/errors/snippet.rs @@ -10,9 +10,6 @@ // Code for annotating snippets. -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; - use super::Level; #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] @@ -184,7 +181,7 @@ pub struct StyledString { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum Style { diff --git a/crates/swc_common/src/lib.rs b/crates/swc_common/src/lib.rs index c8c7c226efc..746d37ea7e8 100644 --- a/crates/swc_common/src/lib.rs +++ b/crates/swc_common/src/lib.rs @@ -79,19 +79,3 @@ pub mod util; #[cfg(all(not(debug_assertions), feature = "plugin-rt", feature = "plugin-mode"))] compile_error!("You can't enable `plugin-rt` and `plugin-mode` at the same time"); - -#[cfg(all( - not(debug_assertions), - feature = "plugin-bytecheck-rt", - feature = "plugin-bytecheck-mode" -))] -compile_error!( - "You can't enable `plugin-bytecheck-rt` and `plugin-bytecheck-mode` at the same time" -); - -#[cfg(all( - not(debug_assertions), - feature = "plugin-base", - feature = "plugin-bytecheck-base" -))] -compile_error!("Bytecheck, non-bytecheck serialization cannot be enabled same time"); diff --git a/crates/swc_common/src/plugin/diagnostics.rs b/crates/swc_common/src/plugin/diagnostics.rs index d97787a48eb..9d8176b244f 100644 --- a/crates/swc_common/src/plugin/diagnostics.rs +++ b/crates/swc_common/src/plugin/diagnostics.rs @@ -1,13 +1,10 @@ -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; - /// A serializable, wrapped struct for the diagnostics information /// included in plugin binaries. /// TODO: Must implement bytecheck with forward-compatible schema changes to /// prevent handshake failure. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct PluginCorePkgDiagnostics { diff --git a/crates/swc_common/src/plugin/serialized.rs b/crates/swc_common/src/plugin/serialized.rs index 41b9f854534..0637d25d4d8 100644 --- a/crates/swc_common/src/plugin/serialized.rs +++ b/crates/swc_common/src/plugin/serialized.rs @@ -3,8 +3,6 @@ use std::any::type_name; use anyhow::Error; #[cfg(feature = "__rkyv")] use rkyv::Deserialize; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] diff --git a/crates/swc_common/src/syntax_pos.rs b/crates/swc_common/src/syntax_pos.rs index 11292d42ee7..39dcf55c2aa 100644 --- a/crates/swc_common/src/syntax_pos.rs +++ b/crates/swc_common/src/syntax_pos.rs @@ -11,8 +11,6 @@ use std::{ #[cfg(feature = "parking_lot")] use parking_lot::Mutex; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use serde::{Deserialize, Serialize}; use url::Url; @@ -33,7 +31,7 @@ pub mod hygiene; /// `BytePos` range between files. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct Span { @@ -119,18 +117,12 @@ better_scoped_tls::scoped_tls!( ); #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] pub enum FileName { - Real( - #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), - with(crate::source_map::EncodePathBuf) - )] - PathBuf, - ), + Real(#[cfg_attr(any(feature = "rkyv-impl"), with(crate::source_map::EncodePathBuf))] PathBuf), /// A macro. This includes the full name of the macro, so that there are no /// clashes. Macros(String), @@ -141,13 +133,7 @@ pub enum FileName { /// Hack in src/libsyntax/parse.rs MacroExpansion, ProcMacroSourceCode, - Url( - #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), - with(crate::source_map::EncodeUrl) - )] - Url, - ), + Url(#[cfg_attr(any(feature = "rkyv-impl"), with(crate::source_map::EncodeUrl))] Url), Internal(String), /// Custom sources for explicit parser calls from plugins and drivers Custom(String), @@ -166,7 +152,7 @@ pub enum FileName { #[derive(Debug, Clone, Copy)] pub struct EncodePathBuf; -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::ArchiveWith for EncodePathBuf { type Archived = rkyv::string::ArchivedString; type Resolver = rkyv::string::StringResolver; @@ -184,7 +170,7 @@ impl rkyv::with::ArchiveWith for EncodePathBuf { } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::SerializeWith for EncodePathBuf where S: ?Sized + rkyv::ser::Serializer, @@ -196,7 +182,7 @@ where } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::DeserializeWith for EncodePathBuf where D: ?Sized + rkyv::Fallible, @@ -215,7 +201,7 @@ where #[derive(Debug, Clone, Copy)] pub struct EncodeUrl; -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::ArchiveWith for EncodeUrl { type Archived = rkyv::string::ArchivedString; type Resolver = rkyv::string::StringResolver; @@ -231,7 +217,7 @@ impl rkyv::with::ArchiveWith for EncodeUrl { } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::SerializeWith for EncodeUrl where S: ?Sized + rkyv::ser::Serializer, @@ -243,7 +229,7 @@ where } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::DeserializeWith, Url, D> for EncodeUrl where D: ?Sized + rkyv::Fallible, @@ -318,7 +304,7 @@ impl FileName { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct PrimarySpanLabel(pub Span, pub String); @@ -335,7 +321,7 @@ pub struct PrimarySpanLabel(pub Span, pub String); derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct MultiSpan { @@ -737,7 +723,7 @@ pub const NO_EXPANSION: SyntaxContext = SyntaxContext::empty(); /// Identifies an offset of a multi-byte character in a SourceFile #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Copy, Clone, Eq, PartialEq, Debug)] @@ -765,7 +751,7 @@ impl MultiByteChar { /// Identifies an offset of a non-narrow character in a SourceFile #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Copy, Clone, Eq, PartialEq, Debug)] @@ -832,7 +818,7 @@ impl Sub for NonNarrowChar { /// A single source in the SourceMap. #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Clone)] @@ -1051,7 +1037,7 @@ pub trait Pos { #[serde(transparent)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct BytePos(#[cfg_attr(feature = "__rkyv", omit_bounds)] pub u32); @@ -1078,7 +1064,7 @@ impl BytePos { /// is not equivalent to a character offset. The SourceMap will convert BytePos /// values to CharPos values as necessary. #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] @@ -1191,7 +1177,7 @@ pub struct Loc { /// A struct to exchange `Loc` with omitting SourceFile as needed. /// This is internal struct between plugins to the host, not a public interface. #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Debug, Clone) )] pub struct PartialLoc { @@ -1220,7 +1206,7 @@ pub struct SourceFileAndLine { } #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[derive(Debug)] @@ -1231,7 +1217,7 @@ pub struct SourceFileAndBytePos { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct LineInfo { @@ -1267,7 +1253,7 @@ pub struct FileLines { /// A struct to exchange `FileLines` with omitting SourceFile as needed. /// This is internal struct between plugins to the host, not a public interface. #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Debug, Clone) )] pub struct PartialFileLines { @@ -1286,7 +1272,7 @@ pub type PartialFileLinesResult = Result>; #[derive(Clone, PartialEq, Eq, Debug)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum SpanLinesError { @@ -1296,7 +1282,7 @@ pub enum SpanLinesError { #[derive(Clone, PartialEq, Eq, Debug)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum SpanSnippetError { @@ -1309,14 +1295,14 @@ pub enum SpanSnippetError { #[derive(Clone, PartialEq, Eq, Debug)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct FilePos(pub FileName, pub BytePos); #[derive(Clone, PartialEq, Eq, Debug)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct DistinctSources { @@ -1326,7 +1312,7 @@ pub struct DistinctSources { #[derive(Clone, PartialEq, Eq, Debug)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct MalformedSourceMapPositions { diff --git a/crates/swc_common/src/syntax_pos/hygiene.rs b/crates/swc_common/src/syntax_pos/hygiene.rs index ef4708f03da..790107f688d 100644 --- a/crates/swc_common/src/syntax_pos/hygiene.rs +++ b/crates/swc_common/src/syntax_pos/hygiene.rs @@ -21,8 +21,6 @@ use std::{ fmt, }; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use serde::{Deserialize, Serialize}; use super::GLOBALS; @@ -33,7 +31,7 @@ use crate::collections::AHashMap; #[derive(Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct SyntaxContext(#[cfg_attr(feature = "__rkyv", omit_bounds)] u32); @@ -69,7 +67,7 @@ pub(crate) struct MarkData { } #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct MutableMarkContext(pub u32, pub u32, pub u32); diff --git a/crates/swc_common/tests/attr_interop.rs b/crates/swc_common/tests/attr_interop.rs index 88747a1bab4..09131a1f84a 100644 --- a/crates/swc_common/tests/attr_interop.rs +++ b/crates/swc_common/tests/attr_interop.rs @@ -15,11 +15,11 @@ pub struct Tuple(#[span] HasSpan, usize, usize); #[derive(Debug, Clone, PartialEq, Eq, Spanned, Serialize, Deserialize)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), archive(bound(serialize = "__S: rkyv::ser::Serializer + rkyv::ser::ScratchSpace")) )] pub struct HasSpan { diff --git a/crates/swc_core/Cargo.toml b/crates/swc_core/Cargo.toml index bab55b7cbdd..24083de9d72 100644 --- a/crates/swc_core/Cargo.toml +++ b/crates/swc_core/Cargo.toml @@ -257,20 +257,6 @@ __ecma_plugin_transform = [ "swc_ecma_ast/rkyv-impl", ] -__plugin_transform_bytecheck = [ - # Dependent features - "ecma_visit", - "__common", - "ecma_ast", - "swc_ecma_ast/rkyv-bytecheck-impl", - "swc_atoms/rkyv-bytecheck-impl", - "swc_common/plugin-bytecheck-mode", - "swc_plugin_proxy/plugin-bytecheck-mode", - "swc_plugin_macro", - "swc_plugin", - "once_cell", -] - # Internal flags for any transform plugin host feature __plugin_transform_host = [ # Dependent features @@ -283,16 +269,6 @@ __plugin_transform_host = [ "swc/plugin", ] -# Internal flags for the transform plugin host, if it needs to enable bytecheck -__plugin_transform_host_bytecheck = [ - "__common", - "swc_atoms/rkyv-bytecheck-impl", - "swc_common/plugin-bytecheck-rt", - "swc_ecma_ast/rkyv-bytecheck-impl", - "swc_plugin_proxy/plugin-bytecheck-rt", - "swc/plugin-bytecheck", -] - # Internal flags to control plugin environment __plugin_transform_env_native = [ "swc/plugin_transform_host_native", diff --git a/crates/swc_core/tests/fixture/stub_napi/Cargo.toml b/crates/swc_core/tests/fixture/stub_napi/Cargo.toml index 4a03aeefb7d..f7cd7e413ac 100644 --- a/crates/swc_core/tests/fixture/stub_napi/Cargo.toml +++ b/crates/swc_core/tests/fixture/stub_napi/Cargo.toml @@ -15,13 +15,6 @@ plugin = ["swc_core/plugin_transform_host_native"] swc_v1 = ["swc_core/bundler_node_v1"] swc_v2 = ["swc_core/bundler_node_v2"] -# Experiemntal bytechecked plugin serialization / deserialization. -plugin_bytecheck = [ - # "swc_core/__plugin_transform_host_bytecheck", - "swc_core/__plugin_transform_host_schema_v1", - "swc_core/__plugin_transform_env_native", -] - # Internal flag for testing purpose only. __plugin_transform_vtest = [ "swc_core/__plugin_transform_host", diff --git a/crates/swc_css_ast/Cargo.toml b/crates/swc_css_ast/Cargo.toml index 6b3f8e70e53..cf21adcf494 100644 --- a/crates/swc_css_ast/Cargo.toml +++ b/crates/swc_css_ast/Cargo.toml @@ -12,14 +12,12 @@ version = "0.137.1" bench = false [features] -__rkyv = [] -default = [] -rkyv-bytecheck-impl = [] -rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] -serde-impl = ["serde"] +__rkyv = [] +default = [] +rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] +serde-impl = ["serde"] [dependencies] -bytecheck = { version = "0.6.9", optional = true } is-macro = "0.2.0" rkyv = { version = "=0.7.40", optional = true, features = [ "strict", diff --git a/crates/swc_css_ast/src/token.rs b/crates/swc_css_ast/src/token.rs index 6ed1ca529f3..26280f30143 100644 --- a/crates/swc_css_ast/src/token.rs +++ b/crates/swc_css_ast/src/token.rs @@ -28,7 +28,7 @@ impl Take for TokenAndSpan { #[derive(Debug, Clone, PartialEq, EqIgnoreSpan, Hash)] #[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub struct UrlKeyValue(pub Atom, pub Atom); diff --git a/crates/swc_ecma_ast/Cargo.toml b/crates/swc_ecma_ast/Cargo.toml index 556c1492109..82b0fb27cd1 100644 --- a/crates/swc_ecma_ast/Cargo.toml +++ b/crates/swc_ecma_ast/Cargo.toml @@ -16,35 +16,21 @@ version = "0.103.1" bench = false [features] -__rkyv = [] -default = [] -fuzzing = ["arbitrary", "swc_common/arbitrary"] -# Enably rkyv serialization with stable version of rkyv. -rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] -# Enable rkyv serialization with updated version of rkyv, along with bytecheck. -rkyv-bytecheck-impl = [ - "__rkyv", - "rkyv-latest", - "swc_atoms/rkyv-bytecheck-impl", - "swc_common/rkyv-bytecheck-impl", -] +__rkyv = [] +default = [] +fuzzing = ["arbitrary", "swc_common/arbitrary"] +rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] serde-impl = ["serde"] [dependencies] arbitrary = { version = "1", optional = true, features = ["derive"] } bitflags = "1" -bytecheck = { version = "0.6.9", optional = true } is-macro = "0.2.1" num-bigint = { version = "0.4", features = ["serde"] } rkyv = { package = "rkyv", version = "=0.7.40", optional = true, features = [ "strict", "validation", ] } -# This is to avoid cargo version selection conflict between rkyv=0.7.40 and other versions, as it is strictly pinned -# cannot be merged. -rkyv-latest = { package = "rkyv-test", version = "=0.7.38-test.2", optional = true, features = [ - "strict", -] } scoped-tls = "1.0.0" serde = { version = "1.0.133", features = ["derive"], optional = true } unicode-id = "0.3" diff --git a/crates/swc_ecma_ast/src/class.rs b/crates/swc_ecma_ast/src/class.rs index 975d48e9dd1..24dbb89db55 100644 --- a/crates/swc_ecma_ast/src/class.rs +++ b/crates/swc_ecma_ast/src/class.rs @@ -1,6 +1,4 @@ use is_macro::Is; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span, DUMMY_SP}; use crate::{ @@ -250,7 +248,7 @@ pub struct Decorator { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))] diff --git a/crates/swc_ecma_ast/src/decl.rs b/crates/swc_ecma_ast/src/decl.rs index a79a3cf4bd8..b1013e29149 100644 --- a/crates/swc_ecma_ast/src/decl.rs +++ b/crates/swc_ecma_ast/src/decl.rs @@ -1,6 +1,4 @@ use is_macro::Is; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use string_enum::StringEnum; use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span, DUMMY_SP}; @@ -117,7 +115,7 @@ impl Take for VarDecl { #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum VarDeclKind { diff --git a/crates/swc_ecma_ast/src/expr.rs b/crates/swc_ecma_ast/src/expr.rs index e90e15f3ec5..08be25fb8cc 100644 --- a/crates/swc_ecma_ast/src/expr.rs +++ b/crates/swc_ecma_ast/src/expr.rs @@ -1,7 +1,5 @@ #![allow(clippy::vec_box)] use is_macro::Is; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[cfg(feature = "serde-impl")] use serde::{ self, @@ -574,11 +572,11 @@ bridge_expr_from!(ClassExpr, Box); #[derive(Spanned, Clone, Debug, PartialEq)] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), archive(bound( serialize = "__S: rkyv::ser::Serializer + rkyv::ser::ScratchSpace + \ rkyv::ser::SharedSerializeRegistry", @@ -939,7 +937,7 @@ pub struct MetaPropExpr { #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum MetaPropKind { @@ -1120,11 +1118,11 @@ impl Take for Import { #[derive(Clone, Debug, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), archive(bound( serialize = "__S: rkyv::ser::Serializer + rkyv::ser::ScratchSpace + \ rkyv::ser::SharedSerializeRegistry", diff --git a/crates/swc_ecma_ast/src/ident.rs b/crates/swc_ecma_ast/src/ident.rs index bd87ec80a7f..f4e1f10f5bd 100644 --- a/crates/swc_ecma_ast/src/ident.rs +++ b/crates/swc_ecma_ast/src/ident.rs @@ -1,7 +1,5 @@ use std::fmt::Display; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use scoped_tls::scoped_thread_local; use swc_atoms::{js_word, JsWord}; use swc_common::{ @@ -15,11 +13,11 @@ use crate::typescript::TsTypeAnn; #[derive(Spanned, Clone, Debug, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), archive(bound( serialize = "__S: rkyv::ser::Serializer + rkyv::ser::ScratchSpace + \ rkyv::ser::SharedSerializeRegistry", @@ -115,10 +113,7 @@ bridge_from!(BindingIdent, Ident, Id); pub struct Ident { pub span: Span, #[cfg_attr(feature = "serde-impl", serde(rename = "value"))] - #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), - with(swc_atoms::EncodeJsWord) - )] + #[cfg_attr(any(feature = "rkyv-impl"), with(swc_atoms::EncodeJsWord))] pub sym: JsWord, /// TypeScript only. Used in case of an optional parameter. diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index 301c26afd77..299f490758b 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -9,9 +9,6 @@ #![allow(clippy::clone_on_copy)] #![recursion_limit = "1024"] -#[cfg(all(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] -compile_error!("Cannot enable bytechcked, non-bytechecked rkyv both"); - #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use swc_common::{ast_node, EqIgnoreSpan, Span}; diff --git a/crates/swc_ecma_ast/src/lit.rs b/crates/swc_ecma_ast/src/lit.rs index 1944e92d0bb..a09d5c1f2f6 100644 --- a/crates/swc_ecma_ast/src/lit.rs +++ b/crates/swc_ecma_ast/src/lit.rs @@ -6,8 +6,6 @@ use std::{ }; use num_bigint::BigInt as BigIntValue; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use swc_atoms::{js_word, Atom, JsWord}; use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span, DUMMY_SP}; @@ -68,10 +66,7 @@ bridge_lit_from!(BigInt, BigIntValue); #[derive(Eq, Hash)] pub struct BigInt { pub span: Span, - #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), - with(EncodeBigInt) - )] + #[cfg_attr(any(feature = "rkyv-impl"), with(EncodeBigInt))] pub value: Box, /// Use `None` value only for transformations to avoid recalculate @@ -89,7 +84,7 @@ impl EqIgnoreSpan for BigInt { #[derive(Debug, Clone, Copy)] pub struct EncodeBigInt; -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::ArchiveWith> for EncodeBigInt { type Archived = rkyv::Archived; type Resolver = rkyv::Resolver; @@ -107,7 +102,7 @@ impl rkyv::with::ArchiveWith> for EncodeBigInt { } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::SerializeWith, S> for EncodeBigInt where S: ?Sized + rkyv::ser::Serializer, @@ -121,7 +116,7 @@ where } } -#[cfg(any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] +#[cfg(any(feature = "rkyv-impl"))] impl rkyv::with::DeserializeWith, Box, D> for EncodeBigInt where D: ?Sized + rkyv::Fallible, @@ -167,10 +162,7 @@ impl From for BigInt { pub struct Str { pub span: Span, - #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), - with(swc_atoms::EncodeJsWord) - )] + #[cfg_attr(any(feature = "rkyv-impl"), with(swc_atoms::EncodeJsWord))] pub value: JsWord, /// Use `None` value only for transformations to avoid recalculate escaped diff --git a/crates/swc_ecma_ast/src/operators.rs b/crates/swc_ecma_ast/src/operators.rs index 7b77d5a3d93..ded98f9c36e 100644 --- a/crates/swc_ecma_ast/src/operators.rs +++ b/crates/swc_ecma_ast/src/operators.rs @@ -1,12 +1,10 @@ -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; use string_enum::StringEnum; use swc_common::EqIgnoreSpan; #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum BinaryOp { @@ -115,7 +113,7 @@ impl BinaryOp { #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum AssignOp { @@ -188,7 +186,7 @@ impl AssignOp { #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum UpdateOp { @@ -201,7 +199,7 @@ pub enum UpdateOp { #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum UnaryOp { diff --git a/crates/swc_ecma_ast/src/typescript.rs b/crates/swc_ecma_ast/src/typescript.rs index 6ae86fb662a..eb0af2b83f8 100644 --- a/crates/swc_ecma_ast/src/typescript.rs +++ b/crates/swc_ecma_ast/src/typescript.rs @@ -5,8 +5,6 @@ use std::fmt; use is_macro::Is; -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[cfg(feature = "serde-impl")] use serde::{ de::{self, Unexpected, Visitor}, @@ -397,7 +395,7 @@ pub struct TsKeywordType { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))] @@ -679,7 +677,7 @@ pub struct TsTypeOperator { #[derive(StringEnum, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum TsTypeOperatorOp { @@ -705,7 +703,7 @@ pub struct TsIndexedAccessType { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] pub enum TruePlusMinus { @@ -1078,7 +1076,7 @@ pub struct TsSatisfiesExpr { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr( - any(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"), + any(feature = "rkyv-impl"), derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))] diff --git a/crates/swc_html_ast/Cargo.toml b/crates/swc_html_ast/Cargo.toml index c3fc6b9481e..098c07053b8 100644 --- a/crates/swc_html_ast/Cargo.toml +++ b/crates/swc_html_ast/Cargo.toml @@ -15,13 +15,11 @@ version = "0.31.1" bench = false [features] -__rkyv = [] -rkyv-bytecheck-impl = [] -rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] -serde-impl = ["serde"] +__rkyv = [] +rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "swc_common/rkyv-impl"] +serde-impl = ["serde"] [dependencies] -bytecheck = { version = "0.6.9", optional = true } is-macro = "0.2.0" rkyv = { version = "=0.7.40", optional = true, features = [ "strict", diff --git a/crates/swc_plugin_proxy/Cargo.toml b/crates/swc_plugin_proxy/Cargo.toml index e9591ffee33..9571e4c4bc7 100644 --- a/crates/swc_plugin_proxy/Cargo.toml +++ b/crates/swc_plugin_proxy/Cargo.toml @@ -11,29 +11,14 @@ version = "0.32.1" bench = false [features] -__rkyv = [] -# Enably rkyv serialization with stable version of rkyv. +__rkyv = [] rkyv-impl = ["__rkyv", "rkyv"] -# Enable rkyv serialization with updated version of rkyv, along with bytecheck. -rkyv-bytecheck-impl = ["__rkyv", "rkyv-latest"] __plugin_mode = [] __plugin_rt = [] # swc/core, which runs plugin -plugin-bytecheck-rt = [ - "__plugin_rt", - "swc_common/plugin-bytecheck-base", - "rkyv-bytecheck-impl", -] -plugin-rt = ["__plugin_rt", "swc_common/plugin-base", "rkyv-impl"] - -# actual wasm plugin binary -plugin-bytecheck-mode = [ - "__plugin_mode", - "swc_common/plugin-bytecheck-base", - "rkyv-bytecheck-impl", -] plugin-mode = ["__plugin_mode", "swc_common/plugin-base", "rkyv-impl"] +plugin-rt = ["__plugin_rt", "swc_common/plugin-base", "rkyv-impl"] [dependencies] @@ -41,10 +26,7 @@ rkyv = { package = "rkyv", version = "=0.7.40", optional = true, features = [ "strict", "validation", ] } -# This is to avoid cargo version selection conflict between rkyv=0.7.40 and other versions, as it is strictly pinned -# cannot be merged. -rkyv-latest = { package = "rkyv-test", version = "=0.7.38-test.2", optional = true } -tracing = "0.1.32" +tracing = "0.1.32" better_scoped_tls = { version = "0.1.0", path = "../better_scoped_tls" } swc_common = { version = "0.31.1", path = "../swc_common" } 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 b1fb40767d5..acf7587485a 100644 --- a/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs +++ b/crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[cfg(feature = "__plugin_mode")] use swc_common::{ comments::{Comment, Comments}, diff --git a/crates/swc_plugin_proxy/src/lib.rs b/crates/swc_plugin_proxy/src/lib.rs index 69b7d16bc6f..c37bf5289a6 100644 --- a/crates/swc_plugin_proxy/src/lib.rs +++ b/crates/swc_plugin_proxy/src/lib.rs @@ -1,8 +1,5 @@ #![cfg_attr(not(feature = "__rkyv"), allow(warnings))] -#[cfg(all(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))] -compile_error!("Cannot enable bytechcked, non-bytechecked rkyv both"); - mod comments; mod memory_interop; mod metadata; 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 6a2b00f9a2c..56ace2fbd89 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 @@ -1,5 +1,3 @@ -#[cfg(feature = "rkyv-bytecheck-impl")] -use rkyv_latest as rkyv; #[cfg_attr(not(target_arch = "wasm32"), allow(unused))] #[cfg(any(feature = "__plugin_rt", feature = "__plugin_mode"))] use swc_common::plugin::serialized::{deserialize_from_ptr, PluginSerializedBytes}; diff --git a/crates/swc_plugin_runner/Cargo.toml b/crates/swc_plugin_runner/Cargo.toml index 1778d518251..f8e9c3f3a4d 100644 --- a/crates/swc_plugin_runner/Cargo.toml +++ b/crates/swc_plugin_runner/Cargo.toml @@ -44,12 +44,7 @@ ecma = ["swc_ecma_ast/rkyv-impl"] # Enable CSS support css = ["swc_css_ast/rkyv-impl"] -__rkyv = [] -rkyv-bytecheck-impl = [ - "__rkyv", - "swc_common/plugin-bytecheck-rt", - "swc_plugin_proxy/plugin-bytecheck-rt", -] +__rkyv = [] rkyv-impl = ["__rkyv", "swc_common/plugin-rt", "swc_plugin_proxy/plugin-rt"] [dependencies] diff --git a/package.json b/package.json index 9aad5a7dfbc..8b7aebfac98 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "build:wasm": "npm-run-all \"pack -- build ./bindings/binding_core_wasm --scope swc {1} -t {2} --features plugin\" --", "build": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --cargo-cwd ./bindings -p binding_core_node --release", "build:dev": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --cargo-cwd ./bindings -p binding_core_node", - "build:bytecheck": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --cargo-cwd ./bindings --features swc_v1,plugin_bytecheck -p binding_core_node --cargo-flags=--no-default-features --release", "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --config ./node-swc/jest.config.js", "version": "napi version -p scripts/npm" }, @@ -178,4 +177,4 @@ "bindings/binding_core_wasm/pkg/binding_core_wasm.d.ts" ], "packageManager": "yarn@3.5.0" -} +} \ No newline at end of file diff --git a/scripts/github/tests.yml b/scripts/github/tests.yml index ade62017fb0..15c993c7dd3 100644 --- a/scripts/github/tests.yml +++ b/scripts/github/tests.yml @@ -26,13 +26,13 @@ os: check: swc: # plugin feature is verified by other tasks - - "cargo hack check --feature-powerset --no-dev-deps --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest --exclude-features plugin-bytecheck" + - "cargo hack check --feature-powerset --no-dev-deps --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest" swc_bundler: - "cargo hack check --feature-powerset --no-dev-deps" swc_common: - - "cargo hack check --feature-powerset --no-dev-deps --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features plugin-bytecheck-base --exclude-features plugin-bytecheck-mode --exclude-features plugin-bytecheck-rt --exclude-features rkyv-bytecheck-impl --exclude-features rkyv-impl" + - "cargo hack check --feature-powerset --no-dev-deps --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features rkyv-impl" swc_ecma_ast: - - "cargo hack check --feature-powerset --no-dev-deps --exclude-features __rkyv --exclude-features rkyv-bytecheck-impl" + - "cargo hack check --feature-powerset --no-dev-deps --exclude-features __rkyv" swc_ecma_loader: - "cargo hack check --feature-powerset --no-dev-deps" swc_ecma_transforms: