feat(plugin/runner): Improve error message for Wasm plugin crashes (#8794)

**Related issue:**

 - Closes #4333
This commit is contained in:
Donny/강동윤 2024-04-01 14:26:18 +09:00 committed by GitHub
parent 504ddb9eeb
commit 571d29781a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
use std::{env, sync::Arc};
use anyhow::{anyhow, Error};
use anyhow::{anyhow, Context, Error};
use parking_lot::Mutex;
#[cfg(feature = "__rkyv")]
use swc_common::plugin::serialized::{PluginError, PluginSerializedBytes};
@ -389,6 +389,13 @@ impl TransformExecutor {
) -> Result<PluginSerializedBytes, Error> {
let mut transform_state = self.setup_plugin_env_exports()?;
transform_state.is_transform_schema_compatible()?;
transform_state.run(program, self.unresolved_mark, should_enable_comments_proxy)
transform_state
.run(program, self.unresolved_mark, should_enable_comments_proxy)
.context(
"failed to run Wasm plugin transform. Please ensure the version of `swc_core` \
used by the plugin is compatible with the host runtime. See https://swc.rs/docs/plugin/selecting-swc-core\
for compatibility information. If you are an author of the plugin, please update \
`swc_core` to the compatible version.",
)
}
}