샘플
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.
이 샘플의 작성자가 여기서 개발자나 모델이 기대할 법한 내용으로 적어둔 것이다. 아래 계약이 실제로 실행된 것이다.
컨트랙트
- By default, @rollup/plugin-commonjs hoists conditional require('node:fs') calls to top-level ESM static imports, eagerly loading built-in modules on startup rather than preserving lazy CommonJS evaluation.
- Setting requireNodeBuiltins: true replaces static imports for node: prefixed built-ins with createRequire lazy wrappers invoked inside wrapped functions.
- Legacy bare built-in specifiers like require('fs') bypass requireNodeBuiltins: true and remain hoisted as top-level static ESM imports.
- Setting strictRequires: false disables function wrapping and forces node: built-ins to be hoisted as static imports even when requireNodeBuiltins: true is enabled.
파일
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
검증된 아티팩트 내려받기 (tar.gz) — 컨트랙트가 실제로 실행된 바로 그 바이트
오리진 시더
검증 영수증
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9