CodeSampleX

샘플

@ampproject/remapping 2.3.0

검증된 샘플 — npm @ampproject/remapping 2.3.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: remapping composes multi-step sourcemaps back to…

sha256:a5b8161b04e6d701c9d95717de416cc01ebc4df652a7daef4c633451993bffb5

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

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

케이스

HOW
목표
verify pkg:npm/%40ampproject/remapping@2.3.0
패키지
환경
node 22.23.2
생성일
2026-08-20T14:44:43Z

컨트랙트

  1. remapping composes multi-step sourcemaps back to original source files
  2. remapping supports loader callback returning null for original source files
  3. remapping accepts JSON string as sourcemap input
  4. remapping supports decodedMappings option returning segment arrays
  5. remapping supports excludeContent option omitting sourcesContent
  6. remapping SourceMap toString returns valid JSON string

파일

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

소스 아티팩트 내려받기 (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/%40ampproject/remapping@2.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40ampproject/remapping@2.3.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:0184a4bfadedd85b2619f5944a31d7cb7c7ca63b9aed67198b62447e954c8c1e","constraints":{"executionContext":"node"},"contract":["remapping composes multi-step sourcemaps back to original source files","remapping supports loader callback returning null for original source files","remapping accepts JSON string as sourcemap input","remapping supports decodedMappings option returning segment arrays","remapping supports excludeContent option omitting sourcesContent","remapping SourceMap toString returns valid JSON string"],"goal":"verify pkg:npm/%40ampproject/remapping@2.3.0","kind":"HOW","packages":["pkg:npm/%40ampproject/remapping@2.3.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40ampproject/remapping@2.3.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-ampproject-remapping",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-ampproject-remapping",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@ampproject/remapping": "2.3.0"
      }
    },
    "node_modules/@ampproject/remapping": {
      "version": "2.3.0",
      "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
      "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
      "license": "Apache-2.0",
      "dependencies": {
        "@jridgewell/gen-mapping": "^0.3.5",
        "@jridgewell/trace-mapping": "^0.3.24"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/@jridgewell/gen-mapping": {
      "version": "0.3.13",
      "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
      "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
      "license": "MIT",
      "dependencies": {
        "@jridgewell/sourcemap-codec": "^1.5.0",
        "@jridgewell/trace-mapping": "^0.3.24"
      }
    },
    "node_modules/@jridgewell/resolve-uri": {
      "version": "3.1.2",
      "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
      "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
      "license": "MIT",
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/@jridgewell/sourcemap-codec": {
      "version": "1.5.5",
      "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
      "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
      "license": "MIT"
    },
    "node_modules/@jridgewell/trace-mapping": {
      "version": "0.3.31",
      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
      "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
      "license": "MIT",
      "dependencies": {
        "@jridgewell/resolve-uri": "^3.1.0",
        "@jridgewell/sourcemap-codec": "^1.4.14"
      }
    }
  }
}
package.json
{
  "name": "sample-ampproject-remapping",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for @ampproject/remapping",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "@ampproject/remapping": "2.3.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40ampproject/remapping@2.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40ampproject/remapping@2.3.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const remapping = require('@ampproject/remapping');

function remapSourcemap(inputMap, loader, options) {
  return remapping(inputMap, loader, options);
}

module.exports = {
  remapping,
  remapSourcemap
};
test/contract.js
'use strict';

const assert = require('node:assert');
const remapping = require('@ampproject/remapping');
const { remapSourcemap } = require('../src/index.js');

function runTests() {
  // 1. Compose multi-step sourcemaps back to original source file
  const minifiedMap = {
    version: 3,
    file: 'output.min.js',
    sources: ['transpiled.js'],
    mappings: 'AAAA;',
    sourcesContent: ['const answer = 42;']
  };

  const transpiledMap = {
    version: 3,
    file: 'transpiled.js',
    sources: ['source.ts'],
    mappings: 'AAAA;',
    sourcesContent: ['export const answer: number = 42;']
  };

  const remapped = remapping(minifiedMap, (sourcefile) => {
    if (sourcefile === 'transpiled.js') {
      return transpiledMap;
    }
    return null;
  });

  assert.strictEqual(remapped.version, 3, 'remapped version should be 3');
  assert.strictEqual(remapped.file, 'output.min.js', 'remapped file should match target');
  assert.deepStrictEqual(remapped.sources, ['source.ts'], 'remapped sources should point to original source file');
  assert.deepStrictEqual(
    remapped.sourcesContent,
    ['export const answer: number = 42;'],
    'remapped sourcesContent should match original source content'
  );

  // 2. remapSourcemap wrapper functionality
  const wrappedResult = remapSourcemap(minifiedMap, (sourcefile) => {
    if (sourcefile === 'transpiled.js') {
      return transpiledMap;
    }
    return null;
  });
  assert.deepStrictEqual(wrappedResult.sources, ['source.ts']);

  // 3. Loader callback returning null treated as original source file
  const singleStepMap = {
    version: 3,
    file: 'bundle.js',
    sources: ['root.js'],
    mappings: 'AAAA;',
    sourcesContent: ['console.log("hello");']
  };

  const singleRemapped = remapping(singleStepMap, () => null);
  assert.deepStrictEqual(singleRemapped.sources, ['root.js']);
  assert.deepStrictEqual(singleRemapped.sourcesContent, ['console.log("hello");']);

  // 4. Accept JSON string as sourcemap input
  const jsonInput = JSON.stringify(minifiedMap);
  const stringInputRemapped = remapping(jsonInput, (sourcefile) => {
    if (sourcefile === 'transpiled.js') {
      return transpiledMap;
    }
    return null;
  });
  assert.deepStrictEqual(stringInputRemapped.sources, ['source.ts']);

  // 5. decodedMappings option returning segment arrays
  const decodedResult = remapping(
    minifiedMap,
    (sourcefile) => (sourcefile === 'transpiled.js' ? transpiledMap : null),
    { decodedMappings: true }
  );
  assert(Array.isArray(decodedResult.mappings), 'mappings should be an array when decodedMappings is true');
  assert(Array.isArray(decodedResult.mappings[0]), 'first line mappings should be an array');

  // 6. excludeContent option omitting sourcesContent
  const excludedContentResult = remapping(
    minifiedMap,
    (sourcefile) => (sourcefile === 'transpiled.js' ? transpiledMap : null),
    { excludeContent: true }
  );
  assert.strictEqual(
    excludedContentResult.sourcesContent,
    undefined,
    'sourcesContent should be undefined when excludeContent is true'
  );

  // 7. toString() method returns valid JSON string
  const jsonString = remapped.toString();
  const parsed = JSON.parse(jsonString);
  assert.strictEqual(parsed.version, 3);
  assert.deepStrictEqual(parsed.sources, ['source.ts']);

  console.log('All @ampproject/remapping contract assertions passed.');
}

runTests();

오리진 시더

익명