샘플
@rollup/plugin-commonjs 29.0.3: ignoreTryCatch
검증된 샘플 — npm @rollup/plugin-commonjs 29.0.3: ignoreTryCatch. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: By default, @rollup/plugin-commonjs…
sha256:d8b4a7d44e66ca9e49856354ceee9722a12adacd7ab94b7e36119939ed9f994b
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-03 |
케이스
HOW- 목표
- verify pkg:npm/%40rollup/plugin-commonjs@29.0.3
- 심벌
-
- @rollup/plugin-commonjs
- ignoreTryCatch
- 환경
- node 22.23.2
- 생성일
- 2026-09-03T12:34:51Z
컨트랙트
- By default, @rollup/plugin-commonjs leaves external require calls inside try-catch blocks untransformed as dynamic require() calls, preventing top-level static ESM imports.
- Setting ignoreTryCatch: false hoists external require calls inside try-catch to top-level static ESM imports, bypassing runtime try-catch error handling.
- Setting ignoreTryCatch: 'remove' replaces external require calls inside try-catch with undefined inline without emitting static ESM imports.
- Specifying an array of module IDs in ignoreTryCatch selectively preserves matching IDs as unconverted requires while hoisting non-matching IDs to static imports.
- Providing a filter function to ignoreTryCatch dynamically evaluates external module IDs and supports returning 'remove', true, or false per module ID.
파일
- NOTES.md
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
# Notes: Rollup CommonJS Plugin Optional Dependency Handling with ignoreTryCatch
## Search Result
`search_known_solution` returned `NO_SAFE_MATCH` for `ignoreTryCatch` in `@rollup/plugin-commonjs@29.0.3`. Existing public samples for this version only cover `defaultIsModuleExports`, `requireNodeBuiltins`, and `esmExternals`. This sample verifies optional external dependency resolution and import hoisting control via `ignoreTryCatch`.
## Naive Model Assumption
Developers and models often assume that `@rollup/plugin-commonjs` either always hoists external require statements to top-level static imports regardless of try-catch blocks, or conversely that setting `ignoreTryCatch: false` will gracefully catch import failures at runtime.
## Failure Mode
When `ignoreTryCatch: false` is configured, external require calls located inside try-catch clauses are converted into top-level static ESM imports (`import require$$0 from 'dep'`). If the external dependency is optional or missing at runtime, the module loader aborts immediately with a startup error (such as `ERR_MODULE_NOT_FOUND`) during module evaluation before any user code or try-catch block can execute. In contrast, the default `ignoreTryCatch: true` preserves the dynamic `require()` call inside the try-catch block, and `ignoreTryCatch: 'remove'` replaces the require call with `undefined` inline to completely avoid both startup crashes and runtime resolution errors.
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/%40rollup/plugin-commonjs@29.0.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40rollup/plugin-commonjs@29.0.3
Demonstrate these symbols/APIs:
- ignoreTryCatch
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"believed":"When bundling CommonJS modules that wrap external require calls inside try-catch blocks into ESM, @rollup/plugin-commonjs always hoists the requires to top-level static imports or always preserves runtime try-catch error handling.","caseId":"case:sha256:a044e1bd6e862c00dbde8c946946102740b1e8514f3df85f97d513df7256f7d4","constraints":{"executionContext":"node"},"contract":["By default, @rollup/plugin-commonjs leaves external require calls inside try-catch blocks untransformed as dynamic require() calls, preventing top-level static ESM imports.","Setting ignoreTryCatch: false hoists external require calls inside try-catch to top-level static ESM imports, bypassing runtime try-catch error handling.","Setting ignoreTryCatch: 'remove' replaces external require calls inside try-catch with undefined inline without emitting static ESM imports.","Specifying an array of module IDs in ignoreTryCatch selectively preserves matching IDs as unconverted requires while hoisting non-matching IDs to static imports.","Providing a filter function to ignoreTryCatch dynamically evaluates external module IDs and supports returning 'remove', true, or false per module ID."],"goal":"verify pkg:npm/%40rollup/plugin-commonjs@29.0.3","kind":"HOW","packages":["pkg:npm/%40rollup/plugin-commonjs@29.0.3"],"schemaVersion":1,"symbols":["@rollup/plugin-commonjs","ignoreTryCatch"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40rollup/plugin-commonjs@29.0.3"],"schemaVersion":1,"subject":"pkg:npm/%40rollup/plugin-commonjs@29.0.3","symbols":["@rollup/plugin-commonjs","ignoreTryCatch"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-rollup-plugin-commonjs-ignore-try-catch",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-rollup-plugin-commonjs-ignore-try-catch",
"version": "1.0.0",
"dependencies": {
"@rollup/plugin-commonjs": "29.0.3",
"rollup": "4.62.4"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
"license": "MIT"
},
"node_modules/@napi-rs/lzma-linux-x64-gnu": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
"integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": "^22.20 || ^24.12 || >=25"
}
},
"node_modules/@rollup/plugin-commonjs": {
"version": "29.0.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-29.0.3.tgz",
"integrity": "sha512-ZaOxZceP7SOUW7Lqw5IRVweSQYWaeIPnXIGLiB690EBA3FGJTO40EEr2L5yZplJWsgTCogILRSpcAe7+U0Otdg==",
"license": "MIT",
"dependencies": {
"@rollup/pluginutils": "^5.0.1",
"commondir": "^1.0.1",
"estree-walker": "^2.0.2",
"fdir": "^6.2.0",
"is-reference": "1.2.1",
"magic-string": "^0.30.3",
"picomatch": "^4.0.2"
},
"engines": {
"node": ">=16.0.0 || 14 >= 14.17"
},
"peerDependencies": {
"rollup": "^2.68.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/pluginutils": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.4.0.tgz",
"integrity": "sha512-MfPp06CjRLfXQ3wY0R8vJDYBy/MvVcc9OulEfR0B8Iv9ko+GCNaRZ+EpJYFl27LhKsZK0o420sYCRHCjfCgeUg==",
"license": "MIT",
"dependencies": {
"@types/estree": "^1.0.0",
"estree-walker": "^2.0.2",
"picomatch": "^4.0.2"
},
"engines": {
"node": ">=14.0.0"
},
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.4.tgz",
"integrity": "sha512-RrPokAb7dmbxFoeO3TloqHyOjgye8RkBhSqmp4aJMIex4c9r46ZstPnleDQOq1t46VOVjwIuwNogIqbodV1Vvg==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@rollup/rollup-android-arm64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.4.tgz",
"integrity": "sha512-JKuJc+pnpks2pjy7L/N3v/cAkZxYlnmuZoD840ldbMI5KDbC4iO9NKwPKYdjYFCMAIIlBzYSFHxIJVYzRo2/8A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@rollup/rollup-darwin-arm64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.4.tgz",
"integrity": "sha512-krw5uS2STmvJ02x0uTXHbqQNuz+9eZ1iw+qXk9dmW2gvV4jV7O2hEoOnuhFrpOPiel1mBFtqbxYZZtC46hXLOw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@rollup/rollup-darwin-x64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.4.tgz",
"integrity": "sha512-wsTxtgApb4PrOsNJIm0FZ1h3WvCC+k9uxLJ4ad75hgoS4NiRes2SoJFlDAyMwiUY8IssDqGcHbXuN0sx1tfF1A==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@rollup/rollup-freebsd-arm64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.4.tgz",
"integrity": "sha512-GUOnQlyZe3yAXhWOtOMsn5Qkrv5E5mZXa0thbARWi5Ei2szlVXJFQhddZ4HbAzh8q92w5twp+CQvs/eFanz9YQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@rollup/rollup-freebsd-x64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.4.tgz",
"integrity": "sha512-/Y7f3QuxjzPKsjA/rfEDa3+0vXqyjmJ50Ln8dPpCmWkKTrUoWHG1cWhTqaAMLob2m2nESWuC7yGrREz019Ztqg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.4.tgz",
"integrity": "sha512-81wiiX3v7aqy+T+bT61TJ78yJjRquqFFTTbAPt08imfQQzkPIW8t6aJbkTagtCCrXMNc9D66+geqlK7ydLPNqA==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.4.tgz",
"integrity": "sha512-9kmDIvNZqdoHOBZgNtpTBeLWYO/LVipM3H/j62P8848/l/VPEQL6N3uxU9pvP1oZAsXyC2MEnFP3ovRjo7WYNQ==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.4.tgz",
"integrity": "sha512-CcnXHWnXg69g+DX5VWL3FHts3qMRN2uVEHX+BZvGLdd07/gXkn3ePjYtO1LDJvxkGKVHMclKBRa1QUTH+6toYQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm64-musl": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.4.tgz",
"integrity": "sha512-iFOibiHnTRuhrWLlRsOQFdZJJIa7S8OwkneJr4ocALP16u5yk6lWLINFwhHaEqBFMsKDUZofLkGos7+CPzGB3g==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-loong64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.4.tgz",
"integrity": "sha512-XnWYMI7euHlb5a871xPja+Gm7DRCFU+FGRrtS2sMq9N8FvqtpagUy6gD4YOemC5MRk9xbh8+jYMEJbigFQwsgA==",
"cpu": [
"loong64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-loong64-musl": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.4.tgz",
"integrity": "sha512-qGDAlO0U8xedCcsdRm9oaoQY8DAx/QT7uIxJWhCdx0ceIWX783UC9QSYkdpzAe29wNiVfp24+bZdQmn49o45SQ==",
"cpu": [
"loong64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-ppc64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.4.tgz",
"integrity": "sha512-ru4H6ezD7ysA5EiEK6qkkaEb4modH8CTej6kUy/gQi20u3kB3G7Zn8snXXkeJSCOFKG/rbPPtM/+9Wgas1961w==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-ppc64-musl": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.4.tgz",
"integrity": "sha512-2W4MO5WQVJnbJaZdvDb9rhBDuFU1nKIepPFpJUBsTh2k1YY2g+ODViaWuyOAjQ5cOP7NvrvLzt3wvHOoiAvc7w==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.4.tgz",
"integrity": "sha512-+fxjfuoAmVMCYV5QyjoIpu0cp5DOiOTeqYFk1AVaxGr+/ravWLX89XfQmptsoWcaVy/TGf2hexzbUOrCQIL1CQ==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-riscv64-musl": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.4.tgz",
"integrity": "sha512-jTn8JfHGL4djjFxPuM06LmNUJDsst2jeVlsd9OmIH6zc5sC9K6rIuO4YajXatLUpBmBKl6b35ro1QZocLi+tcA==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-s390x-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.4.tgz",
"integrity": "sha512-oCJCJL4pXsoDcP2QZ+JVlPTIRc6266zsIaeJJsWImmF7HO0W8nb6HuSgZlMWxJwaPf8ehbSw8yo0EUw925hKsA==",
"cpu": [
"s390x"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.4.tgz",
"integrity": "sha512-W69hukhZ3KKNRCaMIEzKvcFye42hh0FE1+YoYaf5+Ikacuftoco6yO/xouz0hc5d5W/s3yBro5jRiuEE/Q5vUw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-x64-musl": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.4.tgz",
"integrity": "sha512-qiXbGG2jkjXhzXpsFZSR2Xpb8DN/UaxYsbb/STbuR/6fpaDgRmmaq1B/LmtF2wQFOFOSsK2jdE0RZ3a0zHn4QA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-openbsd-x64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.4.tgz",
"integrity": "sha512-nWeM//hxv8mIo6jD7Hu4o48DVmV9pbV6gsKaWU+4NFyqHoPKwrkRiZGLKUhOBk8qNmDmpwFtPKg80Bo/Tn4xiQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"openbsd"
]
},
"node_modules/@rollup/rollup-openharmony-arm64": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.4.tgz",
"integrity": "sha512-s62SQ/vgsRSvMwDkOEfTqfgASF0f26ZNaQuTA6Aok5lrikf89yI2W0gFHvZb2Jpgc6N8JnOKZgCK2iciO3CsxQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"openharmony"
]
},
"node_modules/@rollup/rollup-win32-arm64-msvc": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.4.tgz",
"integrity": "sha512-J6wGf8TVGbXJq+HH+ttTvrcfNKPbuZecV6KT1B8I18BC5IURUh5kl4Yl5OEP5eFIUoI5BWxCsyYMhFsDx8kekw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-ia32-msvc": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.4.tgz",
"integrity": "sha512-zmfrQd/0wu6oJs8Vq8KwY/YtsKSsLtKe/HwAP4Wqy8LhWjeT55fHRAkOhYQ12wI3ayS4Tt12d5CDRD7N96SAYQ==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-x64-gnu": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.4.tgz",
"integrity": "sha512-qPzHqdj9rfUD+w79dtE07zi/kFwKyCJqplp5K5ygeLTp7jLpAoc16OAH39HSmRC9UpozaecsleI8uAdEj6v2yw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-x64-msvc": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.4.tgz",
"integrity": "sha512-zD6NdeWEByGE9QF9vCrlJ5YQB4oq9q91kPZS37Jwj5hOkvR1lTBSpsKhKDw4IJtbQ35LsTS1HD9DZYGKIshU1Q==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@types/estree": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
"integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
"license": "MIT"
},
"node_modules/commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==",
"license": "MIT"
},
"node_modules/estree-walker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
"license": "MIT"
},
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
"license": "MIT",
"dependencies": {
"@types/estree": "*"
}
},
"node_modules/magic-string": {
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.5"
}
},
"node_modules/picomatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/rollup": {
"version": "4.62.4",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz",
"integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==",
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.9"
},
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"optionalDependencies": {
"@napi-rs/lzma-linux-x64-gnu": "1.5.1",
"@rollup/rollup-android-arm-eabi": "4.62.4",
"@rollup/rollup-android-arm64": "4.62.4",
"@rollup/rollup-darwin-arm64": "4.62.4",
"@rollup/rollup-darwin-x64": "4.62.4",
"@rollup/rollup-freebsd-arm64": "4.62.4",
"@rollup/rollup-freebsd-x64": "4.62.4",
"@rollup/rollup-linux-arm-gnueabihf": "4.62.4",
"@rollup/rollup-linux-arm-musleabihf": "4.62.4",
"@rollup/rollup-linux-arm64-gnu": "4.62.4",
"@rollup/rollup-linux-arm64-musl": "4.62.4",
"@rollup/rollup-linux-loong64-gnu": "4.62.4",
"@rollup/rollup-linux-loong64-musl": "4.62.4",
"@rollup/rollup-linux-ppc64-gnu": "4.62.4",
"@rollup/rollup-linux-ppc64-musl": "4.62.4",
"@rollup/rollup-linux-riscv64-gnu": "4.62.4",
"@rollup/rollup-linux-riscv64-musl": "4.62.4",
"@rollup/rollup-linux-s390x-gnu": "4.62.4",
"@rollup/rollup-linux-x64-gnu": "4.62.4",
"@rollup/rollup-linux-x64-musl": "4.62.4",
"@rollup/rollup-openbsd-x64": "4.62.4",
"@rollup/rollup-openharmony-arm64": "4.62.4",
"@rollup/rollup-win32-arm64-msvc": "4.62.4",
"@rollup/rollup-win32-ia32-msvc": "4.62.4",
"@rollup/rollup-win32-x64-gnu": "4.62.4",
"@rollup/rollup-win32-x64-msvc": "4.62.4",
"fsevents": "~2.3.2"
}
}
}
}
{
"name": "sample-rollup-plugin-commonjs-ignore-try-catch",
"version": "1.0.0",
"type": "commonjs",
"dependencies": {
"@rollup/plugin-commonjs": "29.0.3",
"rollup": "4.62.4"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40rollup/plugin-commonjs@29.0.3",
"kind": "HOW",
"packages": [
"pkg:npm/%40rollup/plugin-commonjs@29.0.3"
],
"symbols": [
"ignoreTryCatch"
]
}
import assert from 'node:assert/strict';
import { rollup } from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
async function runContract() {
// ---------------------------------------------------------------------------
// Contract 1:
// By default, @rollup/plugin-commonjs leaves external require calls inside
// try-catch blocks untransformed as dynamic require() calls, preventing top-level
// static ESM imports.
// ---------------------------------------------------------------------------
{
const bundle = await rollup({
input: 'entry-default.js',
external: ['optional-pkg'],
plugins: [
{
name: 'virtual-loader',
resolveId(id) {
if (id === 'entry-default.js') return id;
},
load(id) {
if (id === 'entry-default.js') {
return `
let dep;
try {
dep = require('optional-pkg');
} catch (err) {
dep = 'fallback';
}
module.exports = { dep };
`;
}
}
},
commonjs()
]
});
const { output } = await bundle.generate({ format: 'es' });
const code = output[0].code;
assert.equal(
code.includes("from 'optional-pkg'"),
false,
'Default ignoreTryCatch: true must not hoist static ESM import for optional-pkg'
);
assert.match(
code,
/try\s*\{\s*dep\s*=\s*require\('optional-pkg'\);\s*\}\s*catch/,
'Default ignoreTryCatch: true preserves dynamic require call inside try block'
);
}
// ---------------------------------------------------------------------------
// Contract 2:
// Setting ignoreTryCatch: false hoists external require calls inside try-catch
// to top-level static ESM imports, bypassing runtime try-catch error handling.
// ---------------------------------------------------------------------------
{
const bundle = await rollup({
input: 'entry-false.js',
external: ['optional-pkg'],
plugins: [
{
name: 'virtual-loader',
resolveId(id) {
if (id === 'entry-false.js') return id;
},
load(id) {
if (id === 'entry-false.js') {
return `
let dep;
try {
dep = require('optional-pkg');
} catch (err) {
dep = 'fallback';
}
module.exports = { dep };
`;
}
}
},
commonjs({
ignoreTryCatch: false
})
]
});
const { output } = await bundle.generate({ format: 'es' });
const code = output[0].code;
assert.match(
code,
/^import\s+require\$\$\d+\s+from\s+'optional-pkg';/m,
'ignoreTryCatch: false hoists static ESM import to top-level'
);
assert.match(
code,
/try\s*\{\s*dep\s*=\s*require\$\$\d+;\s*\}\s*catch/,
'ignoreTryCatch: false assigns imported variable inside try block'
);
assert.equal(
code.includes("require('optional-pkg')"),
false,
'ignoreTryCatch: false eliminates dynamic require call'
);
}
// ---------------------------------------------------------------------------
// Contract 3:
// Setting ignoreTryCatch: 'remove' replaces external require calls inside try-catch
// with undefined inline without emitting static ESM imports.
// ---------------------------------------------------------------------------
{
const bundle = await rollup({
input: 'entry-remove.js',
external: ['optional-pkg'],
plugins: [
{
name: 'virtual-loader',
resolveId(id) {
if (id === 'entry-remove.js') return id;
},
load(id) {
if (id === 'entry-remove.js') {
return `
let dep;
try {
dep = require('optional-pkg');
} catch (err) {
dep = 'fallback';
}
module.exports = { dep };
`;
}
}
},
commonjs({
ignoreTryCatch: 'remove'
})
]
});
const { output } = await bundle.generate({ format: 'es' });
const code = output[0].code;
assert.equal(
code.includes("from 'optional-pkg'"),
false,
'ignoreTryCatch: "remove" must not hoist static ESM import'
);
assert.match(
code,
/try\s*\{\s*dep\s*=\s*undefined;\s*\}\s*catch/,
'ignoreTryCatch: "remove" replaces require call with undefined'
);
}
// ---------------------------------------------------------------------------
// Contract 4:
// Specifying an array of module IDs in ignoreTryCatch selectively preserves only
// matching IDs as unconverted requires while hoisting non-matching IDs to static imports.
// ---------------------------------------------------------------------------
{
const bundle = await rollup({
input: 'entry-array.js',
external: ['pkg-keep', 'pkg-hoist'],
plugins: [
{
name: 'virtual-loader',
resolveId(id) {
if (id === 'entry-array.js') return id;
},
load(id) {
if (id === 'entry-array.js') {
return `
let a, b;
try { a = require('pkg-keep'); } catch (e) { a = 'fallback-a'; }
try { b = require('pkg-hoist'); } catch (e) { b = 'fallback-b'; }
module.exports = { a, b };
`;
}
}
},
commonjs({
ignoreTryCatch: ['pkg-keep']
})
]
});
const { output } = await bundle.generate({ format: 'es' });
const code = output[0].code;
assert.match(
code,
/^import\s+require\$\$\d+\s+from\s+'pkg-hoist';/m,
'Non-matching ID is hoisted as static ESM import'
);
assert.equal(
code.includes("from 'pkg-keep'"),
false,
'Matching ID pkg-keep is not hoisted'
);
assert.match(
code,
/try\s*\{\s*a\s*=\s*require\('pkg-keep'\);\s*\}\s*catch/,
'Matching ID pkg-keep remains as require call inside try block'
);
}
// ---------------------------------------------------------------------------
// Contract 5:
// Providing a filter function to ignoreTryCatch dynamically evaluates external module IDs
// and supports returning 'remove', true, or false per module ID.
// ---------------------------------------------------------------------------
{
const bundle = await rollup({
input: 'entry-fn.js',
external: ['pkg-remove', 'pkg-convert'],
plugins: [
{
name: 'virtual-loader',
resolveId(id) {
if (id === 'entry-fn.js') return id;
},
load(id) {
if (id === 'entry-fn.js') {
return `
let r, c;
try { r = require('pkg-remove'); } catch (e) { r = 'fallback-r'; }
try { c = require('pkg-convert'); } catch (e) { c = 'fallback-c'; }
module.exports = { r, c };
`;
}
}
},
commonjs({
ignoreTryCatch: (id) => {
if (id === 'pkg-remove') return 'remove';
return false;
}
})
]
});
const { output } = await bundle.generate({ format: 'es' });
const code = output[0].code;
assert.match(
code,
/^import\s+require\$\$\d+\s+from\s+'pkg-convert';/m,
'Filter returning false hoists pkg-convert as static ESM import'
);
assert.match(
code,
/try\s*\{\s*r\s*=\s*undefined;\s*\}\s*catch/,
'Filter returning "remove" replaces require call with undefined'
);
assert.equal(
code.includes("from 'pkg-remove'"),
false,
'Filter returning "remove" does not emit static ESM import'
);
}
console.log('All ignoreTryCatch contract assertions passed successfully.');
}
runContract().catch((err) => {
console.error('Contract failed:', err);
process.exit(1);
});
오리진 시더
익명