Skip to content

Commit

Permalink
fix: wrong module source (#6396)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a authored Apr 29, 2024
1 parent 56872df commit d84f9bf
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,27 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
let original_map = source.map(&MapOptions::new(use_source_map));
let source = source.source();

let gen_terminate_res = |diagnostics: Vec<Box<dyn Diagnostic + Send + Sync>>| {
Ok(
ParseResult {
source: create_source(
source.to_string(),
resource_data.resource_path.to_string_lossy().to_string(),
enable_source_map,
),
dependencies: vec![],
blocks: vec![],
presentational_dependencies: vec![],
analyze_result: Default::default(),
side_effects_bailout: None,
}
.with_diagnostic(map_box_diagnostics_to_module_parse_diagnostics(
diagnostics,
loaders,
)),
)
};
let result_with_diagnostics =
|source: String, diagnostics: Vec<Box<dyn Diagnostic + Send + Sync>>| {
Ok(
ParseResult {
source: create_source(
source,
resource_data.resource_path.to_string_lossy().to_string(),
enable_source_map,
),
dependencies: vec![],
blocks: vec![],
presentational_dependencies: vec![],
analyze_result: Default::default(),
side_effects_bailout: None,
}
.with_diagnostic(map_box_diagnostics_to_module_parse_diagnostics(
diagnostics,
loaders,
)),
)
};

let mut ast =
if let Some(RspackAst::JavaScript(loader_ast)) = additional_data.remove::<RspackAst>() {
Expand All @@ -145,7 +146,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
Ok(ast) => ast,
Err(e) => {
diagnostics.append(&mut e.into_iter().map(|e| e.boxed()).collect());
return gen_terminate_res(diagnostics);
return result_with_diagnostics(source.to_string(), diagnostics);
}
}
.0
Expand All @@ -169,7 +170,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
Ok(parse_result) => parse_result,
Err(e) => {
diagnostics.append(&mut e.into_iter().map(|e| e.boxed()).collect());
return gen_terminate_res(diagnostics);
return result_with_diagnostics(output.code.clone(), diagnostics);
}
};

Expand Down Expand Up @@ -209,7 +210,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
Ok(result) => result,
Err(mut e) => {
diagnostics.append(&mut e);
return gen_terminate_res(diagnostics);
return result_with_diagnostics(output.code.clone(), diagnostics);
}
};
diagnostics.append(&mut warning_diagnostics);
Expand Down

2 comments on commit d84f9bf

@rspack-bot
Copy link

Choose a reason for hiding this comment

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

📝 Ran ecosystem CI: Open

suite result
modernjs, self-hosted, Linux, ci ❌ failure
_selftest, ubuntu-latest ✅ success
nx, ubuntu-latest ✅ success
rspress, ubuntu-latest ❌ failure
rsbuild, ubuntu-latest ✅ success
compat, ubuntu-latest ✅ success
examples, ubuntu-latest ✅ success

@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-04-29 ec3c0df) Current Change
10000_development-mode + exec 2.8 s ± 43 ms 2.78 s ± 33 ms -0.38 %
10000_development-mode_hmr + exec 690 ms ± 16 ms 686 ms ± 4.1 ms -0.66 %
10000_production-mode + exec 2.49 s ± 18 ms 2.5 s ± 34 ms +0.59 %
arco-pro_development-mode + exec 2.54 s ± 39 ms 2.61 s ± 86 ms +2.78 %
arco-pro_development-mode_hmr + exec 431 ms ± 2.6 ms 430 ms ± 2.2 ms -0.25 %
arco-pro_development-mode_hmr_intercept-plugin + exec 443 ms ± 2.5 ms 441 ms ± 3 ms -0.32 %
arco-pro_development-mode_intercept-plugin + exec 3.25 s ± 72 ms 3.39 s ± 47 ms +4.55 %
arco-pro_production-mode + exec 3.99 s ± 103 ms 4.05 s ± 77 ms +1.48 %
arco-pro_production-mode_intercept-plugin + exec 4.75 s ± 102 ms 4.88 s ± 47 ms +2.76 %
threejs_development-mode_10x + exec 2.08 s ± 23 ms 2.09 s ± 33 ms +0.46 %
threejs_development-mode_10x_hmr + exec 771 ms ± 32 ms 755 ms ± 14 ms -2.12 %
threejs_production-mode_10x + exec 5.26 s ± 54 ms 5.2 s ± 27 ms -1.22 %

Please sign in to comment.