Skip to content
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
3 changes: 1 addition & 2 deletions crates/rspack_core/src/loader/rspack_loader.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use rspack_error::{Diagnostic, Result};
use rspack_fs::ReadableFileSystem;
Expand All @@ -10,7 +10,6 @@ use crate::{RunnerContext, SharedPluginDriver, utils::extract_source_map};

pub struct RspackLoaderRunnerPlugin {
pub plugin_driver: SharedPluginDriver,
pub current_loader: Mutex<Option<String>>,
pub extract_source_map: Option<bool>,
}

Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/normal_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ impl Module for NormalModule {

let plugin = Arc::new(RspackLoaderRunnerPlugin {
plugin_driver: build_context.plugin_driver.clone(),
current_loader: Default::default(),
extract_source_map: self.inner().extract_source_map,
});

Expand Down
10 changes: 4 additions & 6 deletions crates/rspack_plugin_esm_library/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ impl EsmLibraryPlugin {
// codegen uses self.concatenated_modules_map_for_codegen which has hold another Arc, so
// it's safe to access concate_modules_map lock
let mut concate_modules_map = self.concatenated_modules_map.write().await;
let concate_modules_map = Arc::get_mut(&mut concate_modules_map)
.expect("should have unique access to concatenated modules map");

// analyze every modules and collect identifiers to concate_modules_map
self
.analyze_module(compilation, concate_modules_map)
.analyze_module(compilation, &mut concate_modules_map)
.await?;

// initialize data for link chunks
Expand Down Expand Up @@ -250,7 +248,7 @@ impl EsmLibraryPlugin {
for chunk_link in link.values_mut() {
self.deconflict_symbols(
compilation,
concate_modules_map,
&mut concate_modules_map,
chunk_link,
&escaped_names,
&escaped_identifiers,
Expand All @@ -262,7 +260,7 @@ impl EsmLibraryPlugin {
compilation.extend_diagnostics(self.link_imports_and_exports(
compilation,
&mut link,
concate_modules_map,
&mut concate_modules_map,
&mut needed_namespace_objects_by_ukey,
&escaped_identifiers,
));
Expand Down Expand Up @@ -327,7 +325,7 @@ impl EsmLibraryPlugin {
&compilation.module_graph_cache_artifact,
module_info_id,
vec![export_info.name().cloned().unwrap_or("".into())],
concate_modules_map,
&mut concate_modules_map,
&mut needed_namespace_objects,
false,
false,
Expand Down
6 changes: 4 additions & 2 deletions crates/rspack_plugin_esm_library/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ pub struct EsmLibraryPlugin {
pub(crate) preserve_modules: Option<PathBuf>,
// module instance will hold this map till compile done, we can't mutate it,
// normal concatenateModule just read the info from it
// the Arc here is to for module_codegen API, which needs to render module in parallel
// and read-only access the map, so it receives the map as an Arc
pub(crate) concatenated_modules_map_for_codegen:
AtomicRefCell<Arc<IdentifierIndexMap<ModuleInfo>>>,
pub(crate) concatenated_modules_map: RwLock<Arc<IdentifierIndexMap<ModuleInfo>>>,
pub(crate) concatenated_modules_map: RwLock<IdentifierIndexMap<ModuleInfo>>,
pub(crate) links: AtomicRefCell<UkeyMap<ChunkUkey, ChunkLinkContext>>,
}

Expand Down Expand Up @@ -253,7 +255,7 @@ async fn finish_modules(&self, compilation: &mut Compilation) -> Result<()> {
*map = Arc::new(modules_map.clone());
drop(map);

*self.concatenated_modules_map.write().await = Arc::new(modules_map);
*self.concatenated_modules_map.write().await = modules_map;
// mark all entry exports as used
let mut entry_modules = IdentifierSet::default();
for entry_data in compilation.entries.values() {
Expand Down
Loading