CodeSampleX

Sample

rollup 4.63.3: rollup

Verified sample for npm rollup 4.63.3: rollup. The contract ran on node 22 · linux debian/x64 · docker and passed: Bundling virtual ES modules with rollup…

sha256:0c284ca600f1e7cfbce5427cc81e119506b354a42c38391e86fdd5bca629161a

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-17

Case

HOW
Goal
verify rollup.rollup in pkg:npm/rollup@4.63.3
Packages
Symbols
  • rollup.rollup
Environment
node 22.23.2
Created
2026-09-17T00:14:51Z

Contract

  1. Bundling virtual ES modules with rollup and calling bundle.generate produces inline bundled chunks for ESM and exports for CJS.
  2. Configuring manualChunks splits shared dependencies into dedicated chunk files referenced by entry points.
  3. Custom transform plugin hooks intercept module code and apply AST/string replacements prior to chunk generation.

Files

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

Download the source artifact (tar.gz)

Source

NOTES.md
# Rollup 4.63.3 Programmatic Bundling and Chunk Splitting

## Prior Solutions Query

A search for prior solutions returned COMPATIBLE samples for Rollup:
- Sample `ff850f6fc4dd7a51ecad7c7901a9a8c816e5c6d0f050c173d970d8ee383756ae`: verify pkg:npm/rollup@4.62.4.

This sample proves programmatic bundling, multi-entry chunk splitting via manualChunks, and plugin transformation hooks on rollup@4.63.3.

## Pinned Release

- `rollup`: `4.63.3`

## Proved Behavior

1. **Single bundle generation**: `rollup.rollup({ input, plugins })` creates a bundle that can be rendered to both ES modules (`bundle.generate({ format: 'es' })`) and CommonJS (`bundle.generate({ format: 'cjs' })`), correctly resolving and inlining internal module dependencies.
2. **Code splitting with manualChunks**: Supplying a `manualChunks` function splits shared dependencies into isolated chunk files referenced by multi-entry chunk outputs.
3. **Plugin transforms**: The `transform` plugin hook modifies module source code prior to bundle composition, ensuring replaced tokens appear in final chunks.
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 rollup.rollup in pkg:npm/rollup@4.63.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/rollup@4.63.3
Demonstrate these symbols/APIs:
  - rollup.rollup

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:f5c46e29cbcdbe3fa4b6e940342b0ee939bc94903cc197ae70d86e084cd588aa","constraints":{"executionContext":"node"},"contract":["Bundling virtual ES modules with rollup and calling bundle.generate produces inline bundled chunks for ESM and exports for CJS.","Configuring manualChunks splits shared dependencies into dedicated chunk files referenced by entry points.","Custom transform plugin hooks intercept module code and apply AST/string replacements prior to chunk generation."],"goal":"verify rollup.rollup in pkg:npm/rollup@4.63.3","kind":"HOW","packages":["pkg:npm/rollup@4.63.3"],"schemaVersion":1,"symbols":["rollup.rollup"]},"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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/rollup@4.63.3"],"schemaVersion":1,"subject":"pkg:npm/rollup@4.63.3","symbols":["rollup.rollup"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "rollup-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "rollup-sample",
      "version": "1.0.0",
      "dependencies": {
        "rollup": "4.63.3"
      }
    },
    "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.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.3.tgz",
      "integrity": "sha512-w3Jnvi1ocaVm/c7yVPpfB98XeSRBMyzp6njL5MVVbGyXjpmUkN+s6Hp4t0PqhGCCaI1ZHMKXt/w0lA1RCaLVcw==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@rollup/rollup-android-arm64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.3.tgz",
      "integrity": "sha512-uI/ESiaIbbRYAEhzy8PCUWDp1hB0bjAqM06mW9flOoNO4Q8DQpeoREhBR5Hegfl+wpXiguyJv6XSPzEN7OxyHQ==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@rollup/rollup-darwin-arm64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.3.tgz",
      "integrity": "sha512-oxhrd1jmXLwWZ83eQYDXxuqRdkqkzrjR3JobKeuUyfdNZo11FuQIvqEOZhyIT7OBHxXoGslDDjN0cQcM6T0TqQ==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-darwin-x64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.3.tgz",
      "integrity": "sha512-7/YiIMghVE8DrxKvNdorAaJVdriOFgOIpdStnPx8ppx5zfTwC3jBCSEAIzB7JD5404m65THl6H93UTTVUvypmg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-freebsd-arm64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.3.tgz",
      "integrity": "sha512-GXFZRRoMAytaI5z6N3Zhfw0WL18Q0M8r95D5hlC4GqE/lGk8pbSJNUBoOWDfbm6dTciqHj2nU87tI5f6XhQiOg==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@rollup/rollup-freebsd-x64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.3.tgz",
      "integrity": "sha512-77W+8X3ddYgPxUpB8nZFQs2Mq+wc4HVlcSRtApXLjYBcnPMkttrSnU8VwKQjeWYhMsITHFs5cWBQ8vz1Q+5RHQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.3.tgz",
      "integrity": "sha512-FVkwK+iUC+mq+GipVK46rRVticfAPtvPUNlqlGXUDxdVk/UGjQiiiUVPUrEXdSpU2ufU0XxLGyTqDtBidDOVmg==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm-musleabihf": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.3.tgz",
      "integrity": "sha512-+aGU1t3398yQOVj1Bz8o3e+KtswxAPvO+mtxtNdfXYMkXIHu7XhhkCD7/DEH9q8tF8uhDnMWvfpUKI8y1sZJsg==",
      "cpu": [
        "arm"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.3.tgz",
      "integrity": "sha512-cR0kjpRXR2KJ2oQK8E2KTPtphs+b9hZ8IhTZubNryt/RsqgdOZBQ2Zq0q5UedtiIi0rs3jVhJh55RE1ZHUVGUA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-musl": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.3.tgz",
      "integrity": "sha512-y1RYi4Q3/9ByVWSSt9kX2ustE0B7kFYbJ6zZdVZVyqopZs3yhCTwRfrjIX4vezUJInma/Gs6BOFDJg7yZmJ0IQ==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-loong64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.3.tgz",
      "integrity": "sha512-DNhEA5viIj3Z5bZLE4z4oV8N5ozWqDwyt7T6KG7VdLDJ0nW+rNOYlphBl4/3HQkK75qipPLsVOfStHHOwN9WSg==",
      "cpu": [
        "loong64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-loong64-musl": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.3.tgz",
      "integrity": "sha512-17gQCqrIpXBX2Cmi9/TygnVOqGbzsba/iaqcYSL8FY7lNugg+7AiYNs5c5nKWD+NRQha36Sa0CqkJqH4XVHwnQ==",
      "cpu": [
        "loong64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-ppc64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.3.tgz",
      "integrity": "sha512-6LwVnZRIyINpdku/yOcI8Tm9YqLmhHK5emmlOOnW9tO0SYEm1FmKPcsSAGp0NBlqR2P04xaND4jvN6sTHqhq8A==",
      "cpu": [
        "ppc64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-ppc64-musl": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.3.tgz",
      "integrity": "sha512-xMUqkTXlEUtI/p5AAukMwBRr1enU3efsTeF+bskeFfk8t1C9rcC8sLREcZXmTfAXEbvRdJVSonVJez3TMlbR3w==",
      "cpu": [
        "ppc64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-riscv64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.3.tgz",
      "integrity": "sha512-S3E94co9F9WRRqEaUoQZ38K1gCz6KiM+nL7/3ijq7fDGF3OznjS5TasgYITlvl27GQKtu4lOAOsr5MFwkijvOA==",
      "cpu": [
        "riscv64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-riscv64-musl": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.3.tgz",
      "integrity": "sha512-1QtRDwG42x5BJI3s9mxu5rEjDnfbSnk20HQ9/ylTAYnSwYwxMVb+Vgu34wzzTQ7ogqBybebgQNUDAvZVQ38DbA==",
      "cpu": [
        "riscv64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-s390x-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.3.tgz",
      "integrity": "sha512-BQhejF6ZXOpxbngiNTP12GCGQeaDVL2QXGeBVViKIYzFHM5RKxTxwUMB1fr1BeNFphFMpnRqC5QSXFSa4z6UQw==",
      "cpu": [
        "s390x"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.3.tgz",
      "integrity": "sha512-SXagRwnI2Wlwlitllu59UK/nGVbD1CKPcNqDplHwIC4BqJcpXFjD32d1R/RbuISa95HdQrZM3/7v4bKiowFaLA==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-musl": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.3.tgz",
      "integrity": "sha512-2IPozoEALRCziGqE8O9KMK60PMu5TS1huv4fwoeCexj+WjmcwFtX9CTOVbfXCUqcELAubEwRFPYlzb/WvwY2HQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-openbsd-x64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.3.tgz",
      "integrity": "sha512-AoxqosUHT9IX54hFn2TiN6A7d6ZKTtE6pd2bqWtqkkNJ6HJGaU6FRouGX8L1O7R/ZwsnCnpQrHzb4pDEx+UHRQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "openbsd"
      ]
    },
    "node_modules/@rollup/rollup-openharmony-arm64": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.3.tgz",
      "integrity": "sha512-d+CaftKgmkFBzCwezMqqy1d0QNNYugqLCMcYVQWBy5SS2YfeMP8Q8ripkgx9O8IyBXXLHrJ+aaCV4U96usv6Yg==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "openharmony"
      ]
    },
    "node_modules/@rollup/rollup-win32-arm64-msvc": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.3.tgz",
      "integrity": "sha512-xXlDF6nR1eOuXbdDy5Hl5fmtY7teUDevF/k0O7IPoZe4Tpmdv+lgdE5JRsnhQtt37ql9P0VF2kAN9a0OCZdo+Q==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-ia32-msvc": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.3.tgz",
      "integrity": "sha512-YtXAgLN+JP7Ay6qG3eWhc7IHMQPzLc8r3uvhAvlJIoCz/4Q32+Bl9Fmnywidh8v1GOIMmymjovfqY9ETAtysvA==",
      "cpu": [
        "ia32"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-x64-gnu": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.3.tgz",
      "integrity": "sha512-WuWtSJRNo549vzcfZyEgfqb6zeSgn1F+UE5kQ+BCjzz0W4MGCjntUHkZVc1VRuAM7+ULaSyhiPxD1spyewFvkQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-x64-msvc": {
      "version": "4.63.3",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.3.tgz",
      "integrity": "sha512-+lIKX7O0+IGe7WuhATaAMMeT7B76vfhXH/l9wLQL+nvyhbw2ohYCKIdWL56JfDu75CWt5oKRP4QFH/jkMtBquA==",
      "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.63.3",
      "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.3.tgz",
      "integrity": "sha512-1i2XreiAoMMXuPGD6Msj2xWrMMkHojNRKivInxGQcg7/1KuPuYlfUutLyh4drnOxUTHX9cHI4wFoat8D/NKaBw==",
      "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.63.3",
        "@rollup/rollup-android-arm64": "4.63.3",
        "@rollup/rollup-darwin-arm64": "4.63.3",
        "@rollup/rollup-darwin-x64": "4.63.3",
        "@rollup/rollup-freebsd-arm64": "4.63.3",
        "@rollup/rollup-freebsd-x64": "4.63.3",
        "@rollup/rollup-linux-arm-gnueabihf": "4.63.3",
        "@rollup/rollup-linux-arm-musleabihf": "4.63.3",
        "@rollup/rollup-linux-arm64-gnu": "4.63.3",
        "@rollup/rollup-linux-arm64-musl": "4.63.3",
        "@rollup/rollup-linux-loong64-gnu": "4.63.3",
        "@rollup/rollup-linux-loong64-musl": "4.63.3",
        "@rollup/rollup-linux-ppc64-gnu": "4.63.3",
        "@rollup/rollup-linux-ppc64-musl": "4.63.3",
        "@rollup/rollup-linux-riscv64-gnu": "4.63.3",
        "@rollup/rollup-linux-riscv64-musl": "4.63.3",
        "@rollup/rollup-linux-s390x-gnu": "4.63.3",
        "@rollup/rollup-linux-x64-gnu": "4.63.3",
        "@rollup/rollup-linux-x64-musl": "4.63.3",
        "@rollup/rollup-openbsd-x64": "4.63.3",
        "@rollup/rollup-openharmony-arm64": "4.63.3",
        "@rollup/rollup-win32-arm64-msvc": "4.63.3",
        "@rollup/rollup-win32-ia32-msvc": "4.63.3",
        "@rollup/rollup-win32-x64-gnu": "4.63.3",
        "@rollup/rollup-win32-x64-msvc": "4.63.3",
        "fsevents": "~2.3.2"
      }
    }
  }
}
package.json
{
  "name": "rollup-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "rollup": "4.63.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify rollup.rollup in pkg:npm/rollup@4.63.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/rollup@4.63.3"
  ],
  "symbols": [
    "rollup.rollup"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { rollup } from 'rollup';

// In-memory plugin providing mock modules for testing rollup API
function virtualModulesPlugin(modules = {}) {
  return {
    name: 'test-virtual-modules',
    resolveId(id) {
      if (id in modules) return id;
      if (id.startsWith('./') && id.slice(2) in modules) return id.slice(2);
      return null;
    },
    load(id) {
      return modules[id] ?? null;
    },
  };
}

async function testSingleBundleGeneration() {
  const modules = {
    'entry.js': `
      import { add } from './math.js';
      export const compute = (x) => add(x, 10);
    `,
    'math.js': `
      export function add(a, b) {
        return a + b;
      }
    `,
  };

  const bundle = await rollup({
    input: 'entry.js',
    plugins: [virtualModulesPlugin(modules)],
  });

  // Test ESM output
  const esmResult = await bundle.generate({ format: 'es' });
  assert.strictEqual(esmResult.output.length, 1);
  const esmChunk = esmResult.output[0];
  assert.strictEqual(esmChunk.type, 'chunk');
  assert.ok(esmChunk.code.includes('export { compute }'));
  assert.ok(!esmChunk.code.includes('import { add }'), 'math.js should be bundled inline');

  // Test CJS output
  const cjsResult = await bundle.generate({ format: 'cjs', exports: 'named' });
  assert.strictEqual(cjsResult.output.length, 1);
  const cjsChunk = cjsResult.output[0];
  assert.strictEqual(cjsChunk.type, 'chunk');
  assert.ok(cjsChunk.code.includes('exports.compute = compute'));

  // Evaluate CJS output
  const cjsExports = {};
  const cjsFn = new Function('exports', cjsChunk.code);
  cjsFn(cjsExports);
  assert.strictEqual(typeof cjsExports.compute, 'function');
  assert.strictEqual(cjsExports.compute(32), 42);
}

async function testManualChunking() {
  const modules = {
    'appA.js': `
      import { sharedHelper } from './shared.js';
      export const a = sharedHelper() + ' from A';
    `,
    'appB.js': `
      import { sharedHelper } from './shared.js';
      export const b = sharedHelper() + ' from B';
    `,
    'shared.js': `
      export function sharedHelper() {
        return 'shared_value';
      }
    `,
  };

  const bundle = await rollup({
    input: {
      appA: 'appA.js',
      appB: 'appB.js',
    },
    plugins: [virtualModulesPlugin(modules)],
  });

  const { output } = await bundle.generate({
    format: 'es',
    manualChunks(id) {
      if (id === 'shared.js') {
        return 'vendor-shared';
      }
    },
  });

  const chunkNames = output.map((c) => c.fileName);
  assert.ok(chunkNames.some((name) => name.includes('vendor-shared')), 'vendor-shared chunk must be generated');
  assert.ok(chunkNames.some((name) => name.includes('appA')), 'appA chunk must be generated');
  assert.ok(chunkNames.some((name) => name.includes('appB')), 'appB chunk must be generated');

  const vendorChunk = output.find((c) => c.fileName.includes('vendor-shared'));
  assert.ok(vendorChunk.code.includes('sharedHelper'), 'sharedHelper must be in vendor chunk');
}

async function testPluginTransformHook() {
  const modules = {
    'index.js': `
      export const appVersion = '__APP_VERSION__';
    `,
  };

  const transformPlugin = {
    name: 'test-transform',
    transform(code, id) {
      if (id === 'index.js') {
        return {
          code: code.replace('__APP_VERSION__', '4.63.3'),
          map: null,
        };
      }
      return null;
    },
  };

  const bundle = await rollup({
    input: 'index.js',
    plugins: [virtualModulesPlugin(modules), transformPlugin],
  });

  const { output: [chunk] } = await bundle.generate({ format: 'es' });
  assert.ok(chunk.code.includes("'4.63.3'"), 'Transform hook must replace replacement token with target value');
  assert.ok(!chunk.code.includes('__APP_VERSION__'), 'Original token must not exist in output');
}

async function main() {
  await testSingleBundleGeneration();
  await testManualChunking();
  await testPluginTransformHook();
}

main();

Origin Seeder

anonymous