Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove old tree shaking code #6884

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crates/rspack_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ derivative = { workspace = true }
dyn-clone = "1.0.17"
either = "1"
futures = { workspace = true }
glob-match = "0.2.1"
hashlink = { workspace = true }
hex = { workspace = true }
indexmap = { workspace = true }
Expand All @@ -27,7 +26,6 @@ num-bigint = "0.4.4"
once_cell = { workspace = true }
oxc_resolver = { version = "1.8.1", features = ["package_json_raw_json_api"] }
paste = { workspace = true }
petgraph = { version = "0.6.4", features = ["serde-1"] }
rayon = { workspace = true }
regex = { workspace = true }
rspack_ast = { path = "../rspack_ast" }
Expand Down
14 changes: 5 additions & 9 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ use crate::{
prepare_get_exports_type, to_identifier, BoxDependency, BoxModule, CacheCount, CacheOptions,
Chunk, ChunkByUkey, ChunkContentHash, ChunkGraph, ChunkGroupByUkey, ChunkGroupUkey, ChunkKind,
ChunkUkey, CodeGenerationResults, CompilationLogger, CompilationLogging, CompilerOptions,
DependencyId, DependencyType, Entry, EntryData, EntryOptions, Entrypoint, ErrorSpan,
ExecuteModuleId, Filename, ImportVarMap, LocalFilenameFn, Logger, Module, ModuleFactory,
ModuleGraph, ModuleGraphPartial, ModuleIdentifier, PathData, ResolverFactory, RuntimeGlobals,
RuntimeModule, RuntimeSpec, SharedPluginDriver, SourceType, Stats,
DependencyId, DependencyType, Entry, EntryData, EntryOptions, Entrypoint, ExecuteModuleId,
Filename, ImportVarMap, LocalFilenameFn, Logger, Module, ModuleFactory, ModuleGraph,
ModuleGraphPartial, ModuleIdentifier, PathData, ResolverFactory, RuntimeGlobals, RuntimeModule,
RuntimeSpec, SharedPluginDriver, SourceType, Stats,
};

pub type BuildDependency = (
Expand Down Expand Up @@ -1637,11 +1637,7 @@ impl Compilation {
let dependency_type = dependency.dependency_type();
self
.dependency_factories
.get(&match dependency_type {
DependencyType::EsmImport(_) => DependencyType::EsmImport(ErrorSpan::default()),
DependencyType::EsmExport(_) => DependencyType::EsmExport(ErrorSpan::default()),
_ => dependency_type.clone(),
})
.get(dependency_type)
.unwrap_or_else(|| {
panic!(
"No module factory available for dependency type: {}, resourceIdentifier: {:?}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use rustc_hash::FxHashMap as HashMap;
use super::{factorize::FactorizeTask, MakeTaskContext};
use crate::{
utils::task_loop::{Task, TaskResult, TaskType},
ContextDependency, DependencyId, DependencyType, ErrorSpan, Module, ModuleIdentifier,
ModuleProfile, NormalModuleSource,
ContextDependency, DependencyId, Module, ModuleIdentifier, ModuleProfile, NormalModuleSource,
};

#[derive(Debug)]
Expand Down Expand Up @@ -88,11 +87,7 @@ impl Task<MakeTaskContext> for ProcessDependenciesTask {
// TODO move module_factory calculate to dependency factories
let module_factory = context
.dependency_factories
.get(&match dependency_type {
DependencyType::EsmImport(_) => DependencyType::EsmImport(ErrorSpan::default()),
DependencyType::EsmExport(_) => DependencyType::EsmExport(ErrorSpan::default()),
_ => dependency_type.clone(),
})
.get(dependency_type)
.unwrap_or_else(|| {
panic!(
"No module factory available for dependency type: {}, resourceIdentifier: {:?}",
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/concatenated_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2206,8 +2206,8 @@ pub fn is_harmony_dep_like(dep: &BoxDependency) -> bool {
dep.dependency_type(),
DependencyType::EsmImportSpecifier
| DependencyType::EsmExportImportedSpecifier
| DependencyType::EsmImport(_)
| DependencyType::EsmExport(_)
| DependencyType::EsmImport
| DependencyType::EsmExport
)
}

Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/context_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ impl Module for ContextModule {
},
dependencies,
blocks,
analyze_result: Default::default(),
optimization_bailouts: vec![],
})
}
Expand Down
10 changes: 5 additions & 5 deletions crates/rspack_core/src/dependency/dependency_type.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::fmt::{Debug, Display};

use crate::{ContextTypePrefix, ErrorSpan};
use crate::ContextTypePrefix;

// Used to describe dependencies' types, see webpack's `type` getter in `Dependency`
// Note: This is almost the same with the old `ResolveKind`
Expand All @@ -12,10 +12,10 @@ pub enum DependencyType {
ExportInfoApi,
Entry,
// Harmony import
EsmImport(/* HarmonyImportSideEffectDependency.span */ ErrorSpan), /* TODO: remove span after old tree shaking is removed */
EsmImport,
EsmImportSpecifier,
// Harmony export
EsmExport(ErrorSpan),
EsmExport,
EsmExportImportedSpecifier,
EsmExportSpecifier,
EsmExportExpression,
Expand Down Expand Up @@ -104,8 +104,8 @@ impl DependencyType {
match self {
DependencyType::Unknown => Cow::Borrowed("unknown"),
DependencyType::Entry => Cow::Borrowed("entry"),
DependencyType::EsmImport(_) => Cow::Borrowed("esm import"),
DependencyType::EsmExport(_) => Cow::Borrowed("esm export"),
DependencyType::EsmImport => Cow::Borrowed("esm import"),
DependencyType::EsmExport => Cow::Borrowed("esm export"),
DependencyType::EsmExportSpecifier => Cow::Borrowed("esm export specifier"),
DependencyType::EsmExportImportedSpecifier => Cow::Borrowed("esm export import specifier"),
DependencyType::EsmImportSpecifier => Cow::Borrowed("esm import specifier"),
Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/external_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ impl Module for ExternalModule {
build_meta: Default::default(),
dependencies: Vec::new(),
blocks: Vec::new(),
analyze_result: Default::default(),
optimization_bailouts: vec![],
};
// TODO add exports_type for request
Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ pub mod resolver;
pub use resolver::*;
pub mod concatenated_module;
pub mod reserved_names;
pub mod tree_shaking;

pub use rspack_loader_runner::{get_scheme, ResourceData, Scheme, BUILTIN_LOADER_PREFIX};
pub use rspack_macros::{impl_runtime_module, impl_source_map_config};
Expand Down
3 changes: 0 additions & 3 deletions crates/rspack_core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use rustc_hash::FxHashSet as HashSet;
use swc_core::ecma::atoms::Atom;

use crate::concatenated_module::ConcatenatedModule;
use crate::tree_shaking::visitor::OptimizeAnalyzeResult;
use crate::{
AsyncDependenciesBlock, BoxDependency, ChunkGraph, ChunkUkey, CodeGenerationResult, Compilation,
CompilerOptions, ConcatenationScope, ConnectionState, Context, ContextModule, DependenciesBlock,
Expand Down Expand Up @@ -158,7 +157,6 @@ pub struct BuildResult {
/// Whether the result is cacheable, i.e shared between builds.
pub build_meta: BuildMeta,
pub build_info: BuildInfo,
pub analyze_result: OptimizeAnalyzeResult,
pub dependencies: Vec<BoxDependency>,
pub blocks: Vec<AsyncDependenciesBlock>,
pub optimization_bailouts: Vec<String>,
Expand Down Expand Up @@ -220,7 +218,6 @@ pub trait Module:
build_meta: Default::default(),
dependencies: Vec::new(),
blocks: Vec::new(),
analyze_result: Default::default(),
optimization_bailouts: vec![],
})
}
Expand Down
4 changes: 0 additions & 4 deletions crates/rspack_core/src/normal_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ impl Module for NormalModule {
build_meta: Default::default(),
dependencies: Vec::new(),
blocks: Vec::new(),
analyze_result: Default::default(),
optimization_bailouts: vec![],
});
}
Expand Down Expand Up @@ -472,7 +471,6 @@ impl Module for NormalModule {
build_meta,
dependencies: Vec::new(),
blocks: Vec::new(),
analyze_result: Default::default(),
optimization_bailouts: Vec::new(),
});
}
Expand All @@ -491,7 +489,6 @@ impl Module for NormalModule {
blocks,
presentational_dependencies,
code_generation_dependencies,
analyze_result,
side_effects_bailout,
},
diagnostics,
Expand Down Expand Up @@ -546,7 +543,6 @@ impl Module for NormalModule {
build_meta,
dependencies,
blocks,
analyze_result,
optimization_bailouts,
})
}
Expand Down
8 changes: 3 additions & 5 deletions crates/rspack_core/src/parser_and_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use rspack_util::source_map::SourceMapKind;
use swc_core::common::Span;

use crate::{
tree_shaking::visitor::OptimizeAnalyzeResult, AsyncDependenciesBlock, BoxDependency, BoxLoader,
BuildInfo, BuildMeta, CodeGenerationData, Compilation, CompilerOptions, DependencyTemplate,
GeneratorOptions, Module, ModuleDependency, ModuleIdentifier, ModuleType, ParserOptions,
RuntimeGlobals, RuntimeSpec, SourceType,
AsyncDependenciesBlock, BoxDependency, BoxLoader, BuildInfo, BuildMeta, CodeGenerationData,
Compilation, CompilerOptions, DependencyTemplate, GeneratorOptions, Module, ModuleDependency,
ModuleIdentifier, ModuleType, ParserOptions, RuntimeGlobals, RuntimeSpec, SourceType,
};
use crate::{ChunkGraph, ConcatenationScope, Context, ModuleGraph};

Expand Down Expand Up @@ -67,7 +66,6 @@ pub struct ParseResult {
pub presentational_dependencies: Vec<Box<dyn DependencyTemplate>>,
pub code_generation_dependencies: Vec<Box<dyn ModuleDependency>>,
pub source: BoxSource,
pub analyze_result: OptimizeAnalyzeResult,
pub side_effects_bailout: Option<SideEffectsBailoutItem>,
}

Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/self_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ impl Module for SelfModule {
build_meta: Default::default(),
dependencies: Vec::new(),
blocks: Vec::new(),
analyze_result: Default::default(),
optimization_bailouts: vec![],
})
}
Expand Down
5 changes: 0 additions & 5 deletions crates/rspack_core/src/tree_shaking/analyzer.rs

This file was deleted.

21 changes: 0 additions & 21 deletions crates/rspack_core/src/tree_shaking/asset_module.rs

This file was deleted.

23 changes: 0 additions & 23 deletions crates/rspack_core/src/tree_shaking/debug_helper.rs

This file was deleted.

56 changes: 0 additions & 56 deletions crates/rspack_core/src/tree_shaking/js_module.rs

This file was deleted.

Loading
Loading