Exemple
import-fresh 3.3.1
Échantillon vérifié pour npm import-fresh 3.3.1. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:b9ed95eeb82afdc30a82de96ec34c7acd2bb94eb18bd39a50db5575dd4ba8e1a
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-23 |
Cas
HOW- Objectif
- verify pkg:npm/import-fresh@3.3.1
- Paquets
- Créé
- 2026-08-23T14:08:52Z
Contrat
- importFresh throws TypeError when moduleId argument is not a string
- importFresh imports a module and returns its exported value
- importFresh returns a new module instance on each call bypassing require cache
- importFresh resolves relative module paths relative to the caller file directory in CommonJS
- importFresh loads fresh parsed objects for JSON files bypassing cache
- importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
- test/fixtures/data.json
- test/fixtures/stateful.cjs
- test/fixtures/sub/caller.cjs
- test/fixtures/sub/target.cjs
Code source
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/import-fresh@3.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/import-fresh@3.3.1
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:885649d8df8598de2c77ac3b0819456947b809ea10a9359ecd8f7cd395b135c8","contract":["importFresh throws TypeError when moduleId argument is not a string","importFresh imports a module and returns its exported value","importFresh returns a new module instance on each call bypassing require cache","importFresh resolves relative module paths relative to the caller file directory in CommonJS","importFresh loads fresh parsed objects for JSON files bypassing cache","importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved"],"goal":"verify pkg:npm/import-fresh@3.3.1","kind":"HOW","packages":["pkg:npm/import-fresh@3.3.1"],"schemaVersion":1},"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/import-fresh@3.3.1"],"schemaVersion":1,"subject":"pkg:npm/import-fresh@3.3.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-import-fresh",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-import-fresh",
"version": "1.0.0",
"dependencies": {
"import-fresh": "3.3.1"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/import-fresh": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"license": "MIT",
"dependencies": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"license": "MIT",
"dependencies": {
"callsites": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"license": "MIT",
"engines": {
"node": ">=4"
}
}
}
}
{
"name": "sample-import-fresh",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"import-fresh": "3.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/import-fresh@3.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/import-fresh@3.3.1"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import path from 'node:path';
import importFresh from 'import-fresh';
const require = createRequire(import.meta.url);
const { loadRelativeTarget } = require('./fixtures/sub/caller.cjs');
// 1. importFresh throws TypeError when moduleId argument is not a string
{
assert.throws(
() => {
importFresh(12345);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
assert.throws(
() => {
importFresh(null);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
assert.throws(
() => {
importFresh(undefined);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
}
// 2. importFresh imports a module and returns its exported value
{
const fixturePath = path.resolve('test/fixtures/stateful.cjs');
const mod = importFresh(fixturePath);
assert.ok(mod !== null && typeof mod === 'object');
assert.equal(typeof mod.getExecutionCount, 'function');
assert.equal(typeof mod.instanceId, 'object');
}
// 3. importFresh returns a new module instance on each call bypassing require cache
{
const fixturePath = path.resolve('test/fixtures/stateful.cjs');
const mod1 = importFresh(fixturePath);
const mod2 = importFresh(fixturePath);
assert.notEqual(mod1, mod2);
assert.notEqual(mod1.instanceId, mod2.instanceId);
}
// 4. importFresh resolves relative module paths relative to the caller file directory in CommonJS
{
const result1 = loadRelativeTarget();
const result2 = loadRelativeTarget();
assert.equal(result1.name, 'sub-target');
assert.equal(result2.name, 'sub-target');
assert.notEqual(result1.uniqueRef, result2.uniqueRef);
}
// 5. importFresh loads fresh parsed objects for JSON files bypassing cache
{
const jsonPath = path.resolve('test/fixtures/data.json');
const data1 = importFresh(jsonPath);
const data2 = importFresh(jsonPath);
assert.deepEqual(data1, {
name: 'sample-data',
version: 1,
nested: {
active: true,
},
});
assert.notEqual(data1, data2);
assert.notEqual(data1.nested, data2.nested);
}
// 6. importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved
{
assert.throws(
() => {
importFresh(path.resolve('test/fixtures/non-existent-module.cjs'));
},
(err) => {
return err.code === 'MODULE_NOT_FOUND' || err.message.includes('Cannot find module');
}
);
}
{
"name": "sample-data",
"version": 1,
"nested": {
"active": true
}
}
'use strict';
let executionCount = 0;
executionCount += 1;
module.exports = {
instanceId: {},
createdAt: Date.now(),
getExecutionCount: () => executionCount,
};
'use strict';
const importFresh = require('import-fresh');
module.exports = {
loadRelativeTarget: function () {
return importFresh('./target.cjs');
},
};
'use strict';
module.exports = {
name: 'sub-target',
uniqueRef: {},
};
Seeder d'origine
anonyme