Skip to content

Commit

Permalink
refactor: cleanup ImporterInfo (#5744)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanjoi authored Feb 21, 2024
1 parent 397e6cb commit c885fb6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use swc_core::ecma::ast::{ImportDecl, ImportSpecifier, ModuleExportName};

use super::JavascriptParserPlugin;
use crate::dependency::{HarmonyImportSideEffectDependency, Specifier};
use crate::visitors::harmony_import_dependency_scanner::ImporterReferenceInfo;
use crate::visitors::ImporterReferenceInfo;
use crate::visitors::JavascriptParser;

pub(super) fn handle_harmony_import_side_effects_dep(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
dependency::PureExpressionDependency,
is_pure_class, is_pure_class_member,
plugin::side_effects_flag_plugin::is_pure_expression,
visitors::{harmony_import_dependency_scanner::ImportMap, ExtraSpanInfo},
visitors::{ExtraSpanInfo, ImportMap},
ClassExt,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,6 @@ impl ImporterReferenceInfo {

pub type ImportMap = HashMap<Id, ImporterReferenceInfo>;

#[derive(Debug)]
pub struct ImporterInfo {
pub span: Span,
pub source_span: Span,
pub specifiers: Vec<Specifier>,
pub exports_all: bool,
}

impl ImporterInfo {
pub fn new(span: Span, source_span: Span, specifiers: Vec<Specifier>, exports_all: bool) -> Self {
Self {
span,
source_span,
specifiers,
exports_all,
}
}
}

pub struct HarmonyImportRefDependencyScanner<'a> {
pub enter_callee: bool,
pub enter_new_expr: bool,
Expand Down
14 changes: 6 additions & 8 deletions crates/rspack_plugin_javascript/src/visitors/dependency/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
mod context_dependency_helper;
mod context_helper;
mod harmony_export_dependency_scanner;
pub mod harmony_import_dependency_scanner;
mod harmony_import_dependency_scanner;
mod parser;
mod util;

pub use context_dependency_helper::create_context_dependency;
pub use context_helper::{scanner_context_module, ContextModuleScanResult};
use rspack_ast::javascript::Program;
use rspack_core::needs_refactor::WorkerSyntaxList;
use rspack_core::{
Expand All @@ -19,14 +17,14 @@ use swc_core::common::comments::Comments;
use swc_core::common::{SourceFile, Span};
use swc_core::ecma::atoms::Atom;

use self::harmony_import_dependency_scanner::ImportMap;
pub use self::context_dependency_helper::create_context_dependency;
pub use self::context_helper::{scanner_context_module, ContextModuleScanResult};
use self::harmony_export_dependency_scanner::HarmonyExportDependencyScanner;
use self::harmony_import_dependency_scanner::HarmonyImportRefDependencyScanner;
pub use self::harmony_import_dependency_scanner::{ImportMap, ImporterReferenceInfo};
pub use self::parser::{CallExpressionInfo, CallHooksName, ExportedVariableInfo};
pub use self::parser::{JavascriptParser, MemberExpressionInfo, TagInfoData, TopLevelScope};
pub use self::util::*;
use self::{
harmony_export_dependency_scanner::HarmonyExportDependencyScanner,
harmony_import_dependency_scanner::HarmonyImportRefDependencyScanner,
};

pub struct ScanDependenciesResult {
pub dependencies: Vec<BoxDependency>,
Expand Down

1 comment on commit c885fb6

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-02-21 792b402) Current Change
10000_development-mode + exec 1.69 s ± 13 ms 1.7 s ± 24 ms +0.56 %
10000_development-mode_hmr + exec 921 ms ± 14 ms 915 ms ± 13 ms -0.62 %
10000_production-mode + exec 2.68 s ± 68 ms 2.63 s ± 23 ms -2.06 %
arco-pro_development-mode + exec 2.48 s ± 54 ms 2.48 s ± 31 ms -0.21 %
arco-pro_development-mode_hmr + exec 866 ms ± 7.6 ms 864 ms ± 11 ms -0.13 %
arco-pro_production-mode + exec 4.11 s ± 30 ms 4.1 s ± 63 ms -0.21 %
threejs_development-mode_10x + exec 1.89 s ± 17 ms 1.9 s ± 23 ms +0.62 %
threejs_development-mode_10x_hmr + exec 1.14 s ± 13 ms 1.14 s ± 11 ms -0.07 %
threejs_production-mode_10x + exec 5.67 s ± 107 ms 5.85 s ± 70 ms +3.23 %

Please sign in to comment.