CodeSampleX

サンプル

rollup 4.62.5

検証済みサンプル — npm rollup 4.62.5. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: rollup.rollup splits dynamic imports into distinct entry and…

sha256:4a8ff1dac313a1e3813889a1b29b031b5587960fa4e0fc0f796e485de82f9a38

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

ケース

HOW
ゴール
verify pkg:npm/rollup@4.62.5
パッケージ
環境
node 22.23.2
作成日
2026-08-21T12:07:17Z

コントラクト

  1. rollup.rollup splits dynamic imports into distinct entry and dynamic entry chunks with chunk dependency metadata
  2. output.manualChunks partitions specified modules into dedicated vendor chunks with exported bindings
  3. Rollup plugin transform and renderChunk hooks intercept and mutate module source code and final chunk code
  4. Rollup plugin this.emitFile emits auxiliary asset files included in generated bundle output artifacts

ファイル

  • 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/rollup@4.62.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/rollup@4.62.5

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:88561cfa36ae30b7dbbad0249c1d84bc4e08c307ca57b68ecd1b510ef21fbdf3","contract":["rollup.rollup splits dynamic imports into distinct entry and dynamic entry chunks with chunk dependency metadata","output.manualChunks partitions specified modules into dedicated vendor chunks with exported bindings","Rollup plugin transform and renderChunk hooks intercept and mutate module source code and final chunk code","Rollup plugin this.emitFile emits auxiliary asset files included in generated bundle output artifacts"],"goal":"verify pkg:npm/rollup@4.62.5","kind":"HOW","packages":["pkg:npm/rollup@4.62.5"],"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/rollup@4.62.5"],"schemaVersion":1,"subject":"pkg:npm/rollup@4.62.5","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-rollup",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-rollup",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "rollup": "4.62.5"
      }
    },
    "node_modules/@napi-rs/lzma-linux-x64-gnu": {
      "version": "1.5.1",
      "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
      "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": "^22.20 || ^24.12 || >=25"
      }
    },
    "node_modules/@rollup/rollup-android-arm-eabi": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.5.tgz",
      "integrity": "sha512-jfkGfTwhQpsiSckPF8r9bU3pn3vyd72NlWaO+TgEO6WPSDnUhXzrNYCHBMOYj0ACaUgjm6eERLF+XV9a6RstoA==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@rollup/rollup-android-arm64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.5.tgz",
      "integrity": "sha512-oGVqyQlxnrz9/ty89oHpU857VUHEl5/Xu4R2lS+aivCTrNnSsbiENzTnNaBsjxH0CNWGPhzHArOLFwo+oKXveA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@rollup/rollup-darwin-arm64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.5.tgz",
      "integrity": "sha512-bW7B8xMEq8n99Q3ieEcPRGuphurdZAaFzQc9Efyyw3FL6DZO6pMy9xhdN+kBoD7Sy05xNXSr4OyPPnpkYriS/A==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-darwin-x64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.5.tgz",
      "integrity": "sha512-YSwBS86QeHOGlrxJ1PSOIZSkzRL/JmKeunhc+lV6M1a6En8QuVCD/T/qIA0J4Gd2Y86RIOBYrLcOUtqGh9+/1w==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-freebsd-arm64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.5.tgz",
      "integrity": "sha512-2fST8lILgl7cKbme/1KDdPCmbXbG+gqoV3bHp19L0ypX/3akYMBVdOunPleRCwonoLnXOZ/0F+Mt/v8POFmfcQ==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@rollup/rollup-freebsd-x64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.5.tgz",
      "integrity": "sha512-cpIxQCP9J+EVad0a6LO1kY3ZGODlk80VlI+2I96B8xMcdHZ4pLVhfQ49JFpYqjPF91FFkQWftf57YlDcTiw9yQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.5.tgz",
      "integrity": "sha512-r9fGh3eFs3e/udWh5ZjXQtxiYK/xoFxQaYR/cELxac/Udkl5Th+IsFm0CX3Kl9hmUH/we7EoMpjJgeQNnE0+IA==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm-musleabihf": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.5.tgz",
      "integrity": "sha512-xdvFdp7OM6KLJviJT2g/YuRSUjnZgGHk4RNgwIbN7X6cPugOucV60DdHXWzsBVCUdrGb6qSXnJQrrAKMmQuj3Q==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.5.tgz",
      "integrity": "sha512-rRqILAndyzHzP7T9NFQrq+4HFWNhqkqkKur7eiBpfLmz01PO0JKx5Vchu3YllE4YXI/Ftgq/szrDWg5GJ0mI8g==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-musl": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.5.tgz",
      "integrity": "sha512-Gf4X3qVMucayUvux6aXXPgXovocSFUC0rrffDuPI/S2nHhNMhjcZxsrAFYCOF350PRreW1XwzFj3CT/3bKsWCw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-loong64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.5.tgz",
      "integrity": "sha512-+s5qA0TNM0qm8PK/a5gt/1Hpx+NV08uSuCncvhziIlQzT6AEV2fnUQo7eBtFTFO0nA9scauvoR2HusfXmQnO4w==",
      "cpu": [
        "loong64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-loong64-musl": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.5.tgz",
      "integrity": "sha512-ybb6QvWwWJCbBWqERpc8K3pYVGIrXlG8MEQ8IIuJY6Y9KdHQxoFoNyfkAOtKn1VHu3KuLidXvwrvGR1mEjeWCw==",
      "cpu": [
        "loong64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-ppc64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.5.tgz",
      "integrity": "sha512-nZb1DtnOyhCmYvsC8A2CwOkopVg+IS1+fPUa7rMOAXtNw5+lLCLLPqd6XAiNrGtoQKsbvIBOwsHnBH/3wnb4HQ==",
      "cpu": [
        "ppc64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-ppc64-musl": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.5.tgz",
      "integrity": "sha512-yMbj63Sp89ryrXLWyz+sy+fYD2HpOnMCLGbe4Oa1smclFSUukdtD/BgdiHaAetJNb74URD8U4hM+qG5KVzMEkg==",
      "cpu": [
        "ppc64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-riscv64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.5.tgz",
      "integrity": "sha512-mhoan3OJw2kYV/e1jtIdmvUZgyBFeA6zGWsOswmR0Tg19TQbowZuR+JMLID6spbbBN7Zee2ejrgmy3+FxGrIdA==",
      "cpu": [
        "riscv64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-riscv64-musl": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.5.tgz",
      "integrity": "sha512-5ZTLmjWbb1VZdjuyhe83K/8QO0/h11midQCBP+X5OYn32ra7eOBoM0ZqtaY4nkgNsYgmdVhMYPoyVPTjUpHf3w==",
      "cpu": [
        "riscv64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-s390x-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.5.tgz",
      "integrity": "sha512-m53kG+br6PGxOTmgBEM2DHSDs9RVjsyEbUwjJPJGTFm1grWOG8EKJggDCTb60unD4Tjby8fi7/m9XfkEWasVWg==",
      "cpu": [
        "s390x"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.5.tgz",
      "integrity": "sha512-6RHPJR1g/uvdYU8uXBnfq3nlqyZCP82Fr6NHgfGoaIeSh0YEqnX/x6uA9MmJJbnSH7swqX4F+CkGdUF+6doiQA==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-musl": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.5.tgz",
      "integrity": "sha512-xs+OXQtEXgpXT0DmA5+U3qnRZHdCST/5HRQxS8wSPZTUZN/EMWeHuSIod32LQklTBZBV9DyfncKBQ8n5V3eFdw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-openbsd-x64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.5.tgz",
      "integrity": "sha512-e7hD+sl3s+mcLQDZ8pbudBVsdG6r5yN4w3LqG2TJ8sQHDpblWj5lrJs/3m01Cvlxbt4x13zu5thLjgypgtkYzw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "openbsd"
      ]
    },
    "node_modules/@rollup/rollup-openharmony-arm64": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.5.tgz",
      "integrity": "sha512-GiyJaCf+WpMub/17aPcKk27QMl5W6f+KhdPTjlFOn5akH5Wa/DCM9Stdx5cDfmasyKB08MqpVQ1uJE2RkkpbXg==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "openharmony"
      ]
    },
    "node_modules/@rollup/rollup-win32-arm64-msvc": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.5.tgz",
      "integrity": "sha512-+OQ8U2DdoEfXl8T4Fb18AjmEwbXMerKDKCL8yCPAYhKCEEKoul7rkbeGCBFCbAlaGaa7pmtRTpkAJM2LE/i5FA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-ia32-msvc": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.5.tgz",
      "integrity": "sha512-KanvAZrPKbDBFwrgiU9yEVpQoox9QPV1WZOXX7HudJQY+eSlu82CtWxDU8WtuRRvtN5EGkLczkd6Y6DTcvm9wA==",
      "cpu": [
        "ia32"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-x64-gnu": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.5.tgz",
      "integrity": "sha512-1aC3UEWTtRl3RK3VpDJ/Tqk1XI4SLTmXIthAq6wRWo8XiSXJNd+VprJM4/1P4+i6HIaFEFlVi9sTTziniD2tOQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-x64-msvc": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.5.tgz",
      "integrity": "sha512-/gDJaRs4gl0NPIwqCz+6PkpmhhjRAD2j6P4rSNHBzUkO3naEx2mIU0pRle1vUNRQ7mE/+8OOeXLTv/J56FKiQg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@types/estree": {
      "version": "1.0.9",
      "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
      "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
      "license": "MIT"
    },
    "node_modules/fsevents": {
      "version": "2.3.3",
      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
      "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
      "hasInstallScript": true,
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ],
      "engines": {
        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
      }
    },
    "node_modules/rollup": {
      "version": "4.62.5",
      "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.5.tgz",
      "integrity": "sha512-/tqMfgP7GPA3PHhCmuiS4vIjrSVhHLgY++i+dhbG462euyAj7FpM4D9uq1X3BgjlqRdpcOrYhcQtfiQLNc8tqw==",
      "license": "MIT",
      "dependencies": {
        "@types/estree": "1.0.9"
      },
      "bin": {
        "rollup": "dist/bin/rollup"
      },
      "engines": {
        "node": ">=18.0.0",
        "npm": ">=8.0.0"
      },
      "optionalDependencies": {
        "@napi-rs/lzma-linux-x64-gnu": "1.5.1",
        "@rollup/rollup-android-arm-eabi": "4.62.5",
        "@rollup/rollup-android-arm64": "4.62.5",
        "@rollup/rollup-darwin-arm64": "4.62.5",
        "@rollup/rollup-darwin-x64": "4.62.5",
        "@rollup/rollup-freebsd-arm64": "4.62.5",
        "@rollup/rollup-freebsd-x64": "4.62.5",
        "@rollup/rollup-linux-arm-gnueabihf": "4.62.5",
        "@rollup/rollup-linux-arm-musleabihf": "4.62.5",
        "@rollup/rollup-linux-arm64-gnu": "4.62.5",
        "@rollup/rollup-linux-arm64-musl": "4.62.5",
        "@rollup/rollup-linux-loong64-gnu": "4.62.5",
        "@rollup/rollup-linux-loong64-musl": "4.62.5",
        "@rollup/rollup-linux-ppc64-gnu": "4.62.5",
        "@rollup/rollup-linux-ppc64-musl": "4.62.5",
        "@rollup/rollup-linux-riscv64-gnu": "4.62.5",
        "@rollup/rollup-linux-riscv64-musl": "4.62.5",
        "@rollup/rollup-linux-s390x-gnu": "4.62.5",
        "@rollup/rollup-linux-x64-gnu": "4.62.5",
        "@rollup/rollup-linux-x64-musl": "4.62.5",
        "@rollup/rollup-openbsd-x64": "4.62.5",
        "@rollup/rollup-openharmony-arm64": "4.62.5",
        "@rollup/rollup-win32-arm64-msvc": "4.62.5",
        "@rollup/rollup-win32-ia32-msvc": "4.62.5",
        "@rollup/rollup-win32-x64-gnu": "4.62.5",
        "@rollup/rollup-win32-x64-msvc": "4.62.5",
        "fsevents": "~2.3.2"
      }
    }
  }
}
package.json
{
  "name": "sample-rollup",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for pkg:npm/rollup@4.62.5",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "rollup": "4.62.5"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/rollup@4.62.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/rollup@4.62.5"
  ]
}
src/index.js
const rollup = require('rollup');

/**
 * Builds a bundle from in-memory virtual modules using dynamic import code splitting.
 * @param {Record<string, string>} modules - Mapping of module specifiers to code.
 * @param {string} entryModule - Primary entry module identifier.
 * @param {import('rollup').OutputOptions} [outputOptions] - Rollup output options.
 * @returns {Promise<import('rollup').RollupOutput>} Rollup generated output.
 */
async function bundleWithDynamicImports(modules, entryModule, outputOptions = {}) {
  const plugin = {
    name: 'dynamic-virtual-loader',
    resolveId(id) {
      if (id in modules) return id;
      return null;
    },
    load(id) {
      if (id in modules) return modules[id];
      return null;
    }
  };

  const bundle = await rollup.rollup({
    input: entryModule,
    plugins: [plugin]
  });

  const result = await bundle.generate({
    format: 'esm',
    ...outputOptions
  });

  await bundle.close();
  return result;
}

/**
 * Bundles modules with explicit manualChunks splitting.
 * @param {Record<string, string>} modules - Mapping of module specifiers to code.
 * @param {Record<string, string>} entries - Mapping of entry chunk names to entry module IDs.
 * @param {Record<string, string[]>} manualChunks - manualChunks configuration.
 * @returns {Promise<import('rollup').RollupOutput>} Rollup generated output with split chunks.
 */
async function bundleWithManualChunks(modules, entries, manualChunks) {
  const plugin = {
    name: 'manual-chunks-loader',
    resolveId(id) {
      if (id in modules) return id;
      return null;
    },
    load(id) {
      if (id in modules) return modules[id];
      return null;
    }
  };

  const bundle = await rollup.rollup({
    input: entries,
    plugins: [plugin]
  });

  const result = await bundle.generate({
    format: 'esm',
    manualChunks
  });

  await bundle.close();
  return result;
}

/**
 * Bundles code using transform, renderChunk plugin hooks and asset emission.
 * @param {Record<string, string>} modules - Virtual modules mapping.
 * @param {string} entryModule - Entry module ID.
 * @param {object} options - Custom plugin hooks.
 * @param {(code: string, id: string) => string | null} [options.transform] - Source transform hook.
 * @param {(code: string, chunk: object) => string | null} [options.renderChunk] - Chunk render hook.
 * @param {{ name: string, source: string | Buffer }} [options.emitAsset] - Asset to emit via this.emitFile.
 * @returns {Promise<{ result: import('rollup').RollupOutput, emittedAssetId: string | null }>} Rollup output and asset reference.
 */
async function bundleWithPluginPipeline(modules, entryModule, options = {}) {
  let emittedAssetId = null;

  const plugin = {
    name: 'pipeline-plugin',
    buildStart() {
      if (options.emitAsset) {
        emittedAssetId = this.emitFile({
          type: 'asset',
          name: options.emitAsset.name,
          source: options.emitAsset.source
        });
      }
    },
    resolveId(id) {
      if (id in modules) return id;
      return null;
    },
    load(id) {
      if (id in modules) return modules[id];
      return null;
    },
    transform(code, id) {
      if (options.transform) {
        return options.transform(code, id);
      }
      return null;
    },
    renderChunk(code, chunk) {
      if (options.renderChunk) {
        return options.renderChunk(code, chunk);
      }
      return null;
    }
  };

  const bundle = await rollup.rollup({
    input: entryModule,
    plugins: [plugin]
  });

  const result = await bundle.generate({
    format: 'esm'
  });

  await bundle.close();
  return { result, emittedAssetId };
}

module.exports = {
  rollup,
  bundleWithDynamicImports,
  bundleWithManualChunks,
  bundleWithPluginPipeline
};
test/contract.js
const assert = require('node:assert');
const {
  rollup,
  bundleWithDynamicImports,
  bundleWithManualChunks,
  bundleWithPluginPipeline
} = require('../src/index.js');

async function runContractTests() {
  // 1. Rollup version verification
  assert.strictEqual(rollup.VERSION, '4.62.5', 'Rollup version should match 4.62.5');
  assert.strictEqual(typeof rollup.rollup, 'function', 'rollup.rollup should be a function');

  // 2. rollup.rollup splits dynamic imports into distinct entry and dynamic entry chunks with chunk dependency metadata
  const dynamicModules = {
    'entry.js': `
      export async function loadFeature() {
        const mod = await import('./dynamicFeature.js');
        return mod.computeResult(21);
      }
    `,
    './dynamicFeature.js': `
      export function computeResult(val) {
        return val * 2;
      }
    `
  };

  const dynamicResult = await bundleWithDynamicImports(dynamicModules, 'entry.js');
  assert.strictEqual(dynamicResult.output.length, 2, 'Dynamic import bundling should produce 2 chunks');

  const entryChunk = dynamicResult.output.find(c => c.isEntry);
  const dynamicChunk = dynamicResult.output.find(c => c.isDynamicEntry);

  assert.ok(entryChunk, 'Entry chunk must be present and marked isEntry=true');
  assert.ok(dynamicChunk, 'Dynamic chunk must be present and marked isDynamicEntry=true');
  assert.strictEqual(entryChunk.dynamicImports.length, 1, 'Entry chunk dynamicImports should list 1 target');
  assert.strictEqual(entryChunk.dynamicImports[0], dynamicChunk.fileName, 'dynamicImports should reference dynamic chunk fileName');
  assert.ok(dynamicChunk.code.includes('computeResult'), 'Dynamic chunk should contain computeResult function');

  // 3. output.manualChunks partitions specified modules into dedicated vendor chunks with exported bindings
  const manualChunkModules = {
    'app.js': `
      import { calculate } from 'calculator-pkg';
      import { formatMessage } from 'formatter-pkg';
      export const result = formatMessage(calculate(10, 5));
    `,
    'calculator-pkg': `
      export function calculate(a, b) {
        return a * b;
      }
    `,
    'formatter-pkg': `
      export function formatMessage(val) {
        return 'Value: ' + val;
      }
    `
  };

  const manualResult = await bundleWithManualChunks(
    manualChunkModules,
    { app: 'app.js' },
    { 'vendor-chunk': ['calculator-pkg', 'formatter-pkg'] }
  );

  const vendorChunk = manualResult.output.find(c => c.name === 'vendor-chunk');
  assert.ok(vendorChunk, 'Vendor chunk named vendor-chunk must be generated');
  assert.ok(vendorChunk.code.includes('calculate'), 'Vendor chunk should contain calculate function');
  assert.ok(vendorChunk.code.includes('formatMessage'), 'Vendor chunk should contain formatMessage function');

  const appChunk = manualResult.output.find(c => c.name === 'app');
  assert.ok(appChunk, 'App entry chunk must be generated');
  assert.ok(appChunk.imports.includes(vendorChunk.fileName), 'App chunk imports should include vendor chunk fileName');

  // 4. Rollup plugin transform and renderChunk hooks intercept and mutate module source code and final chunk code
  const pipelineModules = {
    'main.js': `export const VALUE = 100;`
  };

  const { result: transformedResult } = await bundleWithPluginPipeline(
    pipelineModules,
    'main.js',
    {
      transform(code, id) {
        if (id === 'main.js') {
          return code.replace('100', '999');
        }
        return null;
      },
      renderChunk(code, chunk) {
        return '/* injected-header-comment */\n' + code;
      }
    }
  );

  const mainChunk = transformedResult.output[0];
  assert.ok(mainChunk.code.startsWith('/* injected-header-comment */'), 'renderChunk hook should prepend custom comment');
  assert.ok(mainChunk.code.includes('999'), 'transform hook should replace 100 with 999');

  // 5. Rollup plugin this.emitFile emits auxiliary asset files included in generated bundle output artifacts
  const assetPayload = JSON.stringify({ name: 'sample-asset', status: 'ready' });
  const { result: assetResult, emittedAssetId } = await bundleWithPluginPipeline(
    pipelineModules,
    'main.js',
    {
      emitAsset: {
        name: 'metadata.json',
        source: assetPayload
      }
    }
  );

  assert.strictEqual(typeof emittedAssetId, 'string', 'this.emitFile should return an asset reference ID');
  const assetOutput = assetResult.output.find(o => o.type === 'asset' && o.name === 'metadata.json');
  assert.ok(assetOutput, 'Emitted asset should appear in bundle output');
  assert.strictEqual(assetOutput.source, assetPayload, 'Emitted asset source should match input payload');

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

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

オリジンシーダー

匿名