サンプル
real-require 1.0.0: realRequire
検証済みサンプル — npm real-require 1.0.0: realRequire. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: realRequire is exported as a function from…
sha256:77b9c7d06246a3b9e0883d11249f2aa10017fc1ee619621adca7eb3d69d89d17
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-10-12 |
ケース
HOW- ゴール
- verify real-require.realRequire in pkg:npm/real-require@1.0.0
- パッケージ
- シンボル
-
- real-require.realRequire
- 作成日
- 2026-10-12T09:57:46Z
コントラクト
- realRequire is exported as a function from real-require
- realRequire loads Node.js built-in modules using runtime require
- realRequire delegates to __non_webpack__require__ when globally defined
- realRequire falls back to standard require when __non_webpack__require__ is undefined
- realRequire throws MODULE_NOT_FOUND when loading non-existent modules
ファイル
- 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 real-require.realRequire in pkg:npm/real-require@1.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/real-require@1.0.0
Demonstrate these symbols/APIs:
- real-require.realRequire
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:7c2cb3546bf6ee631c39365897920b66a639e1672790ce3691e186b4b113637f","contract":["realRequire is exported as a function from real-require","realRequire loads Node.js built-in modules using runtime require","realRequire delegates to __non_webpack__require__ when globally defined","realRequire falls back to standard require when __non_webpack__require__ is undefined","realRequire throws MODULE_NOT_FOUND when loading non-existent modules"],"goal":"verify real-require.realRequire in pkg:npm/real-require@1.0.0","kind":"HOW","packages":["pkg:npm/real-require@1.0.0"],"schemaVersion":1,"symbols":["real-require.realRequire"]},"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/real-require@1.0.0"],"schemaVersion":1,"subject":"pkg:npm/real-require@1.0.0","symbols":["real-require.realRequire"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-real-require",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-real-require",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"real-require": "1.0.0"
}
},
"node_modules/real-require": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz",
"integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==",
"license": "MIT"
}
}
}
{
"name": "sample-real-require",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for real-require@1.0.0",
"main": "src/index.js",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"real-require": "1.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify real-require.realRequire in pkg:npm/real-require@1.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/real-require@1.0.0"
],
"symbols": [
"real-require.realRequire"
]
}
'use strict';
const { realRequire, realImport } = require('real-require');
/**
* Loads a module using realRequire.
*
* @param {string} modulePath - The specifier of the module to require.
* @returns {*} The exported module.
*/
function loadModule(modulePath) {
return realRequire(modulePath);
}
module.exports = {
realRequire,
realImport,
loadModule
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { realRequire, loadModule } = require('../src/index.js');
async function testAll() {
// 1. realRequire is exported as a function from real-require
assert.equal(typeof realRequire, 'function', 'realRequire must be a function');
assert.equal(typeof loadModule, 'function', 'loadModule helper must be a function');
// 2. realRequire loads Node.js built-in modules using runtime require
{
const path = realRequire('node:path');
assert.equal(typeof path.join, 'function', 'realRequire should load path module');
assert.equal(path.join('foo', 'bar'), 'foo/bar');
const os = loadModule('node:os');
assert.equal(typeof os.platform, 'function', 'loadModule should load os module');
}
// 3. realRequire delegates to __non_webpack__require__ when globally defined
{
let captured = null;
globalThis.__non_webpack__require__ = (id) => {
captured = id;
return { mocked: true, target: id };
};
try {
const result = realRequire('virtual-mock-module');
assert.equal(captured, 'virtual-mock-module', '__non_webpack__require__ should be invoked with target id');
assert.deepEqual(result, { mocked: true, target: 'virtual-mock-module' });
} finally {
delete globalThis.__non_webpack__require__;
}
}
// 4. realRequire falls back to standard require when __non_webpack__require__ is undefined
{
assert.equal(typeof globalThis.__non_webpack__require__, 'undefined');
const fs = realRequire('node:fs');
assert.equal(typeof fs.readFileSync, 'function', 'realRequire falls back to standard require for fs');
}
// 5. realRequire throws MODULE_NOT_FOUND when loading non-existent modules
{
assert.throws(
() => realRequire('non-existent-module-xyz-12345'),
(err) => {
return err && (err.code === 'MODULE_NOT_FOUND' || (err.message && err.message.includes('Cannot find module')));
},
'realRequire should throw error for non-existent module'
);
}
console.log('All real-require contract tests passed successfully.');
}
testAll().catch((err) => {
console.error('Contract test failure:', err);
process.exit(1);
});
オリジンシーダー
匿名