CodeSampleX

샘플

source-map-support 0.5.21: sourceMapSupport.install

검증된 샘플 — npm source-map-support 0.5.21: sourceMapSupport.install. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: sourceMapSupport.install…

sha256:538be996e4848ae80667e27ec77f4129821af67b64457af004c41cfb4c596ce3

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

케이스

HOW
목표
verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21
패키지
심벌
  • sourceMapSupport.install
생성일
2026-09-01T11:51:22Z

컨트랙트

  1. sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping
  2. sourceMapSupport.install rewrites stack traces to map generated positions back to original source files
  3. sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps
  4. sourceMapSupport.install preserves standard stack trace structure when no source map is found

파일

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

소스 아티팩트 내려받기 (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 sourceMapSupport.install in pkg:npm/source-map-support@0.5.21
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/source-map-support@0.5.21
Demonstrate these symbols/APIs:
  - sourceMapSupport.install

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:5046590449b2dfd1c98ea3da01e34f5959b466640c9ac3098f2d932ae84d8491","contract":["sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping","sourceMapSupport.install rewrites stack traces to map generated positions back to original source files","sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps","sourceMapSupport.install preserves standard stack trace structure when no source map is found"],"goal":"verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21","kind":"HOW","packages":["pkg:npm/source-map-support@0.5.21"],"schemaVersion":1,"symbols":["sourceMapSupport.install"]},"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/source-map-support@0.5.21"],"schemaVersion":1,"subject":"pkg:npm/source-map-support@0.5.21","symbols":["sourceMapSupport.install"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-source-map-support-install",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-source-map-support-install",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "source-map-support": "0.5.21"
      }
    },
    "node_modules/buffer-from": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
      "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
      "license": "MIT"
    },
    "node_modules/source-map": {
      "version": "0.6.1",
      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
      "license": "BSD-3-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/source-map-support": {
      "version": "0.5.21",
      "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
      "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
      "license": "MIT",
      "dependencies": {
        "buffer-from": "^1.0.0",
        "source-map": "^0.6.0"
      }
    }
  }
}
package.json
{
  "name": "sample-source-map-support-install",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of sourceMapSupport.install in source-map-support",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "license": "MIT-0",
  "dependencies": {
    "source-map-support": "0.5.21"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify sourceMapSupport.install in pkg:npm/source-map-support@0.5.21",
  "kind": "HOW",
  "packages": [
    "pkg:npm/source-map-support@0.5.21"
  ],
  "symbols": [
    "sourceMapSupport.install"
  ]
}
src/index.js
const sourceMapSupport = require("source-map-support");

/**
 * Installs source map support into Node.js stack trace handling.
 * @param {object} [options]
 * @returns {void}
 */
function install(options) {
  return sourceMapSupport.install(options);
}

/**
 * Resets custom retrieve handlers to defaults if available.
 * @returns {void}
 */
function resetRetrieveHandlers() {
  if (typeof sourceMapSupport.resetRetrieveHandlers === "function") {
    sourceMapSupport.resetRetrieveHandlers();
  }
}

module.exports = {
  sourceMapSupport,
  install,
  resetRetrieveHandlers,
};
test/contract.mjs
import assert from "node:assert";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const { sourceMapSupport, install, resetRetrieveHandlers } = require("../src/index.js");

async function runContract() {
  // 1. sourceMapSupport.install configures Error.prepareStackTrace for stack trace remapping
  assert.strictEqual(typeof sourceMapSupport.install, "function", "sourceMapSupport.install must be a function");
  assert.strictEqual(typeof install, "function", "install wrapper must be a function");

  let hookInvocations = 0;
  const sampleSourceMap = {
    version: 3,
    file: "compiled-bundle.js",
    sources: ["src/original-module.ts"],
    sourcesContent: [
      "export function executeTask(value: number): number {\n  if (value < 0) throw new Error(\"negative value\");\n  return value * 2;\n}\n"
    ],
    names: ["executeTask", "value"],
    mappings: "AAAA,gBAAsBA,YAAY,CAACC,KAAa;IAC9C,IAAIA,KAAK,GAAG,CAAC;MAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,OAAOA,KAAK,GAAG,CAAC,CAAC;AACnB,CAAC"
  };

  install({
    emptyCacheBetweenOperations: true,
    handleUncaughtExceptions: false,
    environment: "node",
    retrieveSourceMap(source) {
      if (source === "compiled-bundle.js" || source.endsWith("/compiled-bundle.js")) {
        hookInvocations++;
        return {
          url: "compiled-bundle.js",
          map: sampleSourceMap,
        };
      }
      return null;
    },
  });

  assert.strictEqual(typeof Error.prepareStackTrace, "function", "Error.prepareStackTrace must be a function after install()");

  // 2. sourceMapSupport.install rewrites stack traces to map generated positions back to original source files
  const fnWithSourceURL = new Function(
    "//# sourceURL=compiled-bundle.js\nthrow new Error(\"error inside compiled bundle\");"
  );
  let caughtError = null;
  try {
    fnWithSourceURL();
  } catch (err) {
    caughtError = err;
  }

  assert.ok(caughtError instanceof Error, "Expected error to be thrown");
  assert.ok(
    caughtError.stack.includes("src/original-module.ts"),
    `Expected stack trace to contain mapped original file "src/original-module.ts", got:\n${caughtError.stack}`
  );

  // 3. sourceMapSupport.install supports custom retrieveSourceMap hook to resolve in-memory source maps
  assert.ok(hookInvocations > 0, "Expected custom retrieveSourceMap hook to be invoked when formatting stack trace");

  // 4. sourceMapSupport.install preserves standard stack trace structure when no source map is found
  const fnUnmapped = new Function(
    "//# sourceURL=unmapped-file.js\nthrow new Error(\"unmapped error message\");"
  );
  let unmappedErr = null;
  try {
    fnUnmapped();
  } catch (err) {
    unmappedErr = err;
  }
  assert.ok(unmappedErr instanceof Error, "Expected unmapped error");
  assert.ok(typeof unmappedErr.stack === "string", "Stack trace must be a string");
  assert.ok(unmappedErr.stack.includes("unmapped error message"), "Stack trace must contain original error message");
  assert.ok(unmappedErr.stack.includes("unmapped-file.js"), "Stack trace must contain unmapped source URL");

  resetRetrieveHandlers();
  console.log("Contract assertions passed successfully.");
}

runContract().catch((err) => {
  console.error("Contract test failed:", err);
  process.exit(1);
});

오리진 시더

익명