Skip to content

Commit

Permalink
Fix test by using a hack
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Nov 18, 2024
1 parent 903a1d8 commit a9959e6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use turbopack_core::{
compile_time_info::{
CompileTimeInfo, DefineableNameSegment, FreeVarReference, FreeVarReferences,
},
context::AssetContext,
environment::Rendering,
error::PrettyPrintError,
issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource, StyledString},
Expand Down Expand Up @@ -124,7 +125,7 @@ use crate::{
top_level_await::has_top_level_await,
ConstantNumber, ConstantString, JsValueUrlKind, RequireContextValue,
},
chunk::EcmascriptExports,
chunk::{EcmascriptChunkPlaceable, EcmascriptExports},
code_gen::{CodeGen, CodeGenerateable, CodeGenerateableWithAsyncModuleInfo, CodeGenerateables},
magic_identifier,
parse::parse,
Expand Down Expand Up @@ -591,6 +592,10 @@ pub(crate) async fn analyse_ecmascript_module_internal(
set_handler_and_globals(&handler, globals, || create_graph(program, eval_context));

let mut evaluation_references = Vec::new();
let side_effect_free_packages = module.asset_context().side_effect_free_packages();
let is_side_effect_free = *module
.is_marked_as_side_effect_free(side_effect_free_packages)
.await?;

for (i, r) in eval_context.imports.references().enumerate() {
let r = EsmAssetReference::new(
Expand All @@ -607,7 +612,9 @@ pub(crate) async fn analyse_ecmascript_module_internal(
}
ImportedSymbol::Symbol(name) => Some(ModulePart::export((&**name).into())),
ImportedSymbol::PartEvaluation(part_id) => {
evaluation_references.push(i);
if !is_side_effect_free {
evaluation_references.push(i);
}
Some(ModulePart::internal_evaluation(*part_id))
}
ImportedSymbol::Part(part_id) => Some(ModulePart::internal(*part_id)),
Expand Down

0 comments on commit a9959e6

Please sign in to comment.