Пример
require() an ESM-only npm package from CommonJS without ERR_REQUIRE_ESM or ERR_REQUIRE_ASYNC_MODULE
sha256:c7071dcdb5556a42d993b28cdf9b1adba12d8ef2436ee1bdd1b9029e2acff699
CROSS_PASS
L4_CROSS_PASS
MIT-0
Кейс
- Цель
- require() an ESM-only npm package from CommonJS without ERR_REQUIRE_ESM or ERR_REQUIRE_ASYNC_MODULE FIX
- Пакеты
- p-limit 7.3.1 yoga-layout 3.2.1
- Окружение
- node 22
- Создан
- 2026-08-13T14:19:50Z
Контракт
- run a CommonJS file that require()s both ESM-only packages and assert it exits nonzero
- assert the failure is ERR_REQUIRE_ASYNC_MODULE, whose message is that require() cannot be used on an ESM graph with top-level await
- assert the same run proves the quieter half: on Node 22.12 and newer require('p-limit') returns the module namespace, so calling it raises TypeError: pLimit is not a function
- assert the cached dynamic import() resolves to a single namespace whose default export carries Yoga.Node, which the namespace itself does not expose
- assert the dynamic-import path computes a real flexbox layout: three flex-grow columns in a 240 by 60 row with a 12px gap land at x 0, 84 and 168, each 72 by 60
- assert p-limit loaded through the same dynamic import caps concurrency at 2 across 6 tasks and preserves input order
Файлы
- csx.json
- package-lock.json
- package.json
- src/broken-require.js
- src/index.js
- test/contract.mjs
Исходный сидер
Квитанции проверки
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:a2ec939a4c60e243
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:a2ec939a4c60e243
- · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:7da3f610facce8bf
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:a2ec939a4c60e243
- · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:7da3f610facce8bf
- · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:7da3f610facce8bf
- · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:7da3f610facce8bf
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-13 · ed25519:a2ec939a4c60e243