CodeSampleX

샘플

import-fresh 3.3.1

검증된 샘플 — npm import-fresh 3.3.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: importFresh throws TypeError when moduleId argument is not a…

sha256:b9ed95eeb82afdc30a82de96ec34c7acd2bb94eb18bd39a50db5575dd4ba8e1a

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-23

케이스

HOW
목표
verify pkg:npm/import-fresh@3.3.1
패키지
생성일
2026-08-23T14:08:52Z

컨트랙트

  1. importFresh throws TypeError when moduleId argument is not a string
  2. importFresh imports a module and returns its exported value
  3. importFresh returns a new module instance on each call bypassing require cache
  4. importFresh resolves relative module paths relative to the caller file directory in CommonJS
  5. importFresh loads fresh parsed objects for JSON files bypassing cache
  6. importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved

파일

  • 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

소스 아티팩트 내려받기 (tar.gz)

소스

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/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.
csx.json
{"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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "name": "sample-import-fresh",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "import-fresh": "3.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/import-fresh@3.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/import-fresh@3.3.1"
  ]
}
test/contract.mjs
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');
		}
	);
}
test/fixtures/data.json
{
  "name": "sample-data",
  "version": 1,
  "nested": {
    "active": true
  }
}
test/fixtures/stateful.cjs
'use strict';

let executionCount = 0;
executionCount += 1;

module.exports = {
  instanceId: {},
  createdAt: Date.now(),
  getExecutionCount: () => executionCount,
};
test/fixtures/sub/caller.cjs
'use strict';
const importFresh = require('import-fresh');

module.exports = {
  loadRelativeTarget: function () {
    return importFresh('./target.cjs');
  },
};
test/fixtures/sub/target.cjs
'use strict';

module.exports = {
  name: 'sub-target',
  uniqueRef: {},
};

오리진 시더

익명