Skip to content

Commit 571d297

Browse files
authoredApr 1, 2024··
feat(plugin/runner): Improve error message for Wasm plugin crashes (#8794)
**Related issue:** - Closes #4333
1 parent 504ddb9 commit 571d297

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎crates/swc_plugin_runner/src/transform_executor.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{env, sync::Arc};
22

3-
use anyhow::{anyhow, Error};
3+
use anyhow::{anyhow, Context, Error};
44
use parking_lot::Mutex;
55
#[cfg(feature = "__rkyv")]
66
use swc_common::plugin::serialized::{PluginError, PluginSerializedBytes};
@@ -389,6 +389,13 @@ impl TransformExecutor {
389389
) -> Result<PluginSerializedBytes, Error> {
390390
let mut transform_state = self.setup_plugin_env_exports()?;
391391
transform_state.is_transform_schema_compatible()?;
392-
transform_state.run(program, self.unresolved_mark, should_enable_comments_proxy)
392+
transform_state
393+
.run(program, self.unresolved_mark, should_enable_comments_proxy)
394+
.context(
395+
"failed to run Wasm plugin transform. Please ensure the version of `swc_core` \
396+
used by the plugin is compatible with the host runtime. See https://swc.rs/docs/plugin/selecting-swc-core\
397+
for compatibility information. If you are an author of the plugin, please update \
398+
`swc_core` to the compatible version.",
399+
)
393400
}
394401
}

0 commit comments

Comments
 (0)
Please sign in to comment.