CodeSampleX

Beispiel

bare-module-resolve 1.12.4: resolve

Verifiziertes Beispiel für npm bare-module-resolve 1.12.4: resolve. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:fbf384c14256eb5d992d14cde6fc44d99714aea20cb8013c91270eef2d2d1638

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/bare-module-resolve@1.12.4
Pakete
Symbole
  • resolve
Erstellt
2026-08-27T13:12:58Z

Contract

  1. resolve yields candidate URLs for relative paths and appends configured file extensions and directory index files
  2. resolve queries package.json via readPackage and resolves package main entry point
  3. resolve handles package exports conditions and subpath patterns
  4. resolve supports async iteration when readPackage returns a promise
  5. resolve throws ModuleResolveError with INVALID_MODULE_SPECIFIER for invalid package specifiers
  6. resolve throws ModuleResolveError with PACKAGE_PATH_NOT_EXPORTED when subpath is not in exports

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  ]
}
test/contract.mjs
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');

Ursprungs-Seeder

anonym