diff --git a/.changeset/violet-jobs-cough.md b/.changeset/violet-jobs-cough.md new file mode 100644 index 000000000000..d8dddfbd218d --- /dev/null +++ b/.changeset/violet-jobs-cough.md @@ -0,0 +1,8 @@ +--- +swc_ecma_parser: major +swc_ecma_lints: major +swc_ecma_transforms_base: major +swc_ecma_utils: major +--- + +refactor: Apply all pending breaking changes diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index a62074c3609d..e5be5b17ac74 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -37,8 +37,6 @@ use swc_ecma_loader::resolvers::{ }; pub use swc_ecma_minifier::js::*; use swc_ecma_minifier::option::terser::TerserTopLevelOptions; -#[allow(deprecated)] -pub use swc_ecma_parser::JscTarget; use swc_ecma_parser::{parse_file_as_expr, Syntax, TsSyntax}; pub use swc_ecma_transforms::proposals::DecoratorVersion; use swc_ecma_transforms::{ @@ -53,7 +51,7 @@ use swc_ecma_transforms::{ optimization::{const_modules, json_parse, simplifier}, proposals::{ decorators, explicit_resource_management::explicit_resource_management, - export_default_from, import_assertions, + export_default_from, import_attributes, }, react::{self, default_pragma, default_pragma_frag}, resolver, @@ -729,7 +727,7 @@ impl Options { // The transform strips import assertions, so it's only enabled if // keep_import_assertions is false. ( - Optional::new(import_assertions(), !keep_import_attributes), + Optional::new(import_attributes(), !keep_import_attributes), Optional::new( typescript::tsx::>( cm.clone(), @@ -1466,10 +1464,6 @@ pub struct TransformConfig { #[serde(default)] pub regenerator: regenerator::Config, - #[serde(default)] - #[deprecated] - pub treat_const_enum_as_enum: BoolConfig, - /// https://www.typescriptlang.org/tsconfig#useDefineForClassFields #[serde(default)] pub use_define_for_class_fields: BoolConfig, diff --git a/crates/swc_ecma_lints/src/rules/mod.rs b/crates/swc_ecma_lints/src/rules/mod.rs index 230c632a7ff8..e6c606d71230 100644 --- a/crates/swc_ecma_lints/src/rules/mod.rs +++ b/crates/swc_ecma_lints/src/rules/mod.rs @@ -3,8 +3,6 @@ use std::sync::Arc; use swc_common::{SourceMap, SyntaxContext}; use swc_ecma_ast::*; -#[deprecated = "Use lint_pass instead"] -pub use self::lint_pass as lint_to_fold; use crate::{config::LintConfig, rule::Rule}; mod const_assign; diff --git a/crates/swc_ecma_minifier/scripts/_/samply-script.js b/crates/swc_ecma_minifier/scripts/_/samply-script.js index b25e31b1ff78..79009b7cc6fb 100644 --- a/crates/swc_ecma_minifier/scripts/_/samply-script.js +++ b/crates/swc_ecma_minifier/scripts/_/samply-script.js @@ -49,7 +49,7 @@ const lib = row.querySelector(".lib"); const libText = lib.textContent.trim(); if ( - libText.endsWith("/swc_ecma_visit/src/") || + libText.includes("/swc_ecma_visit/src/") || libText.endsWith("/swc_ecma_utils/src/parallel.rs") || libText.includes("/.rustup/") || libText.includes("/std/") || diff --git a/crates/swc_ecma_minifier/src/pass/mangle_names/mod.rs b/crates/swc_ecma_minifier/src/pass/mangle_names/mod.rs index e71e1a29fe32..25442d101af2 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_names/mod.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_names/mod.rs @@ -49,7 +49,6 @@ pub(crate) fn mangle_names( top_level_mark, ignore_eval: options.eval, preserved_symbols: options.reserved.iter().cloned().collect(), - ..Default::default() }, ManglingRenamer { chars, diff --git a/crates/swc_ecma_minifier/tests/compress.rs b/crates/swc_ecma_minifier/tests/compress.rs index d0695854ea11..e64a6c90d90a 100644 --- a/crates/swc_ecma_minifier/tests/compress.rs +++ b/crates/swc_ecma_minifier/tests/compress.rs @@ -18,6 +18,7 @@ use serde::Deserialize; use swc_common::{ comments::{Comments, SingleThreadedComments}, errors::{Handler, HANDLER}, + input::SourceFileInput, sync::Lrc, util::take::Take, EqIgnoreSpan, FileName, Mark, SourceMap, @@ -34,10 +35,7 @@ use swc_ecma_minifier::{ MinifyOptions, TopLevelOptions, }, }; -use swc_ecma_parser::{ - lexer::{input::SourceFileInput, Lexer}, - EsSyntax, Parser, Syntax, -}; +use swc_ecma_parser::{lexer::Lexer, EsSyntax, Parser, Syntax}; use swc_ecma_testing::{exec_node_js, JsExecOptions}; use swc_ecma_transforms_base::{ fixer::{fixer, paren_remover}, diff --git a/crates/swc_ecma_minifier/tests/terser_exec.rs b/crates/swc_ecma_minifier/tests/terser_exec.rs index fd13cab795de..3bf3b66c1586 100644 --- a/crates/swc_ecma_minifier/tests/terser_exec.rs +++ b/crates/swc_ecma_minifier/tests/terser_exec.rs @@ -16,6 +16,7 @@ use serde::Deserialize; use swc_common::{ comments::SingleThreadedComments, errors::{Handler, HANDLER}, + input::SourceFileInput, sync::Lrc, Mark, SourceMap, }; @@ -28,10 +29,7 @@ use swc_ecma_minifier::{ optimize, option::{terser::TerserCompressorOptions, CompressOptions, ExtraOptions, MinifyOptions}, }; -use swc_ecma_parser::{ - lexer::{input::SourceFileInput, Lexer}, - EsSyntax, Parser, Syntax, -}; +use swc_ecma_parser::{lexer::Lexer, EsSyntax, Parser, Syntax}; use swc_ecma_transforms_base::{ fixer::{fixer, paren_remover}, hygiene::hygiene, diff --git a/crates/swc_ecma_parser/src/lexer/mod.rs b/crates/swc_ecma_parser/src/lexer/mod.rs index 31bb91f29d3a..db4a35322a1e 100644 --- a/crates/swc_ecma_parser/src/lexer/mod.rs +++ b/crates/swc_ecma_parser/src/lexer/mod.rs @@ -5,19 +5,20 @@ use std::{cell::RefCell, char, iter::FusedIterator, mem::transmute, rc::Rc}; use either::Either::{Left, Right}; use smallvec::{smallvec, SmallVec}; use swc_atoms::{Atom, AtomStoreCell}; -use swc_common::{comments::Comments, input::StringInput, BytePos, Span}; +use swc_common::{ + comments::Comments, + input::{Input, StringInput}, + BytePos, Span, +}; use swc_ecma_ast::{op, AssignOp, EsVersion, Ident}; +pub use self::state::{TokenContext, TokenContexts}; use self::{ comments_buffer::CommentsBuffer, state::State, table::{ByteHandler, BYTE_HANDLERS}, util::*, }; -pub use self::{ - input::Input, - state::{TokenContext, TokenContexts}, -}; use crate::{ error::{Error, SyntaxError}, token::{BinOpToken, IdentLike, Token, Word}, @@ -25,8 +26,6 @@ use crate::{ }; mod comments_buffer; -#[deprecated = "Directly use swc_common::input instead"] -pub mod input; mod jsx; mod number; mod state; diff --git a/crates/swc_ecma_parser/src/lexer/util.rs b/crates/swc_ecma_parser/src/lexer/util.rs index 0dd8c52a834d..cb7dc83c2681 100644 --- a/crates/swc_ecma_parser/src/lexer/util.rs +++ b/crates/swc_ecma_parser/src/lexer/util.rs @@ -6,15 +6,13 @@ use std::char; use swc_common::{ comments::{Comment, CommentKind}, + input::Input, BytePos, Span, }; use swc_ecma_ast::Ident; use tracing::warn; -use super::{ - comments_buffer::BufferedComment, input::Input, whitespace::SkipWhitespace, Char, LexResult, - Lexer, -}; +use super::{comments_buffer::BufferedComment, whitespace::SkipWhitespace, Char, LexResult, Lexer}; use crate::{ error::{Error, SyntaxError}, lexer::comments_buffer::BufferedCommentKind, diff --git a/crates/swc_ecma_parser/src/lib.rs b/crates/swc_ecma_parser/src/lib.rs index e2ed67dbff1f..1564da41e6ff 100644 --- a/crates/swc_ecma_parser/src/lib.rs +++ b/crates/swc_ecma_parser/src/lib.rs @@ -127,15 +127,11 @@ use error::Error; use lexer::Lexer; use serde::{Deserialize, Serialize}; +pub use swc_common::input::{Input, StringInput}; use swc_common::{comments::Comments, input::SourceFileInput, SourceFile}; use swc_ecma_ast::*; -pub use self::{ - lexer::input::{Input, StringInput}, - parser::*, -}; -#[deprecated(note = "Use `EsVersion` instead")] -pub type JscTarget = EsVersion; +pub use self::parser::*; #[macro_use] mod macros; @@ -331,9 +327,6 @@ pub struct TsSyntax { pub disallow_ambiguous_jsx_like: bool, } -#[deprecated(note = "Use 'TsSyntax' instead")] -pub type TsConfig = TsSyntax; - #[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct EsSyntax { @@ -376,9 +369,6 @@ pub struct EsSyntax { pub explicit_resource_management: bool, } -#[deprecated(note = "Use 'EsSyntax' instead")] -pub type EsConfig = EsSyntax; - /// Syntactic context. #[derive(Debug, Clone, Copy, Default)] pub struct Context { diff --git a/crates/swc_ecma_transforms_base/src/assumptions.rs b/crates/swc_ecma_transforms_base/src/assumptions.rs index 9b4b551531fb..7c6f9ad47b19 100644 --- a/crates/swc_ecma_transforms_base/src/assumptions.rs +++ b/crates/swc_ecma_transforms_base/src/assumptions.rs @@ -95,10 +95,6 @@ pub struct Assumptions { /// https://babeljs.io/docs/en/assumptions#superiscallableconstructor #[serde(default)] pub super_is_callable_constructor: bool, - - #[serde(default)] - #[deprecated(note = "This value will be always true")] - pub ts_enum_is_readonly: bool, } #[allow(deprecated)] @@ -127,7 +123,6 @@ impl Assumptions { set_spread_properties: true, skip_for_of_iterator_closing: true, super_is_callable_constructor: true, - ts_enum_is_readonly: true, } } } diff --git a/crates/swc_ecma_transforms_base/src/hygiene/mod.rs b/crates/swc_ecma_transforms_base/src/hygiene/mod.rs index 1e5b1cc0a1be..aa74c96cf2db 100644 --- a/crates/swc_ecma_transforms_base/src/hygiene/mod.rs +++ b/crates/swc_ecma_transforms_base/src/hygiene/mod.rs @@ -16,10 +16,6 @@ pub struct Config { /// If true, the `hygiene` pass will preserve class names. pub keep_class_names: bool, - /// If true, the bug of safari 10 is avoided. - #[deprecated = "This field is no longer required to work around bugs in Safari 10."] - pub safari_10: bool, - /// The marks derived from this marks will treated as `specified by user` /// and other marks will be treated as `generated by swc`. pub top_level_mark: Mark, diff --git a/crates/swc_ecma_transforms_base/src/rename/analyzer/scope.rs b/crates/swc_ecma_transforms_base/src/rename/analyzer/scope.rs index 3afff98aa2d4..007981b2cdae 100644 --- a/crates/swc_ecma_transforms_base/src/rename/analyzer/scope.rs +++ b/crates/swc_ecma_transforms_base/src/rename/analyzer/scope.rs @@ -199,7 +199,10 @@ impl Scope { true } - #[cfg_attr(not(feature = "concurrent-renamer"), allow(unused))] + #[cfg_attr( + not(feature = "concurrent-renamer"), + allow(unused, clippy::only_used_in_recursion) + )] pub(crate) fn rename_in_mangle_mode( &mut self, renamer: &R, diff --git a/crates/swc_ecma_transforms_module/src/path.rs b/crates/swc_ecma_transforms_module/src/path.rs index df65484b5c36..fd71e36c5be3 100644 --- a/crates/swc_ecma_transforms_module/src/path.rs +++ b/crates/swc_ecma_transforms_module/src/path.rs @@ -117,22 +117,6 @@ impl NodeImportResolver where R: Resolve, { - #[deprecated(note = "Use `with_config`")] - pub fn new(resolver: R) -> Self { - Self::with_config(resolver, Default::default()) - } - - #[deprecated(note = "Use `with_config`")] - pub fn with_base_dir(resolver: R, base_dir: Option) -> Self { - Self::with_config( - resolver, - Config { - base_dir, - ..Default::default() - }, - ) - } - pub fn with_config(resolver: R, config: Config) -> Self { #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] if let Some(base_dir) = &config.base_dir { diff --git a/crates/swc_ecma_transforms_proposal/src/import_assertions.rs b/crates/swc_ecma_transforms_proposal/src/import_attributes.rs similarity index 83% rename from crates/swc_ecma_transforms_proposal/src/import_assertions.rs rename to crates/swc_ecma_transforms_proposal/src/import_attributes.rs index 7d3f0800a44e..dd0ddd59cb7a 100644 --- a/crates/swc_ecma_transforms_proposal/src/import_assertions.rs +++ b/crates/swc_ecma_transforms_proposal/src/import_attributes.rs @@ -1,9 +1,6 @@ use swc_ecma_ast::{ExportAll, ImportDecl, NamedExport, Pass}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut}; -#[deprecated(note = "Please use `import_assertions` instead")] -pub use self::import_attributes as import_assertions; - pub fn import_attributes() -> impl Pass { visit_mut_pass(ImportAssertions) } diff --git a/crates/swc_ecma_transforms_proposal/src/lib.rs b/crates/swc_ecma_transforms_proposal/src/lib.rs index 58ed23fb9eb5..196364016864 100644 --- a/crates/swc_ecma_transforms_proposal/src/lib.rs +++ b/crates/swc_ecma_transforms_proposal/src/lib.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; pub use self::{ decorators::decorators, export_default_from::export_default_from, - import_assertions::import_assertions, + import_attributes::import_attributes, }; #[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)] @@ -27,4 +27,4 @@ mod decorator_impl; pub mod decorators; pub mod explicit_resource_management; mod export_default_from; -mod import_assertions; +mod import_attributes; diff --git a/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs b/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs index 3c9b5abd28eb..05a2ec57dc49 100644 --- a/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs +++ b/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs @@ -1,10 +1,10 @@ use swc_ecma_ast::Pass; use swc_ecma_parser::{EsSyntax, Syntax}; -use swc_ecma_transforms_proposal::import_assertions; +use swc_ecma_transforms_proposal::import_attributes; use swc_ecma_transforms_testing::test; fn tr() -> impl Pass { - import_assertions() + import_attributes() } fn syntax() -> Syntax { diff --git a/crates/swc_ecma_transforms_typescript/src/config.rs b/crates/swc_ecma_transforms_typescript/src/config.rs index 9dffd77f8201..4cb495713ccc 100644 --- a/crates/swc_ecma_transforms_typescript/src/config.rs +++ b/crates/swc_ecma_transforms_typescript/src/config.rs @@ -84,6 +84,3 @@ pub enum ImportsNotUsedAsValues { #[serde(rename = "preserve")] Preserve, } - -#[deprecated = "ImportNotUsedAsValues is renamed to ImportsNotUsedAsValues"] -pub type ImportNotUsedAsValues = ImportsNotUsedAsValues; diff --git a/crates/swc_ecma_utils/src/ident.rs b/crates/swc_ecma_utils/src/ident.rs index db2c96e5c54f..e00d5759f13a 100644 --- a/crates/swc_ecma_utils/src/ident.rs +++ b/crates/swc_ecma_utils/src/ident.rs @@ -83,9 +83,3 @@ impl IdentLike for UnsafeId { unreachable!("UnsafeId.into_id() is not allowed because it is very likely to be unsafe") } } - -#[deprecated = "Use i.to_id() instead"] -#[inline(always)] -pub fn id(i: &Ident) -> Id { - (i.sym.clone(), i.ctxt) -} diff --git a/crates/swc_ecma_utils/src/lib.rs b/crates/swc_ecma_utils/src/lib.rs index 18dd69b7bd98..08f0b08a396c 100644 --- a/crates/swc_ecma_utils/src/lib.rs +++ b/crates/swc_ecma_utils/src/lib.rs @@ -1361,11 +1361,6 @@ pub fn prop_name_to_member_prop(prop_name: PropName) -> MemberProp { } } -#[deprecated(note = "Use default_constructor_with_span instead")] -pub fn default_constructor(has_super: bool) -> Constructor { - default_constructor_with_span(has_super, DUMMY_SP) -} - /// `super_call_span` should be the span of the class definition /// Use value of [`Class::span`]. pub fn default_constructor_with_span(has_super: bool, super_call_span: Span) -> Constructor { @@ -1479,18 +1474,7 @@ pub fn prepend_stmts(to: &mut Vec, stmts: impl ExactSizeIterator pub trait IsDirective { fn as_ref(&self) -> Option<&Stmt>; - #[deprecated(note = "use directive_continue instead")] - fn is_directive(&self) -> bool { - match self.as_ref() { - Some(Stmt::Expr(expr)) => match &*expr.expr { - Expr::Lit(Lit::Str(Str { - raw: Some(value), .. - })) => value.starts_with("\"use ") || value.starts_with("'use "), - _ => false, - }, - _ => false, - } - } + fn directive_continue(&self) -> bool { self.as_ref().map_or(false, Stmt::can_precede_directive) }