CodeSampleX

샘플

@babel/helpers 8.0.0: Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers

검증된 샘플 — npm @babel/helpers 8.0.0: Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers. node 22 · linux…

sha256:5af1e96ca115e335bdc16d2538e1001bae469f6b375379a69fe30b8485ab73b3

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
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
목표
Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers
패키지
생성일
2026-08-20T21:24:14Z

컨트랙트

  1. listAllHelpers returns an array of runtime helper names including typeof, classCallCheck, and wrapRegExp
  2. hasHelper checks if a helper is registered in @babel/helpers list
  3. getHelperAst retrieves the AST node statements for a helper declaration
  4. getHelperGlobals returns the required global identifiers for a helper
  5. getHelperMinVersion returns the minimum Babel runtime version for a helper
  6. getHelperDependencies returns dependent helper names required by a helper
  7. isHelperInternal indicates whether a helper is flagged for internal compiler use
  8. getHelperAst throws BABEL_HELPER_UNKNOWN ReferenceError when requesting an unknown helper name

파일

  • 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: Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/helpers@8.0.0

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:6e79ed0fb65a75c7e4485d11f3eae882c1e147d8845d306677b0e8968e14b238","contract":["listAllHelpers returns an array of runtime helper names including typeof, classCallCheck, and wrapRegExp","hasHelper checks if a helper is registered in @babel/helpers list","getHelperAst retrieves the AST node statements for a helper declaration","getHelperGlobals returns the required global identifiers for a helper","getHelperMinVersion returns the minimum Babel runtime version for a helper","getHelperDependencies returns dependent helper names required by a helper","isHelperInternal indicates whether a helper is flagged for internal compiler use","getHelperAst throws BABEL_HELPER_UNKNOWN ReferenceError when requesting an unknown helper name"],"goal":"Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers","kind":"HOW","packages":["pkg:npm/%40babel/helpers@8.0.0"],"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/helpers@8.0.0"],"schemaVersion":1,"subject":"pkg:npm/%40babel/helpers@8.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-babel-helpers",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-babel-helpers",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@babel/helpers": "8.0.0"
      }
    },
    "node_modules/@babel/code-frame": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-8.0.0.tgz",
      "integrity": "sha512-dYYg153EyN2Ekbqw2zAsbd6/JR+9N2SEoC7YV2GyyqMM7x9bLDTjBD6XBhSMLH0wtIVyJj03jWNriQhaN+eoCw==",
      "license": "MIT",
      "dependencies": {
        "@babel/helper-validator-identifier": "^8.0.0",
        "js-tokens": "^10.0.0"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/helper-string-parser": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.0.0.tgz",
      "integrity": "sha512-6mJgmFFFIIO82vvoLt9XtRC7/TkzXfts1t/SpRX4IHSzMgqoPYCWesVu1udUPUWioAE/2fcG6WuI8zrkE1gwrg==",
      "license": "MIT",
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/helper-validator-identifier": {
      "version": "8.0.4",
      "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.4.tgz",
      "integrity": "sha512-4wFaiLd0bVo4cIoTXI3zKI038NIWE/cr3jvBjejOVYVxV/m8Ltav1USiGzG1fmS5J2RhgEOgXNNK46cRPnRsrg==",
      "license": "MIT",
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/helpers": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-8.0.0.tgz",
      "integrity": "sha512-wfbi91pM3py96oIiJEz7qIpyXDytgr9zQC1HEWwlGNVRAEmItuU/0a41ZUKu1sJGyhhOIpc4t5vk4PYzt8wpsg==",
      "license": "MIT",
      "dependencies": {
        "@babel/template": "^8.0.0",
        "@babel/types": "^8.0.0"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/parser": {
      "version": "8.0.4",
      "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.0.4.tgz",
      "integrity": "sha512-srpptsAkEbbNIC/q8nT7o+m6CQe8CJUTV/t7MYc9NnWlgYVtHOb7JH6SorxMhN0kuRJjVqXbKClG6xSbPtzz+g==",
      "license": "MIT",
      "dependencies": {
        "@babel/types": "^8.0.4"
      },
      "bin": {
        "parser": "bin/babel-parser.js"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/template": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/@babel/template/-/template-8.0.0.tgz",
      "integrity": "sha512-eAD0QW/AlbamBbw0FeGiwasbCVPq5ncW0HNVyLP3B9czqLyh4gvw+5JTSNt6le9+ziAU7mqDZsKTHf3jTb4chQ==",
      "license": "MIT",
      "dependencies": {
        "@babel/code-frame": "^8.0.0",
        "@babel/parser": "^8.0.0",
        "@babel/types": "^8.0.0"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/@babel/types": {
      "version": "8.0.4",
      "resolved": "https://registry.npmjs.org/@babel/types/-/types-8.0.4.tgz",
      "integrity": "sha512-eY+Yn3dCqTGmyiq2QRU66lA5FL8lqqqvecHt0fF3uHONIa7ToYsaCiWV8lOKqAs0Rb2SjixiKFROngnulPtt2g==",
      "license": "MIT",
      "dependencies": {
        "@babel/helper-string-parser": "^8.0.0",
        "@babel/helper-validator-identifier": "^8.0.4"
      },
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    },
    "node_modules/js-tokens": {
      "version": "10.0.0",
      "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz",
      "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-babel-helpers",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @babel/helpers",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@babel/helpers": "8.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "Retrieve AST nodes, dependencies, minimum version, and metadata for runtime helpers with @babel/helpers",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/helpers@8.0.0"
  ]
}
src/index.js
const helpers = require('@babel/helpers');

/**
 * Returns a list of all helper names available in @babel/helpers.
 * @returns {string[]}
 */
function listAllHelpers() {
  return [...helpers.list];
}

/**
 * Checks if a helper is defined in @babel/helpers.
 * @param {string} name
 * @returns {boolean}
 */
function hasHelper(name) {
  return helpers.list.includes(name);
}

/**
 * Retrieves AST node statements for a runtime helper.
 * @param {string} name
 * @param {Function} [getDependency]
 * @param {string} [bindingName]
 * @param {string[]} [localBindings]
 * @returns {object[]}
 */
function getHelperAst(name, getDependency, bindingName, localBindings) {
  const result = helpers.get(name, getDependency, bindingName, localBindings);
  return result.nodes;
}

/**
 * Retrieves required global identifiers for a helper.
 * @param {string} name
 * @returns {string[]}
 */
function getHelperGlobals(name) {
  const result = helpers.get(name);
  return result.globals;
}

/**
 * Retrieves the minimum Babel version required for a helper.
 * @param {string} name
 * @returns {string}
 */
function getHelperMinVersion(name) {
  return helpers.minVersion(name);
}

/**
 * Retrieves dependent helper names for a helper.
 * @param {string} name
 * @returns {string[]}
 */
function getHelperDependencies(name) {
  return helpers.getDependencies(name);
}

/**
 * Checks if a helper is marked internal.
 * @param {string} name
 * @returns {boolean}
 */
function isHelperInternal(name) {
  return Boolean(helpers.isInternal(name));
}

module.exports = {
  listAllHelpers,
  hasHelper,
  getHelperAst,
  getHelperGlobals,
  getHelperMinVersion,
  getHelperDependencies,
  isHelperInternal,
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  listAllHelpers,
  hasHelper,
  getHelperAst,
  getHelperGlobals,
  getHelperMinVersion,
  getHelperDependencies,
  isHelperInternal,
} = require('../src/index.js');

async function runContract() {
  // 1. listAllHelpers
  const helpersList = listAllHelpers();
  assert.ok(Array.isArray(helpersList), 'listAllHelpers should return an array');
  assert.ok(helpersList.length > 50, 'helpers list should contain many helper definitions');
  assert.ok(helpersList.includes('typeof'), 'helpers list should include typeof');
  assert.ok(helpersList.includes('classCallCheck'), 'helpers list should include classCallCheck');
  assert.ok(helpersList.includes('wrapRegExp'), 'helpers list should include wrapRegExp');
  assert.ok(helpersList.includes('inherits'), 'helpers list should include inherits');

  // 2. hasHelper
  assert.strictEqual(hasHelper('typeof'), true, 'hasHelper should return true for typeof');
  assert.strictEqual(hasHelper('wrapRegExp'), true, 'hasHelper should return true for wrapRegExp');
  assert.strictEqual(hasHelper('nonExistentHelper123'), false, 'hasHelper should return false for unknown helper');

  // 3. getHelperAst
  const typeofAstNodes = getHelperAst('typeof');
  assert.ok(Array.isArray(typeofAstNodes), 'getHelperAst should return an array of AST nodes');
  assert.strictEqual(typeofAstNodes.length, 1, 'typeof helper should have 1 top-level AST node');
  assert.strictEqual(typeofAstNodes[0].type, 'FunctionDeclaration', 'typeof helper AST node should be FunctionDeclaration');
  assert.strictEqual(typeofAstNodes[0].id.name, '_typeof', 'typeof helper default function name should be _typeof');

  // 4. getHelperGlobals
  const typeofGlobals = getHelperGlobals('typeof');
  assert.ok(Array.isArray(typeofGlobals), 'getHelperGlobals should return an array of global identifiers');
  assert.ok(typeofGlobals.includes('Symbol'), 'typeof helper globals should include Symbol');

  const classCallCheckGlobals = getHelperGlobals('classCallCheck');
  assert.ok(Array.isArray(classCallCheckGlobals), 'classCallCheck globals should be an array');
  assert.ok(classCallCheckGlobals.includes('TypeError'), 'classCallCheck globals should include TypeError');

  // 5. getHelperMinVersion
  const typeofMinVer = getHelperMinVersion('typeof');
  assert.strictEqual(typeofMinVer, '7.0.0-beta.0', 'typeof helper minimum version should match 7.0.0-beta.0');

  const wrapRegExpMinVer = getHelperMinVersion('wrapRegExp');
  assert.strictEqual(wrapRegExpMinVer, '7.19.0', 'wrapRegExp helper minimum version should match 7.19.0');

  // 6. getHelperDependencies
  const typeofDeps = getHelperDependencies('typeof');
  assert.ok(Array.isArray(typeofDeps), 'getHelperDependencies should return an array');
  assert.deepStrictEqual(typeofDeps, [], 'typeof helper should have no dependencies');

  const wrapRegExpDeps = getHelperDependencies('wrapRegExp');
  assert.ok(Array.isArray(wrapRegExpDeps), 'wrapRegExp dependencies should be an array');
  assert.ok(wrapRegExpDeps.includes('setPrototypeOf'), 'wrapRegExp dependencies should include setPrototypeOf');
  assert.ok(wrapRegExpDeps.includes('inherits'), 'wrapRegExp dependencies should include inherits');

  // 7. isHelperInternal
  assert.strictEqual(isHelperInternal('typeof'), false, 'typeof helper is not internal');
  assert.strictEqual(isHelperInternal('wrapRegExp'), false, 'wrapRegExp helper is not internal');

  // 8. Unknown helper error handling
  assert.throws(
    () => getHelperAst('unknownHelperNameXYZ'),
    (err) => {
      return (
        err instanceof ReferenceError &&
        err.code === 'BABEL_HELPER_UNKNOWN' &&
        err.helper === 'unknownHelperNameXYZ'
      );
    },
    'getHelperAst should throw BABEL_HELPER_UNKNOWN ReferenceError for unknown helper'
  );

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

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

오리진 시더

익명