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

turbopack: propagate no-side-effects annotations

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 50bf604f
...@@ -36,6 +36,7 @@ use crate::{ ...@@ -36,6 +36,7 @@ use crate::{
cjs_ast::{is_global, is_module_dot_exports}, cjs_ast::{is_global, is_module_dot_exports},
graph::{AssignmentScope, AssignmentScopes, EvalContext}, graph::{AssignmentScope, AssignmentScopes, EvalContext},
is_unresolved, is_unresolved_id, is_unresolved, is_unresolved_id,
no_side_effects::{NoSideEffectsInfo, collect_no_side_effects},
}, },
magic_identifier::{MAGIC_IDENTIFIER_DEFAULT_EXPORT, MAGIC_IDENTIFIER_DEFAULT_EXPORT_ATOM}, magic_identifier::{MAGIC_IDENTIFIER_DEFAULT_EXPORT, MAGIC_IDENTIFIER_DEFAULT_EXPORT_ATOM},
module_fragments::{PartId, find_turbopack_part_id_in_asserts}, module_fragments::{PartId, find_turbopack_part_id_in_asserts},
...@@ -464,6 +465,9 @@ pub(crate) struct ImportMap { ...@@ -464,6 +465,9 @@ pub(crate) struct ImportMap {
/// Map from exported name to local binding id (includes the syntax context). /// Map from exported name to local binding id (includes the syntax context).
pub(crate) exports_ids: FxHashMap<RcStr, (Id, Span)>, pub(crate) exports_ids: FxHashMap<RcStr, (Id, Span)>,
/// SWC-compatible binding-level `NO_SIDE_EFFECTS` annotations.
no_side_effects: NoSideEffectsInfo,
/// CommonJS imports: stores the "resolved" imports (eg. `const { a } = require("m")`) /// CommonJS imports: stores the "resolved" imports (eg. `const { a } = require("m")`)
/// and the generic whole-module imports (eg. `const x = require("m")`). /// and the generic whole-module imports (eg. `const x = require("m")`).
cjs_imports: CjsImports, cjs_imports: CjsImports,
...@@ -782,26 +786,26 @@ impl ImportMap { ...@@ -782,26 +786,26 @@ impl ImportMap {
.iter() .iter()
.map(|(name, value)| { .map(|(name, value)| {
let value = match value { let value = match value {
Export::LocalBinding(local, is_fake_esm) => EsmExport::LocalBinding( Export::LocalBinding(local, is_fake_esm) => {
local.clone(), let (id, _) =
if *is_fake_esm { self.exports_ids.get(name).cloned().with_context(|| {
// it is likely that these are not always actually mutable. format!("Exported binding {name} not found in exports_ids")
Liveness::Mutable })?;
} else { let no_side_effects = self.no_side_effects.contains(&id)
eval_context.imports.get_export_ident_liveness( || (name == "default" && self.no_side_effects.default_export());
self.exports_ids EsmExport::LocalBinding(
.get(name) local.clone(),
.cloned() if *is_fake_esm {
.with_context(|| { // it is likely that these are not always actually mutable.
format!( Liveness::Mutable
"Exported binding {name} not found in exports_ids" } else {
) eval_context
})? .imports
.0, .get_export_ident_liveness(id, eval_context.unresolved_mark)
eval_context.unresolved_mark, },
) no_side_effects,
}, )
), }
Export::ImportedBinding(i, name, is_fake_esm) => { Export::ImportedBinding(i, name, is_fake_esm) => {
EsmExport::ImportedBinding( EsmExport::ImportedBinding(
ResolvedVc::upcast(import_references[*i]), ResolvedVc::upcast(import_references[*i]),
...@@ -858,7 +862,10 @@ impl ImportMap { ...@@ -858,7 +862,10 @@ impl ImportMap {
m: &Program, m: &Program,
comments: Option<&dyn Comments>, comments: Option<&dyn Comments>,
) -> Self { ) -> Self {
let mut data = ImportMap::default(); let mut data = ImportMap {
no_side_effects: collect_no_side_effects(m, comments),
..Default::default()
};
let mut analyzer = Analyzer { let mut analyzer = Analyzer {
unresolved_mark, unresolved_mark,
data: &mut data, data: &mut data,
......
...@@ -11,6 +11,7 @@ pub(crate) mod cjs_ast; ...@@ -11,6 +11,7 @@ pub(crate) mod cjs_ast;
pub mod graph; pub mod graph;
pub mod imports; pub mod imports;
pub mod linker; pub mod linker;
pub(crate) mod no_side_effects;
pub mod side_effects; pub mod side_effects;
pub mod top_level_await; pub mod top_level_await;
pub mod well_known; pub mod well_known;
......
use std::collections::HashSet;
use swc_core::{
common::{Spanned, comments::Comments},
ecma::{
ast::{
Decl, DefaultDecl, ExportDecl, ExportDefaultDecl, FnDecl, FnExpr, Id, Pat, Program,
VarDecl,
},
visit::{Visit, VisitWith, noop_visit_type},
},
};
const NO_SIDE_EFFECTS_FLAG: &str = "NO_SIDE_EFFECTS";
/// Bindings declared with an SWC-compatible `NO_SIDE_EFFECTS` annotation.
#[derive(Default, Debug)]
pub(crate) struct NoSideEffectsInfo {
bindings: HashSet<Id>,
default_export: bool,
}
impl NoSideEffectsInfo {
pub(crate) fn contains(&self, id: &Id) -> bool {
self.bindings.contains(id)
}
pub(crate) fn default_export(&self) -> bool {
self.default_export
}
}
pub(crate) fn collect_no_side_effects(
program: &Program,
comments: Option<&dyn Comments>,
) -> NoSideEffectsInfo {
let mut collector = NoSideEffectsCollector {
comments,
info: NoSideEffectsInfo::default(),
};
program.visit_with(&mut collector);
collector.info
}
struct NoSideEffectsCollector<'a> {
comments: Option<&'a dyn Comments>,
info: NoSideEffectsInfo,
}
impl NoSideEffectsCollector<'_> {
fn has_annotation(&self, span: swc_core::common::Span) -> bool {
self.comments
.is_some_and(|comments| comments.has_flag(span.lo, NO_SIDE_EFFECTS_FLAG))
}
}
impl Visit for NoSideEffectsCollector<'_> {
noop_visit_type!(fail);
fn visit_export_decl(&mut self, export: &ExportDecl) {
export.visit_children_with(self);
if let Decl::Fn(function) = &export.decl
&& self.has_annotation(function.function.span)
{
self.info.bindings.insert(function.ident.to_id());
}
}
fn visit_fn_decl(&mut self, function: &FnDecl) {
function.visit_children_with(self);
if self.has_annotation(function.function.span) {
self.info.bindings.insert(function.ident.to_id());
}
}
fn visit_fn_expr(&mut self, function: &FnExpr) {
function.visit_children_with(self);
if let Some(ident) = &function.ident
&& self.has_annotation(function.function.span)
{
self.info.bindings.insert(ident.to_id());
}
}
fn visit_export_default_decl(&mut self, export: &ExportDefaultDecl) {
export.visit_children_with(self);
if let DefaultDecl::Fn(function) = &export.decl
&& self.has_annotation(function.function.span)
{
self.info.default_export = true;
}
}
fn visit_var_decl(&mut self, declaration: &VarDecl) {
declaration.visit_children_with(self);
for declarator in &declaration.decls {
if let Pat::Ident(binding) = &declarator.name
&& let Some(initializer) = &declarator.init
&& (self.has_annotation(declaration.span)
|| self.has_annotation(declarator.span)
|| self.has_annotation(initializer.span()))
{
self.info.bindings.insert(binding.id.to_id());
}
}
}
}
...@@ -50,9 +50,12 @@ use swc_core::{ ...@@ -50,9 +50,12 @@ use swc_core::{
use turbopack_core::module::ModuleSideEffects; use turbopack_core::module::ModuleSideEffects;
use crate::{ use crate::{
analyzer::cjs_ast::{ analyzer::{
as_exports_define_property, is_cjs_export_member, is_global, is_module_dot_exports, cjs_ast::{
is_module_exports_chain, as_exports_define_property, is_cjs_export_member, is_global, is_module_dot_exports,
is_module_exports_chain,
},
no_side_effects::{NoSideEffectsInfo, collect_no_side_effects},
}, },
utils::unparen, utils::unparen,
}; };
...@@ -507,12 +510,14 @@ pub fn compute_module_evaluation_side_effects( ...@@ -507,12 +510,14 @@ pub fn compute_module_evaluation_side_effects(
let module_exports_tainted = module_exports_is_tainted(program, unresolved_mark); let module_exports_tainted = module_exports_is_tainted(program, unresolved_mark);
let module_exports_has_accessor = module_exports_has_accessor(program, unresolved_mark); let module_exports_has_accessor = module_exports_has_accessor(program, unresolved_mark);
let safe_assignment_constant_ids = collect_safe_assignment_constant_ids(program); let safe_assignment_constant_ids = collect_safe_assignment_constant_ids(program);
let no_side_effects = collect_no_side_effects(program, Some(comments));
let mut visitor = SideEffectVisitor::new( let mut visitor = SideEffectVisitor::new(
comments, comments,
unresolved_mark, unresolved_mark,
module_exports_tainted, module_exports_tainted,
module_exports_has_accessor, module_exports_has_accessor,
safe_assignment_constant_ids, safe_assignment_constant_ids,
no_side_effects,
); );
program.visit_with(&mut visitor); program.visit_with(&mut visitor);
if visitor.has_side_effects { if visitor.has_side_effects {
...@@ -536,6 +541,8 @@ struct SideEffectVisitor<'a> { ...@@ -536,6 +541,8 @@ struct SideEffectVisitor<'a> {
/// local `const` bindings initialized with a fresh object/array literal. /// local `const` bindings initialized with a fresh object/array literal.
/// Member mutations rooted at these are not module-evaluation side effects. /// Member mutations rooted at these are not module-evaluation side effects.
safe_assignment_constant_ids: HashSet<Id>, safe_assignment_constant_ids: HashSet<Id>,
/// Local bindings whose calls are covered by `NO_SIDE_EFFECTS`.
no_side_effects: NoSideEffectsInfo,
has_side_effects: bool, has_side_effects: bool,
will_invoke_fn_exprs: bool, will_invoke_fn_exprs: bool,
has_imports: bool, has_imports: bool,
...@@ -548,6 +555,7 @@ impl<'a> SideEffectVisitor<'a> { ...@@ -548,6 +555,7 @@ impl<'a> SideEffectVisitor<'a> {
module_exports_tainted: bool, module_exports_tainted: bool,
module_exports_has_accessor: bool, module_exports_has_accessor: bool,
safe_assignment_constant_ids: HashSet<Id>, safe_assignment_constant_ids: HashSet<Id>,
no_side_effects: NoSideEffectsInfo,
) -> Self { ) -> Self {
Self { Self {
comments, comments,
...@@ -555,6 +563,7 @@ impl<'a> SideEffectVisitor<'a> { ...@@ -555,6 +563,7 @@ impl<'a> SideEffectVisitor<'a> {
module_exports_tainted, module_exports_tainted,
module_exports_has_accessor, module_exports_has_accessor,
safe_assignment_constant_ids, safe_assignment_constant_ids,
no_side_effects,
has_side_effects: false, has_side_effects: false,
will_invoke_fn_exprs: false, will_invoke_fn_exprs: false,
has_imports: false, has_imports: false,
...@@ -586,6 +595,16 @@ impl<'a> SideEffectVisitor<'a> { ...@@ -586,6 +595,16 @@ impl<'a> SideEffectVisitor<'a> {
self.comments.has_flag(span.lo, "PURE") self.comments.has_flag(span.lo, "PURE")
} }
fn is_no_side_effects_callee(&self, callee: &Callee) -> bool {
let Callee::Expr(callee) = callee else {
return false;
};
let Expr::Ident(ident) = unparen(callee) else {
return false;
};
self.no_side_effects.contains(&ident.to_id())
}
/// Check if a callee expression is a known pure built-in function. /// Check if a callee expression is a known pure built-in function.
/// ///
/// This checks if the callee matches patterns like `Math.abs`, `Object.keys`, etc. /// This checks if the callee matches patterns like `Math.abs`, `Object.keys`, etc.
...@@ -1017,8 +1036,10 @@ impl<'a> Visit for SideEffectVisitor<'a> { ...@@ -1017,8 +1036,10 @@ impl<'a> Visit for SideEffectVisitor<'a> {
// Impure expressions (conservative) // Impure expressions (conservative)
Expr::Call(call) => { Expr::Call(call) => {
// Check for /*#__PURE__*/ annotation or for a well known function // A call-level PURE or binding-level NO_SIDE_EFFECTS annotation covers
let is_pure_annotated = self.is_pure_annotated(call.span); // callback invocation effects as well as the callee's own effects.
let is_pure_annotated = self.is_pure_annotated(call.span)
|| self.is_no_side_effects_callee(&call.callee);
if is_pure_annotated || self.is_known_pure_builtin(&call.callee) { if is_pure_annotated || self.is_known_pure_builtin(&call.callee) {
// For known pure builtins, we need to check both: // For known pure builtins, we need to check both:
// 1. The receiver (e.g., the array in [foo(), 2, 3].map(...)) // 1. The receiver (e.g., the array in [foo(), 2, 3].map(...))
...@@ -1569,6 +1590,38 @@ mod tests { ...@@ -1569,6 +1590,38 @@ mod tests {
no_side_effects!(test_pure_annotation_constructor, "/*#__PURE__*/ new Foo();"); no_side_effects!(test_pure_annotation_constructor, "/*#__PURE__*/ new Foo();");
no_side_effects!(
test_no_side_effects_annotation_variable,
"const fn = /*#__NO_SIDE_EFFECTS__*/ other; fn();"
);
no_side_effects!(
test_no_side_effects_annotation_function,
"/*@__NO_SIDE_EFFECTS__*/ function fn() {} fn();"
);
no_side_effects!(
test_no_side_effects_annotation_variable_declaration,
"/*#__NO_SIDE_EFFECTS__*/ const fn = other; fn();"
);
side_effects!(
test_no_side_effects_annotation_ignores_destructuring,
"const { fn } = /*#__NO_SIDE_EFFECTS__*/ other; fn();"
);
side_effects!(
test_no_side_effects_annotation_still_checks_arguments,
"const fn = /*#__NO_SIDE_EFFECTS__*/ other; fn(sideEffect());"
);
side_effects!(
test_no_side_effects_annotation_does_not_purify_initializer,
"const fn = /*#__NO_SIDE_EFFECTS__*/ getFn();"
);
side_effects!(test_unannotated_binding_call, "const fn = other; fn();");
no_side_effects!( no_side_effects!(
test_pure_annotation_in_variable, test_pure_annotation_in_variable,
"const x = /*#__PURE__*/ foo();" "const x = /*#__PURE__*/ foo();"
......
...@@ -175,7 +175,7 @@ impl EcmascriptChunkPlaceable for EcmascriptCollectModuleWithChunkGroup { ...@@ -175,7 +175,7 @@ impl EcmascriptChunkPlaceable for EcmascriptCollectModuleWithChunkGroup {
EsmExports { EsmExports {
exports: [( exports: [(
COLLECT_LIST_EXPORT, COLLECT_LIST_EXPORT,
EsmExport::LocalBinding(COLLECT_LIST_EXPORT, Liveness::Constant), EsmExport::LocalBinding(COLLECT_LIST_EXPORT, Liveness::Constant, false),
)] )]
.into(), .into(),
star_exports: vec![], star_exports: vec![],
......
...@@ -2027,7 +2027,7 @@ async fn process_parse_result( ...@@ -2027,7 +2027,7 @@ async fn process_parse_result(
.await? .await?
.exports .exports
.iter() .iter()
.filter(|(_, e)| matches!(e, export::EsmExport::LocalBinding(_, _))) .filter(|(_, e)| matches!(e, export::EsmExport::LocalBinding(..)))
.map(|(name, e)| { .map(|(name, e)| {
if let Some(((sym, ctxt), _)) = export_contexts.get(name) { if let Some(((sym, ctxt), _)) = export_contexts.get(name) {
Ok((sym.clone(), *ctxt)) Ok((sym.clone(), *ctxt))
......
...@@ -232,7 +232,7 @@ impl ReferencedAsset { ...@@ -232,7 +232,7 @@ impl ReferencedAsset {
let exports = exports.expand_exports(ModuleExportUsageInfo::all()).await?; let exports = exports.expand_exports(ModuleExportUsageInfo::all()).await?;
let esm_export = exports.exports.get(export); let esm_export = exports.exports.get(export);
match esm_export { match esm_export {
Some(EsmExport::LocalBinding(_name, liveness)) => { Some(EsmExport::LocalBinding(_name, liveness, _)) => {
// A local binding in a module that is merged in the same group. Use the // A local binding in a module that is merged in the same group. Use the
// export name as identifier, it will be replaced with the actual // export name as identifier, it will be replaced with the actual
// variable name during AST merging. // variable name during AST merging.
......
...@@ -63,8 +63,8 @@ pub enum Liveness { ...@@ -63,8 +63,8 @@ pub enum Liveness {
pub enum EsmExport { pub enum EsmExport {
/// A local binding that is exported (export { a } or export const a = 1) /// A local binding that is exported (export { a } or export const a = 1)
/// ///
/// Fields: (local_name, liveness) /// Fields: (local_name, liveness, no_side_effects)
LocalBinding(RcStr, Liveness), LocalBinding(RcStr, Liveness, bool),
/// An imported binding that is exported (export { a as b } from "...") /// An imported binding that is exported (export { a as b } from "...")
/// ///
/// Fields: (module_reference, name, is_mutable) /// Fields: (module_reference, name, is_mutable)
...@@ -130,6 +130,66 @@ pub async fn is_export_missing( ...@@ -130,6 +130,66 @@ pub async fn is_export_missing(
Ok(Vc::cell(true)) Ok(Vc::cell(true))
} }
/// Returns whether a statically resolved ESM export is backed by a binding annotated with
/// `NO_SIDE_EFFECTS`. Imported bindings and statically expandable star exports are followed to the
/// local binding that defines the contract.
#[turbo_tasks::function]
pub async fn is_export_no_side_effects(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
export_name: RcStr,
) -> Result<Vc<bool>> {
let mut module = module;
let mut export_name = export_name;
let mut visited = FxHashSet::default();
loop {
if !visited.insert((module, export_name.clone())) {
return Ok(Vc::cell(false));
}
let exports = module.get_exports().await?;
let EcmascriptExports::EsmExports(exports) = &*exports else {
return Ok(Vc::cell(false));
};
let exports_vc = *exports;
let exports = exports_vc.await?;
let export = if let Some(export) = exports.exports.get(&export_name) {
export.clone()
} else {
let expanded = exports_vc
.expand_exports(ModuleExportUsageInfo::all())
.await?;
// A dynamic star exporter may provide the same name at runtime, so do not infer a
// binding-level contract from a different, statically known star exporter.
if !expanded.dynamic_exports.is_empty() {
return Ok(Vc::cell(false));
}
let Some(export) = expanded.exports.get(&export_name) else {
return Ok(Vc::cell(false));
};
export.clone()
};
match &export {
EsmExport::LocalBinding(_, _, no_side_effects) => {
return Ok(Vc::cell(*no_side_effects));
}
EsmExport::ImportedBinding(reference, imported_name, _) => {
let ReferencedAsset::Some(imported_module) =
ReferencedAsset::from_resolve_result(reference.resolve_reference()).await?
else {
return Ok(Vc::cell(false));
};
module = imported_module;
export_name = imported_name.clone();
}
EsmExport::ImportedNamespace(_) | EsmExport::Error => {
return Ok(Vc::cell(false));
}
}
}
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn all_known_export_names( pub async fn all_known_export_names(
module: Vc<Box<dyn EcmascriptChunkPlaceable>>, module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
...@@ -440,7 +500,7 @@ pub async fn expand_star_exports( ...@@ -440,7 +500,7 @@ pub async fn expand_star_exports(
} }
if let Entry::Vacant(entry) = esm_exports.entry(key.clone()) { if let Entry::Vacant(entry) = esm_exports.entry(key.clone()) {
entry.insert(match esm_export { entry.insert(match esm_export {
EsmExport::LocalBinding(_, liveness) => EsmExport::ImportedBinding( EsmExport::LocalBinding(_, liveness, _) => EsmExport::ImportedBinding(
reference, reference,
key.clone(), key.clone(),
*liveness == Liveness::Mutable, *liveness == Liveness::Mutable,
...@@ -1112,7 +1172,7 @@ impl EsmExports { ...@@ -1112,7 +1172,7 @@ impl EsmExports {
EsmExport::Error => ExportBinding::Getter(quote!( EsmExport::Error => ExportBinding::Getter(quote!(
"(() => { throw new Error(\"Failed binding. See build errors!\"); })" as Expr, "(() => { throw new Error(\"Failed binding. See build errors!\"); })" as Expr,
)), )),
EsmExport::LocalBinding(name, liveness) => { EsmExport::LocalBinding(name, liveness, _) => {
// TODO ideally, this information would just be stored in // TODO ideally, this information would just be stored in
// EsmExport::LocalBinding and we wouldn't have to re-correlated this // EsmExport::LocalBinding and we wouldn't have to re-correlated this
// information with eval_context.imports.exports to get the syntax context. // information with eval_context.imports.exports to get the syntax context.
......
...@@ -232,7 +232,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { ...@@ -232,7 +232,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
for (name, export) in &esm_exports.exports { for (name, export) in &esm_exports.exports {
let name = name.clone(); let name = name.clone();
match export { match export {
EsmExport::LocalBinding(_, liveness) => { EsmExport::LocalBinding(_, liveness, _) => {
exports.push(( exports.push((
name.clone(), name.clone(),
EsmExport::ImportedBinding( EsmExport::ImportedBinding(
......
...@@ -170,10 +170,10 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule { ...@@ -170,10 +170,10 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
EsmExport::ImportedBinding(..) | EsmExport::ImportedNamespace(..) => { EsmExport::ImportedBinding(..) | EsmExport::ImportedNamespace(..) => {
// not included in locals module // not included in locals module
} }
EsmExport::LocalBinding(local_name, liveness) => { EsmExport::LocalBinding(local_name, liveness, no_side_effects) => {
exports.push(( exports.push((
name.clone(), name.clone(),
EsmExport::LocalBinding(local_name.clone(), *liveness), EsmExport::LocalBinding(local_name.clone(), *liveness, *no_side_effects),
)); ));
} }
EsmExport::Error => { EsmExport::Error => {
......
import annotatedDefault, {
annotated,
annotatedDeclaration,
exportedLater,
getState,
unannotated,
} from './library'
import { reexported } from './reexport'
import { annotated as starReexported } from './star'
let state = 0 let state = 0
const unused = /*@__PURE__*/ (() => { const unused = /*@__PURE__*/ (() => {
state++ state++
})() })()
annotated()
annotatedDeclaration()
annotatedDefault()
exportedLater()
reexported()
starReexported()
const alias = annotated
alias()
let argumentState = 0
annotated(argumentState++)
unannotated()
it('should remove unused PURE statements', () => { it('should remove unused PURE statements', () => {
expect(state).toBe(0) expect(state).toBe(0)
}) })
it('should propagate NO_SIDE_EFFECTS across imports and reexports', () => {
expect(getState()).toBe(1)
expect(argumentState).toBe(1)
})
let state = 0
export const annotated = /*#__NO_SIDE_EFFECTS__*/ function () {
state++
}
const exportedLater = /*@__NO_SIDE_EFFECTS__*/ function () {
state++
}
export { exportedLater }
export default /*#__NO_SIDE_EFFECTS__*/ function () {
state++
}
export /*#__NO_SIDE_EFFECTS__*/ function annotatedDeclaration() {
state++
}
export function unannotated() {
state++
}
export function getState() {
return state
}
import { annotated, unannotated } from './library'
annotated()
const alias = annotated
alias()
unannotated()
export const annotated = /*#__NO_SIDE_EFFECTS__*/ function () {}
export function unannotated() {}
(()=>{"use strict";(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0_9x_turbopack-tests_tests_snapshot_basic_no-side-effects-import_input_0j6sxdtyjbhtp._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/no-side-effects-import/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$no$2d$side$2d$effects$2d$import$2f$input$2f$library$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/no-side-effects-import/input/library.js [test] (ecmascript)");
;
/*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$no$2d$side$2d$effects$2d$import$2f$input$2f$library$2e$js__$5b$test$5d$__$28$ecmascript$29$__["annotated"])();
const alias = /*#__NO_SIDE_EFFECTS__*/ __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$no$2d$side$2d$effects$2d$import$2f$input$2f$library$2e$js__$5b$test$5d$__$28$ecmascript$29$__["annotated"];
alias();
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$no$2d$side$2d$effects$2d$import$2f$input$2f$library$2e$js__$5b$test$5d$__$28$ecmascript$29$__["unannotated"])();
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/no-side-effects-import/input/library.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"annotated",
()=>annotated,
"unannotated",
()=>unannotated
]);
const annotated = /*#__NO_SIDE_EFFECTS__*/ function() {};
function unannotated() {}
}),
]);})()
//# sourceMappingURL=0_9x_turbopack-tests_tests_snapshot_basic_no-side-effects-import_input_0j6sxdtyjbhtp._.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/basic/no-side-effects-import/input/index.js"],"sourcesContent":["import { annotated, unannotated } from './library'\n\nannotated()\n\nconst alias = annotated\nalias()\n\nunannotated()\n"],"names":["alias"],"mappings":";AAAA;;cAEA,IAAA,qOAAS;AAET,MAAMA,iCAAQ,qOAAS;AACvBA;AAEA,IAAA,uOAAW"}},
{"offset": {"line": 15, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/no-side-effects-import/input/library.js"],"sourcesContent":["export const annotated = /*#__NO_SIDE_EFFECTS__*/ function () {}\nexport function unannotated() {}\n"],"names":["annotated","unannotated"],"mappings":";;;;;;AAAO,MAAMA,YAAY,sBAAsB,GAAG,YAAa;AACxD,SAASC,eAAe"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1ece_tests_snapshot_basic_no-side-effects-import_input_index_0gwnf7iwk9s7n.js",
{"otherChunks":["output/0_9x_turbopack-tests_tests_snapshot_basic_no-side-effects-import_input_0j6sxdtyjbhtp._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/no-side-effects-import/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ 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