Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Oct 18, 2024
1 parent 09fc1ed commit cfab56f
Show file tree
Hide file tree
Showing 48 changed files with 318 additions and 329 deletions.
2 changes: 1 addition & 1 deletion crates/rspack_binding_values/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static RUNTIME_GLOBAL_MAP: LazyLock<(
declare_runtime_global!(COMPAT_GET_DEFAULT_EXPORT);
declare_runtime_global!(CREATE_FAKE_NAMESPACE_OBJECT);
declare_runtime_global!(NODE_MODULE_DECORATOR);
declare_runtime_global!(HARMONY_MODULE_DECORATOR);
declare_runtime_global!(ESM_MODULE_DECORATOR);
declare_runtime_global!(SYSTEM_CONTEXT);
declare_runtime_global!(THIS_AS_EXPORTS);
declare_runtime_global!(CURRENT_REMOTE_GET_SCOPE);
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/chunk_graph/chunk_graph_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl ChunkGraph {
self
.get_module_graph_hash_without_connections(module, compilation, runtime)
.hash(&mut hasher);
let strict = module.get_strict_harmony_module();
let strict = module.get_strict_esm_module();
let mg = compilation.get_module_graph();
let connections = mg
.get_outgoing_connections(&module.identifier())
Expand Down
44 changes: 22 additions & 22 deletions crates/rspack_core/src/concatenated_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl Module for ConcatenatedModule {
context_dependencies: Default::default(),
missing_dependencies: Default::default(),
build_dependencies: Default::default(),
harmony_named_exports: Default::default(),
esm_named_exports: Default::default(),
all_star_exports: Default::default(),
need_create_require: Default::default(),
json_data: Default::default(),
Expand Down Expand Up @@ -570,7 +570,7 @@ impl Module for ConcatenatedModule {
.dependency_by_id(dep_id)
.expect("should have dependency");
let module_id_of_dep = module_graph.module_identifier_by_dependency_id(dep_id);
if !is_harmony_dep_like(dep) || !modules.contains(&module_id_of_dep) {
if !is_esm_dep_like(dep) || !modules.contains(&module_id_of_dep) {
self.dependencies.push(*dep_id);
}
}
Expand Down Expand Up @@ -862,7 +862,7 @@ impl Module for ConcatenatedModule {
.collect::<Vec<_>>(),
match_info.call,
!match_info.direct_import,
build_meta.strict_harmony_module,
build_meta.strict_esm_module,
match_info.asi_safe,
));
}
Expand All @@ -878,7 +878,7 @@ impl Module for ConcatenatedModule {
export_name,
call,
call_context,
strict_harmony_module,
strict_esm_module,
asi_safe,
) in info_params_list
{
Expand All @@ -891,7 +891,7 @@ impl Module for ConcatenatedModule {
&mut needed_namespace_objects,
call,
call_context,
strict_harmony_module,
strict_esm_module,
asi_safe,
&context,
);
Expand Down Expand Up @@ -922,9 +922,9 @@ impl Module for ConcatenatedModule {
let root_module = module_graph
.module_by_identifier(&root_module_id)
.expect("should have box module");
let strict_harmony_module = root_module
let strict_esm_module = root_module
.build_meta()
.map(|item| item.strict_harmony_module)
.map(|item| item.strict_esm_module)
.unwrap_or_default();

let exports_info = module_graph.get_exports_info(&root_module_id);
Expand Down Expand Up @@ -957,7 +957,7 @@ impl Module for ConcatenatedModule {
&mut needed_namespace_objects,
false,
false,
strict_harmony_module,
strict_esm_module,
Some(true),
&compilation.options.context,
);
Expand All @@ -975,7 +975,7 @@ impl Module for ConcatenatedModule {
}

let mut result = ConcatSource::default();
let mut should_add_harmony_flag = false;
let mut should_add_esm_flag = false;

// Add ESM compatibility flag (must be first because of possible circular dependencies)
if compilation
Expand All @@ -985,7 +985,7 @@ impl Module for ConcatenatedModule {
.get_used(&module_graph, runtime)
!= UsageState::Unused
{
should_add_harmony_flag = true
should_add_esm_flag = true
}

// Assuming the necessary imports and dependencies are declared
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl Module for ConcatenatedModule {
runtime_requirements.insert(RuntimeGlobals::EXPORTS);
runtime_requirements.insert(RuntimeGlobals::DEFINE_PROPERTY_GETTERS);

if should_add_harmony_flag {
if should_add_esm_flag {
result.add(RawSource::from("// ESM COMPAT FLAG\n"));
result.add(RawSource::from(define_es_module_flag_statement(
self.get_exports_argument(),
Expand Down Expand Up @@ -1073,9 +1073,9 @@ impl Module for ConcatenatedModule {
.module_by_identifier(module_info_id)
.expect("should have box module");
let module_readable_identifier = box_module.readable_identifier(&context);
let strict_harmony_module = box_module
let strict_esm_module = box_module
.build_meta()
.map(|meta| meta.strict_harmony_module)
.map(|meta| meta.strict_esm_module)
.unwrap_or_default();
let name_space_name = module_info.namespace_object_name.clone();

Expand Down Expand Up @@ -1106,7 +1106,7 @@ impl Module for ConcatenatedModule {
&mut needed_namespace_objects,
false,
false,
strict_harmony_module,
strict_esm_module,
Some(true),
&context,
);
Expand Down Expand Up @@ -1610,7 +1610,7 @@ impl ConcatenatedModule {
let dep = mg
.dependency_by_id(&connection.dependency_id)
.expect("should have dependency");
if !is_harmony_dep_like(dep) {
if !is_esm_dep_like(dep) {
return None;
}

Expand All @@ -1619,7 +1619,7 @@ impl ConcatenatedModule {
{
return None;
}
// now the dep should be one of `HarmonyExportImportedSpecifierDependency`, `HarmonyImportSideEffectDependency`, `HarmonyImportSpecifierDependency`,
// now the dep should be one of `ESMExportImportedSpecifierDependency`, `ESMImportSideEffectDependency`, `ESMImportSpecifierDependency`,
// the expect is safe now
Some(ConcatenatedModuleImportInfo {
connection,
Expand Down Expand Up @@ -1788,7 +1788,7 @@ impl ConcatenatedModule {
needed_namespace_objects: &mut IdentifierIndexSet,
as_call: bool,
call_context: bool,
strict_harmony_module: bool,
strict_esm_module: bool,
asi_safe: Option<bool>,
context: &Context,
) -> String {
Expand All @@ -1800,7 +1800,7 @@ impl ConcatenatedModule {
runtime,
needed_namespace_objects,
as_call,
strict_harmony_module,
strict_esm_module,
asi_safe,
&mut HashSet::default(),
);
Expand Down Expand Up @@ -1874,7 +1874,7 @@ impl ConcatenatedModule {
runtime: Option<&RuntimeSpec>,
needed_namespace_objects: &mut IdentifierIndexSet,
as_call: bool,
strict_harmony_module: bool,
strict_esm_module: bool,
asi_safe: Option<bool>,
already_visited: &mut HashSet<ExportInfo>,
) -> Binding {
Expand All @@ -1885,7 +1885,7 @@ impl ConcatenatedModule {
let module = mg
.module_by_identifier(&info.id())
.expect("should have module");
let exports_type = module.get_exports_type(mg, strict_harmony_module);
let exports_type = module.get_exports_type(mg, strict_esm_module);

if export_name.is_empty() {
match exports_type {
Expand Down Expand Up @@ -2146,7 +2146,7 @@ impl ConcatenatedModule {
runtime,
needed_namespace_objects,
as_call,
build_meta.strict_harmony_module,
build_meta.strict_esm_module,
asi_safe,
already_visited,
);
Expand Down Expand Up @@ -2215,7 +2215,7 @@ impl ConcatenatedModule {
}
}

pub fn is_harmony_dep_like(dep: &BoxDependency) -> bool {
pub fn is_esm_dep_like(dep: &BoxDependency) -> bool {
matches!(
dep.dependency_type(),
DependencyType::EsmImportSpecifier
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/dependency/dependency_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl DependencyId {

/// # Panic
/// This method will panic if one of following condition is true:
/// * current dependency id is not belongs to `HarmonyImportSpecifierDependency` or `HarmonyExportImportedSpecifierDependency`
/// * current dependency id is not belongs to `ESMImportSpecifierDependency` or `ESMExportImportedSpecifierDependency`
/// * current id is not in `ModuleGraph`
pub fn get_ids(&self, mg: &ModuleGraph) -> Vec<Atom> {
let dep = mg.dependency_by_id(self).expect("should have dep");
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/dependency/dependency_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub trait Dependency:
None
}

// For now only `HarmonyImportSpecifierDependency` and
// `HarmonyExportImportedSpecifierDependency` can use this method
// For now only `ESMImportSpecifierDependency` and
// `ESMExportImportedSpecifierDependency` can use this method
fn get_ids(&self, _mg: &ModuleGraph) -> Vec<Atom> {
unreachable!()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/dependency/dependency_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub enum DependencyType {
Unknown,
ExportInfoApi,
Entry,
// Harmony import
// ESM import
EsmImport,
EsmImportSpecifier,
// Harmony export
// ESM export
EsmExport,
EsmExportImportedSpecifier,
EsmExportSpecifier,
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/dependency/runtime_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ pub fn export_from_import(
init_fragments.push(
NormalInitFragment::new(
name.clone(),
InitFragmentStage::StageHarmonyExports,
InitFragmentStage::StageESMExports,
-1,
InitFragmentKey::HarmonyFakeNamespaceObjectFragment(name),
InitFragmentKey::ESMFakeNamespaceObjectFragment(name),
None,
)
.boxed(),
Expand Down Expand Up @@ -258,7 +258,7 @@ pub fn get_exports_type(
let strict = module_graph
.module_by_identifier(parent_module)
.expect("should have mgm")
.get_strict_harmony_module();
.get_strict_esm_module();
get_exports_type_with_strict(module_graph, id, strict)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/external_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl ExternalModule {
NormalInitFragment::new(
"import { createRequire as __WEBPACK_EXTERNAL_createRequire } from \"module\";\n"
.to_string(),
InitFragmentStage::StageHarmonyImports,
InitFragmentStage::StageESMImports,
0,
InitFragmentKey::ModuleExternal("node-commonjs".to_string()),
None,
Expand Down Expand Up @@ -310,7 +310,7 @@ impl ExternalModule {
id.clone(),
json_stringify(request.primary())
),
InitFragmentStage::StageHarmonyImports,
InitFragmentStage::StageESMImports,
0,
InitFragmentKey::ModuleExternal(request.primary().into()),
None,
Expand Down
Loading

0 comments on commit cfab56f

Please sign in to comment.