CodeSampleX

サンプル

@esbuild/openharmony-arm64 0.28.1

検証済みサンプル — npm @esbuild/openharmony-arm64 0.28.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: esbuild WASM CLI reports the matching package…

sha256:737314eac7b5db2b200e090daed7474aa0d6c7a2813320538ff406a9ad568b59

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript 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
ゴール
verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1
パッケージ
環境
node 22.23.2
作成日
2026-08-20T19:42:43Z

コントラクト

  1. esbuild WASM CLI reports the matching package version 0.28.1
  2. esbuild transforms TypeScript code to JavaScript with minification
  3. esbuild transforms JSX syntax into standard JavaScript
  4. esbuild bundles modular source files into a single bundle

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

.npmrc
force=true
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/%40esbuild/openharmony-arm64@0.28.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40esbuild/openharmony-arm64@0.28.1
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:ca61a51ab3d1546ee9790ea59319a7121ef42c46cb26e1c96cae7e7d4592979b","constraints":{"executionContext":"node"},"contract":["esbuild WASM CLI reports the matching package version 0.28.1","esbuild transforms TypeScript code to JavaScript with minification","esbuild transforms JSX syntax into standard JavaScript","esbuild bundles modular source files into a single bundle"],"goal":"verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1","kind":"HOW","packages":["pkg:npm/%40esbuild/openharmony-arm64@0.28.1"],"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40esbuild/openharmony-arm64@0.28.1"],"schemaVersion":1,"subject":"pkg:npm/%40esbuild/openharmony-arm64@0.28.1","verifierAdapter":"node-typescript@1"}
index.js
const { spawnSync } = require('child_process');
const fs = require('fs');

const esbuildBin = require.resolve('@esbuild/openharmony-arm64/bin/esbuild');

function getVersion() {
  const result = spawnSync(process.execPath, [esbuildBin, '--version'], {
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild --version failed: ${result.stderr}`);
  }
  return result.stdout.trim();
}

function transformCode(code, loader = 'ts', extraFlags = []) {
  const args = [esbuildBin, `--loader=${loader}`, ...extraFlags];
  const result = spawnSync(process.execPath, args, {
    input: code,
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild transform failed: ${result.stderr}`);
  }
  return result.stdout;
}

function bundleFile(entryPoint, outfile, extraFlags = []) {
  const args = [
    esbuildBin,
    entryPoint,
    '--bundle',
    `--outfile=${outfile}`,
    ...extraFlags,
  ];
  const result = spawnSync(process.execPath, args, {
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild bundle failed: ${result.stderr}`);
  }
  return fs.readFileSync(outfile, 'utf8');
}

module.exports = {
  getVersion,
  transformCode,
  bundleFile,
};
package-lock.json
{
  "name": "sample-esbuild-openharmony-arm64",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-esbuild-openharmony-arm64",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@esbuild/openharmony-arm64": "0.28.1"
      }
    },
    "node_modules/@esbuild/openharmony-arm64": {
      "version": "0.28.1",
      "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz",
      "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "os": [
        "openharmony"
      ],
      "engines": {
        "node": ">=18"
      }
    }
  }
}
package.json
{
  "name": "sample-esbuild-openharmony-arm64",
  "version": "1.0.0",
  "description": "verify pkg:npm/@esbuild/openharmony-arm64@0.28.1",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "@esbuild/openharmony-arm64": "0.28.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40esbuild/openharmony-arm64@0.28.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const { getVersion, transformCode, bundleFile } = require('../index.js');

// Contract 1: esbuild WASM CLI reports the matching package version 0.28.1
{
  const version = getVersion();
  assert.strictEqual(version, '0.28.1', 'Expected version to be 0.28.1');
}

// Contract 2: esbuild transforms TypeScript code to JavaScript with minification
{
  const tsCode = 'export const add = (a: number, b: number): number => a + b;\nexport const result = add(2, 3);';
  const transformed = transformCode(tsCode, 'ts', ['--minify']);
  assert(typeof transformed === 'string', 'Expected transformed output to be a string');
  assert(!transformed.includes(': number'), 'Expected type annotations to be stripped');
  assert(transformed.includes('add=(a,b)=>a+b') || transformed.includes('add=(n,e)=>n+e') || transformed.includes('add'), 'Expected transformed output');
}

// Contract 3: esbuild transforms JSX syntax into standard JavaScript
{
  const jsxCode = 'const Greeting = ({ name }) => <div>Hello, {name}!</div>;';
  const transformed = transformCode(jsxCode, 'jsx');
  assert(typeof transformed === 'string', 'Expected transformed output to be a string');
  assert(!transformed.includes('<div>'), 'Expected JSX tags to be transformed');
  assert(transformed.includes('React.createElement') || transformed.includes('Hello'), 'Expected JSX transformed output');
}

// Contract 4: esbuild bundles modular source files into a single bundle
{
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'esbuild-test-'));
  const entryFile = path.join(tmpDir, 'entry.js');
  const modFile = path.join(tmpDir, 'math.js');
  const outFile = path.join(tmpDir, 'bundle.js');

  fs.writeFileSync(modFile, 'export function multiply(x, y) { return x * y; }');
  fs.writeFileSync(entryFile, 'import { multiply } from "./math.js"; console.log(multiply(6, 7));');

  const bundled = bundleFile(entryFile, outFile, ['--format=cjs']);
  assert(fs.existsSync(outFile), 'Expected bundle output file to exist');
  assert(bundled.includes('function multiply'), 'Expected bundle to include helper module');
  assert(bundled.includes('multiply(6, 7)'), 'Expected bundle to include entry call');

  fs.rmSync(tmpDir, { recursive: true, force: true });
}

console.log('All contracts passed successfully.');

オリジンシーダー

匿名