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

test(turbopack): compare CommonJS tree shaking with webpack

Co-authored-by: 's avatarJimmy Miller <6071338+jimmyhmiller@users.noreply.github.com>
parent 6cfca45f
......@@ -178,6 +178,8 @@ pub async fn compute_binding_usage_info(
return Ok(GraphTraversalAction::Continue);
};
let mut effective_export_usage = ref_data.binding_usage.export.clone();
if remove_unused_imports {
// If this is an evaluation reference and the target has no side effects
// then we can drop it. NOTE: many `imports` create parallel Evaluation
......@@ -203,14 +205,24 @@ pub async fn compute_binding_usage_info(
}
// If the current edge is an unused import, skip it
match &ref_data.binding_usage.import {
ImportUsage::Exports(exports) => {
ImportUsage::Exports(exports)
| ImportUsage::ExportsWithEvaluation(exports) => {
let source_used_exports = used_exports
.get(&parent)
.context("parent module must have usage info")?;
if exports
let owning_exports_unused = exports
.iter()
.all(|e| !source_used_exports.is_export_used(e))
{
.all(|e| !source_used_exports.is_export_used(e));
let evaluation_can_be_dropped =
matches!(&ref_data.binding_usage.import, ImportUsage::Exports(_))
|| side_effect_free_modules
.as_ref()
.expect(
"this must be present if `remove_unused_imports` is \
true",
)
.contains(&target);
if owning_exports_unused && evaluation_can_be_dropped {
// all exports are unused
#[cfg(debug_assertions)]
debug_unused_references_name.insert((
......@@ -226,6 +238,14 @@ pub async fn compute_binding_usage_info(
return Ok(GraphTraversalAction::Skip);
} else {
if owning_exports_unused
&& matches!(
&ref_data.binding_usage.import,
ImportUsage::ExportsWithEvaluation(_)
)
{
effective_export_usage = ExportUsage::Evaluation;
}
#[cfg(debug_assertions)]
debug_unused_references_name.remove(&(
parent,
......@@ -266,7 +286,7 @@ pub async fn compute_binding_usage_info(
}
let is_first_visit = !used_exports.contains_key(&target);
let changed = match &ref_data.binding_usage.export {
let changed = match &effective_export_usage {
ExportUsage::Passthrough {
namespace_object_may_escape,
} => {
......
......@@ -162,6 +162,13 @@ pub enum ImportUsage {
/// (This is only ever set on `ModulePart::Export` references. Side effects are handled via
/// `ModulePart::Evaluation` references, which always have `ImportUsage::TopLevel`.)
Exports(FrozenSet<RcStr>),
/// This import is used only by these exports, but the same reference also performs module
/// evaluation. It can only be removed when all owning exports are unused *and* the target is
/// declared side-effect-free.
///
/// CommonJS direct-property re-exports use this because a single `require()` both reads the
/// forwarded value and evaluates the dependency.
ExportsWithEvaluation(FrozenSet<RcStr>),
}
/// Defines what parts of a module are used by another module
......
......@@ -4,7 +4,7 @@ use swc_core::{
common::BytePos,
ecma::{ast::*, visit::VisitWithAstPath},
};
use turbopack_core::resolve::ExportUsage;
use turbopack_core::resolve::{ExportUsage, ImportUsage};
pub use crate::analyzer::graph::{
effects::{
......@@ -41,6 +41,9 @@ pub struct VarGraph<'a> {
/// calls fall back to `ExportUsage::All`.
pub require_usage: FxHashMap<BytePos, ExportUsage>,
/// [`ImportUsage`] per `require("…")` call when its evaluation is owned by named exports.
pub require_import_usage: FxHashMap<BytePos, ImportUsage>,
/// Present when the module is a statically-analyzable CommonJS module (no
/// dynamic exports); carries its named exports for scope hoisting.
pub cjs_static_exports: Option<CjsStaticExports>,
......@@ -76,6 +79,7 @@ pub fn create_graph<'a>(
effects: Default::default(),
code_gens: Default::default(),
require_usage: Default::default(),
require_import_usage: Default::default(),
cjs_static_exports: Default::default(),
},
eval_context,
......
......@@ -115,6 +115,9 @@ struct CjsExportsCollector {
has_top_level_return: bool,
/// Whether any export is defined with `Object.defineProperty`.
has_define_property_export: bool,
/// Whether an export write is nested in top-level control flow. Such writes are droppable,
/// but aren't unconditional bindings that can participate in scope hoisting.
has_conditional_export: bool,
}
/// The removable writes, the always-removable ones, and whether the `__esModule`
......@@ -585,6 +588,7 @@ mod analyzer_state {
pub(in crate::analyzer::graph) fn enable_require_usage(&mut self, imports: &ImportMap) {
let cjs_imports = imports.cjs_imports();
self.data.require_usage = cjs_imports.resolved.clone();
self.data.require_import_usage = cjs_imports.import_usage.clone();
// Seed each namespace binding as `Evaluation`; a binding that's never
// read keeps that (only the target's side effects matter), while a
// member read upgrades it to `PartialNamespaceObject` below.
......@@ -705,6 +709,12 @@ mod analyzer_state {
}
}
pub(super) fn set_cjs_has_conditional_export(&mut self) {
if let Some(c) = &mut self.state.cjs_exports {
c.has_conditional_export = true;
}
}
pub(super) fn record_cjs_export(&mut self, name: RcStr, path: AstPath) {
self.push_cjs_export(DroppableCjsExportAssignment::Write { name, path });
}
......@@ -743,9 +753,10 @@ mod analyzer_state {
// A top-level `return` skips the writes after it, and would abandon the rest
// of a merged factory. An `Object.defineProperty` export keeps its value in
// the descriptor, which the merge has no local to bind it to.
let static_exports =
(!c.has_top_level_return && !c.has_define_property_export).then(|| {
CjsStaticExports {
let static_exports = (!c.has_top_level_return
&& !c.has_define_property_export
&& !c.has_conditional_export)
.then(|| CjsStaticExports {
export_names: c
.writes
.iter()
......@@ -760,7 +771,6 @@ mod analyzer_state {
.cloned()
.collect(),
has_es_module: c.has_es_module,
}
});
// Dropping an unused write stays sound regardless of the `return`, but
// `__esModule` may be set after it, so it can't be claimed.
......@@ -780,7 +790,7 @@ mod analyzer_state {
let AssignTarget::Simple(SimpleAssignTarget::Member(member)) = target else {
return false;
};
if !matches!(member.prop, MemberProp::Ident(_)) {
if extract_name_from_member_prop(&member.prop).is_none() {
return false;
}
is_exports_object(&member.obj, self.eval_context.unresolved_mark)
......@@ -1467,25 +1477,32 @@ impl<'a> Analyzer<'a, '_> {
if n.op != AssignOp::Assign {
return;
}
// Only top-level writes can be dropped.
if self.is_in_fn() || self.is_in_nested_block_scope() {
// Writes inside functions run after module evaluation and can mutate the export
// namespace at arbitrary times. Top-level control-flow blocks are safe to track:
// dropping an unused assignment keeps both the branch and its RHS effects intact.
if self.is_in_fn() {
self.taint_cjs_exports();
return;
}
if self.is_in_nested_block_scope() {
self.set_cjs_has_conditional_export();
}
let AssignTarget::Simple(SimpleAssignTarget::Member(member)) = &n.left else {
return;
};
// After a replacement only `module.exports` still reaches the exports object.
let dead = self.cjs_exports_object_replaced()
&& !is_module_exports_chain(&member.obj, self.eval_context.unresolved_mark);
let MemberProp::Ident(name) = &member.prop else {
let Some(name) =
extract_name_from_member_prop(&member.prop).and_then(|names| names.into_iter().next())
else {
return;
};
// Transpilers use this to signal that this is transpiled esm.
// Which in turn changes the behavior of default exports. such that `import foo from
// 'transpiled-esm-cjs'` gets the `default` export instead of the namespace
if !dead && name.sym.as_ref() == "__esModule" {
if !dead && &*name == "__esModule" {
// Only a literal `true` is the interop marker.
if matches!(unparen(&n.right), Expr::Lit(Lit::Bool(b)) if b.value) {
self.set_cjs_has_es_module();
......@@ -1494,7 +1511,6 @@ impl<'a> Analyzer<'a, '_> {
}
// The RHS isn't inspected; the code-gen keeps it as `<value>`.
let name = RcStr::from(name.sym.as_str());
let path = as_parent_path(ast_path).into();
if dead {
self.record_dead_cjs_write(name, path);
......
......@@ -32,7 +32,7 @@ use crate::{
SpecifiedModuleType,
analyzer::{
Bump, ConstantString, ConstantValue, ObjectPart,
cjs_ast::{is_global, is_module_dot_exports},
cjs_ast::{is_exports_object, is_global, is_module_dot_exports},
graph::{AssignmentScope, AssignmentScopes, EvalContext},
is_unresolved, is_unresolved_id,
},
......@@ -370,7 +370,7 @@ impl ProgramDeclUsage {
// Fold re-exports (`export { x } from "foo"`) into `import_usage` for tree-shaking.
for (reference, names) in &self.named_reexports {
let usage = match import_usage.get(reference) {
Some(ImportUsage::TopLevel) => continue,
Some(ImportUsage::TopLevel | ImportUsage::ExportsWithEvaluation(_)) => continue,
// Used locally and re-exported, e.g.
// `import {foo} from 'm'; export function w(){foo()} export {foo} from 'm'`
// → union: Exports({"w"}) ∪ {"foo"}.
......@@ -472,6 +472,9 @@ pub(crate) struct CjsImports {
/// `const x = require("m")`
pub(crate) bindings: FxHashMap<Id, BytePos>,
/// A direct-property `require()` whose value is owned by named CommonJS exports.
pub(crate) import_usage: FxHashMap<BytePos, ImportUsage>,
}
/// Represents a collection of [webpack-style "magic comments"][magic] that override import
......@@ -1536,7 +1539,8 @@ impl Visit for Analyzer<'_> {
fn visit_assign_expr(&mut self, node: &AssignExpr) {
if node.op == AssignOp::Assign
&& let AssignTarget::Simple(SimpleAssignTarget::Member(target)) = &node.left
&& is_module_dot_exports(target, self.unresolved_mark)
{
if is_module_dot_exports(target, self.unresolved_mark)
&& let Some(call) = as_require_call(&node.right, self.unresolved_mark)
{
self.data.cjs_imports.resolved.insert(
......@@ -1545,6 +1549,23 @@ impl Visit for Analyzer<'_> {
namespace_object_may_escape: true,
},
);
} else if is_exports_object(&target.obj, self.unresolved_mark)
&& let Some(exported) = extract_name_from_member_prop(&target.prop)
.and_then(|names| names.into_iter().next())
&& let Expr::Member(source) = unparen(&node.right)
&& let Some(call) = as_require_call(&source.obj, self.unresolved_mark)
&& let Some(imported) = extract_name_from_member_prop(&source.prop)
.and_then(|names| names.into_iter().next())
{
self.data
.cjs_imports
.resolved
.insert(call.span.lo, ExportUsage::Named(imported));
self.data.cjs_imports.import_usage.insert(
call.span.lo,
ImportUsage::ExportsWithEvaluation([exported].into_iter().collect()),
);
}
}
node.visit_children_with(self);
}
......
......@@ -105,6 +105,7 @@ pub struct CjsRequireAssetReference {
chunking_type_attribute: Option<SpecifiedChunkingType>,
resolve_override: Option<ResolvedVc<Box<dyn Module>>>,
usage: ExportUsage,
import_usage: ImportUsage,
cjs_tree_shaking: bool,
}
......@@ -117,6 +118,7 @@ impl CjsRequireAssetReference {
chunking_type_attribute: Option<SpecifiedChunkingType>,
resolve_override: Option<ResolvedVc<Box<dyn Module>>>,
usage: ExportUsage,
import_usage: ImportUsage,
cjs_tree_shaking: bool,
) -> Self {
CjsRequireAssetReference {
......@@ -127,6 +129,7 @@ impl CjsRequireAssetReference {
chunking_type_attribute,
resolve_override,
usage,
import_usage,
cjs_tree_shaking,
}
}
......@@ -163,7 +166,7 @@ impl ModuleReference for CjsRequireAssetReference {
fn binding_usage(&self) -> BindingUsage {
BindingUsage {
import: ImportUsage::TopLevel,
import: self.import_usage.clone(),
export: self.usage.clone(),
}
}
......
......@@ -863,6 +863,7 @@ async fn analyze_ecmascript_module_internal(
let effects = take(&mut var_graph.effects);
// How each `require("…")` call's result is used, keyed by call position.
let require_binding_usage = take(&mut var_graph.require_usage);
let require_import_usage = take(&mut var_graph.require_import_usage);
// The module's static CommonJS exports, if any, for scope hoisting.
analysis.cjs_static_exports = take(&mut var_graph.cjs_static_exports);
let compile_time_info_ref = compile_time_info.await?;
......@@ -1111,6 +1112,10 @@ async fn analyze_ecmascript_module_internal(
.get(&span.lo)
.cloned()
.unwrap_or(ExportUsage::All);
let call_import_usage = require_import_usage
.get(&span.lo)
.cloned()
.unwrap_or(ImportUsage::TopLevel);
let args = process_effect_args(args, &mut queue_stack);
handle_call(
......@@ -1124,6 +1129,7 @@ async fn analyze_ecmascript_module_internal(
new,
eval_context.imports.get_attributes(span),
call_usage,
call_import_usage,
)
.await?;
}
......@@ -1224,6 +1230,7 @@ async fn analyze_ecmascript_module_internal(
// A member call (`obj.method(...)`) result isn't narrowed
// for require export usage.
ExportUsage::All,
ImportUsage::TopLevel,
)
.await?;
}
......@@ -1686,6 +1693,7 @@ async fn handle_call<'a>(
new: bool,
attributes: &ImportAttributes,
call_usage: ExportUsage,
call_import_usage: ImportUsage,
) -> Result<()> {
let &AnalysisState {
handler,
......@@ -1746,6 +1754,7 @@ async fn handle_call<'a>(
tracing_only,
attributes,
call_usage.clone(),
call_import_usage.clone(),
)
.await?;
}
......@@ -1773,6 +1782,7 @@ async fn handle_call<'a>(
tracing_only,
attributes,
call_usage,
call_import_usage,
)
.await?;
}
......@@ -1964,6 +1974,7 @@ async fn handle_well_known_function_call<'a, 'l, F, Fut>(
tracing_only: bool,
attributes: &ImportAttributes,
call_usage: ExportUsage,
call_import_usage: ImportUsage,
) -> Result<()>
where
'a: 'l,
......@@ -2290,6 +2301,7 @@ where
attributes.chunking_type,
resolve_override,
call_usage.clone(),
call_import_usage.clone(),
state.cjs_tree_shaking,
),
ast_path.to_vec().into(),
......@@ -2347,6 +2359,7 @@ where
attributes.chunking_type,
None,
call_usage.clone(),
call_import_usage.clone(),
state.cjs_tree_shaking,
),
ast_path.to_vec().into(),
......
import assert from 'node:assert/strict'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
import { createRequire } from 'node:module'
const [fixtureArg, repoRootArg] = process.argv.slice(2)
if (!fixtureArg || !repoRootArg) {
throw new Error('usage: node cjs-webpack-parity.mjs <fixture> <repo-root>')
}
const fixture = path.resolve(fixtureArg)
const repoRoot = path.resolve(repoRootArg)
const input = path.join(fixture, 'input')
const turbopackOutput = path.join(fixture, 'output')
const expectedPath = path.join(fixture, 'differential.json')
const update = process.env.UPDATE === '1'
const requireFromRoot = createRequire(path.join(repoRoot, 'package.json'))
const webpackPath = requireFromRoot.resolve('webpack')
const webpack = requireFromRoot(webpackPath)
const webpackVersion = requireFromRoot('webpack/package.json').version
assert.equal(webpackVersion, '5.98.0', 'unexpected root-pinned webpack version')
const cases = {
direct: {
modules: ['direct.js'],
sentinels: ['USED_DIRECT_EXPORT', 'UNUSED_DIRECT_EXPORT'],
},
objectLiteral: {
modules: ['object-literal.js'],
sentinels: ['USED_OBJECT_LITERAL', 'UNUSED_OBJECT_LITERAL'],
},
defineProperty: {
modules: ['define-property.js'],
sentinels: ['USED_DEFINE_PROPERTY', 'UNUSED_DEFINE_PROPERTY'],
},
computed: {
modules: ['computed.js'],
sentinels: ['USED_COMPUTED_KEY', 'UNUSED_COMPUTED_KEY'],
},
dynamicComputed: {
modules: ['dynamic-computed.js'],
sentinels: [
'USED_DYNAMIC_COMPUTED',
'USED_DYNAMIC_FIXED',
'UNUSED_DYNAMIC_CONSERVATIVE',
],
},
conditional: {
modules: ['conditional.js'],
sentinels: [
'USED_CONDITIONAL_THEN',
'USED_CONDITIONAL_ELSE',
'UNUSED_CONDITIONAL_THEN',
'UNUSED_CONDITIONAL_ELSE',
'conditional:condition',
'conditional:unused-rhs-then',
'conditional:unused-rhs-else',
],
},
wholeReexport: {
modules: ['whole-reexport.js', 'whole-reexport-leaf.js'],
sentinels: ['USED_WHOLE_REEXPORT_LEAF', 'UNUSED_WHOLE_REEXPORT_LEAF'],
},
directProperty: {
modules: [
'direct-property-reexport.js',
'direct-property-used-leaf.js',
'direct-property-unused-leaf.js',
'direct-property-side-effect-leaf.js',
],
sentinels: [
'USED_DIRECT_PROPERTY_REEXPORT_LEAF',
'UNUSED_DIRECT_PROPERTY_REEXPORT_LEAF',
'UNUSED_SIDE_EFFECT_EXPORT_VALUE',
'direct-property:side-effect-leaf',
],
},
cycle: {
modules: ['cycle-a.js', 'cycle-b.js'],
sentinels: [
'USED_CYCLE_A_BEFORE',
'USED_CYCLE_A_AFTER',
'USED_CYCLE_B_VALUE',
],
},
}
function allJavaScript(directory) {
return fs
.readdirSync(directory, { recursive: true, withFileTypes: true })
.filter((entry) => entry.isFile() && entry.name.endsWith('.js'))
.map((entry) =>
fs.readFileSync(path.join(entry.parentPath, entry.name), 'utf8')
)
.join('\n')
}
function execute(entry) {
const result = spawnSync(process.execPath, [entry], {
cwd: path.dirname(entry),
encoding: 'utf8',
})
if (result.status !== 0) {
throw new Error(
`bundle execution failed (${entry})\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`
)
}
const line = result.stdout
.split(/\r?\n/)
.find((candidate) => candidate.startsWith('CJS_PARITY_RESULT='))
if (!line) {
throw new Error(
`bundle emitted no CJS_PARITY_RESULT line:\n${result.stdout}`
)
}
return JSON.parse(line.slice('CJS_PARITY_RESULT='.length))
}
function manifest(bundle) {
return Object.fromEntries(
Object.entries(cases).map(([name, definition]) => [
name,
{
modules: Object.fromEntries(
definition.modules.map((module) => [
module,
bundle.includes(`/${module}`) || bundle.includes(`./${module}`),
])
),
sentinels: Object.fromEntries(
definition.sentinels.map((sentinel) => [
sentinel,
bundle.includes(sentinel),
])
),
},
])
)
}
function flatten(value, prefix = '') {
return Object.entries(value).flatMap(([key, child]) => {
const field = prefix ? `${prefix}.${key}` : key
return child && typeof child === 'object'
? flatten(child, field)
: [[field, child]]
})
}
function differences(turbopack, webpackManifest) {
const webpackFields = new Map(flatten(webpackManifest))
return flatten(turbopack)
.filter(([field, value]) => webpackFields.get(field) !== value)
.map(([field, turbopackValue]) => ({
field,
turbopack: turbopackValue,
webpack: webpackFields.get(field),
}))
}
function webpackBuild(outputPath) {
return new Promise((resolve, reject) => {
webpack(
{
mode: 'production',
target: 'node',
context: input,
entry: './index.js',
devtool: false,
output: {
path: outputPath,
filename: 'index.js',
},
module: {
rules: [
{
// Match the Turbopack-only `use turbopack: no side effects` directive in the
// shared leaf without changing the canonical input for either bundler.
test: /direct-property-unused-leaf\.js$/,
sideEffects: false,
},
],
},
optimization: {
usedExports: true,
minimize: true,
// Stable path-based IDs let the retention manifest observe module presence in the
// emitted JavaScript without relying on webpack stats or hashed numeric IDs.
moduleIds: 'named',
// Keep each CommonJS producer visible as its own module; concatenation would erase
// module boundaries and make a module-presence comparison meaningless.
concatenateModules: false,
},
},
(error, stats) => {
if (error) return reject(error)
if (stats.hasErrors()) {
return reject(new Error(stats.toString({ all: false, errors: true })))
}
resolve()
}
)
})
}
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'cjs-webpack-parity-'))
try {
await webpackBuild(temp)
const runtime = {
turbopack: execute(path.join(turbopackOutput, 'index.entry.js')),
webpack: execute(path.join(temp, 'index.js')),
}
const retention = {
turbopack: manifest(allJavaScript(turbopackOutput)),
webpack: manifest(allJavaScript(temp)),
}
const actualDifferences = differences(retention.turbopack, retention.webpack)
if (update || !fs.existsSync(expectedPath)) {
const previous = fs.existsSync(expectedPath)
? JSON.parse(fs.readFileSync(expectedPath, 'utf8'))
: { classifications: [] }
const previousClassifications = new Map(
previous.classifications.map((item) => [
JSON.stringify([item.field, item.turbopack, item.webpack]),
item,
])
)
const classifications = actualDifferences.map((difference) => {
const previousItem = previousClassifications.get(
JSON.stringify([
difference.field,
difference.turbopack,
difference.webpack,
])
)
return {
...difference,
classification: previousItem?.classification ?? 'REVIEW_REQUIRED',
reason: previousItem?.reason ?? 'REVIEW_REQUIRED',
}
})
fs.writeFileSync(
expectedPath,
`${JSON.stringify(
{
webpackVersion,
runtime: runtime.turbopack,
retention,
classifications,
},
null,
2
)}\n`
)
if (!update) {
throw new Error(`missing ${expectedPath}; generated a review draft`)
}
console.log(`updated ${expectedPath}`)
} else {
const expected = JSON.parse(fs.readFileSync(expectedPath, 'utf8'))
assert.deepEqual(runtime.turbopack, runtime.webpack, 'runtime differential')
assert.deepEqual(runtime.turbopack, expected.runtime, 'runtime oracle')
assert.deepEqual(retention, expected.retention, 'retention oracle')
assert.deepEqual(
actualDifferences,
expected.classifications.map(
({ classification, reason, ...difference }) => difference
),
'unclassified retention difference'
)
for (const item of expected.classifications) {
assert.match(
item.classification,
/^(turbopack-gap|turbopack-improvement|intentional-divergence)$/,
`invalid classification for ${item.field}`
)
assert.ok(item.reason && item.reason !== 'REVIEW_REQUIRED')
}
console.log(
`CJS webpack parity passed (webpack ${webpackVersion}, ${actualDifferences.length} classified retention differences)`
)
}
} finally {
fs.rmSync(temp, { recursive: true, force: true })
}
globalThis.CJS_PARITY_TRACE = []
globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS = 0
const {
used: direct,
} = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/direct.js')
const objectLiteral =
require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/object-literal.js').used
const defineProperty =
require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/define-property.js').used
const computed =
require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/computed.js').used
const dynamicComputed = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/dynamic-computed.js')
const conditional =
require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/conditional.js').used
const wholeReexport = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js')
const wholeReexportLeaf = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js')
const directProperty =
require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-reexport.js').used
const cycle = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-a.js')
const cycleB = require('../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-b.js')
it('matches the CommonJS parity runtime oracle', () => {
expect({
values: {
direct,
objectLiteral,
defineProperty,
computed,
dynamicComputed: dynamicComputed.dynamic,
dynamicFixed: dynamicComputed.fixed,
conditional,
wholeReexport: wholeReexport.used,
directPropertyReexport: directProperty,
},
trace: globalThis.CJS_PARITY_TRACE,
sideEffectLeafEvaluations:
globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS,
wholeReexportIdentity: wholeReexport === wholeReexportLeaf,
cache: {
wrapper: Boolean(
require.cache[
require.resolve(
'../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js'
)
]
),
leaf: Boolean(
require.cache[
require.resolve(
'../../../../../snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js'
)
]
),
},
cycle: {
before: cycle.before,
fromB: cycle.fromB,
after: cycle.after,
bSawBefore: cycleB.sawBefore,
bSawAfter: cycleB.sawAfter ?? null,
},
}).toEqual({
values: {
direct: 'USED_DIRECT_EXPORT',
objectLiteral: 'USED_OBJECT_LITERAL',
defineProperty: 'USED_DEFINE_PROPERTY',
computed: 'USED_COMPUTED_KEY',
dynamicComputed: 'USED_DYNAMIC_COMPUTED',
dynamicFixed: 'USED_DYNAMIC_FIXED',
conditional: 'USED_CONDITIONAL_ELSE',
wholeReexport: 'USED_WHOLE_REEXPORT_LEAF',
directPropertyReexport: 'USED_DIRECT_PROPERTY_REEXPORT_LEAF',
},
trace: [
'conditional:condition',
'conditional:unused-rhs-else',
'direct-property:side-effect-leaf',
],
sideEffectLeafEvaluations: 1,
wholeReexportIdentity: true,
cache: { wrapper: true, leaf: true },
cycle: {
before: 'USED_CYCLE_A_BEFORE',
fromB: 'USED_CYCLE_B_VALUE',
after: 'USED_CYCLE_A_AFTER',
bSawBefore: 'USED_CYCLE_A_BEFORE',
bSawAfter: null,
},
})
})
......@@ -3,7 +3,7 @@
mod util;
use std::{collections::VecDeque, fs, fs::canonicalize, io, path::PathBuf};
use std::{collections::VecDeque, fs, fs::canonicalize, io, path::PathBuf, process::Command};
use anyhow::{Context, Result};
use rustc_hash::FxHashSet;
......@@ -232,7 +232,20 @@ fn test(resource: PathBuf) {
// Separating this into a different function fixes my IDE's types for some
// reason...
run(resource).unwrap();
run(resource.clone()).unwrap();
if resource.join("differential.json").is_file() {
let script = PathBuf::from(REPO_ROOT.as_str())
.join("turbopack/crates/turbopack-tests/js/cjs-webpack-parity.mjs");
let status = Command::new("node")
.arg(script)
.arg(&resource)
.arg(REPO_ROOT.as_str())
.status()
.context("failed to run CommonJS webpack parity helper")
.unwrap();
assert!(status.success(), "CommonJS webpack parity helper failed");
}
}
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
......
{
"webpackVersion": "5.98.0",
"runtime": {
"values": {
"direct": "USED_DIRECT_EXPORT",
"objectLiteral": "USED_OBJECT_LITERAL",
"defineProperty": "USED_DEFINE_PROPERTY",
"computed": "USED_COMPUTED_KEY",
"dynamicComputed": "USED_DYNAMIC_COMPUTED",
"dynamicFixed": "USED_DYNAMIC_FIXED",
"conditional": "USED_CONDITIONAL_ELSE",
"wholeReexport": "USED_WHOLE_REEXPORT_LEAF",
"directPropertyReexport": "USED_DIRECT_PROPERTY_REEXPORT_LEAF"
},
"trace": [
"conditional:condition",
"conditional:unused-rhs-else",
"direct-property:side-effect-leaf"
],
"sideEffectLeafEvaluations": 1,
"wholeReexportIdentity": true,
"cache": {
"wrapper": true,
"leaf": true
},
"cycle": {
"before": "USED_CYCLE_A_BEFORE",
"fromB": "USED_CYCLE_B_VALUE",
"after": "USED_CYCLE_A_AFTER",
"bSawBefore": "USED_CYCLE_A_BEFORE",
"bSawAfter": null
}
},
"retention": {
"turbopack": {
"direct": {
"modules": {
"direct.js": true
},
"sentinels": {
"USED_DIRECT_EXPORT": true,
"UNUSED_DIRECT_EXPORT": false
}
},
"objectLiteral": {
"modules": {
"object-literal.js": true
},
"sentinels": {
"USED_OBJECT_LITERAL": true,
"UNUSED_OBJECT_LITERAL": false
}
},
"defineProperty": {
"modules": {
"define-property.js": true
},
"sentinels": {
"USED_DEFINE_PROPERTY": true,
"UNUSED_DEFINE_PROPERTY": false
}
},
"computed": {
"modules": {
"computed.js": true
},
"sentinels": {
"USED_COMPUTED_KEY": true,
"UNUSED_COMPUTED_KEY": false
}
},
"dynamicComputed": {
"modules": {
"dynamic-computed.js": true
},
"sentinels": {
"USED_DYNAMIC_COMPUTED": true,
"USED_DYNAMIC_FIXED": true,
"UNUSED_DYNAMIC_CONSERVATIVE": true
}
},
"conditional": {
"modules": {
"conditional.js": true
},
"sentinels": {
"USED_CONDITIONAL_THEN": false,
"USED_CONDITIONAL_ELSE": true,
"UNUSED_CONDITIONAL_THEN": false,
"UNUSED_CONDITIONAL_ELSE": false,
"conditional:condition": true,
"conditional:unused-rhs-then": false,
"conditional:unused-rhs-else": true
}
},
"wholeReexport": {
"modules": {
"whole-reexport.js": true,
"whole-reexport-leaf.js": true
},
"sentinels": {
"USED_WHOLE_REEXPORT_LEAF": true,
"UNUSED_WHOLE_REEXPORT_LEAF": true
}
},
"directProperty": {
"modules": {
"direct-property-reexport.js": true,
"direct-property-used-leaf.js": true,
"direct-property-unused-leaf.js": false,
"direct-property-side-effect-leaf.js": true
},
"sentinels": {
"USED_DIRECT_PROPERTY_REEXPORT_LEAF": true,
"UNUSED_DIRECT_PROPERTY_REEXPORT_LEAF": false,
"UNUSED_SIDE_EFFECT_EXPORT_VALUE": false,
"direct-property:side-effect-leaf": true
}
},
"cycle": {
"modules": {
"cycle-a.js": true,
"cycle-b.js": true
},
"sentinels": {
"USED_CYCLE_A_BEFORE": true,
"USED_CYCLE_A_AFTER": true,
"USED_CYCLE_B_VALUE": true
}
}
},
"webpack": {
"direct": {
"modules": {
"direct.js": true
},
"sentinels": {
"USED_DIRECT_EXPORT": true,
"UNUSED_DIRECT_EXPORT": true
}
},
"objectLiteral": {
"modules": {
"object-literal.js": true
},
"sentinels": {
"USED_OBJECT_LITERAL": true,
"UNUSED_OBJECT_LITERAL": true
}
},
"defineProperty": {
"modules": {
"define-property.js": true
},
"sentinels": {
"USED_DEFINE_PROPERTY": true,
"UNUSED_DEFINE_PROPERTY": false
}
},
"computed": {
"modules": {
"computed.js": true
},
"sentinels": {
"USED_COMPUTED_KEY": true,
"UNUSED_COMPUTED_KEY": false
}
},
"dynamicComputed": {
"modules": {
"dynamic-computed.js": true
},
"sentinels": {
"USED_DYNAMIC_COMPUTED": true,
"USED_DYNAMIC_FIXED": true,
"UNUSED_DYNAMIC_CONSERVATIVE": true
}
},
"conditional": {
"modules": {
"conditional.js": true
},
"sentinels": {
"USED_CONDITIONAL_THEN": false,
"USED_CONDITIONAL_ELSE": true,
"UNUSED_CONDITIONAL_THEN": false,
"UNUSED_CONDITIONAL_ELSE": false,
"conditional:condition": true,
"conditional:unused-rhs-then": false,
"conditional:unused-rhs-else": true
}
},
"wholeReexport": {
"modules": {
"whole-reexport.js": true,
"whole-reexport-leaf.js": true
},
"sentinels": {
"USED_WHOLE_REEXPORT_LEAF": true,
"UNUSED_WHOLE_REEXPORT_LEAF": true
}
},
"directProperty": {
"modules": {
"direct-property-reexport.js": true,
"direct-property-used-leaf.js": true,
"direct-property-unused-leaf.js": true,
"direct-property-side-effect-leaf.js": true
},
"sentinels": {
"USED_DIRECT_PROPERTY_REEXPORT_LEAF": true,
"UNUSED_DIRECT_PROPERTY_REEXPORT_LEAF": false,
"UNUSED_SIDE_EFFECT_EXPORT_VALUE": false,
"direct-property:side-effect-leaf": true
}
},
"cycle": {
"modules": {
"cycle-a.js": true,
"cycle-b.js": true
},
"sentinels": {
"USED_CYCLE_A_BEFORE": true,
"USED_CYCLE_A_AFTER": true,
"USED_CYCLE_B_VALUE": true
}
}
}
},
"classifications": [
{
"field": "direct.sentinels.UNUSED_DIRECT_EXPORT",
"turbopack": false,
"webpack": true,
"classification": "turbopack-improvement",
"reason": "Turbopack recognizes direct dot-property CommonJS writes as named exports and removes the unused pure assignment; webpack 5.98.0 retains its literal."
},
{
"field": "objectLiteral.sentinels.UNUSED_OBJECT_LITERAL",
"turbopack": false,
"webpack": true,
"classification": "turbopack-improvement",
"reason": "Turbopack removes the unused pure property from a module.exports object literal; webpack 5.98.0 retains it."
},
{
"field": "directProperty.modules.direct-property-unused-leaf.js",
"turbopack": false,
"webpack": true,
"classification": "turbopack-improvement",
"reason": "Turbopack drops the export-owned require edge when the outer export is unused and the leaf is explicitly side-effect-free; webpack 5.98.0 keeps the empty leaf module."
}
]
}
// String-literal computed keys are static export names, just like dot properties.
exports['used'] = 'USED_COMPUTED_KEY'
exports['unused'] = 'UNUSED_COMPUTED_KEY'
// Top-level control-flow writes remain statically named exports.
const condition =
(globalThis.CJS_PARITY_TRACE.push('conditional:condition'), false)
if (condition) {
exports.used = 'USED_CONDITIONAL_THEN'
exports.unused =
(globalThis.CJS_PARITY_TRACE.push('conditional:unused-rhs-then'),
'UNUSED_CONDITIONAL_THEN')
} else {
exports.used = 'USED_CONDITIONAL_ELSE'
exports.unused =
(globalThis.CJS_PARITY_TRACE.push('conditional:unused-rhs-else'),
'UNUSED_CONDITIONAL_ELSE')
}
exports.before = 'USED_CYCLE_A_BEFORE'
const b = require('./cycle-b.js')
exports.fromB = b.value
exports.after = 'USED_CYCLE_A_AFTER'
const a = require('./cycle-a.js')
exports.sawBefore = a.before
exports.sawAfter = a.after
exports.value = 'USED_CYCLE_B_VALUE'
Object.defineProperty(exports, 'used', {
enumerable: true,
get() {
return 'USED_DEFINE_PROPERTY'
},
})
Object.defineProperty(exports, 'unused', {
enumerable: true,
get() {
return 'UNUSED_DEFINE_PROPERTY'
},
})
exports.used = require('./direct-property-used-leaf.js').value
exports.unused = require('./direct-property-unused-leaf.js').value
// A side-effectful dependency must remain evaluated even though its outer export is unused.
exports.sideEffect = require('./direct-property-side-effect-leaf.js').value
globalThis.CJS_PARITY_TRACE.push('direct-property:side-effect-leaf')
globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS =
(globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS || 0) + 1
exports.value = 'UNUSED_SIDE_EFFECT_EXPORT_VALUE'
'use turbopack: no side effects'
exports.value = 'UNUSED_DIRECT_PROPERTY_REEXPORT_LEAF'
exports.used = 'USED_DIRECT_EXPORT'
exports.unused = 'UNUSED_DIRECT_EXPORT'
const dynamicName = 'dynamic'
exports[dynamicName] = 'USED_DYNAMIC_COMPUTED'
exports.fixed = 'USED_DYNAMIC_FIXED'
exports.unused = 'UNUSED_DYNAMIC_CONSERVATIVE'
globalThis.CJS_PARITY_TRACE = []
globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS = 0
const { used: direct } = require('./direct.js')
const objectLiteral = require('./object-literal.js').used
const defineProperty = require('./define-property.js').used
const computed = require('./computed.js').used
const dynamicComputed = require('./dynamic-computed.js')
const conditional = require('./conditional.js').used
const wholeReexport = require('./whole-reexport.js')
const wholeReexportLeaf = require('./whole-reexport-leaf.js')
const directPropertyReexport = require('./direct-property-reexport.js').used
const cycle = require('./cycle-a.js')
const cycleB = require('./cycle-b.js')
const result = {
values: {
direct,
objectLiteral,
defineProperty,
computed,
dynamicComputed: dynamicComputed.dynamic,
dynamicFixed: dynamicComputed.fixed,
conditional,
wholeReexport: wholeReexport.used,
directPropertyReexport,
},
trace: globalThis.CJS_PARITY_TRACE,
sideEffectLeafEvaluations: globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS,
wholeReexportIdentity: wholeReexport === wholeReexportLeaf,
cache: {
wrapper: Boolean(require.cache[require.resolve('./whole-reexport.js')]),
leaf: Boolean(require.cache[require.resolve('./whole-reexport-leaf.js')]),
},
cycle: {
before: cycle.before,
fromB: cycle.fromB,
after: cycle.after,
bSawBefore: cycleB.sawBefore,
bSawAfter: cycleB.sawAfter ?? null,
},
}
console.log(`CJS_PARITY_RESULT=${JSON.stringify(result)}`)
const used = 'USED_OBJECT_LITERAL'
const unused = 'UNUSED_OBJECT_LITERAL'
module.exports = { used, unused }
exports.used = 'USED_WHOLE_REEXPORT_LEAF'
exports.unused = 'UNUSED_WHOLE_REEXPORT_LEAF'
// Known gap: a whole CommonJS re-export remains as an intermediate module.
module.exports = require('./whole-reexport-leaf.js')
{
"runtime": "NodeJs",
"runtimeType": "Production",
"removeUnusedImports": true,
"removeUnusedExports": true,
"cjsTreeShaking": true,
"followReexports": true,
"minifyType": {
"Minify": {
"mangle": null
}
}
}
module.exports=["[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/computed.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.used="USED_COMPUTED_KEY"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/conditional.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{globalThis.CJS_PARITY_TRACE.push("conditional:condition"),exports.used="USED_CONDITIONAL_ELSE",globalThis.CJS_PARITY_TRACE.push("conditional:unused-rhs-else")},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-a.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.before="USED_CYCLE_A_BEFORE",exports.fromB=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-b.js [test] (ecmascript)").value,exports.after="USED_CYCLE_A_AFTER"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-b.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{let a=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-a.js [test] (ecmascript)");exports.sawBefore=a.before,exports.sawAfter=a.after,exports.value="USED_CYCLE_B_VALUE"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/define-property.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{Object.defineProperty(exports,"used",{enumerable:!0,get:()=>"USED_DEFINE_PROPERTY"})},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-reexport.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.used=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-used-leaf.js [test] (ecmascript)").value,0..value,__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-side-effect-leaf.js [test] (ecmascript)").value},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-side-effect-leaf.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{globalThis.CJS_PARITY_TRACE.push("direct-property:side-effect-leaf"),globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS=(globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS||0)+1},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-used-leaf.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.value="USED_DIRECT_PROPERTY_REEXPORT_LEAF"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.used="USED_DIRECT_EXPORT"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/dynamic-computed.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.dynamic="USED_DYNAMIC_COMPUTED",exports.fixed="USED_DYNAMIC_FIXED",exports.unused="UNUSED_DYNAMIC_CONSERVATIVE"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/index.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{globalThis.CJS_PARITY_TRACE=[],globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS=0;let{used:direct}=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct.js [test] (ecmascript)"),objectLiteral=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/object-literal.js [test] (ecmascript)").used,defineProperty=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/define-property.js [test] (ecmascript)").used,computed=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/computed.js [test] (ecmascript)").used,dynamicComputed=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/dynamic-computed.js [test] (ecmascript)"),conditional=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/conditional.js [test] (ecmascript)").used,wholeReexport=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js [test] (ecmascript)"),wholeReexportLeaf=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js [test] (ecmascript)"),directPropertyReexport=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-reexport.js [test] (ecmascript)").used,cycle=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-a.js [test] (ecmascript)"),cycleB=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-b.js [test] (ecmascript)"),result={values:{direct,objectLiteral,defineProperty,computed,dynamicComputed:dynamicComputed.dynamic,dynamicFixed:dynamicComputed.fixed,conditional,wholeReexport:wholeReexport.used,directPropertyReexport},trace:globalThis.CJS_PARITY_TRACE,sideEffectLeafEvaluations:globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS,wholeReexportIdentity:wholeReexport===wholeReexportLeaf,cache:{wrapper:!!__turbopack_context__.c["[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js [test] (ecmascript)"],leaf:!!__turbopack_context__.c["[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js [test] (ecmascript)"]},cycle:{before:cycle.before,fromB:cycle.fromB,after:cycle.after,bSawBefore:cycleB.sawBefore,bSawAfter:cycleB.sawAfter??null}};console.log(`CJS_PARITY_RESULT=${JSON.stringify(result)}`)},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/object-literal.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{module1.exports={used:"USED_OBJECT_LITERAL"}},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{exports.used="USED_WHOLE_REEXPORT_LEAF",exports.unused="UNUSED_WHOLE_REEXPORT_LEAF"},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js [test] (ecmascript)",(__turbopack_context__,module1,exports)=>{module1.exports=__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js [test] (ecmascript)")}];
//# sourceMappingURL=1jsg_tests_snapshot_cjs-remove-unused-exports_webpack-parity_input_1sbzh_1p37sm6._.js.map
\ No newline at end of file
{"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/computed.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/conditional.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-a.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/cycle-b.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/define-property.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-reexport.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-side-effect-leaf.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct-property-used-leaf.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/direct.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/dynamic-computed.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/index.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/object-literal.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport-leaf.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/whole-reexport.js"],"sourcesContent":["// String-literal computed keys are static export names, just like dot properties.\nexports['used'] = 'USED_COMPUTED_KEY'\nexports['unused'] = 'UNUSED_COMPUTED_KEY'\n","// Top-level control-flow writes remain statically named exports.\nconst condition =\n (globalThis.CJS_PARITY_TRACE.push('conditional:condition'), false)\nif (condition) {\n exports.used = 'USED_CONDITIONAL_THEN'\n exports.unused =\n (globalThis.CJS_PARITY_TRACE.push('conditional:unused-rhs-then'),\n 'UNUSED_CONDITIONAL_THEN')\n} else {\n exports.used = 'USED_CONDITIONAL_ELSE'\n exports.unused =\n (globalThis.CJS_PARITY_TRACE.push('conditional:unused-rhs-else'),\n 'UNUSED_CONDITIONAL_ELSE')\n}\n","exports.before = 'USED_CYCLE_A_BEFORE'\nconst b = require('./cycle-b.js')\nexports.fromB = b.value\nexports.after = 'USED_CYCLE_A_AFTER'\n","const a = require('./cycle-a.js')\nexports.sawBefore = a.before\nexports.sawAfter = a.after\nexports.value = 'USED_CYCLE_B_VALUE'\n","Object.defineProperty(exports, 'used', {\n enumerable: true,\n get() {\n return 'USED_DEFINE_PROPERTY'\n },\n})\nObject.defineProperty(exports, 'unused', {\n enumerable: true,\n get() {\n return 'UNUSED_DEFINE_PROPERTY'\n },\n})\n","exports.used = require('./direct-property-used-leaf.js').value\nexports.unused = require('./direct-property-unused-leaf.js').value\n// A side-effectful dependency must remain evaluated even though its outer export is unused.\nexports.sideEffect = require('./direct-property-side-effect-leaf.js').value\n","globalThis.CJS_PARITY_TRACE.push('direct-property:side-effect-leaf')\nglobalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS =\n (globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS || 0) + 1\nexports.value = 'UNUSED_SIDE_EFFECT_EXPORT_VALUE'\n","exports.value = 'USED_DIRECT_PROPERTY_REEXPORT_LEAF'\n","exports.used = 'USED_DIRECT_EXPORT'\nexports.unused = 'UNUSED_DIRECT_EXPORT'\n","const dynamicName = 'dynamic'\nexports[dynamicName] = 'USED_DYNAMIC_COMPUTED'\nexports.fixed = 'USED_DYNAMIC_FIXED'\nexports.unused = 'UNUSED_DYNAMIC_CONSERVATIVE'\n","globalThis.CJS_PARITY_TRACE = []\nglobalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS = 0\n\nconst { used: direct } = require('./direct.js')\nconst objectLiteral = require('./object-literal.js').used\nconst defineProperty = require('./define-property.js').used\nconst computed = require('./computed.js').used\nconst dynamicComputed = require('./dynamic-computed.js')\nconst conditional = require('./conditional.js').used\nconst wholeReexport = require('./whole-reexport.js')\nconst wholeReexportLeaf = require('./whole-reexport-leaf.js')\nconst directPropertyReexport = require('./direct-property-reexport.js').used\nconst cycle = require('./cycle-a.js')\nconst cycleB = require('./cycle-b.js')\n\nconst result = {\n values: {\n direct,\n objectLiteral,\n defineProperty,\n computed,\n dynamicComputed: dynamicComputed.dynamic,\n dynamicFixed: dynamicComputed.fixed,\n conditional,\n wholeReexport: wholeReexport.used,\n directPropertyReexport,\n },\n trace: globalThis.CJS_PARITY_TRACE,\n sideEffectLeafEvaluations: globalThis.CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS,\n wholeReexportIdentity: wholeReexport === wholeReexportLeaf,\n cache: {\n wrapper: Boolean(require.cache[require.resolve('./whole-reexport.js')]),\n leaf: Boolean(require.cache[require.resolve('./whole-reexport-leaf.js')]),\n },\n cycle: {\n before: cycle.before,\n fromB: cycle.fromB,\n after: cycle.after,\n bSawBefore: cycleB.sawBefore,\n bSawAfter: cycleB.sawAfter ?? null,\n },\n}\n\nconsole.log(`CJS_PARITY_RESULT=${JSON.stringify(result)}`)\n","const used = 'USED_OBJECT_LITERAL'\nconst unused = 'UNUSED_OBJECT_LITERAL'\n\nmodule.exports = { used, unused }\n","exports.used = 'USED_WHOLE_REEXPORT_LEAF'\nexports.unused = 'UNUSED_WHOLE_REEXPORT_LEAF'\n","// Known gap: a whole CommonJS re-export remains as an intermediate module.\nmodule.exports = require('./whole-reexport-leaf.js')\n"],"names":["exports","condition","globalThis","CJS_PARITY_TRACE","push","used","before","b","fromB","value","after","a","sawBefore","sawAfter","Object","defineProperty","enumerable","get","CJS_PARITY_SIDE_EFFECT_LEAF_EVALUATIONS","dynamicName","fixed","unused","direct","objectLiteral","computed","dynamicComputed","conditional","wholeReexport","wholeReexportLeaf","directPropertyReexport","cycle","cycleB","result","values","dynamic","dynamicFixed","trace","sideEffectLeafEvaluations","wholeReexportIdentity","cache","wrapper","Boolean","leaf","bSawBefore","bSawAfter","console","log","JSON","stringify","module"],"mappings":"qMACAA,OAAO,CAAC,IAAO,CAAG,6MCCfE,WAAWC,gBAAgB,CAACC,IAAI,CAAC,yBAOlCJ,CAP4D,KAAK,EAOzDK,IAAI,CAAG,wBAEZH,WAAWC,gBAAgB,CAACC,IAAI,CAAC,gCAClC,oLCZJJ,QAAQM,MAAM,CAAG,sBAEjBN,QAAQQ,KAAK,CAAGD,AADVA,sBAAAA,CAAAA,CAAAA,2IACYE,KAAK,CACvBT,QAAQU,KAAK,CAAG,0MCHhB,IAAMC,EAAAA,sBAAAA,CAAAA,CAAAA,2IACNX,QAAQY,SAAS,CAAGD,EAAEL,MAAM,CAC5BN,QAAQa,QAAQ,CAAGF,EAAED,KAAK,CAC1BV,QAAQS,KAAK,CAAG,kNCHhBK,OAAOC,cAAc,CAACf,QAAS,OAAQ,CACrCgB,YAAY,MACZC,IACS,sBAEX,yMCLAjB,QAAQK,IAAI,CAAG,sBAAA,CAAA,CAAA,6JAA0CI,KAAK,CAC7C,GAA4CA,KAAK,CAE7C,sBAAA,CAAA,CAAA,oKAAiDA,KAAK,+MCH3EP,WAAWC,gBAAgB,CAACC,IAAI,CAAC,oCACjCF,WAAWgB,uCAAuC,CAChD,CAAChB,WAAWgB,uCAAuC,EAAI,CAAC,EAAI,yMCF9DlB,QAAQS,KAAK,CAAG,yNCAhBT,QAAQK,IAAI,CAAG,mNCCfL,OAAO,CAACmB,AADY,OACA,CAAG,wBACvBnB,QA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,KAAKC,SAAS,CAAChB,QAAAA,CAAS,8LCxCzDiB,QAAOjD,OAAO,CAAG,CAAEK,KAHN,qBAGmB,mMCHhCL,QAAQK,IAAI,CAAG,2BACfL,QAAQqB,MAAM,CAAG,yNCAjB4B,QAAOjD,OAAO,CAAA,sBAAA,CAAA,CAAA"}
\ No newline at end of file
var RUNTIME_PUBLIC_PATH = "output/[turbopack]_runtime.js";
var RELATIVE_ROOT_PATH = "../../../../../../..";
var ASSET_PREFIX = "/";
/**
* This file contains runtime types and functions that are shared between all
* TurboPack ECMAScript runtimes.
*
* It will be prepended to the runtime code of each runtime.
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-types.d.ts" />
/// <reference path="./async-module.ts" />
/**
* Describes why a module was instantiated.
* Shared between browser and Node.js runtimes.
*/ var SourceType = /*#__PURE__*/ function(SourceType) {
/**
* The module was instantiated because it was included in an evaluated chunk's
* runtime.
* SourceData is a ChunkPath.
*/ SourceType[SourceType["Runtime"] = 0] = "Runtime";
/**
* The module was instantiated because a parent module imported it.
* SourceData is a ModuleId.
*/ SourceType[SourceType["Parent"] = 1] = "Parent";
/**
* The module was instantiated because it was included in a chunk's hot module
* update.
* SourceData is an array of ModuleIds or undefined.
*/ SourceType[SourceType["Update"] = 2] = "Update";
return SourceType;
}(SourceType || {});
/**
* Flag indicating which module object type to create when a module is merged. Set to `true`
* by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,
* nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it
* uses plain Module objects.
*/ let createModuleWithDirectionFlag = false;
const REEXPORTED_OBJECTS = new WeakMap();
/**
* Constructs the `__turbopack_context__` object for a module.
*/ function Context(module, exports) {
this.m = module;
// We need to store this here instead of accessing it from the module object to:
// 1. Make it available to factories directly, since we rewrite `this` to
// `__turbopack_context__.e` in CJS modules.
// 2. Support async modules which rewrite `module.exports` to a promise, so we
// can still access the original exports object from functions like
// `esmExport`
// Ideally we could find a new approach for async modules and drop this property altogether.
this.e = exports;
}
const contextPrototype = Context.prototype;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag;
function defineProp(obj, name, options) {
if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options);
}
function getOverwrittenModule(moduleCache, id) {
let module = moduleCache[id];
if (!module) {
if (createModuleWithDirectionFlag) {
// set in development modes for hmr support
module = createModuleWithDirection(id);
} else {
module = createModuleObject(id);
}
moduleCache[id] = module;
}
return module;
}
/**
* Creates the module object. Only done here to ensure all module objects have the same shape.
*/ function createModuleObject(id) {
return {
exports: {},
error: undefined,
id,
namespaceObject: undefined
};
}
function createModuleWithDirection(id) {
return {
exports: {},
error: undefined,
id,
namespaceObject: undefined,
parents: [],
children: []
};
}
const BindingTag_Value = 0;
/**
* Adds the getters to the exports object.
*/ function esm(exports, bindings, dynamic) {
defineProp(exports, '__esModule', {
value: true
});
if (toStringTag) defineProp(exports, toStringTag, {
value: 'Module'
});
let i = 0;
while(i < bindings.length){
const propName = bindings[i++];
const tagOrFunction = bindings[i++];
if (typeof tagOrFunction === 'number') {
if (tagOrFunction === BindingTag_Value) {
defineProp(exports, propName, {
value: bindings[i++],
enumerable: true,
writable: false
});
} else {
throw new Error(`unexpected tag: ${tagOrFunction}`);
}
} else {
const getterFn = tagOrFunction;
if (typeof bindings[i] === 'function') {
const setterFn = bindings[i++];
defineProp(exports, propName, {
get: getterFn,
set: setterFn,
enumerable: true
});
} else {
defineProp(exports, propName, {
get: getterFn,
enumerable: true
});
}
}
}
// The properties defined above are already non-configurable and
// non-writable, so the namespace's existing exports are effectively
// immutable. Sealing additionally makes the object non-extensible, matching
// real ESM-namespace semantics. Modules with dynamic re-exports
// (`export *` from a CommonJS module) must stay extensible so the dynamic
// export proxy can surface keys discovered at runtime, so skip the seal for
// them.
if (!dynamic) Object.seal(exports);
}
/**
* Makes the module an ESM with exports
*/ function esmExport(bindings, id, dynamic) {
let module;
let exports;
if (id != null) {
module = getOverwrittenModule(this.c, id);
exports = module.exports;
} else {
module = this.m;
exports = this.e;
}
module.namespaceObject = exports;
esm(exports, bindings, dynamic);
}
contextPrototype.s = esmExport;
function ensureDynamicExports(module, exports) {
let reexportedObjects = REEXPORTED_OBJECTS.get(module);
if (!reexportedObjects) {
REEXPORTED_OBJECTS.set(module, reexportedObjects = []);
// Returns the re-exported object that provides `prop` as an own property,
// or `undefined` if none does. The traps share this logic so they always
// agree on which keys are synthesized from `reexportedObjects`. `default`
// is never re-exported by `export *`, so it is never synthesized.
const reexportOwning = (prop)=>{
if (prop !== 'default') {
for (const obj of reexportedObjects){
if (hasOwnProperty.call(obj, prop)) return obj;
}
}
return undefined;
};
// Modules with dynamic re-exports are not sealed by `esm()`, so the
// target beneath the namespace stays extensible. That is what lets the
// `ownKeys` and `getOwnPropertyDescriptor` traps legally report keys that
// exist on `reexportedObjects` but not on the target itself.
module.exports = module.namespaceObject = new Proxy(exports, {
get (target, prop) {
if (hasOwnProperty.call(target, prop) || prop === 'default' || prop === '__esModule') {
return Reflect.get(target, prop);
}
const obj = reexportOwning(prop);
return obj && Reflect.get(obj, prop);
},
// The namespace is read-only, like a real esm namespace object. The
// re-exported modules can still mutate their own exports (exposed live
// via `get`), but mutating the namespace itself is rejected. Refusing
// here, rather than forwarding to the extensible target, also prevents an
// assignment/definition from shadowing a dynamic re-export. It also
// prevents delete from removing a static export.
set () {
return false;
},
defineProperty () {
return false;
},
deleteProperty () {
return false;
},
// The `has` trap ensures that `'exportName' in starImports` will reflect
// the truth of whether a key is exported.
has (target, prop) {
if (Reflect.has(target, prop)) return true;
if (prop === 'default' || prop === '__esModule') return false;
return reexportOwning(prop) !== undefined;
},
// ownKeys and getOwnPropertyDescriptor together make the keys enumerable.
// If a value is returned from `ownKeys` but its property descriptor is
// not enumerable, it will not be visible to iterator methods.
// Collectively, they allow code like the following:
//
// ```
// // module.js re-exports dynamic CJS exports
// export * from './legacyModule.cjs'
//
// // from another JS file, reference the re-exported dynamic values
// import * as Namespace from './module.js'
// Object.keys(Namespace)
// ```
ownKeys (target) {
const keys = Reflect.ownKeys(target);
for (const obj of reexportedObjects){
for (const key of Reflect.ownKeys(obj)){
if (key !== 'default' && !keys.includes(key)) keys.push(key);
}
}
return keys;
},
getOwnPropertyDescriptor (target, prop) {
const own = Reflect.getOwnPropertyDescriptor(target, prop);
if (own || prop === 'default' || prop === '__esModule') return own;
const obj = reexportOwning(prop);
if (obj) {
// Synthetic keys don't exist on the target, so they MUST be
// reported as configurable. However the set/delete traps above will
// prevent them from actually being changed
return {
enumerable: true,
configurable: true,
get: ()=>Reflect.get(obj, prop)
};
}
return undefined;
}
});
}
return reexportedObjects;
}
/**
* Dynamically exports properties from an object
*/ function dynamicExport(object, id) {
let module;
let exports;
if (id != null) {
module = getOverwrittenModule(this.c, id);
exports = module.exports;
} else {
module = this.m;
exports = this.e;
}
const reexportedObjects = ensureDynamicExports(module, exports);
if (typeof object === 'object' && object !== null) {
reexportedObjects.push(object);
}
}
contextPrototype.j = dynamicExport;
function exportValue(value, id) {
let module;
if (id != null) {
module = getOverwrittenModule(this.c, id);
} else {
module = this.m;
}
module.exports = value;
}
contextPrototype.v = exportValue;
function exportNamespace(namespace, id) {
let module;
if (id != null) {
module = getOverwrittenModule(this.c, id);
} else {
module = this.m;
}
module.exports = module.namespaceObject = namespace;
}
contextPrototype.n = exportNamespace;
function createGetter(obj, key) {
return ()=>obj[key];
}
/**
* @returns prototype of the object
*/ const getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
/** Prototypes that are not expanded for exports */ const LEAF_PROTOTYPES = [
null,
getProto({}),
getProto([]),
getProto(getProto)
];
/**
* @param raw
* @param ns
* @param allowExportDefault
* * `false`: will have the raw module as default export
* * `true`: will have the default property as default export
*/ function interopEsm(raw, ns, allowExportDefault) {
const bindings = [];
let defaultLocation = -1;
for(let current = raw; (typeof current === 'object' || typeof current === 'function') && !LEAF_PROTOTYPES.includes(current); current = getProto(current)){
for (const key of Object.getOwnPropertyNames(current)){
bindings.push(key, createGetter(raw, key));
if (defaultLocation === -1 && key === 'default') {
defaultLocation = bindings.length - 1;
}
}
}
// this is not really correct
// we should set the `default` getter if the imported module is a `.cjs file`
if (!(allowExportDefault && defaultLocation >= 0)) {
// Replace the binding with one for the namespace itself in order to preserve iteration order.
if (defaultLocation >= 0) {
// Replace the getter with the value
bindings.splice(defaultLocation, 1, BindingTag_Value, raw);
} else {
bindings.push('default', BindingTag_Value, raw);
}
}
esm(ns, bindings);
return ns;
}
function createNS(raw) {
if (typeof raw === 'function') {
return function(...args) {
return raw.apply(this, args);
};
} else {
return Object.create(null);
}
}
function esmImport(id) {
const module = getOrInstantiateModuleFromParent(id, this.m);
// any ES module has to have `module.namespaceObject` defined.
if (module.namespaceObject) return module.namespaceObject;
// only ESM can be an async module, so we don't need to worry about exports being a promise here.
const raw = module.exports;
return module.namespaceObject = interopEsm(raw, createNS(raw), raw && raw.__esModule);
}
contextPrototype.i = esmImport;
function asyncLoader(moduleId) {
const loader = this.r(moduleId);
return loader(esmImport.bind(this));
}
contextPrototype.A = asyncLoader;
// Add a simple runtime require so that environments without one can still pass
// `typeof require` CommonJS checks so that exports are correctly registered.
const runtimeRequire = // @ts-ignore
typeof require === 'function' ? require : function require1() {
throw new Error('Unexpected use of runtime require');
};
contextPrototype.t = runtimeRequire;
function commonJsRequire(id) {
return getOrInstantiateModuleFromParent(id, this.m).exports;
}
contextPrototype.r = commonJsRequire;
/**
* Remove fragments and query parameters since they are never part of the context map keys
*
* This matches how we parse patterns at resolving time. Arguably we should only do this for
* strings passed to `import` but the resolve does it for `import` and `require` and so we do
* here as well.
*/ function parseRequest(request) {
// Per the URI spec fragments can contain `?` characters, so we should trim it off first
// https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
const hashIndex = request.indexOf('#');
if (hashIndex !== -1) {
request = request.substring(0, hashIndex);
}
const queryIndex = request.indexOf('?');
if (queryIndex !== -1) {
request = request.substring(0, queryIndex);
}
return request;
}
/**
* `require.context` and require/import expression runtime.
*/ function moduleContext(map) {
function moduleContext(id) {
id = parseRequest(id);
if (hasOwnProperty.call(map, id)) {
return map[id].module();
}
const e = new Error(`Cannot find module '${id}'`);
e.code = 'MODULE_NOT_FOUND';
throw e;
}
moduleContext.keys = ()=>{
return Object.keys(map);
};
moduleContext.resolve = (id)=>{
id = parseRequest(id);
if (hasOwnProperty.call(map, id)) {
return map[id].id();
}
const e = new Error(`Cannot find module '${id}'`);
e.code = 'MODULE_NOT_FOUND';
throw e;
};
moduleContext.import = async (id)=>{
return await moduleContext(id);
};
return moduleContext;
}
contextPrototype.f = moduleContext;
/**
* Returns the path of a chunk defined by its data.
*/ function getChunkPath(chunkData) {
return typeof chunkData === 'string' ? chunkData : chunkData.path;
}
// Load the CompressedModuleFactories of a chunk into the `moduleFactories` Map.
// The flat format alternates one or more module IDs with their factory function.
// Strict factories can be prepended as a nested array.
function installCompressedModuleFactories(chunkModules, offset, moduleFactories, newModuleId) {
let i = offset;
const strictFactories = chunkModules[i];
if (Array.isArray(strictFactories)) {
installCompressedModuleFactories(strictFactories, 0, moduleFactories, newModuleId);
i++;
}
while(i < chunkModules.length){
let end = i + 1;
// Find our factory function
while(end < chunkModules.length && typeof chunkModules[end] !== 'function'){
end++;
}
if (end === chunkModules.length) {
throw new Error('malformed chunk format, expected a factory function');
}
// Install the factory for each module ID that doesn't already have one.
// When some IDs in this group already have a factory, reuse that existing
// group factory for the missing IDs to keep all IDs in the group consistent.
// Otherwise, install the factory from this chunk.
const moduleFactoryFn = chunkModules[end];
let existingGroupFactory = undefined;
for(let j = i; j < end; j++){
const id = chunkModules[j];
const existingFactory = moduleFactories.get(id);
if (existingFactory) {
existingGroupFactory = existingFactory;
break;
}
}
const factoryToInstall = existingGroupFactory ?? moduleFactoryFn;
let didInstallFactory = false;
for(let j = i; j < end; j++){
const id = chunkModules[j];
if (!moduleFactories.has(id)) {
if (!didInstallFactory) {
if (factoryToInstall === moduleFactoryFn) {
applyModuleFactoryName(moduleFactoryFn);
}
didInstallFactory = true;
}
moduleFactories.set(id, factoryToInstall);
newModuleId?.(id);
}
}
i = end + 1;
}
}
/**
* A pseudo "fake" URL object to resolve to its relative path.
*
* When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this
* runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid
* hydration mismatch.
*
* This is based on webpack's existing implementation:
* https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js
*/ const relativeURL = function relativeURL(inputUrl) {
const realUrl = new URL(inputUrl, 'x:/');
const values = {};
for(const key in realUrl)values[key] = realUrl[key];
values.href = inputUrl;
values.pathname = inputUrl.replace(/[?#].*/, '');
values.origin = values.protocol = '';
values.toString = values.toJSON = (..._args)=>inputUrl;
for(const key in values)Object.defineProperty(this, key, {
enumerable: true,
configurable: true,
value: values[key]
});
};
relativeURL.prototype = URL.prototype;
contextPrototype.U = relativeURL;
/**
* Utility function to ensure all variants of an enum are handled.
*/ function invariant(never, computeMessage) {
throw new Error(`Invariant: ${computeMessage(never)}`);
}
/**
* Constructs an error message for when a module factory is not available.
*/ function factoryNotAvailableMessage(moduleId, sourceType, sourceData) {
let instantiationReason;
switch(sourceType){
case 0:
instantiationReason = `as a runtime entry of chunk ${sourceData}`;
break;
case 1:
instantiationReason = `because it was required from module ${sourceData}`;
break;
case 2:
instantiationReason = 'because of an HMR update';
break;
default:
invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
}
return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`;
}
/**
* A stub function to make `require` available but non-functional in ESM.
*/ function requireStub(_moduleId) {
throw new Error('dynamic usage of require is not supported');
}
contextPrototype.z = requireStub;
// Make `globalThis` available to the module in a way that cannot be shadowed by a local variable.
contextPrototype.g = globalThis;
function applyModuleFactoryName(factory) {
// Give the module factory a nice name to improve stack traces.
Object.defineProperty(factory, 'name', {
value: 'module evaluation'
});
}
/// <reference path="../shared/runtime/runtime-utils.ts" />
/// A 'base' utilities to support runtime can have externals.
/// Currently this is for node.js / edge runtime both.
/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.
async function externalImport(id) {
let raw;
try {
raw = await import(id);
} catch (err) {
// TODO(alexkirsz) This can happen when a client-side module tries to load
// an external module we don't provide a shim for (e.g. querystring, url).
// For now, we fail semi-silently, but in the future this should be a
// compilation error.
throw new Error(`Failed to load external module ${id}: ${err}`);
}
if (raw && raw.__esModule && raw.default && 'default' in raw.default) {
return interopEsm(raw.default, createNS(raw), true);
}
return raw;
}
contextPrototype.y = externalImport;
function externalRequire(id, thunk, esm = false) {
let raw;
try {
raw = thunk();
} catch (err) {
// TODO(alexkirsz) This can happen when a client-side module tries to load
// an external module we don't provide a shim for (e.g. querystring, url).
// For now, we fail semi-silently, but in the future this should be a
// compilation error.
throw new Error(`Failed to load external module ${id}: ${err}`);
}
if (!esm || raw.__esModule) {
return raw;
}
return interopEsm(raw, createNS(raw), true);
}
externalRequire.resolve = (id, options)=>{
return require.resolve(id, options);
};
contextPrototype.x = externalRequire;
/* eslint-disable @typescript-eslint/no-unused-vars */ const path = require('path');
const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.');
// Compute the relative path to the `distDir`.
const relativePathToDistRoot = path.join(relativePathToRuntimeRoot, RELATIVE_ROOT_PATH);
const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);
// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.
const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
/**
* Returns an absolute path to the given module path.
* Module path should be relative, either path to a file or a directory.
*
* This fn allows to calculate an absolute path for some global static values, such as
* `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.
* See ImportMetaBinding::code_generation for the usage.
*/ function resolveAbsolutePath(modulePath) {
if (modulePath) {
return path.join(ABSOLUTE_ROOT, modulePath);
}
return ABSOLUTE_ROOT;
}
Context.prototype.P = resolveAbsolutePath;
/**
* Returns an absolute `file://` URL for the given module path.
*
* Uses `url.pathToFileURL` so that the resulting URL is a valid file URI on
* all platforms (forward slashes on Windows, drive letters handled
* correctly, path segments URL-encoded).
*/ function resolveFileUrl(modulePath) {
return require('url').pathToFileURL(resolveAbsolutePath(modulePath)).href;
}
Context.prototype.F = resolveFileUrl;
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../shared/runtime/runtime-utils.ts" />
/// <reference path="../../shared-node/base-externals-utils.ts" />
/// <reference path="../../shared-node/node-externals-utils.ts" />
/// <reference path="./nodejs-globals.d.ts" />
/**
* Base Node.js runtime shared between production and development.
* Contains chunk loading, module caching, and other non-HMR functionality.
*/ process.env.TURBOPACK = '1';
const url = require('url');
const moduleFactories = new Map();
const moduleCache = Object.create(null);
/**
* Returns an absolute path to the given module's id.
*/ function resolvePathFromModule(moduleId) {
const exported = this.r(moduleId);
const exportedPath = exported?.default ?? exported;
if (typeof exportedPath !== 'string') {
return exported;
}
const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length);
const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix);
return url.pathToFileURL(resolved).href;
}
/**
* Exports a URL value. No suffix is added in Node.js runtime.
*/ function exportUrl(urlValue, id) {
exportValue.call(this, urlValue, id);
}
function loadRuntimeChunk(sourcePath, chunkData) {
if (typeof chunkData === 'string') {
loadRuntimeChunkPath(sourcePath, chunkData);
} else {
loadRuntimeChunkPath(sourcePath, chunkData.path);
}
}
const loadedChunks = new Set();
const unsupportedLoadChunk = Promise.resolve(undefined);
const loadedChunk = Promise.resolve(undefined);
const chunkCache = new Map();
function clearChunkCache() {
chunkCache.clear();
loadedChunks.clear();
}
function loadRuntimeChunkPath(sourcePath, chunkPath) {
if (!isJs(chunkPath)) {
// We only support loading JS chunks in Node.js.
// This branch can be hit when trying to load a CSS chunk.
return;
}
if (loadedChunks.has(chunkPath)) {
return;
}
try {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
const chunkModules = require(resolved);
installCompressedModuleFactories(chunkModules, 0, moduleFactories);
loadedChunks.add(chunkPath);
} catch (cause) {
let errorMessage = `Failed to load chunk ${chunkPath}`;
if (sourcePath) {
errorMessage += ` from runtime for chunk ${sourcePath}`;
}
const error = new Error(errorMessage, {
cause
});
error.name = 'ChunkLoadError';
throw error;
}
}
function loadChunkAsync(chunkData) {
const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path;
if (!isJs(chunkPath)) {
// We only support loading JS chunks in Node.js.
// This branch can be hit when trying to load a CSS chunk.
return unsupportedLoadChunk;
}
let entry = chunkCache.get(chunkPath);
if (entry === undefined) {
try {
// resolve to an absolute path to simplify `require` handling
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
// TODO: consider switching to `import()` to enable concurrent chunk loading and async file io
// However this is incompatible with hot reloading (since `import` doesn't use the require cache)
const chunkModules = require(resolved);
installCompressedModuleFactories(chunkModules, 0, moduleFactories);
entry = loadedChunk;
} catch (cause) {
const errorMessage = `Failed to load chunk ${chunkPath} from module ${this.m.id}`;
const error = new Error(errorMessage, {
cause
});
error.name = 'ChunkLoadError';
// Cache the failure promise, future requests will also get this same rejection
entry = Promise.reject(error);
}
chunkCache.set(chunkPath, entry);
}
// TODO: Return an instrumented Promise that React can use instead of relying on referential equality.
return entry;
}
contextPrototype.l = loadChunkAsync;
function loadChunkAsyncByUrl(chunkUrl) {
const path1 = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT));
return loadChunkAsync.call(this, path1);
}
contextPrototype.L = loadChunkAsyncByUrl;
// Shared runtime primitive: the root that on-disk chunk paths are resolved
// against. Used by the bundled wasm helper (exposed as `__turbopack_runtime_root__`).
contextPrototype.w = RUNTIME_ROOT;
const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
/**
* Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
*/ function isJs(chunkUrlOrPath) {
return regexJsUrl.test(chunkUrlOrPath);
}
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-base.ts" />
/**
* Production Node.js runtime.
* Uses ModuleWithDirection and simple module instantiation without HMR support.
*/ // moduleCache and moduleFactories are declared in runtime-base.ts
// this is read in runtime-utils.ts so it creates a module with direction for hmr
createModuleWithDirectionFlag = true;
const nodeContextPrototype = Context.prototype;
nodeContextPrototype.q = exportUrl;
nodeContextPrototype.M = moduleFactories;
// Cast moduleCache to ModuleWithDirection for production mode
nodeContextPrototype.c = moduleCache;
nodeContextPrototype.R = resolvePathFromModule;
nodeContextPrototype.C = clearChunkCache;
function instantiateModule(id, sourceType, sourceData) {
const moduleFactory = moduleFactories.get(id);
if (typeof moduleFactory !== 'function') {
// This can happen if modules incorrectly handle HMR disposes/updates,
// e.g. when they keep a `setTimeout` around which still executes old code
// and contains e.g. a `require("something")` call.
throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData));
}
const module1 = createModuleWithDirection(id);
const exports = module1.exports;
moduleCache[id] = module1;
const context = new Context(module1, exports);
// NOTE(alexkirsz) This can fail when the module encounters a runtime error.
try {
moduleFactory(context, module1, exports);
} catch (error) {
module1.error = error;
throw error;
}
;
module1.loaded = true;
if (module1.namespaceObject && module1.exports !== module1.namespaceObject) {
// in case of a circular dependency: cjs1 -> esm2 -> cjs1
interopEsm(module1.exports, module1.namespaceObject);
}
return module1;
}
/**
* Retrieves a module from the cache, or instantiate it if it is not cached.
*/ // @ts-ignore
function getOrInstantiateModuleFromParent(id, sourceModule) {
const module1 = moduleCache[id];
if (module1) {
if (module1.error) {
throw module1.error;
}
return module1;
}
return instantiateModule(id, SourceType.Parent, sourceModule.id);
}
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(chunkPath, moduleId) {
return instantiateModule(moduleId, SourceType.Runtime, chunkPath);
}
/**
* Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.
*/ // @ts-ignore TypeScript doesn't separate this module space from the browser runtime
function getOrInstantiateRuntimeModule(chunkPath, moduleId) {
const module1 = moduleCache[moduleId];
if (module1) {
if (module1.error) {
throw module1.error;
}
return module1;
}
return instantiateRuntimeModule(chunkPath, moduleId);
}
module.exports = (sourcePath)=>({
m: (id)=>getOrInstantiateRuntimeModule(sourcePath, id),
c: (chunkData)=>loadRuntimeChunk(sourcePath, chunkData)
});
//# sourceMappingURL=%5Bturbopack%5D_runtime.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/runtime/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-types.d.ts\" />\n/// <reference path=\"./async-module.ts\" />\n\ntype EsmNamespaceObject = Record<string, any>\n\n/**\n * Describes why a module was instantiated.\n * Shared between browser and Node.js runtimes.\n */\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n * SourceData is a ChunkPath.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n * SourceData is a ModuleId.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n * SourceData is an array of ModuleIds or undefined.\n */\n Update = 2,\n}\n\ntype SourceData = ChunkPath | ModuleId | ModuleId[] | undefined\n\n// @ts-ignore Defined in `dev-base.ts`\ndeclare function getOrInstantiateModuleFromParent<M>(\n id: ModuleId,\n sourceModule: M\n): M\n\n/**\n * Flag indicating which module object type to create when a module is merged. Set to `true`\n * by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,\n * nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it\n * uses plain Module objects.\n */\nlet createModuleWithDirectionFlag = false\n\nconst REEXPORTED_OBJECTS = new WeakMap<Module, ReexportedObjects>()\n\n/**\n * Constructs the `__turbopack_context__` object for a module.\n */\nfunction Context(\n this: TurbopackBaseContext<Module>,\n module: Module,\n exports: Exports\n) {\n this.m = module\n // We need to store this here instead of accessing it from the module object to:\n // 1. Make it available to factories directly, since we rewrite `this` to\n // `__turbopack_context__.e` in CJS modules.\n // 2. Support async modules which rewrite `module.exports` to a promise, so we\n // can still access the original exports object from functions like\n // `esmExport`\n // Ideally we could find a new approach for async modules and drop this property altogether.\n this.e = exports\n}\nconst contextPrototype = Context.prototype as TurbopackBaseContext<Module>\n\ntype ModuleContextMap = Record<ModuleId, ModuleContextEntry>\n\ninterface ModuleContextEntry {\n id: () => ModuleId\n module: () => any\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: string): Exports | EsmNamespaceObject\n\n // async import call\n import(moduleId: string): Promise<Exports | EsmNamespaceObject>\n\n keys(): ModuleId[]\n\n resolve(moduleId: string): ModuleId\n}\n\ntype GetOrInstantiateModuleFromParent<M extends Module> = (\n moduleId: M['id'],\n parentModule: M\n) => M\n\ndeclare function getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): Module\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty\nconst toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType<any>\n) {\n if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options)\n}\n\nfunction getOverwrittenModule(\n moduleCache: ModuleCache<Module>,\n id: ModuleId\n): Module {\n let module = moduleCache[id]\n if (!module) {\n if (createModuleWithDirectionFlag) {\n // set in development modes for hmr support\n module = createModuleWithDirection(id)\n } else {\n module = createModuleObject(id)\n }\n moduleCache[id] = module\n }\n return module\n}\n\n/**\n * Creates the module object. Only done here to ensure all module objects have the same shape.\n */\nfunction createModuleObject(id: ModuleId): Module {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n }\n}\n\nfunction createModuleWithDirection(id: ModuleId): ModuleWithDirection {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n parents: [],\n children: [],\n }\n}\n\ntype BindingTag = 0\nconst BindingTag_Value = 0 as BindingTag\n\n// an arbitrary sequence of bindings as\n// - a prop name\n// - BindingTag_Value, a value to be bound directly, or\n// - 1 or 2 functions to bind as getters and sdetters\ntype EsmBindings = Array<\n string | BindingTag | (() => unknown) | ((v: unknown) => void) | unknown\n>\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, bindings: EsmBindings, dynamic?: boolean) {\n defineProp(exports, '__esModule', { value: true })\n if (toStringTag) defineProp(exports, toStringTag, { value: 'Module' })\n let i = 0\n while (i < bindings.length) {\n const propName = bindings[i++] as string\n const tagOrFunction = bindings[i++]\n if (typeof tagOrFunction === 'number') {\n if (tagOrFunction === BindingTag_Value) {\n defineProp(exports, propName, {\n value: bindings[i++],\n enumerable: true,\n writable: false,\n })\n } else {\n throw new Error(`unexpected tag: ${tagOrFunction}`)\n }\n } else {\n const getterFn = tagOrFunction as () => unknown\n if (typeof bindings[i] === 'function') {\n const setterFn = bindings[i++] as (v: unknown) => void\n defineProp(exports, propName, {\n get: getterFn,\n set: setterFn,\n enumerable: true,\n })\n } else {\n defineProp(exports, propName, {\n get: getterFn,\n enumerable: true,\n })\n }\n }\n }\n // The properties defined above are already non-configurable and\n // non-writable, so the namespace's existing exports are effectively\n // immutable. Sealing additionally makes the object non-extensible, matching\n // real ESM-namespace semantics. Modules with dynamic re-exports\n // (`export *` from a CommonJS module) must stay extensible so the dynamic\n // export proxy can surface keys discovered at runtime, so skip the seal for\n // them.\n if (!dynamic) Object.seal(exports)\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n this: TurbopackBaseContext<Module>,\n bindings: EsmBindings,\n id: ModuleId | undefined,\n dynamic?: boolean\n) {\n let module: Module\n let exports: Module['exports']\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n module.namespaceObject = exports\n esm(exports, bindings, dynamic)\n}\ncontextPrototype.s = esmExport\n\ntype ReexportedObjects = Record<PropertyKey, unknown>[]\nfunction ensureDynamicExports(\n module: Module,\n exports: Exports\n): ReexportedObjects {\n let reexportedObjects: ReexportedObjects | undefined =\n REEXPORTED_OBJECTS.get(module)\n\n if (!reexportedObjects) {\n REEXPORTED_OBJECTS.set(module, (reexportedObjects = []))\n // Returns the re-exported object that provides `prop` as an own property,\n // or `undefined` if none does. The traps share this logic so they always\n // agree on which keys are synthesized from `reexportedObjects`. `default`\n // is never re-exported by `export *`, so it is never synthesized.\n const reexportOwning = (prop: PropertyKey) => {\n if (prop !== 'default') {\n for (const obj of reexportedObjects!) {\n if (hasOwnProperty.call(obj, prop)) return obj\n }\n }\n return undefined\n }\n // Modules with dynamic re-exports are not sealed by `esm()`, so the\n // target beneath the namespace stays extensible. That is what lets the\n // `ownKeys` and `getOwnPropertyDescriptor` traps legally report keys that\n // exist on `reexportedObjects` but not on the target itself.\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === 'default' ||\n prop === '__esModule'\n ) {\n return Reflect.get(target, prop)\n }\n const obj = reexportOwning(prop)\n return obj && Reflect.get(obj, prop)\n },\n // The namespace is read-only, like a real esm namespace object. The\n // re-exported modules can still mutate their own exports (exposed live\n // via `get`), but mutating the namespace itself is rejected. Refusing\n // here, rather than forwarding to the extensible target, also prevents an\n // assignment/definition from shadowing a dynamic re-export. It also\n // prevents delete from removing a static export.\n set() {\n return false\n },\n defineProperty() {\n return false\n },\n deleteProperty() {\n return false\n },\n // The `has` trap ensures that `'exportName' in starImports` will reflect\n // the truth of whether a key is exported.\n has(target, prop) {\n if (Reflect.has(target, prop)) return true\n if (prop === 'default' || prop === '__esModule') return false\n return reexportOwning(prop) !== undefined\n },\n // ownKeys and getOwnPropertyDescriptor together make the keys enumerable.\n // If a value is returned from `ownKeys` but its property descriptor is\n // not enumerable, it will not be visible to iterator methods.\n // Collectively, they allow code like the following:\n //\n // ```\n // // module.js re-exports dynamic CJS exports\n // export * from './legacyModule.cjs'\n //\n // // from another JS file, reference the re-exported dynamic values\n // import * as Namespace from './module.js'\n // Object.keys(Namespace)\n // ```\n ownKeys(target) {\n const keys = Reflect.ownKeys(target)\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== 'default' && !keys.includes(key)) keys.push(key)\n }\n }\n return keys\n },\n getOwnPropertyDescriptor(target, prop) {\n const own = Reflect.getOwnPropertyDescriptor(target, prop)\n if (own || prop === 'default' || prop === '__esModule') return own\n const obj = reexportOwning(prop)\n if (obj) {\n // Synthetic keys don't exist on the target, so they MUST be\n // reported as configurable. However the set/delete traps above will\n // prevent them from actually being changed\n return {\n enumerable: true,\n configurable: true,\n get: () => Reflect.get(obj, prop),\n }\n }\n return undefined\n },\n })\n }\n return reexportedObjects\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n this: TurbopackBaseContext<Module>,\n object: Record<string, any>,\n id: ModuleId | undefined\n) {\n let module: Module\n let exports: Exports\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n const reexportedObjects = ensureDynamicExports(module, exports)\n\n if (typeof object === 'object' && object !== null) {\n reexportedObjects.push(object)\n }\n}\ncontextPrototype.j = dynamicExport\n\nfunction exportValue(\n this: TurbopackBaseContext<Module>,\n value: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = value\n}\ncontextPrototype.v = exportValue\n\nfunction exportNamespace(\n this: TurbopackBaseContext<Module>,\n namespace: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = module.namespaceObject = namespace\n}\ncontextPrototype.n = exportNamespace\n\nfunction createGetter(obj: Record<string | symbol, any>, key: string | symbol) {\n return () => obj[key]\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)]\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const bindings: EsmBindings = []\n let defaultLocation = -1\n for (\n let current = raw;\n (typeof current === 'object' || typeof current === 'function') &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n bindings.push(key, createGetter(raw, key))\n if (defaultLocation === -1 && key === 'default') {\n defaultLocation = bindings.length - 1\n }\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && defaultLocation >= 0)) {\n // Replace the binding with one for the namespace itself in order to preserve iteration order.\n if (defaultLocation >= 0) {\n // Replace the getter with the value\n bindings.splice(defaultLocation, 1, BindingTag_Value, raw)\n } else {\n bindings.push('default', BindingTag_Value, raw)\n }\n }\n\n esm(ns, bindings)\n return ns\n}\n\nfunction createNS(raw: Module['exports']): EsmNamespaceObject {\n if (typeof raw === 'function') {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args)\n }\n } else {\n return Object.create(null)\n }\n}\n\nfunction esmImport(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exclude<Module['namespaceObject'], undefined> {\n const module = getOrInstantiateModuleFromParent(id, this.m)\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ))\n}\ncontextPrototype.i = esmImport\n\nfunction asyncLoader(\n this: TurbopackBaseContext<Module>,\n moduleId: ModuleId\n): Promise<Exports> {\n const loader = this.r(moduleId) as (\n importFunction: EsmImport\n ) => Promise<Exports>\n return loader(esmImport.bind(this))\n}\ncontextPrototype.A = asyncLoader\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n // @ts-ignore\n typeof require === 'function'\n ? // @ts-ignore\n require\n : function require() {\n throw new Error('Unexpected use of runtime require')\n }\ncontextPrototype.t = runtimeRequire\n\nfunction commonJsRequire(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exports {\n return getOrInstantiateModuleFromParent(id, this.m).exports\n}\ncontextPrototype.r = commonJsRequire\n\n/**\n * Remove fragments and query parameters since they are never part of the context map keys\n *\n * This matches how we parse patterns at resolving time. Arguably we should only do this for\n * strings passed to `import` but the resolve does it for `import` and `require` and so we do\n * here as well.\n */\nfunction parseRequest(request: string): string {\n // Per the URI spec fragments can contain `?` characters, so we should trim it off first\n // https://datatracker.ietf.org/doc/html/rfc3986#section-3.5\n const hashIndex = request.indexOf('#')\n if (hashIndex !== -1) {\n request = request.substring(0, hashIndex)\n }\n\n const queryIndex = request.indexOf('?')\n if (queryIndex !== -1) {\n request = request.substring(0, queryIndex)\n }\n\n return request\n}\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: string): Exports {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].module()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.keys = (): string[] => {\n return Object.keys(map)\n }\n\n moduleContext.resolve = (id: string): ModuleId => {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].id()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.import = async (id: string) => {\n return await (moduleContext(id) as Promise<Exports>)\n }\n\n return moduleContext\n}\ncontextPrototype.f = moduleContext\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === 'string' ? chunkData : chunkData.path\n}\n\n// Load the CompressedModuleFactories of a chunk into the `moduleFactories` Map.\n// The flat format alternates one or more module IDs with their factory function.\n// Strict factories can be prepended as a nested array.\nfunction installCompressedModuleFactories(\n chunkModules: CompressedModuleFactories,\n offset: number,\n moduleFactories: ModuleFactories,\n newModuleId?: (id: ModuleId) => void\n) {\n let i = offset\n const strictFactories = chunkModules[i]\n if (Array.isArray(strictFactories)) {\n installCompressedModuleFactories(\n strictFactories,\n 0,\n moduleFactories,\n newModuleId\n )\n i++\n }\n while (i < chunkModules.length) {\n let end = i + 1\n // Find our factory function\n while (\n end < chunkModules.length &&\n typeof chunkModules[end] !== 'function'\n ) {\n end++\n }\n if (end === chunkModules.length) {\n throw new Error('malformed chunk format, expected a factory function')\n }\n\n // Install the factory for each module ID that doesn't already have one.\n // When some IDs in this group already have a factory, reuse that existing\n // group factory for the missing IDs to keep all IDs in the group consistent.\n // Otherwise, install the factory from this chunk.\n const moduleFactoryFn = chunkModules[end] as Function\n let existingGroupFactory: Function | undefined = undefined\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n const existingFactory = moduleFactories.get(id)\n if (existingFactory) {\n existingGroupFactory = existingFactory\n break\n }\n }\n const factoryToInstall = existingGroupFactory ?? moduleFactoryFn\n\n let didInstallFactory = false\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n if (!moduleFactories.has(id)) {\n if (!didInstallFactory) {\n if (factoryToInstall === moduleFactoryFn) {\n applyModuleFactoryName(moduleFactoryFn)\n }\n didInstallFactory = true\n }\n moduleFactories.set(id, factoryToInstall)\n newModuleId?.(id)\n }\n }\n i = end + 1\n }\n}\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, 'x:/')\n const values: Record<string, any> = {}\n for (const key in realUrl) values[key] = (realUrl as any)[key]\n values.href = inputUrl\n values.pathname = inputUrl.replace(/[?#].*/, '')\n values.origin = values.protocol = ''\n values.toString = values.toJSON = (..._args: Array<any>) => inputUrl\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n })\n}\nrelativeURL.prototype = URL.prototype\ncontextPrototype.U = relativeURL\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`)\n}\n\n/**\n * Constructs an error message for when a module factory is not available.\n */\nfunction factoryNotAvailableMessage(\n moduleId: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): string {\n let instantiationReason: string\n switch (sourceType) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${sourceData}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${sourceData}`\n break\n case SourceType.Update:\n instantiationReason = 'because of an HMR update'\n break\n default:\n invariant(\n sourceType,\n (sourceType) => `Unknown source type: ${sourceType}`\n )\n }\n return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`\n}\n\n/**\n * A stub function to make `require` available but non-functional in ESM.\n */\nfunction requireStub(_moduleId: ModuleId): never {\n throw new Error('dynamic usage of require is not supported')\n}\ncontextPrototype.z = requireStub\n\n// Make `globalThis` available to the module in a way that cannot be shadowed by a local variable.\ncontextPrototype.g = globalThis\n\ntype ContextConstructor<M> = {\n new (module: Module, exports: Exports): TurbopackBaseContext<M>\n}\n\nfunction applyModuleFactoryName(factory: Function) {\n // Give the module factory a nice name to improve stack traces.\n Object.defineProperty(factory, 'name', {\n value: 'module evaluation',\n })\n}\n"],"names":["SourceType","createModuleWithDirectionFlag","REEXPORTED_OBJECTS","WeakMap","Context","module","exports","m","e","contextPrototype","prototype","hasOwnProperty","Object","toStringTag","Symbol","defineProp","obj","name","options","call","defineProperty","getOverwrittenModule","moduleCache","id","createModuleWithDirection","createModuleObject","error","undefined","namespaceObject","parents","children","BindingTag_Value","esm","bindings","dynamic","value","i","length","propName","tagOrFunction","enumerable","writable","Error","getterFn","setterFn","get","set","seal","esmExport","c","s","ensureDynamicExports","reexportedObjects","reexportOwning","prop","Proxy","target","Reflect","deleteProperty","has","ownKeys","keys","key","includes","push","getOwnPropertyDescriptor","own","configurable","dynamicExport","object","j","exportValue","v","exportNamespace","namespace","n","createGetter","getProto","getPrototypeOf","__proto__","LEAF_PROTOTYPES","interopEsm","raw","ns","allowExportDefault","defaultLocation","current","getOwnPropertyNames","splice","createNS","args","apply","create","esmImport","getOrInstantiateModuleFromParent","__esModule","asyncLoader","moduleId","loader","r","bind","A","runtimeRequire","require","require1","t","commonJsRequire","parseRequest","request","hashIndex","indexOf","substring","queryIndex","moduleContext","map","code","resolve","import","f","getChunkPath","chunkData","path","installCompressedModuleFactories","chunkModules","offset","moduleFactories","newModuleId","strictFactories","Array","isArray","end","moduleFactoryFn","existingGroupFactory","existingFactory","factoryToInstall","didInstallFactory","applyModuleFactoryName","relativeURL","inputUrl","realUrl","URL","values","href","pathname","replace","origin","protocol","toString","toJSON","_args","U","invariant","never","computeMessage","factoryNotAvailableMessage","sourceType","sourceData","instantiationReason","requireStub","_moduleId","z","g","globalThis","factory"],"mappings":"AAAA;;;;;CAKC,GAED,oDAAoD,GAEpD,6CAA6C;AAC7C,0CAA0C;AAI1C;;;CAGC,GACD,I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YAAY;YACjE;QACF,KA1pBO;YA2pBLC,sBAAsB,CAAC,oCAAoC,EAAED,YAAY;YACzE;QACF,KAvpBO;YAwpBLC,sBAAsB;YACtB;QACF;YACEN,UACEI,YACA,CAACA,aAAe,CAAC,qBAAqB,EAAEA,YAAY;IAE1D;IACA,OAAO,CAAC,OAAO,EAAE1D,SAAS,kBAAkB,EAAE4D,oBAAoB,0CAA0C,CAAC;AAC/G;AAEA;;CAEC,GACD,SAASC,YAAYC,SAAmB;IACtC,MAAM,IAAIrH,MAAM;AAClB;AACAjC,iBAAiBuJ,CAAC,GAAGF;AAErB,kGAAkG;AAClGrJ,iBAAiBwJ,CAAC,GAAGC;AAMrB,SAAS1B,uBAAuB2B,OAAiB;IAC/C,+DAA+D;IAC/DvJ,OAAOQ,cAAc,CAAC+I,SAAS,QAAQ;QACrChI,OAAO;IACT;AACF","ignoreList":[0]}},
{"offset": {"line": 530, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/// <reference path=\"../shared/runtime/runtime-utils.ts\" />\n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: DependencySpecifier) {\n let raw\n try {\n raw = await import(id)\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (raw && raw.__esModule && raw.default && 'default' in raw.default) {\n return interopEsm(raw.default, createNS(raw), true)\n }\n\n return raw\n}\ncontextPrototype.y = externalImport\n\nfunction externalRequire(\n id: ModuleId,\n thunk: () => any,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw\n try {\n raw = thunk()\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (!esm || raw.__esModule) {\n return raw\n }\n\n return interopEsm(raw, createNS(raw), true)\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[]\n }\n) => {\n return require.resolve(id, options)\n}\ncontextPrototype.x = externalRequire\n"],"names":["externalImport","id","raw","err","Error","__esModule","default","interopEsm","createNS","contextPrototype","y","externalRequire","thunk","esm","resolve","options","require","x"],"mappings":"AAAA,2DAA2D;AAE3D,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAeA,eAAeC,EAAuB;IACnD,IAAIC;IACJ,IAAI;QACFA,MAAM,MAAM,MAAM,CAACD;IACrB,EAAE,OAAOE,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAIC,MAAM,CAAC,+BAA+B,EAAEH,GAAG,EAAE,EAAEE,KAAK;IAChE;IAEA,IAAID,OAAOA,IAAIG,UAAU,IAAIH,IAAII,OAAO,IAAI,aAAaJ,IAAII,OAAO,EAAE;QACpE,OAAOC,WAAWL,IAAII,OAAO,EAAEE,SAASN,MAAM;IAChD;IAEA,OAAOA;AACT;AACAO,iBAAiBC,CAAC,GAAGV;AAErB,SAASW,gBACPV,EAAY,EACZW,KAAgB,EAChBC,MAAe,KAAK;IAEpB,IAAIX;IACJ,IAAI;QACFA,MAAMU;IACR,EAAE,OAAOT,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAIC,MAAM,CAAC,+BAA+B,EAAEH,GAAG,EAAE,EAAEE,KAAK;IAChE;IAEA,IAAI,CAACU,OAAOX,IAAIG,UAAU,EAAE;QAC1B,OAAOH;IACT;IAEA,OAAOK,WAAWL,KAAKM,SAASN,MAAM;AACxC;AAEAS,gBAAgBG,OAAO,GAAG,CACxBb,IACAc;IAIA,OAAOC,QAAQF,OAAO,CAACb,IAAIc;AAC7B;AACAN,iBAAiBQ,CAAC,GAAGN","ignoreList":[0]}},
{"offset": {"line": 571, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\ndeclare var RUNTIME_PUBLIC_PATH: string\ndeclare var RELATIVE_ROOT_PATH: string\ndeclare var ASSET_PREFIX: string\n\nconst path = require('path')\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.join(\n relativePathToRuntimeRoot,\n RELATIVE_ROOT_PATH\n)\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot)\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath)\n }\n return ABSOLUTE_ROOT\n}\nContext.prototype.P = resolveAbsolutePath\n\n/**\n * Returns an absolute `file://` URL for the given module path.\n *\n * Uses `url.pathToFileURL` so that the resulting URL is a valid file URI on\n * all platforms (forward slashes on Windows, drive letters handled\n * correctly, path segments URL-encoded).\n */\nfunction resolveFileUrl(modulePath?: string): string {\n return require('url').pathToFileURL(resolveAbsolutePath(modulePath)).href\n}\nContext.prototype.F = resolveFileUrl\n"],"names":["path","require","relativePathToRuntimeRoot","relative","RUNTIME_PUBLIC_PATH","relativePathToDistRoot","join","RELATIVE_ROOT_PATH","RUNTIME_ROOT","resolve","__filename","ABSOLUTE_ROOT","resolveAbsolutePath","modulePath","Context","prototype","P","resolveFileUrl","pathToFileURL","href","F"],"mappings":"AAAA,oDAAoD,GAMpD,MAAMA,OAAOC,QAAQ;AAErB,MAAMC,4BAA4BF,KAAKG,QAAQ,CAACC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAMC,yBAAyBL,KAAKM,IAAI,CACtCJ,2BACAK;AAEF,MAAMC,eAAeR,KAAKS,OAAO,CAACC,YAAYR;AAC9C,mGAAmG;AACnG,MAAMS,gBAAgBX,KAAKS,OAAO,CAACC,YAAYL;AAE/C;;;;;;;CAOC,GACD,SAASO,oBAAoBC,UAAmB;IAC9C,IAAIA,YAAY;QACd,OAAOb,KAAKM,IAAI,CAACK,eAAeE;IAClC;IACA,OAAOF;AACT;AACAG,QAAQC,SAAS,CAACC,CAAC,GAAGJ;AAEtB;;;;;;CAMC,GACD,SAASK,eAAeJ,UAAmB;IACzC,OAAOZ,QAAQ,OAAOiB,aAAa,CAACN,oBAAoBC,aAAaM,IAAI;AAC3E;AACAL,QAAQC,SAAS,CAACK,CAAC,GAAGH","ignoreList":[0]}},
{"offset": {"line": 602, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/runtime-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../../shared/runtime/runtime-utils.ts\" />\n/// <reference path=\"../../shared-node/base-externals-utils.ts\" />\n/// <reference path=\"../../shared-node/node-externals-utils.ts\" />\n/// <reference path=\"./nodejs-globals.d.ts\" />\n\n/**\n * Base Node.js runtime shared between production and development.\n * Contains chunk loading, module caching, and other non-HMR functionality.\n */\n\nprocess.env.TURBOPACK = '1'\n\nconst url = require('url') as typeof import('url')\n\nconst moduleFactories: ModuleFactories = new Map()\nconst moduleCache: ModuleCache<Module> = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction resolvePathFromModule(\n this: TurbopackBaseContext<Module>,\n moduleId: string\n): string {\n const exported = this.r(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n}\n\n/**\n * Exports a URL value. No suffix is added in Node.js runtime.\n */\nfunction exportUrl(\n this: TurbopackBaseContext<Module>,\n urlValue: string,\n id: ModuleId | undefined\n) {\n exportValue.call(this, urlValue, id)\n}\n\nfunction loadRuntimeChunk(sourcePath: ChunkPath, chunkData: ChunkData): void {\n if (typeof chunkData === 'string') {\n loadRuntimeChunkPath(sourcePath, chunkData)\n } else {\n loadRuntimeChunkPath(sourcePath, chunkData.path)\n }\n}\n\nconst loadedChunks = new Set<ChunkPath>()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise<void> = Promise.resolve(undefined)\nconst chunkCache = new Map<ChunkPath, Promise<void>>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n loadedChunks.clear()\n}\n\nfunction loadRuntimeChunkPath(\n sourcePath: ChunkPath,\n chunkPath: ChunkPath\n): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n loadedChunks.add(chunkPath)\n } catch (cause) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (sourcePath) {\n errorMessage += ` from runtime for chunk ${sourcePath}`\n }\n\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n throw error\n }\n}\n\nfunction loadChunkAsync<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkData: ChunkData\n): Promise<void> {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io\n // However this is incompatible with hot reloading (since `import` doesn't use the require cache)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n entry = loadedChunk\n } catch (cause) {\n const errorMessage = `Failed to load chunk ${chunkPath} from module ${this.m.id}`\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(error)\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\ncontextPrototype.l = loadChunkAsync\n\nfunction loadChunkAsyncByUrl<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkUrl: string\n) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync.call(this, path)\n}\ncontextPrototype.L = loadChunkAsyncByUrl\n\n// Shared runtime primitive: the root that on-disk chunk paths are resolved\n// against. Used by the bundled wasm helper (exposed as `__turbopack_runtime_root__`).\ncontextPrototype.w = RUNTIME_ROOT\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n"],"names":["process","env","TURBOPACK","url","require","moduleFactories","Map","moduleCache","Object","create","resolvePathFromModule","moduleId","exported","r","exportedPath","default","strippedAssetPrefix","slice","ASSET_PREFIX","length","resolved","path","resolve","RUNTIME_ROOT","pathToFileURL","href","exportUrl","urlValue","id","exportValue","call","loadRuntimeChunk","sourcePath","chunkData","loadRuntimeChunkPath","loadedChunks","Set","unsupportedLoadChunk","Promise","undefined","loadedChunk","chunkCache","clearChunkCache","clear","chunkPath","isJs","has","chunkModules","installCompressedModuleFactories","add","cause","errorMessage","error","Error","name","loadChunkAsync","entry","get","m","reject","set","contextPrototype","l","loadChunkAsyncByUrl","chunkUrl","path1","fileURLToPath","URL","L","w","regexJsUrl","chunkUrlOrPath","test"],"mappings":"AAAA,oDAAoD,GAEpD,8DAA8D;AAC9D,kEAAkE;AAClE,kEAAkE;AAClE,8CAA8C;AAE9C;;;CAGC,GAEDA,QAAQC,GAAG,CAACC,SAAS,GAAG;AAExB,MAAMC,MAAMC,QAAQ;AAEpB,MAAMC,kBAAmC,IAAIC;AAC7C,MAAMC,cAAmCC,OAAOC,MAAM,CAAC;AAEvD;;CAEC,GACD,SAASC,sBAEPC,QAAgB;IAEhB,MAAMC,WAAW,IAAI,CAACC,CAAC,CAACF;IACxB,MAAMG,eAAeF,UAAUG,WAAWH;IAC1C,IAAI,OAAOE,iBAAiB,UAAU;QACpC,OAAOF;IACT;IAEA,MAAMI,sBAAsBF,aAAaG,KAAK,CAACC,aAAaC,MAAM;IAClE,MAAMC,WAAWC,KAAKC,OAAO,CAACC,cAAcP;IAE5C,OAAOb,IAAIqB,aAAa,CAACJ,UAAUK,IAAI;AACzC;AAEA;;CAEC,GACD,SAASC,UAEPC,QAAgB,EAChBC,EAAwB;IAExBC,YAAYC,IAAI,CAAC,IAAI,EAAEH,UAAUC;AACnC;AAEA,SAASG,iBAAiBC,UAAqB,EAAEC,SAAoB;IACnE,IAAI,OAAOA,cAAc,UAAU;QACjCC,qBAAqBF,YAAYC;IACnC,OAAO;QACLC,qBAAqBF,YAAYC,UAAUZ,IAAI;IACjD;AACF;AAEA,MAAMc,eAAe,IAAIC;AACzB,MAAMC,uBAAuBC,QAAQhB,OAAO,CAACiB;AAC7C,MAAM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ACjF,MAAMwB,QAAQ,IAAIC,MAAMF,cAAc;gBAAED;YAAM;YAC9CE,MAAME,IAAI,GAAG;YAEb,+EAA+E;YAC/EE,QAAQlB,QAAQqB,MAAM,CAACP;QACzB;QACAX,WAAWmB,GAAG,CAAChB,WAAWY;IAC5B;IACA,sGAAsG;IACtG,OAAOA;AACT;AACAK,iBAAiBC,CAAC,GAAGP;AAErB,SAASQ,oBAEPC,QAAgB;IAEhB,MAAMC,QAAO9D,IAAI+D,aAAa,CAAC,IAAIC,IAAIH,UAAUzC;IACjD,OAAOgC,eAAezB,IAAI,CAAC,IAAI,EAAEmC;AACnC;AACAJ,iBAAiBO,CAAC,GAAGL;AAErB,2EAA2E;AAC3E,sFAAsF;AACtFF,iBAAiBQ,CAAC,GAAG9C;AAErB,MAAM+C,aAAa;AACnB;;CAEC,GACD,SAASzB,KAAK0B,cAAoC;IAChD,OAAOD,WAAWE,IAAI,CAACD;AACzB","ignoreList":[0]}},
{"offset": {"line": 717, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/build-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-base.ts\" />\n\n/**\n * Production Node.js runtime.\n * Uses ModuleWithDirection and simple module instantiation without HMR support.\n */\n\n// moduleCache and moduleFactories are declared in runtime-base.ts\n\n// this is read in runtime-utils.ts so it creates a module with direction for hmr\ncreateModuleWithDirectionFlag = true\n\ninterface TurbopackNodeBuildContext\n extends TurbopackBaseContext<ModuleWithDirection> {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n C: typeof clearChunkCache\n}\n\nconst nodeContextPrototype = Context.prototype as TurbopackNodeBuildContext\n\nnodeContextPrototype.q = exportUrl\nnodeContextPrototype.M = moduleFactories\n// Cast moduleCache to ModuleWithDirection for production mode\nnodeContextPrototype.c = moduleCache as ModuleCache<ModuleWithDirection>\nnodeContextPrototype.R = resolvePathFromModule\nnodeContextPrototype.C = clearChunkCache\n\nfunction instantiateModule(\n id: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): ModuleWithDirection {\n const moduleFactory = moduleFactories.get(id)\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData))\n }\n\n const module: ModuleWithDirection = createModuleWithDirection(id)\n const exports = module.exports\n moduleCache[id] = module\n\n const context =\n new (Context as any as ContextConstructor<ModuleWithDirection>)(\n module,\n exports\n )\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n moduleFactory(context, module, exports)\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n ;(module as any).loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: ModuleWithDirection\n): ModuleWithDirection {\n const module = moduleCache[id]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n\n return module\n }\n\n return instantiateModule(id, SourceType.Parent, sourceModule.id)\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n return instantiateModule(moduleId, SourceType.Runtime, chunkPath)\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n const module = moduleCache[moduleId]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(chunkPath, moduleId)\n}\n\nmodule.exports = (sourcePath: ChunkPath) => ({\n m: (id: ModuleId) => getOrInstantiateRuntimeModule(sourcePath, id),\n c: (chunkData: ChunkData) => loadRuntimeChunk(sourcePath, chunkData),\n})\n"],"names":["createModuleWithDirectionFlag","nodeContextPrototype","Context","prototype","q","exportUrl","M","moduleFactories","c","moduleCache","R","resolvePathFromModule","C","clearChunkCache","instantiateModule","id","sourceType","sourceData","moduleFactory","get","Error","factoryNotAvailableMessage","module1","createModuleWithDirection","exports","context","error","loaded","namespaceObject","interopEsm","getOrInstantiateModuleFromParent","sourceModule","SourceType","Parent","instantiateRuntimeModule","chunkPath","moduleId","Runtime","getOrInstantiateRuntimeModule","module","sourcePath","m","chunkData","loadRuntimeChunk"],"mappings":"AAAA,oDAAoD,GAEpD,0CAA0C;AAE1C;;;CAGC,GAED,kEAAkE;AAElE,iFAAiF;AACjFA,gCAAgC;AAUhC,MAAMC,uBAAuBC,QAAQC,SAAS;AAE9CF,qBAAqBG,CAAC,GAAGC;AACzBJ,qBAAqBK,CAAC,GAAGC;AACzB,8DAA8D;AAC9DN,qBAAqBO,CAAC,GAAGC;AACzBR,qBAAqBS,CAAC,GAAGC;AACzBV,qBAAqBW,CAAC,GAAGC;AAEzB,SAASC,kBACPC,EAAY,EACZC,UAAsB,EACtBC,UAAsB;IAEtB,MAAMC,gBAAgBX,gBAAgBY,GAAG,CAACJ;IAC1C,IAAI,OAAOG,kBAAkB,YAAY;QACvC,sEAAsE;QACtE,0EAA0E;QAC1E,mDAAmD;QACnD,MAAM,IAAIE,MAAMC,2BAA2BN,IAAIC,YAAYC;IAC7D;IAEA,MAAMK,UAA8BC,0BAA0BR;IAC9D,MAAMS,UAAUF,QAAOE,OAAO;IAC9Bf,WAAW,CAACM,GAAG,GAAGO;IAElB,MAAMG,UACJ,IAAKvB,QACHoB,SACAE;IAEJ,4EAA4E;IAC5E,IAAI;QACFN,cAAcO,SAASH,SAAQE;IACjC,EAAE,OAAOE,OAAO;QACdJ,QAAOI,KAAK,GAAGA;QACf,MAAMA;IACR;;IAEEJ,QAAeK,MAAM,GAAG;IAC1B,IAAIL,QAAOM,eAAe,IAAIN,QAAOE,OAAO,KAAKF,QAAOM,eAAe,EAAE;QACvE,yDAAyD;QACzDC,WAAWP,QAAOE,OAAO,EAAEF,QAAOM,eAAe;IACnD;IAEA,OAAON;AACT;AAEA;;CAEC,GACD,aAAa;AACb,SAASQ,iCACPf,EAAY,EACZgB,YAAiC;IAEjC,MAAMT,UAASb,WAAW,CAACM,GAAG;IAE9B,IAAIO,SAAQ;QACV,IAAIA,QAAOI,KAAK,EAAE;YAChB,MAAMJ,QAAOI,KAAK;QACpB;QAEA,OAAOJ;IACT;IAEA,OAAOR,kBAAkBC,IAAIiB,WAAWC,MAAM,EAAEF,aAAahB,EAAE;AACjE;AAEA;;CAEC,GACD,SAASmB,yBACPC,SAAoB,EACpBC,QAAkB;IAElB,OAAOtB,kBAAkBsB,UAAUJ,WAAWK,OAAO,EAAEF;AACzD;AAEA;;CAEC,GACD,oFAAoF;AACpF,SAASG,8BACPH,SAAoB,EACpBC,QAAkB;IAElB,MAAMd,UAASb,WAAW,CAAC2B,SAAS;IAEpC,IAAId,SAAQ;QACV,IAAIA,QAAOI,KAAK,EAAE;YAChB,MAAMJ,QAAOI,KAAK;QACpB;QACA,OAAOJ;IACT;IAEA,OAAOY,yBAAyBC,WAAWC;AAC7C;AAEAG,OAAOf,OAAO,GAAG,CAACgB,aAA0B,CAAC;QAC3CC,GAAG,CAAC1B,KAAiBuB,8BAA8BE,YAAYzB;QAC/DP,GAAG,CAACkC,YAAyBC,iBAAiBH,YAAYE;IAC5D,CAAC","ignoreList":[0]}}]
}
\ No newline at end of file
var R=require("./[turbopack]_runtime.js")("output/index.entry.js")
R.c("output/1jsg_tests_snapshot_cjs-remove-unused-exports_webpack-parity_input_1sbzh_1p37sm6._.js")
R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/index.js [test] (ecmascript)")
module.exports=R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/cjs-remove-unused-exports/webpack-parity/input/index.js [test] (ecmascript)").exports
\ 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