Skip to content

Commit

Permalink
revert: feat(diagnostic): improve diagnostics for swc wasm plugins (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a authored Aug 26, 2024
1 parent 8270dc9 commit a33dd61
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 240 deletions.
65 changes: 27 additions & 38 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ rspack_dojang = { version = "0.1.8" }
rate-limit = { existing-packages = 70, new-packages = 70 }
[profile.dev]
codegen-units = 16
debug = 2 # debug build will cause runtime panic if codegen-unints is default
debug = 2 # debug build will cause runtime panic if codegen-unints is default
incremental = true
panic = "abort"

[profile.release]
codegen-units = 1
debug = false
# Performs “thin” LTO. This is similar to “fat”, but takes substantially less time to run while still achieving performance gains similar to “fat”.
lto = "thin"
opt-level = 3
panic = "abort"
strip = true

[profile.release-prod]
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_error/src/miette_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ impl miette::Diagnostic for WithHelp {
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
let help = self.wrap_help.get_or_init(|| {
let prev = self.err.help().map(|h| h.to_string());
let help = self.help.as_ref();
let help = self.help.as_ref().cloned();
if let Some(prev) = prev {
if let Some(help) = &help {
Some(format!("{prev}\n{help}").into())
} else {
Some(prev.into())
}
} else if help.is_some() {
help.cloned()
help
} else {
None
}
Expand Down
3 changes: 0 additions & 3 deletions crates/rspack_loader_swc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ swc_core = { workspace = true, features = ["base", "ecma_ast", "
swc_plugin_import = { version = "0.1.5", path = "../swc_plugin_import" }
tokio = { workspace = true }
url = "2.5.0"

[build-dependencies]
cargo_toml = { version = "0.20.4" }
18 changes: 0 additions & 18 deletions crates/rspack_loader_swc/build.rs

This file was deleted.

32 changes: 1 addition & 31 deletions crates/rspack_loader_swc/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use base64::prelude::*;
use dashmap::DashMap;
use jsonc_parser::parse_to_serde_value;
use rspack_ast::javascript::{Ast as JsAst, Context as JsAstContext, Program as JsProgram};
use rspack_error::miette::MietteDiagnostic;
use rspack_error::DiagnosticExt;
use serde_json::error::Category;
use swc_config::config_types::BoolOr;
use swc_config::merge::Merge;
Expand Down Expand Up @@ -389,35 +387,7 @@ impl SwcCompiler {
try_with_handler(self.cm.clone(), Default::default(), |handler| {
HANDLER.set(handler, || {
// Fold module
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
program.fold_with(&mut pass)
})) {
Ok(v) => Ok(v),
Err(err) => {
macro_rules! swc_error {
($tt:tt) => {{
let swc_core_version = env!("RSPACK_SWC_CORE_VERSION");

MietteDiagnostic::new(format!("Builtin swc-loader error: {}
Help:
The version of the SWC Wasm plugin you're using might not be compatible with `builtin:swc-loader`.
The `swc_core` version of the current `rspack_core` is {swc_core_version}. Please check the `swc_core` version of SWC Wasm plugin to make sure these versions are within the compatible range.
Versions of `swc_core` are more likely to be located in the `Cargo.toml` file in the root directory of these plugin repositories.
Check out this guide as a reference for selecting the versions of SWC Wasm plugins: https://swc.rs/docs/plugin/selecting-swc-core", $tt))
.boxed()
.into()
}}
}
if let Some(err) = err.downcast_ref::<String>() {
Err(swc_error!(err))
} else {
Err(swc_error!("unknown error"))
}
}
}
Ok(program.fold_with(&mut pass))
})
})
})
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Loading

2 comments on commit a33dd61

@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-08-26 36df3c2) Current Change
10000_development-mode + exec 2.37 s ± 34 ms 2.27 s ± 29 ms -3.95 %
10000_development-mode_hmr + exec 698 ms ± 7 ms 708 ms ± 13 ms +1.42 %
10000_production-mode + exec 3.07 s ± 30 ms 2.95 s ± 53 ms -3.63 %
arco-pro_development-mode + exec 1.89 s ± 58 ms 1.87 s ± 81 ms -0.88 %
arco-pro_development-mode_hmr + exec 437 ms ± 2.7 ms 438 ms ± 3.8 ms +0.11 %
arco-pro_production-mode + exec 3.51 s ± 56 ms 3.45 s ± 114 ms -1.79 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.55 s ± 120 ms 3.49 s ± 109 ms -1.71 %
threejs_development-mode_10x + exec 1.69 s ± 7.3 ms 1.7 s ± 14 ms +0.25 %
threejs_development-mode_10x_hmr + exec 804 ms ± 9.6 ms 829 ms ± 9.6 ms +3.13 %
threejs_production-mode_10x + exec 5.57 s ± 17 ms 5.48 s ± 22 ms -1.50 %

@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 ✅ success
_selftest ✅ success
nx ❌ failure
rspress ✅ success
rslib ❌ failure
rsbuild ✅ success
examples ✅ success

Please sign in to comment.