refactor(transformer): improve encapsulation of transforms (#7888)

Modules in `oxc_transformer` only export the minimum required, to make the transforms less tightly coupled to each other.
This commit is contained in:
overlookmotel 2024-12-14 14:48:28 +00:00
parent 98d794673b
commit 2c942362da
6 changed files with 12 additions and 12 deletions

View file

@ -586,8 +586,8 @@ impl<'a> ArrowFunctionConverter<'a> {
/// Transforms a `MemberExpression` whose object is a `super` expression. /// Transforms a `MemberExpression` whose object is a `super` expression.
/// ///
/// In the [`AsyncToGenerator`](crate::es2017::async_to_generator::AsyncToGenerator) and /// In the [`AsyncToGenerator`](crate::es2017::AsyncToGenerator) and
/// [`AsyncGeneratorFunctions`](crate::es2018::async_generator_functions::AsyncGeneratorFunctions) plugins, /// [`AsyncGeneratorFunctions`](crate::es2018::AsyncGeneratorFunctions) plugins,
/// we move the body of an async method to a new generator function. This can cause /// we move the body of an async method to a new generator function. This can cause
/// `super` expressions to appear in unexpected places, leading to syntax errors. /// `super` expressions to appear in unexpected places, leading to syntax errors.
/// ///

View file

@ -1,12 +1,12 @@
pub(crate) mod async_to_generator; mod async_to_generator;
mod options; mod options;
pub use async_to_generator::AsyncGeneratorExecutor; pub use async_to_generator::{AsyncGeneratorExecutor, AsyncToGenerator};
pub use options::ES2017Options; pub use options::ES2017Options;
use oxc_ast::ast::{Expression, Function, Statement}; use oxc_ast::ast::{Expression, Function, Statement};
use oxc_traverse::{Traverse, TraverseCtx}; use oxc_traverse::{Traverse, TraverseCtx};
use crate::{es2017::async_to_generator::AsyncToGenerator, TransformCtx}; use crate::TransformCtx;
#[allow(dead_code)] #[allow(dead_code)]
pub struct ES2017<'a, 'ctx> { pub struct ES2017<'a, 'ctx> {

View file

@ -1,8 +1,8 @@
pub(crate) mod async_generator_functions; mod async_generator_functions;
mod object_rest_spread; mod object_rest_spread;
mod options; mod options;
use async_generator_functions::AsyncGeneratorFunctions; pub use async_generator_functions::AsyncGeneratorFunctions;
pub use object_rest_spread::{ObjectRestSpread, ObjectRestSpreadOptions}; pub use object_rest_spread::{ObjectRestSpread, ObjectRestSpreadOptions};
pub use options::ES2018Options; pub use options::ES2018Options;
use oxc_ast::ast::*; use oxc_ast::ast::*;

View file

@ -2,7 +2,7 @@ mod nullish_coalescing_operator;
mod optional_chaining; mod optional_chaining;
mod options; mod options;
pub use nullish_coalescing_operator::NullishCoalescingOperator; use nullish_coalescing_operator::NullishCoalescingOperator;
pub use optional_chaining::OptionalChaining; pub use optional_chaining::OptionalChaining;
pub use options::ES2020Options; pub use options::ES2020Options;
use oxc_ast::ast::*; use oxc_ast::ast::*;

View file

@ -100,8 +100,8 @@ use oxc_syntax::{
}; };
use oxc_traverse::{BoundIdentifier, Traverse, TraverseCtx}; use oxc_traverse::{BoundIdentifier, Traverse, TraverseCtx};
use super::diagnostics; use super::{
pub use super::{ diagnostics,
jsx_self::JsxSelf, jsx_self::JsxSelf,
jsx_source::JsxSource, jsx_source::JsxSource,
options::{JsxOptions, JsxRuntime}, options::{JsxOptions, JsxRuntime},

View file

@ -12,8 +12,8 @@ mod jsx_source;
mod options; mod options;
mod refresh; mod refresh;
pub(crate) use comments::update_options_with_comments; pub(crate) use comments::update_options_with_comments;
pub use display_name::ReactDisplayName; use display_name::ReactDisplayName;
pub use jsx_impl::JsxImpl; use jsx_impl::JsxImpl;
use jsx_self::JsxSelf; use jsx_self::JsxSelf;
pub use options::{JsxOptions, JsxRuntime, ReactRefreshOptions}; pub use options::{JsxOptions, JsxRuntime, ReactRefreshOptions};
use refresh::ReactRefresh; use refresh::ReactRefresh;