CodeSampleX

Exemplo

@babel/helper-compilation-targets 8.0.0

Amostra verificada para npm @babel/helper-compilation-targets 8.0.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:ac3a911b71fd085d1a494a20bf80ada64d80b68cd502b970c2377913f17ab5f3

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify pkg:npm/%40babel/helper-compilation-targets@8.0.0
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-20T20:57:39Z

Contrato

  1. resolveTargets resolves and normalizes browser and node target versions
  2. validateBrowsersQuery validates browser query format
  3. formatTargets converts normalized target versions to clean display versions
  4. checkFeatureRequired determines if a transform plugin is required for target environment
  5. filterRequiredFeatures filters compatibility matrix to return required feature set
  6. getFeatureInclusionReasons returns the specific targets necessitating the transform

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/%40babel/helper-compilation-targets@8.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/helper-compilation-targets@8.0.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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:b5bc4fba04c0573c7e5bb034a3322a2c5ff2e8f0d81ec25343410eb96ead501e","constraints":{"executionContext":"node"},"contract":["resolveTargets resolves and normalizes browser and node target versions","validateBrowsersQuery validates browser query format","formatTargets converts normalized target versions to clean display versions","checkFeatureRequired determines if a transform plugin is required for target environment","filterRequiredFeatures filters compatibility matrix to return required feature set","getFeatureInclusionReasons returns the specific targets necessitating the transform"],"goal":"verify pkg:npm/%40babel/helper-compilation-targets@8.0.0","kind":"HOW","packages":["pkg:npm/%40babel/helper-compilation-targets@8.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40babel/helper-compilation-targets@8.0.0"],"schemaVersion":1,"subject":"pkg:npm/%40babel/helper-compilation-targets@8.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-babel-helper-compilation-targets",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-babel-helper-compilation-targets",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@babel/helper-compilation-targets": "8.0.0"
      }
    },
    "node_modules/@babel/compat-data": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-8.0.0.tgz",
      "integrity": "sha512-DOjnob/cXOUgDOozCDeq/aK2p5y8dUIVdf6tNhEV1HQRd6I8aQ4f4fbtHRVEvb6lP3BGomrKHiS8ICAASSVQSw==",
      "license": "MIT",
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/helper-compilation-targets": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-8.0.0.tgz",
      "integrity": "sha512-JwculLABZvyPvyLBpwU/E/IbH2uM3mnxNtIJpxnIfb24y1PrdVxK5Dqjle4DpgqpGRnwgC7G8IkzPdSXZrO1Ew==",
      "license": "MIT",
      "dependencies": {
        "@babel/compat-data": "^8.0.0",
        "@babel/helper-validator-option": "^8.0.0",
        "browserslist": "^4.24.0",
        "lru-cache": "^11.0.0",
        "semver": "^7.7.3"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/helper-validator-option": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-8.0.0.tgz",
      "integrity": "sha512-U4Dybxh4WESWHt5XhBeExi4DrY0/DNK1aHpQbsrQXCUbFHuMweT0TpLEWKvaraV2Y6fS+ZXunsZ8zIuZIgvF2Q==",
      "license": "MIT",
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.16",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.16.tgz",
      "integrity": "sha512-H/bNPUFHewJHyCTdjn1n3Pit5+2GmWT6mmeHImPX+8MA9NA6b67jO4gYmi4jTbCJb2otq34KMZnovndDPqJwhQ==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.8",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
      "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "baseline-browser-mapping": "^2.11.12",
        "caniuse-lite": "^1.0.30001809",
        "electron-to-chromium": "^1.5.402",
        "node-releases": "^2.0.53",
        "update-browserslist-db": "^1.3.0"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001809",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz",
      "integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    },
    "node_modules/electron-to-chromium": {
      "version": "1.5.411",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.411.tgz",
      "integrity": "sha512-gglkxzokjHfawpGxq75XdBV2/l3BAPzrsMs70qgaZdTW5rpV1tC4MdgJVP9fN126bODA4ZJQkn1wryEzJyQXIg==",
      "license": "ISC"
    },
    "node_modules/escalade": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
      "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/lru-cache": {
      "version": "11.5.2",
      "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz",
      "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.53",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.53.tgz",
      "integrity": "sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/update-browserslist-db": {
      "version": "1.3.1",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.1.tgz",
      "integrity": "sha512-ZZ61DsRsOnakl74HAmp3oSN4aXUmEWXf+i/yv0h7tIBfICc3VdrFErQKUUKPgu3AMsTUMbcongALEN4l6GSUrQ==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "escalade": "^3.2.0",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "update-browserslist-db": "cli.js"
      },
      "peerDependencies": {
        "browserslist": ">= 4.21.0"
      }
    }
  }
}
package.json
{
  "name": "sample-babel-helper-compilation-targets",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @babel/helper-compilation-targets",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@babel/helper-compilation-targets": "8.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40babel/helper-compilation-targets@8.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/helper-compilation-targets@8.0.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const helperCompilationTargets = require('@babel/helper-compilation-targets');

const getTargets = helperCompilationTargets.default || helperCompilationTargets;
const {
  isRequired,
  filterItems,
  prettifyTargets,
  getInclusionReasons,
  isBrowsersQueryValid,
  TargetNames
} = helperCompilationTargets;

/**
 * Resolves compilation targets from query or explicit target options.
 */
function resolveTargets(inputTargets, options) {
  return getTargets(inputTargets, options);
}

/**
 * Validates whether the browser query is acceptable.
 */
function validateBrowsersQuery(query) {
  return isBrowsersQueryValid(query);
}

/**
 * Formats target version keys into human-readable versions.
 */
function formatTargets(targets) {
  return prettifyTargets(targets);
}

/**
 * Checks if a specific feature is required for given targets.
 */
function checkFeatureRequired(featureName, targets, compatData, options = {}) {
  return isRequired(featureName, targets, { compatData, ...options });
}

/**
 * Filters required features from a compatibility matrix for given targets.
 */
function filterRequiredFeatures(compatData, targets, includes = new Set(), excludes = new Set()) {
  return filterItems(compatData, includes, excludes, targets, null);
}

/**
 * Retrieves the target reasons why a feature needs to be transformed.
 */
function getFeatureInclusionReasons(featureName, targets, compatData) {
  return getInclusionReasons(featureName, targets, compatData);
}

module.exports = {
  helperCompilationTargets,
  getTargets,
  resolveTargets,
  validateBrowsersQuery,
  formatTargets,
  checkFeatureRequired,
  filterRequiredFeatures,
  getFeatureInclusionReasons,
  isRequired,
  filterItems,
  prettifyTargets,
  getInclusionReasons,
  isBrowsersQueryValid,
  TargetNames
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  resolveTargets,
  validateBrowsersQuery,
  formatTargets,
  checkFeatureRequired,
  filterRequiredFeatures,
  getFeatureInclusionReasons,
  TargetNames
} = require('../src/index.js');

async function runContract() {
  // 1. resolveTargets resolves and normalizes browser and node target versions
  const explicitTargets = resolveTargets({ node: '18.0.0', chrome: '100' });
  assert.strictEqual(explicitTargets.node, '18.0.0', 'Node target should be 18.0.0');
  assert.strictEqual(explicitTargets.chrome, '100.0.0', 'Chrome target should be 100.0.0');

  const queryTargets = resolveTargets({ browsers: 'chrome > 90, node >= 18' });
  assert.ok(queryTargets.chrome, 'Chrome target should be present from query');
  assert.ok(queryTargets.node, 'Node target should be present from query');

  // 2. validateBrowsersQuery validates browser query format
  assert.strictEqual(validateBrowsersQuery('last 2 versions'), true, 'Valid browser query should return true');
  assert.strictEqual(validateBrowsersQuery('chrome >= 80'), true, 'Valid query should return true');
  assert.strictEqual(validateBrowsersQuery(12345), false, 'Non-string query should return false');
  assert.strictEqual(validateBrowsersQuery(null), false, 'Null query should return false');

  // 3. formatTargets converts normalized target versions to clean display versions
  const formatted = formatTargets({ chrome: '100.0.0', node: '18.0.0' });
  assert.deepStrictEqual(formatted, { chrome: '100', node: '18' }, 'Formatted targets should match clean display versions');

  // 4. checkFeatureRequired determines if a transform plugin is required for target environment
  const sampleCompatData = {
    'transform-arrow-functions': { chrome: '47.0.0', node: '6.0.0' },
    'transform-pipeline-operator': { chrome: '120.0.0', node: '22.0.0' }
  };
  const activeTargets = { chrome: '100.0.0', node: '18.0.0' };

  const arrowRequired = checkFeatureRequired('transform-arrow-functions', activeTargets, sampleCompatData);
  assert.strictEqual(arrowRequired, false, 'Supported feature should not be required');

  const pipelineRequired = checkFeatureRequired('transform-pipeline-operator', activeTargets, sampleCompatData);
  assert.strictEqual(pipelineRequired, true, 'Unsupported feature should be required');

  // 5. filterRequiredFeatures filters compatibility matrix to return required feature set
  const requiredSet = filterRequiredFeatures(sampleCompatData, activeTargets);
  assert.strictEqual(requiredSet.has('transform-pipeline-operator'), true, 'Set must include unsupported feature');
  assert.strictEqual(requiredSet.has('transform-arrow-functions'), false, 'Set must not include supported feature');

  const withIncludes = filterRequiredFeatures(
    sampleCompatData,
    activeTargets,
    new Set(['transform-arrow-functions'])
  );
  assert.strictEqual(withIncludes.has('transform-arrow-functions'), true, 'Explicitly included feature must be present');
  assert.strictEqual(withIncludes.has('transform-pipeline-operator'), true, 'Unsupported feature must still be present');

  // 6. getFeatureInclusionReasons returns the specific targets necessitating the transform
  const inclusionReasons = getFeatureInclusionReasons('transform-pipeline-operator', activeTargets, sampleCompatData);
  assert.ok(inclusionReasons.chrome, 'Chrome should be listed in inclusion reasons');
  assert.ok(inclusionReasons.node, 'Node should be listed in inclusion reasons');

  // TargetNames constants check
  assert.strictEqual(TargetNames.node, 'node');
  assert.strictEqual(TargetNames.chrome, 'chrome');

  console.log('Contract tests passed successfully.');
}

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

Seeder de origem

anônimo