CodeSampleX

샘플

@rolldown/pluginutils 1.0.0-rc.3

검증된 샘플 — npm @rolldown/pluginutils 1.0.0-rc.3. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: exactRegex creates an anchored RegExp matching…

sha256:295f41ed1011f9fc015dd9c3d7424121d57f34b98ef5a310e61faa7a3c94d05b

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

실행 증거

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

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
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@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-24
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-07

케이스

HOW
목표
verify pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3
패키지
환경
node 22.23.2
생성일
2026-08-24T06:51:46Z

컨트랙트

  1. exactRegex creates an anchored RegExp matching only the exact string
  2. prefixRegex creates a RegExp matching strings starting with the given prefix
  3. makeIdFiltersToMatchWithQuery adapts string globs and regular expressions to also match ids with query strings
  4. and, or, not create composable logical filter expressions
  5. query and queries construct query parameter filter expressions
  6. interpreter evaluates include and exclude expressions sequentially against module code, id, moduleType, and importerId
  7. interpreter correctly handles cleanUrl and query parameter checks
  8. filterVitePlugins removes dev server plugins while preserving build plugins and flattening nested arrays

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • 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: verify pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - 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:d893d6d9ac7972d302b8cecbe58aeb8cf9c9dc82dc0899d3f63c7713f1d0ba06","constraints":{"executionContext":"node"},"contract":["exactRegex creates an anchored RegExp matching only the exact string","prefixRegex creates a RegExp matching strings starting with the given prefix","makeIdFiltersToMatchWithQuery adapts string globs and regular expressions to also match ids with query strings","and, or, not create composable logical filter expressions","query and queries construct query parameter filter expressions","interpreter evaluates include and exclude expressions sequentially against module code, id, moduleType, and importerId","interpreter correctly handles cleanUrl and query parameter checks","filterVitePlugins removes dev server plugins while preserving build plugins and flattening nested arrays"],"goal":"verify pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3","kind":"HOW","packages":["pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3"],"schemaVersion":1},"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/%40rolldown/pluginutils@1.0.0-rc.3"],"schemaVersion":1,"subject":"pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-rolldown-pluginutils",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-rolldown-pluginutils",
      "version": "1.0.0",
      "dependencies": {
        "@rolldown/pluginutils": "1.0.0-rc.3"
      }
    },
    "node_modules/@rolldown/pluginutils": {
      "version": "1.0.0-rc.3",
      "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.3.tgz",
      "integrity": "sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-rolldown-pluginutils",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@rolldown/pluginutils": "1.0.0-rc.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40rolldown/pluginutils@1.0.0-rc.3"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  exactRegex,
  prefixRegex,
  makeIdFiltersToMatchWithQuery,
  and,
  or,
  not,
  id,
  importerId,
  moduleType,
  code,
  query,
  queries,
  include,
  exclude,
  interpreter,
  filterVitePlugins,
} from '@rolldown/pluginutils';

// 1. exactRegex creates an anchored RegExp matching only the exact string
{
  const re = exactRegex('src/index.js');
  assert.ok(re instanceof RegExp);
  assert.equal(re.test('src/index.js'), true);
  assert.equal(re.test('a/src/index.js'), false);
  assert.equal(re.test('src/index.js/more'), false);

  const reFlags = exactRegex('foo.js', 'i');
  assert.equal(reFlags.test('FOO.JS'), true);
}

// 2. prefixRegex creates a RegExp matching strings starting with the given prefix
{
  const re = prefixRegex('node_modules/');
  assert.ok(re instanceof RegExp);
  assert.equal(re.test('node_modules/pkg/index.js'), true);
  assert.equal(re.test('src/node_modules/pkg'), false);
}

// 3. makeIdFiltersToMatchWithQuery adapts string globs and regular expressions to also match ids with query strings
{
  const globResult = makeIdFiltersToMatchWithQuery('**/*.js');
  assert.equal(globResult, '**/*.js{?*,}');

  const regexResult = makeIdFiltersToMatchWithQuery(/\.ts$/);
  assert.ok(regexResult instanceof RegExp);
  assert.equal(regexResult.test('file.ts'), true);
  assert.equal(regexResult.test('file.ts?inline'), true);
  assert.equal(regexResult.test('file.ts.bak'), false);

  const arrayResult = makeIdFiltersToMatchWithQuery(['**/*.vue', /\.svelte$/]);
  assert.equal(arrayResult[0], '**/*.vue{?*,}');
  assert.ok(arrayResult[1] instanceof RegExp);
}

// 4. and, or, not create composable logical filter expressions
{
  const andExpr = and(id(/\.ts$/), moduleType('ts'));
  assert.equal(andExpr.kind, 'and');
  assert.equal(andExpr.args.length, 2);

  const orExpr = or(id(/\.jsx?$/), id(/\.tsx?$/));
  assert.equal(orExpr.kind, 'or');
  assert.equal(orExpr.args.length, 2);

  const notExpr = not(importerId(/node_modules/));
  assert.equal(notExpr.kind, 'not');
  assert.equal(notExpr.expr.kind, 'importerId');

  assert.throws(() => and(), /`And` expects at least one operand/);
  assert.throws(() => or(), /`Or` expects at least one operand/);
}

// 5. query and queries construct query parameter filter expressions
{
  const q1 = query('vue', true);
  assert.equal(q1.kind, 'query');
  assert.equal(q1.key, 'vue');
  assert.equal(q1.pattern, true);

  const q2 = query('type', 'template');
  assert.equal(q2.kind, 'query');
  assert.equal(q2.key, 'type');
  assert.equal(q2.pattern, 'template');

  const composed = queries({ raw: true, lang: 'css' });
  assert.equal(composed.kind, 'and');
  assert.equal(composed.args.length, 2);
}

// 6. interpreter evaluates include and exclude expressions sequentially against module code, id, moduleType, and importerId
{
  const filter = [
    exclude(importerId(/node_modules/)),
    include(and(id(/\.ts$/), moduleType('ts'))),
  ];

  assert.equal(
    interpreter(filter, 'export const x = 1;', 'src/app.ts', 'ts', 'src/main.ts'),
    true
  );

  assert.equal(
    interpreter(filter, 'export const x = 1;', 'src/app.ts', 'ts', 'node_modules/dep/index.js'),
    false
  );

  assert.equal(
    interpreter(filter, 'export const x = 1;', 'src/app.ts', 'js', 'src/main.ts'),
    false
  );
}

// 7. interpreter correctly handles cleanUrl and query parameter checks
{
  const filter = [
    include(
      and(
        id('src/component.vue', { cleanUrl: true }),
        code(/<template>/),
        query('type', 'template')
      )
    ),
  ];

  assert.equal(
    interpreter(filter, '<template><div></div></template>', 'src/component.vue?type=template&lang=html'),
    true
  );

  assert.equal(
    interpreter(filter, '<template><div></div></template>', 'src/component.vue?type=style'),
    false
  );

  assert.equal(
    interpreter(filter, '<script>export default {}</script>', 'src/component.vue?type=template'),
    false
  );
}

// 8. filterVitePlugins removes dev server plugins while preserving build plugins and flattening nested arrays
{
  const plugins = [
    { name: 'build-plugin', apply: 'build' },
    { name: 'serve-plugin', apply: 'serve' },
    { name: 'common-plugin' },
    [
      { name: 'nested-serve', apply: 'serve' },
      { name: 'nested-fn', apply: (config, env) => env.command === 'build' },
    ],
    null,
    false,
  ];

  const filtered = filterVitePlugins(plugins);
  assert.deepEqual(
    filtered.map((p) => p.name),
    ['build-plugin', 'common-plugin', 'nested-fn']
  );
}

오리진 시더

익명