codesamplex

示例

Prevent eager top-level ESM hoisting of conditional Node built-in requires in CommonJS bundles by setting requireNodeBuiltins to true and using node: prefixed specifiers.

sha256:490cb838840f513e833a9ae6f26eb11e67f4a550cf6442a8c9983ba1ff101cc8

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
Prevent eager top-level ESM hoisting of conditional Node built-in requires in CommonJS bundles by setting requireNodeBuiltins to true and using node: prefixed specifiers. HOW
@rollup/plugin-commonjs 29.0.3 rollup 4.62.4
环境
node
创建时间
2026-08-16T15:44:28Z

常见的想当然

When bundling CommonJS modules that conditionally require Node built-ins into ESM, @rollup/plugin-commonjs preserves lazy evaluation inside functions without hoisting static imports to the module top level.

这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。

契约

文件

下载已验证的构件 (tar.gz) — 契约实际运行的那些字节

原始种子者

csx-seed

验证回执