Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: feat(diagnostic): improve diagnostics for swc wasm plugins #7690

Merged
merged 1 commit into from
Aug 26, 2024
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
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
Loading