CodeSampleX

Пример

vite-node 2.1.9: shouldExternalize

Проверенный пример — npm vite-node 2.1.9: shouldExternalize. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден.

sha256:cacbb12e2746dcd20748ee4b4e21a6b45dc4ddcd0313f162050c0007ce58ad46

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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-16

Кейс

HOW
Цель
verify vite-node.shouldExternalize in pkg:npm/vite-node@2.1.9
Пакеты
Символы
  • vite-node.shouldExternalize
Окружение
node 22.23.2
Создан
2026-09-16T15:18:18Z

Контракт

  1. shouldExternalize returns the module identifier for Node.js built-in modules
  2. shouldExternalize returns the specifier for data URLs and network imports
  3. shouldExternalize returns the path when explicitly matched by options.external patterns
  4. shouldExternalize returns false when matched by options.inline patterns
  5. shouldExternalize returns false when the file path is explicitly listed in options.inlineFiles
  6. shouldExternalize returns false for non-library project source files
  7. shouldExternalize caches resolution results when a cache Map is provided

Файлы

  • 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 vite-node.shouldExternalize in pkg:npm/vite-node@2.1.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/vite-node@2.1.9
Demonstrate these symbols/APIs:
  - vite-node.shouldExternalize

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:e48a768c46a6c85574e842b5b740aefb6638288ae126c6dccd713abdb401e9e4","contract":["shouldExternalize returns the module identifier for Node.js built-in modules","shouldExternalize returns the specifier for data URLs and network imports","shouldExternalize returns the path when explicitly matched by options.external patterns","shouldExternalize returns false when matched by options.inline patterns","shouldExternalize returns false when the file path is explicitly listed in options.inlineFiles","shouldExternalize returns false for non-library project source files","shouldExternalize caches resolution results when a cache Map is provided"],"goal":"verify vite-node.shouldExternalize in pkg:npm/vite-node@2.1.9","kind":"HOW","packages":["pkg:npm/vite-node@2.1.9"],"schemaVersion":1,"symbols":["vite-node.shouldExternalize"]},"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/vite-node@2.1.9"],"schemaVersion":1,"subject":"pkg:npm/vite-node@2.1.9","symbols":["vite-node.shouldExternalize"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-vite-node-should-externalize",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-vite-node-should-externalize",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "vite-node": "2.1.9"
      }
    },
    "node_modules/@esbuild/linux-x64": {
      "version": "0.21.5",
      "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz",
      "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">=12"
      }
    },
    "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-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/@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/cac": {
      "version": "6.7.14",
      "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
      "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/es-module-lexer": {
      "version": "1.7.0",
      "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
      "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
      "license": "MIT"
    },
    "node_modules/esbuild": {
      "version": "0.21.5",
      "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
      "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
      "hasInstallScript": true,
      "license": "MIT",
      "bin": {
        "esbuild": "bin/esbuild"
      },
      "engines": {
        "node": ">=12"
      },
      "optionalDependencies": {
        "@esbuild/aix-ppc64": "0.21.5",
        "@esbuild/android-arm": "0.21.5",
        "@esbuild/android-arm64": "0.21.5",
        "@esbuild/android-x64": "0.21.5",
        "@esbuild/darwin-arm64": "0.21.5",
        "@esbuild/darwin-x64": "0.21.5",
        "@esbuild/freebsd-arm64": "0.21.5",
        "@esbuild/freebsd-x64": "0.21.5",
        "@esbuild/linux-arm": "0.21.5",
        "@esbuild/linux-arm64": "0.21.5",
        "@esbuild/linux-ia32": "0.21.5",
        "@esbuild/linux-loong64": "0.21.5",
        "@esbuild/linux-mips64el": "0.21.5",
        "@esbuild/linux-ppc64": "0.21.5",
        "@esbuild/linux-riscv64": "0.21.5",
        "@esbuild/linux-s390x": "0.21.5",
        "@esbuild/linux-x64": "0.21.5",
        "@esbuild/netbsd-x64": "0.21.5",
        "@esbuild/openbsd-x64": "0.21.5",
        "@esbuild/sunos-x64": "0.21.5",
        "@esbuild/win32-arm64": "0.21.5",
        "@esbuild/win32-ia32": "0.21.5",
        "@esbuild/win32-x64": "0.21.5"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/nanoid": {
      "version": "3.3.19",
      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
      "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "bin": {
        "nanoid": "bin/nanoid.cjs"
      },
      "engines": {
        "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
      }
    },
    "node_modules/pathe": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz",
      "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==",
      "license": "MIT"
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/postcss": {
      "version": "8.5.28",
      "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",
      "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/postcss/"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/postcss"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "nanoid": "^3.3.18",
        "picocolors": "^1.1.1",
        "source-map-js": "^1.2.1"
      },
      "engines": {
        "node": "^10 || ^12 || >=14"
      }
    },
    "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"
      }
    },
    "node_modules/source-map-js": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
      "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
      "license": "BSD-3-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/vite": {
      "version": "5.4.21",
      "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
      "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
      "license": "MIT",
      "dependencies": {
        "esbuild": "^0.21.3",
        "postcss": "^8.4.43",
        "rollup": "^4.20.0"
      },
      "bin": {
        "vite": "bin/vite.js"
      },
      "engines": {
        "node": "^18.0.0 || >=20.0.0"
      },
      "funding": {
        "url": "https://github.com/vitejs/vite?sponsor=1"
      },
      "optionalDependencies": {
        "fsevents": "~2.3.3"
      },
      "peerDependencies": {
        "@types/node": "^18.0.0 || >=20.0.0",
        "less": "*",
        "lightningcss": "^1.21.0",
        "sass": "*",
        "sass-embedded": "*",
        "stylus": "*",
        "sugarss": "*",
        "terser": "^5.4.0"
      },
      "peerDependenciesMeta": {
        "@types/node": {
          "optional": true
        },
        "less": {
          "optional": true
        },
        "lightningcss": {
          "optional": true
        },
        "sass": {
          "optional": true
        },
        "sass-embedded": {
          "optional": true
        },
        "stylus": {
          "optional": true
        },
        "sugarss": {
          "optional": true
        },
        "terser": {
          "optional": true
        }
      }
    },
    "node_modules/vite-node": {
      "version": "2.1.9",
      "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz",
      "integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==",
      "license": "MIT",
      "dependencies": {
        "cac": "^6.7.14",
        "debug": "^4.3.7",
        "es-module-lexer": "^1.5.4",
        "pathe": "^1.1.2",
        "vite": "^5.0.0"
      },
      "bin": {
        "vite-node": "vite-node.mjs"
      },
      "engines": {
        "node": "^18.0.0 || >=20.0.0"
      },
      "funding": {
        "url": "https://opencollective.com/vitest"
      }
    }
  }
}
package.json
{
  "name": "sample-vite-node-should-externalize",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for vite-node.shouldExternalize",
  "license": "MIT-0",
  "dependencies": {
    "vite-node": "2.1.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify vite-node.shouldExternalize in pkg:npm/vite-node@2.1.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/vite-node@2.1.9"
  ],
  "symbols": [
    "vite-node.shouldExternalize"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { shouldExternalize } from 'vite-node/server';

async function runContract() {
  // 1. shouldExternalize returns the module identifier for Node.js built-in modules
  const fsResult = await shouldExternalize('node:fs');
  assert.equal(fsResult, 'node:fs', 'Node.js builtin node:fs must be externalized');

  const pathResult = await shouldExternalize('path');
  assert.equal(pathResult, 'path', 'Node.js builtin path must be externalized');

  // 2. shouldExternalize returns the specifier for data URLs and network imports
  const dataUrl = 'data:text/javascript,export const answer = 42;';
  const dataResult = await shouldExternalize(dataUrl);
  assert.equal(dataResult, dataUrl, 'Data URLs must be externalized');

  const httpUrl = 'https://example.com/esm/module.mjs';
  const httpResult = await shouldExternalize(httpUrl);
  assert.equal(httpResult, httpUrl, 'Network imports must be externalized');

  // 3. shouldExternalize returns the path when explicitly matched by options.external patterns
  const externalResult = await shouldExternalize('/workspace/node_modules/sample-external-dep/index.js', {
    external: ['sample-external-dep']
  });
  assert.equal(
    externalResult,
    '/workspace/node_modules/sample-external-dep/index.js',
    'Explicitly externalized dependency must return file path'
  );

  // 4. shouldExternalize returns false when matched by options.inline patterns
  const inlineResult = await shouldExternalize('/workspace/node_modules/sample-inlined-dep/index.js', {
    inline: ['sample-inlined-dep']
  });
  assert.equal(inlineResult, false, 'Explicitly inlined dependency must return false');

  // 5. shouldExternalize returns false when the file path is explicitly listed in options.inlineFiles
  const inlineFile = '/workspace/src/custom-inline.js';
  const inlineFileResult = await shouldExternalize(inlineFile, {
    inlineFiles: [inlineFile]
  });
  assert.equal(inlineFileResult, false, 'Inline files list must return false');

  // 6. shouldExternalize returns false for non-library project source files
  const sourceResult = await shouldExternalize('/workspace/src/app.ts');
  assert.equal(sourceResult, false, 'Project source files outside node_modules must return false');

  // 7. shouldExternalize caches resolution results when a cache Map is provided
  const cache = new Map();
  const cachedResult = await shouldExternalize('node:os', {}, cache);
  assert.equal(cachedResult, 'node:os', 'Cached call should return correct result');
  assert.equal(cache.has('node:os'), true, 'Result promise must be stored in cache map');
  assert.equal(await cache.get('node:os'), 'node:os', 'Cached promise should resolve to result');

  console.log('Contract passed');
}

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

Исходный сидер

аноним