Unverified Commit b8eac180 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Turbopack: prototype flat scope-hoisted exports

Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
parent 23a1f0cb
...@@ -28,6 +28,7 @@ use turbopack_core::{ ...@@ -28,6 +28,7 @@ use turbopack_core::{
ModuleGraph, ModuleGraph,
binding_usage_info::{BindingUsageInfo, ModuleExportUsage}, binding_usage_info::{BindingUsageInfo, ModuleExportUsage},
chunk_group_info::{ChunkGroup, ChunkGroupKey}, chunk_group_info::{ChunkGroup, ChunkGroupKey},
merged_modules::{MergedModuleInfo, OptionMergedModuleGroup},
}, },
output::{ExpandOutputAssetsInput, OutputAsset, OutputAssets, expand_output_assets}, output::{ExpandOutputAssetsInput, OutputAsset, OutputAssets, expand_output_assets},
}; };
...@@ -388,6 +389,7 @@ pub struct BrowserChunkingContext { ...@@ -388,6 +389,7 @@ pub struct BrowserChunkingContext {
module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>, module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>,
/// The module export usage info, if available. /// The module export usage info, if available.
export_usage: Option<ResolvedVc<BindingUsageInfo>>, export_usage: Option<ResolvedVc<BindingUsageInfo>>,
merged_modules: Option<ResolvedVc<MergedModuleInfo>>,
/// Which references are unused and should be skipped (e.g. during codegen). /// Which references are unused and should be skipped (e.g. during codegen).
unused_references: Option<ResolvedVc<UnusedReferences>>, unused_references: Option<ResolvedVc<UnusedReferences>>,
/// The chunking configs /// The chunking configs
...@@ -458,6 +460,7 @@ impl BrowserChunkingContext { ...@@ -458,6 +460,7 @@ impl BrowserChunkingContext {
manifest_chunks: false, manifest_chunks: false,
module_id_strategy: None, module_id_strategy: None,
export_usage: None, export_usage: None,
merged_modules: None,
unused_references: None, unused_references: None,
chunking_configs: Default::default(), chunking_configs: Default::default(),
should_use_absolute_url_references: false, should_use_absolute_url_references: false,
...@@ -1312,6 +1315,32 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -1312,6 +1315,32 @@ impl ChunkingContext for BrowserChunkingContext {
}) })
} }
#[turbo_tasks::function]
async fn with_module_graph(
self: Vc<Self>,
module_graph: Vc<ModuleGraph>,
) -> Result<Vc<Box<dyn ChunkingContext>>> {
let this = self.await?;
if !this.enable_module_merging {
return Ok(Vc::upcast(self));
}
let mut this = (*this).clone();
this.merged_modules = Some(module_graph.merged_modules().to_resolved().await?);
Ok(Vc::upcast(this.cell()))
}
#[turbo_tasks::function]
async fn module_merging_group(
&self,
module: ResolvedVc<Box<dyn Module>>,
) -> Result<Vc<OptionMergedModuleGroup>> {
Ok(Vc::cell(if let Some(info) = self.merged_modules {
info.await?.groups.get(&module).await?.as_deref().copied()
} else {
None
}))
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn module_export_usage( async fn module_export_usage(
&self, &self,
......
...@@ -20,7 +20,8 @@ use crate::{ ...@@ -20,7 +20,8 @@ use crate::{
module::Module, module::Module,
module_graph::{ module_graph::{
ModuleGraph, binding_usage_info::ModuleExportUsage, chunk_group_info::ChunkGroupKey, ModuleGraph, binding_usage_info::ModuleExportUsage, chunk_group_info::ChunkGroupKey,
module_batches::BatchingConfig, style_groups::StyleGroupsAlgorithm, merged_modules::OptionMergedModuleGroup, module_batches::BatchingConfig,
style_groups::StyleGroupsAlgorithm,
}, },
output::{ output::{
ExpandOutputAssetsInput, OutputAsset, OutputAssets, OutputAssetsReferences, ExpandOutputAssetsInput, OutputAsset, OutputAssets, OutputAssetsReferences,
...@@ -543,6 +544,24 @@ pub trait ChunkingContext { ...@@ -543,6 +544,24 @@ pub trait ChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk_item_id_strategy(self: Vc<Self>) -> Result<Vc<ModuleIdStrategy>>; async fn chunk_item_id_strategy(self: Vc<Self>) -> Result<Vc<ModuleIdStrategy>>;
/// Attach scope-hoisting analysis for code generation without changing the graph itself.
#[turbo_tasks::function]
fn with_module_graph(
self: Vc<Self>,
_module_graph: Vc<ModuleGraph>,
) -> Vc<Box<dyn ChunkingContext>> {
self
}
/// Read only the scope-hoisting group containing this module.
#[turbo_tasks::function]
fn module_merging_group(
self: Vc<Self>,
_module: Vc<Box<dyn Module>>,
) -> Vc<OptionMergedModuleGroup> {
Vc::cell(None)
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn module_export_usage( async fn module_export_usage(
self: Vc<Self>, self: Vc<Self>,
......
...@@ -209,8 +209,8 @@ pub enum MergeableModuleExposure { ...@@ -209,8 +209,8 @@ pub enum MergeableModuleExposure {
// This module is only used from within the current group, and but the namespace object is // This module is only used from within the current group, and but the namespace object is
// needed. // needed.
Internal, Internal,
// The exports of this module are read from outside this group (necessitating a namespace // The exports of this module are read from outside this group, so they need runtime
// object anyway). // registration (either in a source-module namespace or a shared flat export table).
External, External,
} }
......
...@@ -33,8 +33,39 @@ pub struct MergedModulesOriginalModules( ...@@ -33,8 +33,39 @@ pub struct MergedModulesOriginalModules(
FxHashMap<ResolvedVc<Box<dyn Module>>, ResolvedVc<Box<dyn Module>>>, FxHashMap<ResolvedVc<Box<dyn Module>>, ResolvedVc<Box<dyn Module>>>,
); );
/// Original modules belonging to the same scope-hoisting group. Kept separately from the
/// replacement decisions so code generation can read just its target's group.
#[turbo_tasks::value(transparent, cell = "keyed")]
pub struct MergedModuleGroups(
FxHashMap<ResolvedVc<Box<dyn Module>>, ResolvedVc<MergedModuleGroup>>,
);
#[turbo_tasks::value]
pub struct MergedModuleGroup {
pub modules: ResolvedVc<MergeableModulesExposed>,
/// The original module whose identity the merged factory uses.
pub entry: ResolvedVc<Box<dyn Module>>,
}
#[turbo_tasks::value_impl]
impl MergedModuleGroup {
// Give each group its own task boundary: rebuilding the global analysis must not change
// an unchanged group's identity just because another group was added or reordered.
#[turbo_tasks::function]
pub fn new(
modules: ResolvedVc<MergeableModulesExposed>,
entry: ResolvedVc<Box<dyn Module>>,
) -> Vc<Self> {
Self { modules, entry }.cell()
}
}
#[turbo_tasks::value(transparent)]
pub struct OptionMergedModuleGroup(pub Option<ResolvedVc<MergedModuleGroup>>);
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct MergedModuleInfo { pub struct MergedModuleInfo {
pub groups: ResolvedVc<MergedModuleGroups>,
/// A map of modules describing how they participate in module merging: /// A map of modules describing how they participate in module merging:
/// - Not present: the module is not affected by merging and a regular chunk item should be /// - Not present: the module is not affected by merging and a regular chunk item should be
/// created for it. /// created for it.
...@@ -845,10 +876,16 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -845,10 +876,16 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let group = MergedModuleGroup::new(
MergeableModulesExposed::interned(list_exposed),
Vc::upcast(entry_points[0]),
)
.to_resolved()
.await?;
let entry = *list.last().unwrap(); let entry = *list.last().unwrap();
let result = entry let result = entry
.merge( .merge(
MergeableModulesExposed::interned(list_exposed), *group.await?.modules,
MergeableModules::interned(entry_points), MergeableModules::interned(entry_points),
) )
.to_resolved() .to_resolved()
...@@ -858,6 +895,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -858,6 +895,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
Ok(Some(( Ok(Some((
ResolvedVc::upcast::<Box<dyn Module>>(entry), ResolvedVc::upcast::<Box<dyn Module>>(entry),
result, result,
group,
list.into_iter() list.into_iter()
.take(list_len - 1) .take(list_len - 1)
.map(ResolvedVc::upcast::<Box<dyn Module>>) .map(ResolvedVc::upcast::<Box<dyn Module>>)
...@@ -881,12 +919,15 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -881,12 +919,15 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
let mut merged_groups = 0; let mut merged_groups = 0;
let mut included_modules = 0; let mut included_modules = 0;
for (original, replacement, replacement_included) in result.into_iter().flatten() { let mut groups = FxHashMap::default();
for (original, replacement, group, replacement_included) in result.into_iter().flatten() {
groups.insert(original, group);
replacements.insert(original, Some(replacement)); replacements.insert(original, Some(replacement));
replacements_to_original.insert(ResolvedVc::upcast(replacement), original); replacements_to_original.insert(ResolvedVc::upcast(replacement), original);
merged_groups += 1; merged_groups += 1;
included_modules += replacement_included.len(); included_modules += replacement_included.len();
for included in replacement_included { for included in replacement_included {
groups.insert(included, group);
replacements.insert(included, None); replacements.insert(included, None);
} }
} }
...@@ -895,6 +936,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -895,6 +936,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
span.record("included_modules", included_modules); span.record("included_modules", included_modules);
Ok(MergedModuleInfo { Ok(MergedModuleInfo {
groups: ResolvedVc::cell(groups),
replacements: ResolvedVc::cell(replacements), replacements: ResolvedVc::cell(replacements),
replacements_to_original: ResolvedVc::cell(replacements_to_original), replacements_to_original: ResolvedVc::cell(replacements_to_original),
} }
......
...@@ -407,7 +407,7 @@ impl EcmascriptChunkItem for EcmascriptModuleChunkItem { ...@@ -407,7 +407,7 @@ impl EcmascriptChunkItem for EcmascriptModuleChunkItem {
estimated: bool, estimated: bool,
) -> Result<Vc<EcmascriptChunkItemContent>> { ) -> Result<Vc<EcmascriptChunkItemContent>> {
Ok(self.module.chunk_item_content( Ok(self.module.chunk_item_content(
*self.chunking_context, self.chunking_context.with_module_graph(*self.module_graph),
*self.module_graph, *self.module_graph,
async_module_info, async_module_info,
estimated, estimated,
......
...@@ -1346,12 +1346,17 @@ impl EcmascriptModuleContent { ...@@ -1346,12 +1346,17 @@ impl EcmascriptModuleContent {
.try_join() .try_join()
.await?; .await?;
let (merged_ast, comments, source_maps, original_source_maps, lookup_table) =
merge_modules(contents, &entry_points, &globals_merged).await?;
// Use the options from an arbitrary module, since they should all be the same with // Use the options from an arbitrary module, since they should all be the same with
// regards to minify_type and chunking_context. // regards to minify_type and chunking_context.
let options = module_options.last().unwrap().await?; let options = module_options.last().unwrap().await?;
let flat_group = *references::esm::mangle::flat_export_group(
*entry_points[0].0,
*options.chunking_context,
)
.await?;
let flat_exports = flat_group.is_some();
let (merged_ast, comments, source_maps, original_source_maps, lookup_table) =
merge_modules(contents, &entry_points, &globals_merged, flat_exports).await?;
let modules_header_width = modules.len().next_power_of_two().trailing_zeros(); let modules_header_width = modules.len().next_power_of_two().trailing_zeros();
let content = CodeGenResult { let content = CodeGenResult {
...@@ -1454,6 +1459,7 @@ async fn merge_modules( ...@@ -1454,6 +1459,7 @@ async fn merge_modules(
mut contents: Vec<(ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, CodeGenResult)>, mut contents: Vec<(ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, CodeGenResult)>,
entry_points: &Vec<(ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, usize)>, entry_points: &Vec<(ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, usize)>,
globals_merged: &'_ Globals, globals_merged: &'_ Globals,
flat_exports: bool,
) -> Result<( ) -> Result<(
Program, Program,
Vec<CodeGenResultComments>, Vec<CodeGenResultComments>,
...@@ -1783,6 +1789,33 @@ async fn merge_modules( ...@@ -1783,6 +1789,33 @@ async fn merge_modules(
} }
drop(span); drop(span);
if flat_exports {
let mut getters = Vec::new();
// The contributions have already had their syntax contexts and source spans rewritten.
// Register before imports so cyclic consumers see the whole group's getters.
// Only inspect generated early-hoisted statements, never user code in `result`,
// which may contain a user binding with the same spelling as the marker.
merged_prelude.retain_mut(|item| {
if let ModuleItem::Stmt(Stmt::Expr(ExprStmt { expr, .. })) = item
&& let Expr::Call(call) = &mut **expr
&& let Callee::Expr(callee) = &call.callee
&& callee.is_ident_ref_to("__turbopack_flat_esm__")
{
let Expr::Array(array) = &mut *call.args[0].expr else { unreachable!() };
getters.append(&mut array.elems);
return false;
}
true
});
if !getters.is_empty() {
let stmt = ModuleItem::Stmt(quote!("$esm($getters);" as Stmt,
esm: Expr = runtime_functions::TURBOPACK_ESM.into(),
getters: Expr = swc_core::ecma::ast::ArrayLit { span: DUMMY_SP, elems: getters }.into(),
));
merged_prelude.insert(0, stmt);
}
}
let span = tracing::trace_span!("hygiene").entered(); let span = tracing::trace_span!("hygiene").entered();
let mut merged_ast = Program::Module(swc_core::ecma::ast::Module { let mut merged_ast = Program::Module(swc_core::ecma::ast::Module {
body: merged_prelude.into_iter().chain(result).collect(), body: merged_prelude.into_iter().chain(result).collect(),
......
...@@ -50,7 +50,7 @@ use crate::{ ...@@ -50,7 +50,7 @@ use crate::{
esm::{ esm::{
EsmExport, EsmExport,
export::{SubsumedImports, all_known_export_names, is_export_missing}, export::{SubsumedImports, all_known_export_names, is_export_missing},
mangle::generated_export_key, mangle::{flat_export_group, generated_export_key},
}, },
util::{SpecifiedChunkingType, throw_module_not_found_expr}, util::{SpecifiedChunkingType, throw_module_not_found_expr},
}, },
...@@ -306,7 +306,13 @@ impl ReferencedAsset { ...@@ -306,7 +306,13 @@ impl ReferencedAsset {
} }
} }
let import_source = ImportSource::Module { asset: *asset }; let target =
if let Some(group) = *flat_export_group(**asset, chunking_context).await? {
group.await?.entry
} else {
*asset
};
let import_source = ImportSource::Module { asset: target };
Some(ReferencedAssetIdent::Module { Some(ReferencedAssetIdent::Module {
namespace_ident: import_source.get_namespace_ident(chunking_context).await?, namespace_ident: import_source.get_namespace_ident(chunking_context).await?,
ctxt: None, ctxt: None,
......
...@@ -37,7 +37,7 @@ use crate::{ ...@@ -37,7 +37,7 @@ use crate::{
module_fragments::part::module::EcmascriptModulePartAsset, module_fragments::part::module::EcmascriptModulePartAsset,
references::esm::{ references::esm::{
base::{EsmAssetReference, ImportSource, ReferencedAsset, ReferencedAssetIdent}, base::{EsmAssetReference, ImportSource, ReferencedAsset, ReferencedAssetIdent},
mangle::mangled_export_names, mangle::{flat_export_group, mangled_export_names},
}, },
runtime_functions::{TURBOPACK_DYNAMIC, TURBOPACK_ESM, TURBOPACK_ESM_REEXPORT}, runtime_functions::{TURBOPACK_DYNAMIC, TURBOPACK_ESM, TURBOPACK_ESM_REEXPORT},
side_effect_optimization::reference::EcmascriptModulePartReference, side_effect_optimization::reference::EcmascriptModulePartReference,
...@@ -1069,6 +1069,14 @@ impl EsmExports { ...@@ -1069,6 +1069,14 @@ impl EsmExports {
// The keys this module's exports are emitted under. Consumers resolve the same map for this // The keys this module's exports are emitted under. Consumers resolve the same map for this
// module (see `ReferencedAsset::get_ident_inner`), so both sides always agree. // module (see `ReferencedAsset::get_ident_inner`), so both sides always agree.
let mangled_names = mangled_export_names(*module, chunking_context).await?; let mangled_names = mangled_export_names(*module, chunking_context).await?;
let flat_group = if scope_hoisting_context.module().is_some() {
*flat_export_group(*module, chunking_context).await?
} else {
None
};
// A group can be re-entered between evaluating two of its source modules, even if
// neither is the chosen cycle breaker. Expose getters before any group imports run.
let early_exports = export_usage_info.is_circuit_breaker || flat_group.is_some();
// A module whose exports are *only* forwarded from other modules can register them all in // A module whose exports are *only* forwarded from other modules can register them all in
// one compact call instead of one arrow function per binding. `export_registration_mode` // one compact call instead of one arrow function per binding. `export_registration_mode`
...@@ -1080,7 +1088,8 @@ impl EsmExports { ...@@ -1080,7 +1088,8 @@ impl EsmExports {
mode: export_registration_mode, mode: export_registration_mode,
is_circuit_breaker: export_usage_info.is_circuit_breaker, is_circuit_breaker: export_usage_info.is_circuit_breaker,
is_async_module, is_async_module,
}) && expanded.dynamic_exports.is_empty() }) && flat_group.is_none()
&& expanded.dynamic_exports.is_empty()
&& !expanded.exports.is_empty() && !expanded.exports.is_empty()
{ {
build_compact_reexports( build_compact_reexports(
...@@ -1143,7 +1152,7 @@ impl EsmExports { ...@@ -1143,7 +1152,7 @@ impl EsmExports {
}); });
let local = Ident::new(local, DUMMY_SP, ctxt); let local = Ident::new(local, DUMMY_SP, ctxt);
match (liveness, export_usage_info.is_circuit_breaker) { match (liveness, early_exports) {
(Liveness::Constant, false) => ExportBinding::Value(Expr::Ident(local)), (Liveness::Constant, false) => ExportBinding::Value(Expr::Ident(local)),
// If the value might change or we are a circuit breaker we must bind a // If the value might change or we are a circuit breaker we must bind a
// getter to avoid capturing the value at the wrong time. // getter to avoid capturing the value at the wrong time.
...@@ -1174,7 +1183,7 @@ impl EsmExports { ...@@ -1174,7 +1183,7 @@ impl EsmExports {
ReferencedAssetIdent::LocalBinding {ctxt, liveness,.. } => { ReferencedAssetIdent::LocalBinding {ctxt, liveness,.. } => {
debug_assert!(*mutable == (*liveness == Liveness::Mutable), "If the re-export is mutable, the merged local must be too"); debug_assert!(*mutable == (*liveness == Liveness::Mutable), "If the re-export is mutable, the merged local must be too");
// If we are re-exporting something but got merged with it we can treat it like a local export // If we are re-exporting something but got merged with it we can treat it like a local export
match (liveness, export_usage_info.is_circuit_breaker) { match (liveness, early_exports) {
(Liveness::Constant, false) => { (Liveness::Constant, false) => {
ExportBinding::Value(read_expr) ExportBinding::Value(read_expr)
} }
...@@ -1233,7 +1242,7 @@ impl EsmExports { ...@@ -1233,7 +1242,7 @@ impl EsmExports {
.await? .await?
.map(|ident| { .map(|ident| {
let imported = ident.as_expr(DUMMY_SP, false); let imported = ident.as_expr(DUMMY_SP, false);
if export_usage_info.is_circuit_breaker { if early_exports {
ExportBinding::Getter(quote!( ExportBinding::Getter(quote!(
"(() => $imported)" as Expr, "(() => $imported)" as Expr,
imported: Expr = imported imported: Expr = imported
...@@ -1302,7 +1311,10 @@ impl EsmExports { ...@@ -1302,7 +1311,10 @@ impl EsmExports {
let has_dynamic_exports = !expanded.dynamic_exports.is_empty(); let has_dynamic_exports = !expanded.dynamic_exports.is_empty();
let esm_exports = vec![CodeGenerationHoistedStmt::new( let esm_exports = vec![CodeGenerationHoistedStmt::new(
rcstr!("__turbopack_esm__"), rcstr!("__turbopack_esm__"),
if let Some(module) = scope_hoisting_context.module() { if flat_group.is_some() {
// AST merging collects these contributions into one registration for the factory.
quote!("__turbopack_flat_esm__($getters);" as Stmt, getters: Expr = getters)
} else if let Some(module) = scope_hoisting_context.module() {
let id = module.chunk_item_id(chunking_context).await?; let id = module.chunk_item_id(chunking_context).await?;
if has_dynamic_exports { if has_dynamic_exports {
quote!("$turbopack_esm($getters, $id, true);" as Stmt, quote!("$turbopack_esm($getters, $id, true);" as Stmt,
...@@ -1331,7 +1343,7 @@ impl EsmExports { ...@@ -1331,7 +1343,7 @@ impl EsmExports {
)]; )];
// If we are a circuit breaker module we need to expose exports first so they are available // If we are a circuit breaker module we need to expose exports first so they are available
// to a cyclic importer otherwise we put them at the bottom of the module factory. // to a cyclic importer otherwise we put them at the bottom of the module factory.
Ok(if export_usage_info.is_circuit_breaker { Ok(if early_exports {
( (
CodeGeneration::new(vec![], dynamic_stmt, esm_exports, vec![], vec![]), CodeGeneration::new(vec![], dynamic_stmt, esm_exports, vec![], vec![]),
Default::default(), Default::default(),
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
//! `{ someVeryLongExportName: () => … }` and every consumer reads //! `{ someVeryLongExportName: () => … }` and every consumer reads
//! `ns["someVeryLongExportName"]`. Both sides are generated by us, so the key can be replaced by a //! `ns["someVeryLongExportName"]`. Both sides are generated by us, so the key can be replaced by a
//! much shorter one — as long as producer and consumer agree, and as long as the name is not //! much shorter one — as long as producer and consumer agree, and as long as the name is not
//! observable from user code. //! observable from user code. Scope-hoisted groups with no observable source-module namespaces
//! share a single allocation domain, with distinct keys for each `(module, export)` binding.
//! //!
//! [`mangled_export_names`] is the single source of truth for that mapping. Both the producer //! [`mangled_export_names`] is the single source of truth for that mapping. Both the producer
//! ([`super::export::EsmExports::code_generation`]) and the consumer //! ([`super::export::EsmExports::code_generation`]) and the consumer
...@@ -25,7 +26,8 @@ use turbo_frozenmap::FrozenMap; ...@@ -25,7 +26,8 @@ use turbo_frozenmap::FrozenMap;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::ChunkingContext, module_graph::binding_usage_info::ModuleExportUsageInfo, chunk::{ChunkingContext, MergeableModuleExposure},
module_graph::{binding_usage_info::ModuleExportUsageInfo, merged_modules::MergedModuleGroup},
}; };
use self::table::shorten_to_unique_names; use self::table::shorten_to_unique_names;
...@@ -35,8 +37,8 @@ use crate::chunk::{EcmascriptChunkPlaceable, EcmascriptExports}; ...@@ -35,8 +37,8 @@ use crate::chunk::{EcmascriptChunkPlaceable, EcmascriptExports};
/// ///
/// `None` means the module is not eligible for mangling at all and keeps every original name (see /// `None` means the module is not eligible for mangling at all and keeps every original name (see
/// [`mangled_export_names`] for the conditions). `Some` covers only the exports that were actually /// [`mangled_export_names`] for the conditions). `Some` covers only the exports that were actually
/// *renamed* — an export that kept its own name because it was already short enough, or because it /// *renamed* for standalone modules. Flat scope-hoisting groups may also explicitly map a name to
/// lost every hash collision, is not a key in the map. So a missing key always means "use the /// itself, since their allocation keys include source-module identity. An absent key means "use the
/// original name", and callers that only want the correct output key can ignore the distinction /// original name", and callers that only want the correct output key can ignore the distinction
/// entirely (see [`generated_export_key`]); the `canMangle` reporting in /// entirely (see [`generated_export_key`]); the `canMangle` reporting in
/// [`crate::references::exports_info`] is the one caller that needs to tell "not eligible" from /// [`crate::references::exports_info`] is the one caller that needs to tell "not eligible" from
...@@ -44,6 +46,95 @@ use crate::chunk::{EcmascriptChunkPlaceable, EcmascriptExports}; ...@@ -44,6 +46,95 @@ use crate::chunk::{EcmascriptChunkPlaceable, EcmascriptExports};
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct MangledExportNames(pub Option<FrozenMap<RcStr, RcStr>>); pub struct MangledExportNames(pub Option<FrozenMap<RcStr, RcStr>>);
/// One flat namespace for a scope-hoisting group. Allocation keys include the module index,
/// so two source modules exporting the same name still get distinct output properties.
#[turbo_tasks::value]
pub struct FlatExportGroup {
pub entry: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
pub names: rustc_hash::FxHashMap<
ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
FrozenMap<RcStr, RcStr>,
>,
}
#[turbo_tasks::value(transparent)]
pub struct OptionFlatExportGroup(pub Option<ResolvedVc<FlatExportGroup>>);
#[turbo_tasks::function]
pub async fn flat_export_group(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<OptionFlatExportGroup>> {
let group = chunking_context
.module_merging_group(*ResolvedVc::upcast(module))
.await?;
if let Some(group) = *group {
return Ok(flat_group_exports(*group, chunking_context));
}
Ok(Vc::cell(None))
}
#[turbo_tasks::function]
async fn flat_group_exports(
group: Vc<MergedModuleGroup>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<OptionFlatExportGroup>> {
let group = group.await?;
let mut exports_to_name = Vec::new();
for (index, (module, exposure)) in group.modules.await?.iter().enumerate() {
let Some(module) = ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(*module)
else {
return Ok(Vc::cell(None));
};
let EcmascriptExports::EsmExports(exports) = *module.get_exports().await? else {
return Ok(Vc::cell(None));
};
if !exports.await?.mangle_export_names || *exposure == MergeableModuleExposure::Internal {
return Ok(Vc::cell(None));
}
let usage = chunking_context
.module_export_usage(*ResolvedVc::upcast(module))
.await?;
if usage.namespace_object_may_escape
|| matches!(*usage.export_usage.await?, ModuleExportUsageInfo::All)
{
return Ok(Vc::cell(None));
}
let expanded = exports.expand_exports(*usage.export_usage).await?;
if !expanded.dynamic_exports.is_empty() {
return Ok(Vc::cell(None));
}
if *exposure == MergeableModuleExposure::External {
for name in expanded.exports.keys() {
exports_to_name.push((
module,
name.clone(),
RcStr::from(format!("{index}:{name}")),
));
}
}
}
let allocated = shorten_to_unique_names(exports_to_name.iter().map(|(_, _, key)| key));
let mut names = rustc_hash::FxHashMap::<_, Vec<_>>::default();
for (module, name, key) in exports_to_name {
names
.entry(module)
.or_default()
.push((name, allocated.get(&key).unwrap().clone()));
}
let entry = ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(group.entry).unwrap();
Ok(Vc::cell(Some(
FlatExportGroup {
entry,
names: names
.into_iter()
.map(|(module, names)| (module, FrozenMap::from_iter(names)))
.collect(),
}
.resolved_cell(),
)))
}
/// Computes the mangled export names of `module`, or `None` when its exports must keep their /// Computes the mangled export names of `module`, or `None` when its exports must keep their
/// original names. /// original names.
/// ///
...@@ -74,6 +165,11 @@ pub async fn mangled_export_names( ...@@ -74,6 +165,11 @@ pub async fn mangled_export_names(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<MangledExportNames>> { ) -> Result<Vc<MangledExportNames>> {
if let Some(group) = *flat_export_group(*module, chunking_context).await? {
return Ok(Vc::cell(Some(
group.await?.names.get(&module).cloned().unwrap_or_default(),
)));
}
// (4) Only statically known ESM exports can be renamed. // (4) Only statically known ESM exports can be renamed.
let EcmascriptExports::EsmExports(exports) = *module.get_exports().await? else { let EcmascriptExports::EsmExports(exports) = *module.get_exports().await? else {
return Ok(Vc::cell(None)); return Ok(Vc::cell(None));
...@@ -135,8 +231,8 @@ pub async fn mangled_export_names( ...@@ -135,8 +231,8 @@ pub async fn mangled_export_names(
/// hand. Code that goes through `ReferencedAssetIdent` (see `super::base`) is already covered. /// hand. Code that goes through `ReferencedAssetIdent` (see `super::base`) is already covered.
/// ///
/// `module` must be the module that actually *produces* the export. For a re-export, resolve to the /// `module` must be the module that actually *produces* the export. For a re-export, resolve to the
/// producing module first (as `ReferencedAsset::get_ident_inner` does), because each module mangles /// producing module first (as `ReferencedAsset::get_ident_inner` does). Flat scope-hoisting groups
/// its own keys independently. /// allocate keys jointly; other modules allocate them independently.
pub async fn generated_export_key( pub async fn generated_export_key(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
......
...@@ -222,7 +222,13 @@ impl EcmascriptModulePartReference { ...@@ -222,7 +222,13 @@ impl EcmascriptModulePartReference {
ReferencedAssetIdent::LocalBinding { .. } => { ReferencedAssetIdent::LocalBinding { .. } => {
// no need to import // no need to import
} }
ReferencedAssetIdent::Module { .. } => { ReferencedAssetIdent::Module {
ref import_source, ..
} => {
let target = match &import_source {
crate::references::esm::base::ImportSource::Module { asset } => *asset,
_ => unreachable!("part module reference must target an in-graph module"),
};
let (sym, ctxt) = ident.into_module_namespace_ident().unwrap(); let (sym, ctxt) = ident.into_module_namespace_ident().unwrap();
if subsumed_namespaces.contains(&(sym.to_string(), ctxt)) { if subsumed_namespaces.contains(&(sym.to_string(), ctxt)) {
// A compact registration performs this import, including evaluation-only // A compact registration performs this import, including evaluation-only
...@@ -232,7 +238,7 @@ impl EcmascriptModulePartReference { ...@@ -232,7 +238,7 @@ impl EcmascriptModulePartReference {
let key = sym.as_str().into(); let key = sym.as_str().into();
let name = Ident::new(sym.into(), DUMMY_SP, ctxt.unwrap_or_default()); let name = Ident::new(sym.into(), DUMMY_SP, ctxt.unwrap_or_default());
let id = module.chunk_item_id(chunking_context).await?; let id = target.chunk_item_id(chunking_context).await?;
result.push(CodeGenerationHoistedStmt::new( result.push(CodeGenerationHoistedStmt::new(
key, key,
......
...@@ -27,7 +27,7 @@ use crate::{ ...@@ -27,7 +27,7 @@ use crate::{
EcmascriptExports, data::EcmascriptChunkData, ecmascript_chunk_item, EcmascriptExports, data::EcmascriptChunkData, ecmascript_chunk_item,
}, },
embed_js::embed_fs, embed_js::embed_fs,
references::esm::generated_export_key, references::esm::{generated_export_key, mangle::flat_export_group},
runtime_functions::{TURBOPACK_EXPORT_VALUE, TURBOPACK_REQUIRE}, runtime_functions::{TURBOPACK_EXPORT_VALUE, TURBOPACK_REQUIRE},
utils::{StringifyJs, StringifyModuleId}, utils::{StringifyJs, StringifyModuleId},
}; };
...@@ -292,20 +292,28 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule { ...@@ -292,20 +292,28 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule {
.cell()); .cell());
} }
let create_worker_module = self.create_worker_module(); let chunking_context = chunking_context.with_module_graph(module_graph);
let create_worker_id = create_worker_module.chunk_item_id(chunking_context).await?; let create_worker_module = self.create_worker_module().to_resolved().await?;
let mut create_worker_target = create_worker_module;
// The helper's `default` export is read here as a string, so it has to go through the same // The helper's `default` export is read here as a string, so it has to go through the same
// mapping the helper itself emits — a hard-coded `["default"]` misses once its exports are // mapping the helper itself emits — a hard-coded `["default"]` misses once its exports are
// mangled. // mangled.
let create_worker_export = match ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>( let create_worker_export = match ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(
create_worker_module.to_resolved().await?, create_worker_module,
) { ) {
Some(placeable) => { Some(placeable) => {
// Resolve the factory identity as well as the key, just like a generated ESM
// import.
if let Some(group) = *flat_export_group(*placeable, chunking_context).await? {
create_worker_target = ResolvedVc::upcast(group.await?.entry);
}
generated_export_key(placeable, chunking_context, &rcstr!("default")).await? generated_export_key(placeable, chunking_context, &rcstr!("default")).await?
} }
None => rcstr!("default"), None => rcstr!("default"),
}; };
let create_worker_id = create_worker_target.chunk_item_id(chunking_context).await?;
let code = match this.worker_type { let code = match this.worker_type {
WorkerType::WebWorker | WorkerType::SharedWebWorker => { WorkerType::WebWorker | WorkerType::SharedWebWorker => {
// For web workers, generate code that exports a function to create the worker. // For web workers, generate code that exports a function to create the worker.
......
...@@ -26,6 +26,7 @@ use turbopack_core::{ ...@@ -26,6 +26,7 @@ use turbopack_core::{
ModuleGraph, ModuleGraph,
binding_usage_info::{BindingUsageInfo, ModuleExportUsage}, binding_usage_info::{BindingUsageInfo, ModuleExportUsage},
chunk_group_info::ChunkGroupKey, chunk_group_info::ChunkGroupKey,
merged_modules::{MergedModuleInfo, OptionMergedModuleGroup},
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets},
}; };
...@@ -238,6 +239,7 @@ pub struct NodeJsChunkingContext { ...@@ -238,6 +239,7 @@ pub struct NodeJsChunkingContext {
module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>, module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>,
/// The module export usage info, if available. /// The module export usage info, if available.
export_usage: Option<ResolvedVc<BindingUsageInfo>>, export_usage: Option<ResolvedVc<BindingUsageInfo>>,
merged_modules: Option<ResolvedVc<MergedModuleInfo>>,
/// Which references are unused and should be skipped (e.g. during codegen). /// Which references are unused and should be skipped (e.g. during codegen).
unused_references: Option<ResolvedVc<UnusedReferences>>, unused_references: Option<ResolvedVc<UnusedReferences>>,
/// The strategy to use for generating source map source uris /// The strategy to use for generating source map source uris
...@@ -294,6 +296,7 @@ impl NodeJsChunkingContext { ...@@ -294,6 +296,7 @@ impl NodeJsChunkingContext {
source_map_source_type: SourceMapSourceType::TurbopackUri, source_map_source_type: SourceMapSourceType::TurbopackUri,
module_id_strategy: None, module_id_strategy: None,
export_usage: None, export_usage: None,
merged_modules: None,
unused_references: None, unused_references: None,
chunking_configs: Default::default(), chunking_configs: Default::default(),
debug_ids: false, debug_ids: false,
...@@ -801,6 +804,32 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -801,6 +804,32 @@ impl ChunkingContext for NodeJsChunkingContext {
}) })
} }
#[turbo_tasks::function]
async fn with_module_graph(
self: Vc<Self>,
module_graph: Vc<ModuleGraph>,
) -> Result<Vc<Box<dyn ChunkingContext>>> {
let this = self.await?;
if !this.enable_module_merging {
return Ok(Vc::upcast(self));
}
let mut this = (*this).clone();
this.merged_modules = Some(module_graph.merged_modules().to_resolved().await?);
Ok(Vc::upcast(this.cell()))
}
#[turbo_tasks::function]
async fn module_merging_group(
&self,
module: ResolvedVc<Box<dyn Module>>,
) -> Result<Vc<OptionMergedModuleGroup>> {
Ok(Vc::cell(if let Some(info) = self.merged_modules {
info.await?.groups.get(&module).await?.as_deref().copied()
} else {
None
}))
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn module_export_usage( async fn module_export_usage(
&self, &self,
......
import { Worker } from 'node:worker_threads'
import { import {
someLongExportName, someLongExportName,
anotherLongExportName, anotherLongExportName,
aLongFunctionName, aLongFunctionName,
a as sharedShort,
} from './shared' } from './shared'
import {
someLongExportName as secondName,
a as secondShort,
liveValue,
increment,
} from './second'
it('should be correct with scope hoisting enabled', () => { it('should be correct with scope hoisting enabled', () => {
expect(someLongExportName).toBe('shared-1') expect(someLongExportName).toBe('shared-1')
expect(anotherLongExportName).toBe('shared-2') expect(anotherLongExportName).toBe('shared-2')
expect(aLongFunctionName()).toBe('shared-fn') expect(aLongFunctionName()).toBe('shared-fn')
expect(secondName).toBe('second-1')
expect(sharedShort).toBe('shared-short')
expect(secondShort).toBe('second-short')
})
it('should resolve worker helper exports with mangling and hoisting enabled', async () => {
const worker = new Worker(new URL('./worker.js', import.meta.url))
try {
const message = await new Promise((resolve, reject) => {
worker.on('message', resolve)
worker.on('error', reject)
})
expect(message).toBe('flat-exports-worker')
} finally {
await worker.terminate()
}
}) })
it('should be correct across a chunk boundary with scope hoisting enabled', async () => { it('should be correct across a chunk boundary with scope hoisting enabled', async () => {
...@@ -16,5 +40,12 @@ it('should be correct across a chunk boundary with scope hoisting enabled', asyn ...@@ -16,5 +40,12 @@ it('should be correct across a chunk boundary with scope hoisting enabled', asyn
const { fromLazy } = await import( const { fromLazy } = await import(
/* turbopackExports: ["fromLazy"] */ './lazy' /* turbopackExports: ["fromLazy"] */ './lazy'
) )
expect(fromLazy()).toBe('shared-1/shared-fn') expect(fromLazy()).toBe(
'shared-1/shared-fn/second-1/shared-short/second-short/0'
)
increment()
expect(liveValue).toBe(1)
expect(fromLazy()).toBe(
'shared-1/shared-fn/second-1/shared-short/second-short/1'
)
}) })
import { someLongExportName, aLongFunctionName } from './shared' import {
someLongExportName,
aLongFunctionName,
a as sharedShort,
} from './shared'
import {
someLongExportName as secondName,
a as secondShort,
liveValue,
} from './second'
export const fromLazy = () => `${someLongExportName}/${aLongFunctionName()}` export const fromLazy = () =>
`${someLongExportName}/${aLongFunctionName()}/${secondName}/${sharedShort}/${secondShort}/${liveValue}`
// Imported in the same order as shared.js from both chunks, so both modules can share a factory.
export const someLongExportName = 'second-1'
export const a = 'second-short'
export let liveValue = 0
export function increment() {
liveValue++
}
// A user binding with the internal marker's spelling must not be consumed as generated code.
function __turbopack_flat_esm__(value) {
if (value !== 'user code') throw new Error('user call changed')
}
__turbopack_flat_esm__('user code')
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// boundary and its export object is really emitted even with scope hoisting on. // boundary and its export object is really emitted even with scope hoisting on.
export const someLongExportName = 'shared-1' export const someLongExportName = 'shared-1'
export const a = 'shared-short'
export const anotherLongExportName = 'shared-2' export const anotherLongExportName = 'shared-2'
export function aLongFunctionName() { export function aLongFunctionName() {
......
import { parentPort } from 'node:worker_threads'
parentPort.postMessage('flat-exports-worker')
export const sameLongExportName = 'first'
export const a = 'first-short'
import { sameLongExportName as first, a as firstShort } from './first'
import { sameLongExportName as second, a as secondShort } from './second'
console.log(first, second, firstShort, secondShort)
import('./lazy').then(({ read }) => console.log(read()))
import { sameLongExportName as first, a as firstShort } from './first'
import { sameLongExportName as second, a as secondShort } from './second'
export const read = () => [first, second, firstShort, secondShort]
export const sameLongExportName = 'second'
export const a = 'second-short'
{
"scopeHoisting": true,
"mangleExportNames": false,
"removeUnusedImports": true,
"removeUnusedExports": true
}
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1ece_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_index_1vrge6jk7spmk.js",
{"otherChunks":["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_lazy_04pakjaudax9j.js","output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_0hnts5i2ue-81._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(()=>{"use strict";(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_0hnts5i2ue-81._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js [test] (ecmascript)", "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js [test] (ecmascript)",
((__turbopack_context__) => {
"use strict";
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js [test] (ecmascript)
;
const sameLongExportName = 'first';
const a = 'first-short';
__turbopack_context__.s([
"a",
0,
a,
"sameLongExportName",
0,
sameLongExportName
], "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js [test] (ecmascript)");
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js [test] (ecmascript)
;
const sameLongExportName1 = 'second';
const a1 = 'second-short';
__turbopack_context__.s([
"a",
0,
a1,
"sameLongExportName",
0,
sameLongExportName1
], "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js [test] (ecmascript)");
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js [test] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js [test] (ecmascript)");
;
;
console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["sameLongExportName"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["sameLongExportName"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"]);
__turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/lazy.js [test] (ecmascript, async loader)").then(({ read })=>console.log(read()));
__turbopack_context__.s([]);
}),
]);})()
//# sourceMappingURL=1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_0hnts5i2ue-81._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js"],"sourcesContent":["export const sameLongExportName = 'first'\nexport const a = 'first-short'\n","export const sameLongExportName = 'second'\nexport const a = 'second-short'\n"],"names":["sameLongExportName","a"],"mappings":";;AAAO,MAAMA,qBAAqB;AAC3B,MAAMC,IAAI;;;;;;;;;;;ACDV,MAAMD,sBAAqB;AAC3B,MAAM,KAAI"}},
{"offset": {"line": 33, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/index.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport { sameLongExportName as second, a as secondShort } from './second'\n\nconsole.log(first, second, firstShort, secondShort)\nimport('./lazy').then(({ read }) => console.log(read()))\n"],"names":["console","log","then","read"],"mappings":"AAAA;AACA;;;AAEAA,QAAQC,GAAG,CAAC,oPAAK,EAAE,qPAAM,EAAE,mOAAU,EAAE,oOAAW;AAClD,0KAAiBC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKH,QAAQC,GAAG,CAACE"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_lazy_04pakjaudax9j.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/lazy.js [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => {
return Promise.all([
"output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_lazy_0w77cwl6ba-xa.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/lazy.js [test] (ecmascript)");
});
});
}),
]);
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_lazy_0w77cwl6ba-xa.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/lazy.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/first.js [test] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/second.js [test] (ecmascript)");
;
;
const read = ()=>[
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["sameLongExportName"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["sameLongExportName"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$disabled$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"]
];
__turbopack_context__.s([
"read",
0,
read
]);
}),
]);
//# sourceMappingURL=1jsg_tests_snapshot_mangle-exports_flat-hoisted-disabled_input_lazy_0w77cwl6ba-xa.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-disabled/input/lazy.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport { sameLongExportName as second, a as secondShort } from './second'\n\nexport const read = () => [first, second, firstShort, secondShort]\n"],"names":["read"],"mappings":"AAAA;AACA;;;AAEO,MAAMA,OAAO,IAAM;QAAC,oPAAK;QAAE,qPAAM;QAAE,mOAAU;QAAE,oOAAW;KAAC"}}]
}
\ No newline at end of file
export const sameLongExportName = 'first'
export const a = 'first-short'
import { sameLongExportName as first, a as firstShort } from './first'
import * as second from './second'
console.log(first, firstShort, Object.keys(second), second)
import('./lazy').then(({ read }) => console.log(read()))
import { sameLongExportName as first, a as firstShort } from './first'
import { sameLongExportName as second, a as secondShort } from './second'
export const read = () => [first, second, firstShort, secondShort]
export const sameLongExportName = 'second'
export const a = 'second-short'
{
"scopeHoisting": true,
"mangleExportNames": true,
"removeUnusedImports": true,
"removeUnusedExports": true
}
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1ece_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_index_0x4dcss-e6of8.js",
{"otherChunks":["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_lazy_1f8vl28-73g6v.js","output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_1j5504fwlb204._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(()=>{"use strict";(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_1j5504fwlb204._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js [test] (ecmascript)", "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)",
((__turbopack_context__) => {
"use strict";
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js [test] (ecmascript)
;
const sameLongExportName = 'first';
const a = 'first-short';
__turbopack_context__.s([
"a",
0,
a,
"k",
0,
sameLongExportName
], "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js [test] (ecmascript)");
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)
;
const sameLongExportName1 = 'second';
const a1 = 'second-short';
__turbopack_context__.s([
"a",
0,
a1,
"sameLongExportName",
0,
sameLongExportName1
], "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)");
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js [test] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)");
;
;
console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["k"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"], Object.keys(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__), __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__);
__turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/lazy.js [test] (ecmascript, async loader)").then(({ read })=>console.log(read()));
__turbopack_context__.s([]);
}),
]);})()
//# sourceMappingURL=1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_1j5504fwlb204._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js"],"sourcesContent":["export const sameLongExportName = 'first'\nexport const a = 'first-short'\n","export const sameLongExportName = 'second'\nexport const a = 'second-short'\n"],"names":["sameLongExportName","a"],"mappings":";;AAAO,MAAMA,qBAAqB;AAC3B,MAAMC,IAAI;;;;;;;;;;;ACDV,MAAMD,sBAAqB;AAC3B,MAAM,KAAI"}},
{"offset": {"line": 33, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/index.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport * as second from './second'\n\nconsole.log(first, firstShort, Object.keys(second), second)\nimport('./lazy').then(({ read }) => console.log(read()))\n"],"names":["console","log","Object","keys","imported module [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)","then","read"],"mappings":"AAAA;AACA;;;AAEAA,QAAQC,GAAG,CAAC,oOAAK,EAAE,oOAAU,EAAEC,OAAOC,IAAI,CAACC,mOAASA;AACpD,2KAAiBC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKN,QAAQC,GAAG,CAACK"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_lazy_1f8vl28-73g6v.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/lazy.js [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => {
return Promise.all([
"output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_lazy_1jiloitq_67ff.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/lazy.js [test] (ecmascript)");
});
});
}),
]);
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_lazy_1jiloitq_67ff.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/lazy.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/first.js [test] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/second.js [test] (ecmascript)");
;
;
const read = ()=>[
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["k"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["sameLongExportName"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2d$namespace$2f$input$2f$second$2e$js__$5b$test$5d$__$28$ecmascript$29$__["a"]
];
__turbopack_context__.s([
"read",
0,
read
]);
}),
]);
//# sourceMappingURL=1jsg_tests_snapshot_mangle-exports_flat-hoisted-namespace_input_lazy_1jiloitq_67ff.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted-namespace/input/lazy.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport { sameLongExportName as second, a as secondShort } from './second'\n\nexport const read = () => [first, second, firstShort, secondShort]\n"],"names":["read"],"mappings":"AAAA;AACA;;;AAEO,MAAMA,OAAO,IAAM;QAAC,oOAAK;QAAE,sPAAM;QAAE,oOAAU;QAAE,qOAAW;KAAC"}}]
}
\ No newline at end of file
export const sameLongExportName = 'first'
export const a = 'first-short'
import { sameLongExportName as first, a as firstShort } from './first'
import { sameLongExportName as second, a as secondShort } from './second'
console.log(first, second, firstShort, secondShort)
import('./lazy').then(({ read }) => console.log(read()))
import { sameLongExportName as first, a as firstShort } from './first'
import { sameLongExportName as second, a as secondShort } from './second'
export const read = () => [first, second, firstShort, secondShort]
export const sameLongExportName = 'second'
export const a = 'second-short'
{
"scopeHoisting": true,
"mangleExportNames": true,
"removeUnusedImports": true,
"removeUnusedExports": true
}
(()=>{"use strict";(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0_9x_turbopack-tests_tests_snapshot_mangle-exports_flat-hoisted_input_19v7j-mslz9_y._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/first.js [test] (ecmascript)", "[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/second.js [test] (ecmascript)",
((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"_",
()=>a1,
"g",
()=>sameLongExportName1,
"k",
()=>a,
"r",
()=>sameLongExportName
]);
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/first.js [test] (ecmascript)
;
const sameLongExportName = 'first';
const a = 'first-short';
// MERGED MODULE: [project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/second.js [test] (ecmascript)
;
const sameLongExportName1 = 'second';
const a1 = 'second-short';
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/first.js [test] (ecmascript)");
;
;
console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["r"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["g"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["k"], __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["_"]);
__turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/lazy.js [test] (ecmascript, async loader)").then(({ read })=>console.log(read()));
__turbopack_context__.s([]);
}),
]);})()
//# sourceMappingURL=0_9x_turbopack-tests_tests_snapshot_mangle-exports_flat-hoisted_input_19v7j-mslz9_y._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/first.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/second.js"],"sourcesContent":["export const sameLongExportName = 'first'\nexport const a = 'first-short'\n","export const sameLongExportName = 'second'\nexport const a = 'second-short'\n"],"names":["sameLongExportName","a"],"mappings":";;;;;;;;;;;;AAAO,MAAMA,qBAAqB;AAC3B,MAAMC,IAAI;;;ACDV,MAAMD,sBAAqB;AAC3B,MAAM,KAAI"}},
{"offset": {"line": 27, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/index.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport { sameLongExportName as second, a as secondShort } from './second'\n\nconsole.log(first, second, firstShort, secondShort)\nimport('./lazy').then(({ read }) => console.log(read()))\n"],"names":["console","log","then","read"],"mappings":"AAAA;;;AAGAA,QAAQC,GAAG,CAAC,uNAAK,EAAE,uNAAM,EAAE,uNAAU,EAAE,uNAAW;AAClD,iKAAiBC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKH,QAAQC,GAAG,CAACE"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1ece_tests_snapshot_mangle-exports_flat-hoisted_input_index_14inmir1_9018.js",
{"otherChunks":["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted_input_lazy_1b7bhnb0dcbw0.js","output/0_9x_turbopack-tests_tests_snapshot_mangle-exports_flat-hoisted_input_19v7j-mslz9_y._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted_input_lazy_09grqm2tey_b9.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/lazy.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/first.js [test] (ecmascript)");
;
;
const read = ()=>[
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["r"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["g"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["k"],
__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$mangle$2d$exports$2f$flat$2d$hoisted$2f$input$2f$first$2e$js__$5b$test$5d$__$28$ecmascript$29$__["_"]
];
__turbopack_context__.s([
"read",
0,
read
]);
}),
]);
//# sourceMappingURL=1jsg_tests_snapshot_mangle-exports_flat-hoisted_input_lazy_09grqm2tey_b9.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/lazy.js"],"sourcesContent":["import { sameLongExportName as first, a as firstShort } from './first'\nimport { sameLongExportName as second, a as secondShort } from './second'\n\nexport const read = () => [first, second, firstShort, secondShort]\n"],"names":["read"],"mappings":"AAAA;;;AAGO,MAAMA,OAAO,IAAM;QAAC,uNAAK;QAAE,uNAAM;QAAE,uNAAU;QAAE,uNAAW;KAAC"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1jsg_tests_snapshot_mangle-exports_flat-hoisted_input_lazy_1b7bhnb0dcbw0.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/lazy.js [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => {
return Promise.all([
"output/1jsg_tests_snapshot_mangle-exports_flat-hoisted_input_lazy_09grqm2tey_b9.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/mangle-exports/flat-hoisted/input/lazy.js [test] (ecmascript)");
});
});
}),
]);
\ No newline at end of file
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