샘플
resolve 1.22.12
검증된 샘플 — npm resolve 1.22.12. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: resolve.isCore identifies standard Node.js built-in core modules…
sha256:844081ef0309af45ce8984461477ba70b08fc3be28a5e22ba8861319b0621ea6
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
케이스
HOW- 목표
- verify pkg:npm/resolve@1.22.12
- 패키지
- 환경
- node 22.23.2
- 생성일
- 2026-08-20T17:37:17Z
컨트랙트
- resolve.isCore identifies standard Node.js built-in core modules and node-prefixed specifiers
- resolve.sync resolves relative module paths and custom file extensions synchronously
- resolve asynchronously resolves module paths and returns resolved target path
- resolve.sync throws MODULE_NOT_FOUND error when a module cannot be resolved
- resolve.sync supports custom basedir, extensions, packageFilter, and pathFilter options
- resolve.sync resolves paths using custom synchronous filesystem overrides
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
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/resolve@1.22.12
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/resolve@1.22.12
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- runtime: node@22.23.2
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":{"caseId":"case:sha256:552e3b932042ddadc520f6277f7e005bc92b70a3d5aeb2fc21ca92a65d478e01","constraints":{"executionContext":"node"},"contract":["resolve.isCore identifies standard Node.js built-in core modules and node-prefixed specifiers","resolve.sync resolves relative module paths and custom file extensions synchronously","resolve asynchronously resolves module paths and returns resolved target path","resolve.sync throws MODULE_NOT_FOUND error when a module cannot be resolved","resolve.sync supports custom basedir, extensions, packageFilter, and pathFilter options","resolve.sync resolves paths using custom synchronous filesystem overrides"],"goal":"verify pkg:npm/resolve@1.22.12","kind":"HOW","packages":["pkg:npm/resolve@1.22.12"],"schemaVersion":1},"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/resolve@1.22.12"],"schemaVersion":1,"subject":"pkg:npm/resolve@1.22.12","verifierAdapter":"node-typescript@1"}
{
"name": "sample-resolve",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-resolve",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"resolve": "1.22.12"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/is-core-module": {
"version": "2.16.2",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz",
"integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==",
"license": "MIT",
"dependencies": {
"hasown": "^2.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"license": "MIT"
},
"node_modules/resolve": {
"version": "1.22.12",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz",
"integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"is-core-module": "^2.16.1",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
}
}
}
{
"name": "sample-resolve",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of resolve",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"resolve": "1.22.12"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/resolve@1.22.12",
"kind": "HOW",
"packages": [
"pkg:npm/resolve@1.22.12"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
const resolve = require('resolve');
/**
* Resolves a module specifier synchronously.
* @param {string} id - Module specifier to resolve
* @param {object} [opts] - Resolution options
* @returns {string} Absolute resolved file path
*/
function resolveModuleSync(id, opts) {
return resolve.sync(id, opts);
}
/**
* Resolves a module specifier asynchronously.
* @param {string} id - Module specifier to resolve
* @param {object} [opts] - Resolution options
* @returns {Promise<string>} Promise resolving to absolute file path
*/
function resolveModuleAsync(id, opts) {
return new Promise((resolvePromise, rejectPromise) => {
resolve(id, opts, (err, res) => {
if (err) {
return rejectPromise(err);
}
resolvePromise(res);
});
});
}
/**
* Checks whether a specifier is a Node.js core module.
* @param {string} id - Module specifier
* @returns {boolean} True if core module
*/
function checkCoreModule(id) {
return resolve.isCore(id);
}
module.exports = {
resolve,
resolveModuleSync,
resolveModuleAsync,
checkCoreModule
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { resolve, resolveModuleSync, resolveModuleAsync, checkCoreModule } = require('../src/index.js');
// 1. Export verification
assert.equal(typeof resolve, 'function', 'resolve must be exported as a function');
assert.equal(typeof resolve.sync, 'function', 'resolve.sync must be exported as a function');
assert.equal(typeof resolve.isCore, 'function', 'resolve.isCore must be exported as a function');
assert.equal(typeof resolveModuleSync, 'function', 'resolveModuleSync must be exported as a function');
assert.equal(typeof resolveModuleAsync, 'function', 'resolveModuleAsync must be exported as a function');
assert.equal(typeof checkCoreModule, 'function', 'checkCoreModule must be exported as a function');
// 2. resolve.isCore identifies standard Node.js built-in core modules and node-prefixed specifiers
assert.equal(resolve.isCore('fs'), true, 'fs is a core module');
assert.equal(resolve.isCore('path'), true, 'path is a core module');
assert.equal(resolve.isCore('events'), true, 'events is a core module');
assert.equal(resolve.isCore('node:fs'), true, 'node:fs is a core module');
assert.equal(resolve.isCore('node:path'), true, 'node:path is a core module');
assert.equal(checkCoreModule('node:test'), true, 'node:test is a core module');
assert.equal(resolve.isCore('non-existent-core-module'), false, 'non-existent package is not core');
assert.equal(checkCoreModule('sample-resolve-xyz'), false, 'sample package is not core');
// 3. resolve.sync resolves relative module paths and custom file extensions synchronously
const basedir = process.cwd();
const resolvedSrc = resolveModuleSync('./src/index', { basedir, extensions: ['.js'] });
assert.ok(resolvedSrc.endsWith('src/index.js'), 'should resolve relative index file with extension');
const resolvedJson = resolveModuleSync('./package', { basedir, extensions: ['.json', '.js'] });
assert.ok(resolvedJson.endsWith('package.json'), 'should resolve file with custom .json extension');
// 4. resolve asynchronously resolves module paths and returns resolved target path
const asyncResolved = await resolveModuleAsync('./src/index', { basedir });
assert.ok(asyncResolved.endsWith('src/index.js'), 'async resolution should match target path');
await new Promise((done, fail) => {
resolve('./package', { basedir, extensions: ['.json'] }, (err, res) => {
if (err) return fail(err);
try {
assert.ok(res.endsWith('package.json'));
done();
} catch (e) {
fail(e);
}
});
});
// 5. resolve.sync throws MODULE_NOT_FOUND error when a module cannot be resolved
assert.throws(
() => resolveModuleSync('./non-existent-target-file-12345', { basedir }),
(err) => err && err.code === 'MODULE_NOT_FOUND'
);
// 6. resolve.sync supports custom basedir, extensions, packageFilter, and pathFilter options
let packageFilterCalled = false;
let pathFilterCalled = false;
const customResolved = resolve.sync('resolve', {
basedir,
packageFilter: (pkg, dir) => {
packageFilterCalled = true;
return pkg;
},
pathFilter: (pkg, path, relativePath) => {
pathFilterCalled = true;
return relativePath;
}
});
assert.equal(packageFilterCalled, true, 'packageFilter hook should be invoked');
assert.equal(pathFilterCalled, true, 'pathFilter hook should be invoked');
assert.ok(customResolved.endsWith('index.js'), 'custom resolved path should point to resolve index.js');
// 7. resolve.sync resolves paths using custom synchronous filesystem overrides
const virtualFiles = {
'/virtual/root/package.json': JSON.stringify({ name: 'virtual-mod', main: 'entry.js' }),
'/virtual/root/entry.js': 'module.exports = "virtual-resolved";'
};
const resolvedVirtual = resolve.sync('./entry', {
basedir: '/virtual/root',
extensions: ['.js'],
readFileSync: (file) => {
if (virtualFiles[file]) return virtualFiles[file];
throw new Error('ENOENT: ' + file);
},
isFile: (file) => Boolean(virtualFiles[file]),
isDirectory: (dir) => dir === '/virtual/root',
realpathSync: (x) => x
});
assert.equal(resolvedVirtual, '/virtual/root/entry.js', 'should resolve using custom virtual filesystem handlers');
console.log('Contract tests passed successfully.');
오리진 시더
익명