Skip to content

Commit

Permalink
fix(mdx): allow failsafe analyze for mdxasset (vercel#7757)
Browse files Browse the repository at this point in the history
### Description

For the `failsafe_analyze`, make it not failable by not bubbling up the
error - the error will be propagated by chunk generation anyway.

Closes PACK-2764
  • Loading branch information
kwonoj authored Mar 18, 2024
1 parent b499b2e commit 1ed9f99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub struct AnalyzeEcmascriptModuleResult {

/// A temporary analysis result builder to pass around, to be turned into an
/// `Vc<AnalyzeEcmascriptModuleResult>` eventually.
pub(crate) struct AnalyzeEcmascriptModuleResultBuilder {
pub struct AnalyzeEcmascriptModuleResultBuilder {
references: IndexSet<Vc<Box<dyn ModuleReference>>>,
local_references: IndexSet<Vc<Box<dyn ModuleReference>>>,
reexport_references: IndexSet<Vc<Box<dyn ModuleReference>>>,
Expand Down
13 changes: 10 additions & 3 deletions crates/turbopack-mdx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use turbopack_ecmascript::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable,
EcmascriptChunkType, EcmascriptChunkingContext, EcmascriptExports,
},
references::AnalyzeEcmascriptModuleResultBuilder,
AnalyzeEcmascriptModuleResult, EcmascriptInputTransforms, EcmascriptModuleAsset,
EcmascriptModuleAssetType,
};
Expand Down Expand Up @@ -163,9 +164,15 @@ impl MdxModuleAsset {

#[turbo_tasks::function]
async fn failsafe_analyze(self: Vc<Self>) -> Result<Vc<AnalyzeEcmascriptModuleResult>> {
Ok(into_ecmascript_module_asset(&self)
.await?
.failsafe_analyze())
let asset = into_ecmascript_module_asset(&self).await;

if let Ok(asset) = asset {
Ok(asset.failsafe_analyze())
} else {
let mut result = AnalyzeEcmascriptModuleResultBuilder::new();
result.set_successful(false);
result.build(false).await
}
}
}

Expand Down

0 comments on commit 1ed9f99

Please sign in to comment.