Пример
bare-module-resolve 1.12.4: resolve
Проверенный пример — npm bare-module-resolve 1.12.4: resolve. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:fbf384c14256eb5d992d14cde6fc44d99714aea20cb8013c91270eef2d2d1638
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
Кейс
HOW- Цель
- verify pkg:npm/bare-module-resolve@1.12.4
- Пакеты
- Символы
-
- resolve
- Создан
- 2026-08-27T13:12:58Z
Контракт
- resolve yields candidate URLs for relative paths and appends configured file extensions and directory index files
- resolve queries package.json via readPackage and resolves package main entry point
- resolve handles package exports conditions and subpath patterns
- resolve supports async iteration when readPackage returns a promise
- resolve throws ModuleResolveError with INVALID_MODULE_SPECIFIER for invalid package specifiers
- resolve throws ModuleResolveError with PACKAGE_PATH_NOT_EXPORTED when subpath is not in exports
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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/bare-module-resolve@1.12.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-module-resolve@1.12.4
Demonstrate these symbols/APIs:
- resolve
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:1fafac81d27032e1582d7618a0e8ddc8340211a97f954729b226eb2f6e208657","contract":["resolve yields candidate URLs for relative paths and appends configured file extensions and directory index files","resolve queries package.json via readPackage and resolves package main entry point","resolve handles package exports conditions and subpath patterns","resolve supports async iteration when readPackage returns a promise","resolve throws ModuleResolveError with INVALID_MODULE_SPECIFIER for invalid package specifiers","resolve throws ModuleResolveError with PACKAGE_PATH_NOT_EXPORTED when subpath is not in exports"],"goal":"verify pkg:npm/bare-module-resolve@1.12.4","kind":"HOW","packages":["pkg:npm/bare-module-resolve@1.12.4"],"schemaVersion":1,"symbols":["resolve"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bare-module-resolve@1.12.4"],"schemaVersion":1,"subject":"pkg:npm/bare-module-resolve@1.12.4","symbols":["resolve"],"verifierAdapter":"node-typescript@1"}
{
"name": "bare-module-resolve-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "bare-module-resolve-sample",
"version": "1.0.0",
"dependencies": {
"bare-module-resolve": "1.12.4"
}
},
"node_modules/bare-module-resolve": {
"version": "1.12.4",
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.12.4.tgz",
"integrity": "sha512-xcfgg2u7HqgJiBmah71O9vvdFAgHCvkqC/WSC2O7Bbgosoc1eC/BWe/6IDJ4OsfKlkxuvC/TDWXC+oH5yeW8mA==",
"license": "Apache-2.0",
"dependencies": {
"bare-semver": "^1.0.0"
},
"peerDependencies": {
"bare-url": "*"
},
"peerDependenciesMeta": {
"bare-url": {
"optional": true
}
}
},
"node_modules/bare-semver": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/bare-semver/-/bare-semver-1.1.0.tgz",
"integrity": "sha512-1Hw5qJ7hXdVt3uPUqjeFTuxyvBUJauvz5A1I2jk8gzjZMHp04n//6nV9MDbG9CMw78JHY2lGV0w6s//LrASm2w==",
"license": "Apache-2.0"
}
}
}
{
"name": "bare-module-resolve-sample",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for bare-module-resolve",
"dependencies": {
"bare-module-resolve": "1.12.4"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/bare-module-resolve@1.12.4",
"kind": "HOW",
"packages": [
"pkg:npm/bare-module-resolve@1.12.4"
],
"symbols": [
"resolve"
]
}
import assert from 'node:assert';
import resolve from 'bare-module-resolve';
// 1. resolve yields candidate URLs for relative paths and appends configured file extensions and directory index files
const parentURL = new URL('file:///workspace/project/src/app.js');
const relativeCandidates = [...resolve('./helpers', parentURL, { extensions: ['.js', '.json'] })];
assert.deepStrictEqual(relativeCandidates.map((u) => u.href), [
'file:///workspace/project/src/helpers',
'file:///workspace/project/src/helpers.js',
'file:///workspace/project/src/helpers.json',
'file:///workspace/project/src/helpers/index.js',
'file:///workspace/project/src/helpers/index.json'
]);
// 2. resolve queries package.json via readPackage and resolves package main entry point
const packageCandidates = [
...resolve('example-lib', parentURL, { extensions: ['.js'] }, (packageURL) => {
if (packageURL.href === 'file:///workspace/project/node_modules/example-lib/package.json') {
return {
name: 'example-lib',
main: './lib/index.js'
};
}
return null;
})
];
assert.strictEqual(
packageCandidates[0].href,
'file:///workspace/project/node_modules/example-lib/lib/index.js'
);
// 3. resolve handles package exports conditions and subpath patterns
const exportCandidates = [
...resolve(
'example-pkg/feature/sub',
parentURL,
{ conditions: ['import', 'node', 'default'] },
(packageURL) => {
if (packageURL.href === 'file:///workspace/project/node_modules/example-pkg/package.json') {
return {
name: 'example-pkg',
exports: {
'.': {
import: './esm/index.js',
require: './cjs/index.cjs'
},
'./feature/*': {
import: './esm/features/*.js',
default: './cjs/features/*.cjs'
}
}
};
}
return null;
}
)
];
assert.strictEqual(
exportCandidates[0].href,
'file:///workspace/project/node_modules/example-pkg/esm/features/sub.js'
);
// 4. resolve supports async iteration when readPackage returns a promise
const asyncResults = [];
for await (const candidate of resolve('async-pkg', parentURL, {}, async (packageURL) => {
if (packageURL.href === 'file:///workspace/project/node_modules/async-pkg/package.json') {
return {
name: 'async-pkg',
main: './dist/bundle.js'
};
}
return null;
})) {
asyncResults.push(candidate);
}
assert.strictEqual(
asyncResults[0].href,
'file:///workspace/project/node_modules/async-pkg/dist/bundle.js'
);
// 5. resolve throws ModuleResolveError with INVALID_MODULE_SPECIFIER for invalid package specifiers
assert.throws(
() => {
[...resolve('', parentURL)];
},
(err) => {
return err.name === 'ModuleResolveError' && err.code === 'INVALID_MODULE_SPECIFIER';
}
);
// 6. resolve throws ModuleResolveError with PACKAGE_PATH_NOT_EXPORTED when subpath is not in exports
assert.throws(
() => {
[
...resolve('example-pkg/unexported', parentURL, {}, (packageURL) => {
if (packageURL.href === 'file:///workspace/project/node_modules/example-pkg/package.json') {
return {
name: 'example-pkg',
exports: {
'./valid': './dist/valid.js'
}
};
}
return null;
})
];
},
(err) => {
return err.name === 'ModuleResolveError' && err.code === 'PACKAGE_PATH_NOT_EXPORTED';
}
);
console.log('Contract passed');
Исходный сидер
аноним