CodeSampleX

Beispiel

@babel/helper-compilation-targets 7.29.7

Verifiziertes Beispiel für npm @babel/helper-compilation-targets 7.29.7. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:546608cc2732e1b2c02f7b6937f7c91b080ec2f98783a2cc548388be16ade8d1

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/%40babel/helper-compilation-targets@7.29.7
Pakete
Erstellt
2026-08-23T06:30:59Z

Contract

  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

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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@7.29.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/helper-compilation-targets@7.29.7

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:c415d8ad112a792d4af744805ce75d9daaca9cd608c9f0747a340aaf0bfc9ec5","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@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/helper-compilation-targets@7.29.7"],"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/%40babel/helper-compilation-targets@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/helper-compilation-targets@7.29.7","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": "7.29.7"
      }
    },
    "node_modules/@babel/compat-data": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz",
      "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/@babel/helper-compilation-targets": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz",
      "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==",
      "license": "MIT",
      "dependencies": {
        "@babel/compat-data": "^7.29.7",
        "@babel/helper-validator-option": "^7.29.7",
        "browserslist": "^4.24.0",
        "lru-cache": "^5.1.1",
        "semver": "^6.3.1"
      },
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/@babel/helper-validator-option": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz",
      "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.18",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.18.tgz",
      "integrity": "sha512-1iEmLEYSiE1SeBoAfPo/Mnx3PzfzHUkDK61ASkCpuk3YXugYLH5DYK1SzqV55F8FMI6s0F+/tCP7Polz1QRjxw==",
      "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.412",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.412.tgz",
      "integrity": "sha512-z4rMe3esBzlzovKHj4gxJnsCGZRK5l4baUvm+gCGJBPE+gsyUMKsuU9tnEUtI1dOebXz1ytAPGjvXhmQ7rIPwA==",
      "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": "5.1.1",
      "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
      "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
      "license": "ISC",
      "dependencies": {
        "yallist": "^3.0.2"
      }
    },
    "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": "6.3.1",
      "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
      "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      }
    },
    "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"
      }
    },
    "node_modules/yallist": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
      "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-babel-helper-compilation-targets",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@babel/helper-compilation-targets": "7.29.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40babel/helper-compilation-targets@7.29.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/helper-compilation-targets@7.29.7"
  ]
}
src/index.mjs
import targetsPkg, {
  prettifyTargets,
  isBrowsersQueryValid,
  isRequired,
  filterItems,
  getInclusionReasons,
  TargetNames
} from "@babel/helper-compilation-targets";

const getTargets = typeof targetsPkg === "function" ? targetsPkg : targetsPkg.default;

export function resolveTargets(inputTargets = {}, options = {}) {
  return getTargets(inputTargets, options);
}

export function validateBrowsersQuery(query) {
  return isBrowsersQueryValid(query);
}

export function formatTargets(targets) {
  return prettifyTargets(targets);
}

export function checkFeatureRequired(featureName, targets, options = {}) {
  return isRequired(featureName, targets, options);
}

export function filterRequiredFeatures(compatData, targets, options = {}) {
  const includes = options.includes || new Set();
  const excludes = options.excludes || new Set();
  return filterItems(compatData, includes, excludes, targets);
}

export function getFeatureInclusionReasons(featureName, targets, compatData) {
  return getInclusionReasons(featureName, targets, compatData);
}

export { TargetNames };
test/contract.mjs
import assert from "node:assert/strict";
import {
  resolveTargets,
  validateBrowsersQuery,
  formatTargets,
  checkFeatureRequired,
  filterRequiredFeatures,
  getFeatureInclusionReasons,
  TargetNames
} from "../src/index.mjs";

// Test 1: resolveTargets resolves and normalizes browser and node target versions
{
  const targets = resolveTargets({
    node: "14.0.0",
    chrome: "80",
    firefox: "75"
  });
  assert.equal(targets.node, "14.0.0");
  assert.equal(targets.chrome, "80.0.0");
  assert.equal(targets.firefox, "75.0.0");
  assert.ok(TargetNames.node);
  assert.ok(TargetNames.chrome);
}

// Test 2: validateBrowsersQuery validates browser query format
{
  assert.equal(validateBrowsersQuery("last 2 versions"), true);
  assert.equal(validateBrowsersQuery(["ie 11", "chrome >= 80"]), true);
  assert.equal(validateBrowsersQuery(12345), false);
  assert.equal(validateBrowsersQuery(null), false);
  assert.equal(validateBrowsersQuery([123]), false);
}

// Test 3: formatTargets converts normalized target versions to clean display versions
{
  const rawTargets = {
    chrome: "80.0.0",
    node: "14.0.0",
    firefox: "75.0.0"
  };
  const prettified = formatTargets(rawTargets);
  assert.deepEqual(prettified, {
    chrome: "80",
    node: "14",
    firefox: "75"
  });
}

// Test 4: checkFeatureRequired determines if a transform plugin is required for target environment
{
  const compatData = {
    "transform-arrow-functions": {
      chrome: "47.0.0",
      node: "6.0.0",
      firefox: "45.0.0"
    }
  };

  const oldTargets = resolveTargets({ node: "5.0.0" });
  const modernTargets = resolveTargets({ node: "14.0.0" });

  assert.equal(checkFeatureRequired("transform-arrow-functions", oldTargets, { compatData }), true);
  assert.equal(checkFeatureRequired("transform-arrow-functions", modernTargets, { compatData }), false);

  assert.equal(
    checkFeatureRequired("transform-arrow-functions", modernTargets, {
      compatData,
      includes: new Set(["transform-arrow-functions"])
    }),
    true
  );
  assert.equal(
    checkFeatureRequired("transform-arrow-functions", oldTargets, {
      compatData,
      excludes: new Set(["transform-arrow-functions"])
    }),
    false
  );
}

// Test 5: filterRequiredFeatures filters compatibility matrix to return required feature set
{
  const compatData = {
    "transform-arrow-functions": { chrome: "47.0.0", node: "6.0.0" },
    "transform-classes": { chrome: "49.0.0", node: "6.0.0" },
    "transform-for-of": { chrome: "51.0.0", node: "0.12.0" }
  };

  const node5Targets = resolveTargets({ node: "5.0.0" });
  const requiredForNode5 = filterRequiredFeatures(compatData, node5Targets);
  assert.ok(requiredForNode5.has("transform-arrow-functions"));
  assert.ok(requiredForNode5.has("transform-classes"));
  assert.ok(!requiredForNode5.has("transform-for-of"));

  const modernTargets = resolveTargets({ node: "14.0.0", chrome: "80" });
  const requiredForModern = filterRequiredFeatures(compatData, modernTargets);
  assert.equal(requiredForModern.size, 0);
}

// Test 6: getFeatureInclusionReasons returns the specific targets necessitating the transform
{
  const compatData = {
    "transform-arrow-functions": {
      chrome: "47.0.0",
      node: "6.0.0"
    }
  };

  const mixedTargets = resolveTargets({
    node: "5.0.0",
    chrome: "80"
  });

  const reasons = getFeatureInclusionReasons("transform-arrow-functions", mixedTargets, compatData);
  assert.deepEqual(reasons, {
    node: "5"
  });
}

console.log("All @babel/helper-compilation-targets contract tests passed successfully.");

Ursprungs-Seeder

anonym