Unverified Commit 593cec11 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: fix "ModuleId not found for ident" regression (#99090)

Regression from #98617

Closes #99082
parent 9806642f
......@@ -733,6 +733,16 @@ async fn build_compact_reexports(
let offset = part_references.len();
for (index, reference) in esm_references.iter().enumerate() {
// Unused re-exports are absent from the module ID map and cannot contribute
// an import or a source-order position to the compact registration.
if chunking_context
.unused_references()
.contains_key(&ResolvedVc::upcast(*reference))
.await?
{
continue;
}
if let Some((key, _)) = compact_reference_target(
ResolvedVc::upcast(*reference),
chunking_context,
......
......@@ -25,6 +25,7 @@ use turbo_tasks_fs::{
use turbo_unix_path::sys_to_unix;
use turbopack::{
ModuleAssetContext,
global_module_ids::get_global_module_id_strategy,
module_options::{
EcmascriptOptionsContext, ModuleOptionsContext, TypescriptTransformOptions,
side_effect_free_packages_glob,
......@@ -287,6 +288,8 @@ struct TestOptions {
minify: bool,
#[serde(default)]
production_chunking: bool,
#[serde(default)]
global_module_ids: bool,
/// Packages that are assumed to be side effect free, unless they declare otherwise in their
/// package.json.
#[serde(default)]
......@@ -317,6 +320,7 @@ impl Default for TestOptions {
infer_module_side_effects: default_true(),
minify: false,
production_chunking: false,
global_module_ids: false,
side_effect_free_packages: Vec::new(),
server_relative_root: default_true(),
}
......@@ -603,6 +607,14 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
None
});
if options.global_module_ids {
builder = builder.module_id_strategy(
get_global_module_id_strategy(module_graph)
.to_resolved()
.await?,
);
}
if options.remove_unused_imports {
builder = builder.unused_references(
binding_usage
......
export async function a() {
const { a } = await import('./b')
return a()
}
it('bundles a dynamic import through a barrel with an unused re-export', async () => {
const { a } = await import('./a')
expect(await a()).toBe('a')
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment