CodeSampleX

샘플

lightningcss 1.33.0: bundle

검증된 샘플 — npm lightningcss 1.33.0: bundle. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: bundle inlines nested @import rules into a single CSS…

sha256:f9abaee8dcb6a28e08887213caf71f63f4a10ac5bd1629fc8190f02ac294896b

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
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-02

케이스

HOW
목표
verify bundle in pkg:npm/lightningcss@1.33.0
패키지
심벌
  • bundle
환경
node 22.23.2
생성일
2026-09-02T01:42:05Z

컨트랙트

  1. bundle inlines nested @import rules into a single CSS output
  2. bundle minifies bundled CSS output when minify option is true
  3. bundle generates source map when sourceMap option is true
  4. bundle generates scoped CSS class names and exports mapping when cssModules option is true
  5. bundle lowers CSS syntax according to specified browser targets
  6. bundle throws an error when an imported file cannot be resolved
  7. bundle throws an error when entry file does not exist

파일

  • PROMPT.md
  • csx.json
  • fixtures/components.css
  • fixtures/main.css
  • fixtures/missing-import.css
  • fixtures/module-button.css
  • fixtures/module-entry.css
  • fixtures/reset.css
  • fixtures/target.css
  • fixtures/vars.css
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

소스 아티팩트 내려받기 (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 bundle in pkg:npm/lightningcss@1.33.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/lightningcss@1.33.0
Demonstrate these symbols/APIs:
  - bundle

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:dda3872af5248b534c7ece84f12719753e01fab21b4282bfc1fd7c33b08a6f5a","constraints":{"executionContext":"node"},"contract":["bundle inlines nested @import rules into a single CSS output","bundle minifies bundled CSS output when minify option is true","bundle generates source map when sourceMap option is true","bundle generates scoped CSS class names and exports mapping when cssModules option is true","bundle lowers CSS syntax according to specified browser targets","bundle throws an error when an imported file cannot be resolved","bundle throws an error when entry file does not exist"],"goal":"verify bundle in pkg:npm/lightningcss@1.33.0","kind":"HOW","packages":["pkg:npm/lightningcss@1.33.0"],"schemaVersion":1,"symbols":["bundle"]},"contractCommand":["node","test/contract.cjs"],"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/lightningcss@1.33.0"],"schemaVersion":1,"subject":"pkg:npm/lightningcss@1.33.0","symbols":["bundle"],"verifierAdapter":"node-typescript@1"}
fixtures/components.css
@import "./vars.css";

.card {
  background: var(--main-bg);
  padding: 10px;
}
fixtures/main.css
@import "./reset.css";
@import "./components.css";

body {
  margin: 0;
}
fixtures/missing-import.css
@import "./non-existent-subfile.css";

.test {
  color: red;
}
fixtures/module-button.css
.btn {
  color: blue;
}
fixtures/module-entry.css
@import "./module-button.css";

.container {
  display: flex;
}
fixtures/reset.css
* {
  box-sizing: border-box;
}
fixtures/target.css
.box {
  user-select: none;
  display: flex;
}
fixtures/vars.css
:root {
  --main-bg: #fff;
}
package-lock.json
{
  "name": "sample-lightningcss-bundle",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-lightningcss-bundle",
      "version": "1.0.0",
      "dependencies": {
        "lightningcss": "1.33.0"
      }
    },
    "node_modules/detect-libc": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
      "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
      "license": "Apache-2.0",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/lightningcss": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
      "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
      "license": "MPL-2.0",
      "dependencies": {
        "detect-libc": "^2.0.3"
      },
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      },
      "optionalDependencies": {
        "lightningcss-android-arm64": "1.33.0",
        "lightningcss-darwin-arm64": "1.33.0",
        "lightningcss-darwin-x64": "1.33.0",
        "lightningcss-freebsd-x64": "1.33.0",
        "lightningcss-linux-arm-gnueabihf": "1.33.0",
        "lightningcss-linux-arm64-gnu": "1.33.0",
        "lightningcss-linux-arm64-musl": "1.33.0",
        "lightningcss-linux-x64-gnu": "1.33.0",
        "lightningcss-linux-x64-musl": "1.33.0",
        "lightningcss-win32-arm64-msvc": "1.33.0",
        "lightningcss-win32-x64-msvc": "1.33.0"
      }
    },
    "node_modules/lightningcss-android-arm64": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
      "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
      "cpu": [
        "arm64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "android"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-darwin-arm64": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
      "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
      "cpu": [
        "arm64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "darwin"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-darwin-x64": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
      "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
      "cpu": [
        "x64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "darwin"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-freebsd-x64": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
      "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
      "cpu": [
        "x64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "freebsd"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-linux-arm-gnueabihf": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
      "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
      "cpu": [
        "arm"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-linux-arm64-gnu": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
      "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
      "cpu": [
        "arm64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-linux-arm64-musl": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
      "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
      "cpu": [
        "arm64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-linux-x64-gnu": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
      "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
      "cpu": [
        "x64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-linux-x64-musl": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
      "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
      "cpu": [
        "x64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-win32-arm64-msvc": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
      "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
      "cpu": [
        "arm64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "win32"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    },
    "node_modules/lightningcss-win32-x64-msvc": {
      "version": "1.33.0",
      "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
      "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
      "cpu": [
        "x64"
      ],
      "license": "MPL-2.0",
      "optional": true,
      "os": [
        "win32"
      ],
      "engines": {
        "node": ">= 12.0.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/parcel"
      }
    }
  }
}
package.json
{
  "name": "sample-lightningcss-bundle",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "lightningcss": "1.33.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify bundle in pkg:npm/lightningcss@1.33.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/lightningcss@1.33.0"
  ],
  "symbols": [
    "bundle"
  ]
}
test/contract.cjs
const assert = require('node:assert/strict');
const path = require('node:path');
const { bundle, browserslistToTargets } = require('lightningcss');

const fixturesDir = path.join(__dirname, '..', 'fixtures');

// 1. bundle inlines nested @import rules into a single CSS output
{
  const entryPath = path.join(fixturesDir, 'main.css');
  const result = bundle({
    filename: entryPath,
  });

  const css = result.code.toString();
  assert.ok(css.includes('box-sizing: border-box;'), 'Should include reset styles');
  assert.ok(css.includes('--main-bg: #fff;'), 'Should include variable definitions');
  assert.ok(css.includes('background: var(--main-bg);'), 'Should include component styles');
  assert.ok(css.includes('margin: 0;'), 'Should include body styles');
  assert.ok(!css.includes('@import'), 'All @import statements should be inlined');
}

// 2. bundle minifies bundled CSS output when minify option is true
{
  const entryPath = path.join(fixturesDir, 'main.css');
  const result = bundle({
    filename: entryPath,
    minify: true,
  });

  const css = result.code.toString();
  assert.equal(css.includes('\n'), false, 'Minified CSS should not contain newlines');
  assert.ok(css.includes('*{box-sizing:border-box}'), 'Should minify reset rule');
  assert.ok(css.includes(':root{--main-bg:#fff}'), 'Should minify root variables');
  assert.ok(css.includes('.card{background:var(--main-bg);padding:10px}'), 'Should minify card rule');
  assert.ok(css.includes('body{margin:0}'), 'Should minify body rule');
}

// 3. bundle generates source map when sourceMap option is true
{
  const entryPath = path.join(fixturesDir, 'main.css');
  const result = bundle({
    filename: entryPath,
    sourceMap: true,
  });

  assert.ok(Buffer.isBuffer(result.map), 'result.map should be a Buffer');
  const map = JSON.parse(result.map.toString());
  assert.equal(map.version, 3, 'Source map version should be 3');
  assert.ok(Array.isArray(map.sources), 'Source map should contain sources array');
  assert.ok(map.sources.some((s) => s.endsWith('main.css')), 'Sources should contain main.css');
  assert.ok(map.sources.some((s) => s.endsWith('reset.css')), 'Sources should contain reset.css');
  assert.ok(map.sources.some((s) => s.endsWith('vars.css')), 'Sources should contain vars.css');
  assert.ok(map.sources.some((s) => s.endsWith('components.css')), 'Sources should contain components.css');
}

// 4. bundle generates scoped CSS class names and exports mapping when cssModules option is true
{
  const entryPath = path.join(fixturesDir, 'module-entry.css');
  const result = bundle({
    filename: entryPath,
    cssModules: true,
  });

  assert.ok(result.exports, 'result.exports should be defined');
  assert.ok(result.exports.container, 'result.exports should contain container export');
  assert.ok(typeof result.exports.container.name === 'string', 'container name should be a string');
  assert.ok(result.exports.container.name.includes('container'), 'container name should include local name');
  const css = result.code.toString();
  assert.ok(css.includes(result.exports.container.name), 'Bundled CSS should contain scoped class name');
}

// 5. bundle lowers CSS syntax according to specified browser targets
{
  const entryPath = path.join(fixturesDir, 'target.css');
  const result = bundle({
    filename: entryPath,
    targets: browserslistToTargets(['ie 11']),
    minify: true,
  });

  const css = result.code.toString();
  assert.ok(css.includes('-ms-user-select:none'), 'Should prefix user-select for IE 11');
  assert.ok(css.includes('user-select:none'), 'Should include standard user-select');
}

// 6. bundle throws an error when an imported file cannot be resolved
{
  const entryPath = path.join(fixturesDir, 'missing-import.css');
  assert.throws(
    () => {
      bundle({
        filename: entryPath,
      });
    },
    (err) => {
      return err instanceof Error && (err.name === 'SyntaxError' || err.message.includes('No such file') || err.data === 'ResolverError');
    },
    'Should throw error when imported file does not exist'
  );
}

// 7. bundle throws an error when entry file does not exist
{
  const entryPath = path.join(fixturesDir, 'does-not-exist.css');
  assert.throws(
    () => {
      bundle({
        filename: entryPath,
      });
    },
    (err) => {
      return err instanceof Error && (err.name === 'SyntaxError' || err.message.includes('No such file') || err.data === 'ResolverError');
    },
    'Should throw error when entry file does not exist'
  );
}

오리진 시더

익명