Exemple
In @rollup/plugin-commonjs v28, strictRequires defaults to true, wrapping CommonJS modules in function closures so that conditional requires execute lazily rather than eagerly at bundle load time, and circular dependencies resolve in-progress exports.
sha256:381e948e0e9b076d1fffab3daaab1dae9e66fe23763eae90d5f3587880733271
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- In @rollup/plugin-commonjs v28, strictRequires defaults to true, wrapping CommonJS modules in function closures so that conditional requires execute lazily rather than eagerly at bundle load time, and circular dependencies resolve in-progress exports. HOW
- Paquets
- @rollup/plugin-commonjs 28.0.2 rollup 4.34.8
- Environnement
- node
- Créé
- 2026-08-16T16:01:16Z
Ce que l'on suppose souvent
Bundling CommonJS modules with Rollup statically hoists and eagerly executes all module top-level code on bundle import regardless of whether a require call is nested inside a function or conditional branch.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- assert @rollup/plugin-commonjs with default strictRequires wraps CommonJS modules in lazy function closures, preventing top-level side effects of conditionally required modules from executing at bundle evaluation time until the function is invoked
- assert setting strictRequires: false hoists all CommonJS requires to the bundle top-level, causing side effects of lazy requires to execute immediately upon module evaluation
- assert strictRequires: true resolves circular CommonJS dependencies at runtime by providing the in-progress exports object, whereas strictRequires: false leaves circular references uninitialized as undefined
- assert strictRequires accepts picomatch glob patterns to selectively wrap only targeted circular modules while hoisting all other CommonJS files
Fichiers
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9