Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed Dec 18, 2023
1 parent eba667e commit 8e982fd
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/rspack_core/src/compiler/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl WorkerTask for BuildTask {
compiler_context: CompilerContext {
options: compiler_options.clone(),
resolver_factory: resolver_factory.clone(),
module: Some(module.identifier()),
module: module.identifier(),
module_context: module.as_normal_module().and_then(|m| m.get_context()),
},
plugin_driver: plugin_driver.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/loader/loader_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{CompilerOptions, Context, ModuleIdentifier, ResolverFactory};
pub struct CompilerContext {
pub options: Arc<CompilerOptions>,
pub resolver_factory: Arc<ResolverFactory>,
pub module: Option<ModuleIdentifier>, // current module
pub module: ModuleIdentifier, // current module
pub module_context: Option<Box<Context>>, // current module context
}

Expand Down
4 changes: 3 additions & 1 deletion crates/rspack_core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mod test {
use std::borrow::Cow;
use std::hash::Hash;

use rspack_error::{Result, TWithDiagnosticArray};
use rspack_error::{Diagnosable, Result, TWithDiagnosticArray};
use rspack_identifier::{Identifiable, Identifier};
use rspack_sources::Source;

Expand Down Expand Up @@ -389,6 +389,8 @@ mod test {
}
}

impl Diagnosable for $ident {}

impl DependenciesBlock for $ident {
fn add_block_id(&mut self, _: AsyncDependenciesBlockIdentifier) {
unreachable!()
Expand Down
4 changes: 3 additions & 1 deletion crates/rspack_core/src/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ impl ModuleGraph {
mod test {
use std::borrow::Cow;

use rspack_error::{Result, TWithDiagnosticArray};
use rspack_error::{Diagnosable, Result, TWithDiagnosticArray};
use rspack_identifier::Identifiable;
use rspack_sources::Source;

Expand All @@ -793,6 +793,8 @@ mod test {
}
}

impl Diagnosable for $ident {}

impl DependenciesBlock for $ident {
fn add_block_id(&mut self, _: AsyncDependenciesBlockIdentifier) {
unreachable!()
Expand Down
19 changes: 16 additions & 3 deletions crates/rspack_core/src/normal_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,28 @@ impl Module for NormalModule {

impl Diagnosable for NormalModule {
fn add_diagnostic(&self, diagnostic: Diagnostic) {
self.diagnostics.lock().unwrap().push(diagnostic);
self
.diagnostics
.lock()
.expect("failed to lock diagnostics")
.push(diagnostic);
}

fn add_diagnostics(&self, mut diagnostics: Vec<Diagnostic>) {
self.diagnostics.lock().unwrap().append(&mut diagnostics);
self
.diagnostics
.lock()
.expect("failed to lock diagnostics")
.append(&mut diagnostics);
}

fn take_diagnostics(&self) -> Vec<Diagnostic> {
self.diagnostics.lock().unwrap().drain(..).collect()
self
.diagnostics
.lock()
.expect("failed to lock diagnostics")
.drain(..)
.collect()
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_loader_sass/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async fn loader_test(actual: impl AsRef<Path>, expected: impl AsRef<Path>) {
profile: false,
}),
resolver_factory: Default::default(),
module: None,
module: "".into(),
module_context: None,
},
)
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_loader_swc/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async fn loader_test(actual: impl AsRef<Path>, expected: impl AsRef<Path>) {
profile: false,
}),
resolver_factory: Default::default(),
module: None,
module: "".into(),
module_context: None,
},
)
Expand Down

0 comments on commit 8e982fd

Please sign in to comment.