@hublo/sentinel 1.7.0-alpha.2 → 1.7.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +2 -0
  2. package/dist/bin/sentinel.js +46 -113
  3. package/dist/{chunk-Z3JI7ZWX.js → chunk-AVT5FSPO.js} +232 -195
  4. package/dist/{chunk-EETHWJBF.js → chunk-B3Y7F7BA.js} +3533 -1074
  5. package/dist/{chunk-DLGBRLUU.js → chunk-EESVRILJ.js} +3 -16
  6. package/dist/chunk-EESVRILJ.js.map +1 -0
  7. package/dist/{chunk-ZNANJEMK.js → chunk-JT7ZMH44.js} +30 -16
  8. package/dist/chunk-JT7ZMH44.js.map +1 -0
  9. package/dist/{chunk-THTXP2QU.js → chunk-LX7EG6PJ.js} +5 -6
  10. package/dist/chunk-LX7EG6PJ.js.map +1 -0
  11. package/dist/chunk-NGLEGAEN.js +190 -0
  12. package/dist/chunk-NGLEGAEN.js.map +1 -0
  13. package/dist/{chunk-4YQXLPJ5.js → chunk-PMRL4MH6.js} +2 -2
  14. package/dist/chunk-PXTU5MPW.js +9 -0
  15. package/dist/chunk-PXTU5MPW.js.map +1 -0
  16. package/dist/{chunk-LNFGVGLE.js → chunk-SWWQ7X7B.js} +11 -23
  17. package/dist/{chunk-LNFGVGLE.js.map → chunk-SWWQ7X7B.js.map} +1 -1
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +6 -6
  20. package/dist/roles/build/nest/toolchain.d.ts +1 -1
  21. package/dist/roles/build/nest/toolchain.js +2 -6
  22. package/dist/roles/build/nest/toolchain.js.map +1 -1
  23. package/dist/roles/sql/config.d.ts +68 -0
  24. package/dist/roles/sql/config.js +8 -0
  25. package/dist/roles/sql/config.js.map +1 -0
  26. package/dist/roles/static-analysis/config.js +2 -1
  27. package/dist/roles/test/nest/toolchain.d.ts +1 -1
  28. package/dist/roles/test/nest/toolchain.js +2 -3
  29. package/dist/roles/test/nest/toolchain.js.map +1 -1
  30. package/dist/roles/test/react/toolchain.js +2 -3
  31. package/dist/roles/test/react/toolchain.js.map +1 -1
  32. package/dist/roles/test/setup/jest-parity.js +2 -2
  33. package/dist/roles/test/setup/workspace-entry.js +2 -2
  34. package/dist/roles/test/shared-test-config.d.ts +1 -1
  35. package/dist/roles/test/shared-test-config.js +2 -3
  36. package/dist/tsconfig/nest.json +1 -10
  37. package/dist/tsconfig/node.json +1 -11
  38. package/dist/tsconfig/react.json +0 -3
  39. package/dist/{tsconfig-aliases-C_PxuZni.d.ts → tsconfig-aliases-Ce6axdJ4.d.ts} +2 -17
  40. package/dist/{validate-LRHF63AW.js → validate-B5567Z7X.js} +2 -4
  41. package/docs/build-adoption.md +0 -7
  42. package/docs/sql-adoption.md +552 -0
  43. package/docs/static-analysis-adoption.md +1 -1
  44. package/docs/test-adoption.md +1 -8
  45. package/docs/typescript-adoption.md +13 -52
  46. package/docs/typescript-traces.md +217 -3
  47. package/docs/using-sentinel.md +2 -1
  48. package/package.json +6 -4
  49. package/dist/chunk-4UUL4SEW.js +0 -50
  50. package/dist/chunk-DLGBRLUU.js.map +0 -1
  51. package/dist/chunk-H4HAFJFZ.js +0 -79
  52. package/dist/chunk-H4HAFJFZ.js.map +0 -1
  53. package/dist/chunk-THTXP2QU.js.map +0 -1
  54. package/dist/chunk-ZNANJEMK.js.map +0 -1
  55. package/dist/migrate-NI33SXZD.js +0 -517
  56. package/dist/tsconfig/legacy.json +0 -21
  57. /package/dist/{chunk-4YQXLPJ5.js.map → chunk-PMRL4MH6.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/roles/build/nest/nest-service.ts","../../../../src/roles/build/nest/copy-assets.ts","../../../../src/roles/build/nest/importer-externals.ts","../../../../src/roles/build/nest/node-manifest.ts","../../../../src/roles/build/nest/toolchain.ts"],"sourcesContent":["/**\n * The whole Vite config for a Nest service, so an adopted module holds two lines.\n *\n * ## Why a shape here, and pieces on the React side\n *\n * It looks inconsistent until you measure the two families. The four React apps each carry a\n * heavy, genuinely different config: one has a plugin wedged between two shared ones, another\n * has two different route-tree footers on the branches of one ternary. Two attempts at a\n * shared shape for them were abandoned, and the rule that survived is that sentinel rewrites\n * their IMPORTS and touches nothing else.\n *\n * The Nest side is the opposite by measurement: 38 services, one shared 25-line webpack config\n * between them, and nothing per-module to preserve. Owning the shape there is not a different\n * philosophy, it is the same one applied to a different fact: sentinel provides the FORM where\n * the form is shared, and the PIECES where it is not.\n *\n * The consequences are the point. An adopted module is readable in review. A correction to the\n * form is one publish instead of 38 diffs. And the day Nest becomes ESM-native, `format`\n * changes here rather than in 38 configs.\n *\n * ## It is a composition, not a block\n *\n * `nestService` assembles the same plugins this module exports individually. A service that\n * needs something else can pass `overrides`, or drop to the pieces entirely. And if the React\n * configs ever converge, a `reactApp()` can be built the same way with no new mechanism.\n */\nimport { join } from 'node:path'\n\nimport { mergeConfig, type UserConfig } from 'vite'\n\nimport { copyAssets } from './copy-assets.js'\nimport { decoratorMetadata } from './decorator-metadata.js'\nimport { importerExternals } from './importer-externals.js'\nimport { nodeManifest } from './node-manifest.js'\nimport type { AssetDeclaration, TransformerDeclaration } from './nx-target.js'\nimport { tsconfigAliases } from './tsconfig-aliases.js'\n\nexport interface NestServiceOptions {\n /** The nx project name. Keys the dependency graph, and names the module in messages. */\n project: string\n /** Absolute path to the module's directory, normally `__dirname`. */\n root: string\n /** Absolute path to the workspace root. */\n workspaceRoot: string\n /** Entry point, relative to `root`. */\n entry?: string\n /**\n * The tsconfig whose emit must be preserved, when the service uses neither conventional name.\n *\n * Relative to `root`. Defaults to `tsconfig.app.json`, then `tsconfig.json`.\n */\n tsconfig?: string\n /** Output directory, relative to `workspaceRoot`. */\n outDir?: string\n /**\n * TypeScript transformers this service compiles with, as its build target declared them.\n *\n * Read off the webpack target by `--init` and written here, never inferred: what a service\n * compiles with is the service's own. Eight services and BFFs run `@nestjs/swagger/plugin`,\n * which writes the `@ApiProperty` decorators their DTOs do not declare by hand. Building\n * without it succeeds and silently costs them most of their published contract (measured on\n * `institution`: 385 insertions, 1378 deletions in the committed OpenAPI document).\n */\n transformers?: readonly TransformerDeclaration[]\n /**\n * Files copied into the output beside the bundle, in the shape `@nx/webpack` declared them.\n *\n * One service here uses it: `planning-period` ships the pug, css and ttf templates it renders\n * printed documents from. Without them the service starts and fails on its first print.\n */\n assets?: readonly AssetDeclaration[]\n /**\n * Anything this service needs that the shape does not give it.\n *\n * Merged with Vite's own `mergeConfig`, never with a merge of our own: plugins concatenate\n * and aliases stack the way Vite does it everywhere else, so there is no second set of\n * semantics to learn or to document.\n */\n overrides?: UserConfig\n}\n\n/**\n * Packages the bundle INLINES rather than requires.\n *\n * `importHelpers: true` in the workspace tsconfig makes TypeScript emit `require(\"tslib\")` for\n * `__decorate` and `__metadata`, so every decorated file depends on it. Hoisted into one scope\n * Rollup inlined it and nobody noticed; preserving modules left it external, and the manifest nx\n * generates from the project graph does not list it, because no module DECLARES tslib. The image\n * therefore did not install it and the service died on its first require, only in the image:\n * locally and in CI the workspace root has tslib.\n *\n * One list, read by both `ssr.noExternal` and `importerExternals`, because the second runs\n * `enforce: 'pre'` and would otherwise win against the first and bring the incident back.\n */\nexport const NEST_SERVICE_NO_EXTERNAL: readonly string[] = ['tslib']\n\nconst baseConfig = (options: NestServiceOptions): UserConfig => {\n const outDir = join(options.workspaceRoot, options.outDir ?? `dist/${options.project}`)\n const entry = join(options.root, options.entry ?? 'src/main.ts')\n /*\n * The module's own chain, as tsc reads it for this build, and the workspace base only when the\n * chain declares no `paths`: a service that stops extending the base must be bundled with the\n * aliases it type-checks with. Same candidates, same order, as `decorator-metadata.ts`.\n */\n const aliases = tsconfigAliases(options.workspaceRoot, {\n moduleRoot: options.root,\n candidates: [options.tsconfig, 'tsconfig.app.json', 'tsconfig.json'],\n })\n return {\n plugins: [\n importerExternals({ noExternal: NEST_SERVICE_NO_EXTERNAL, aliases }),\n decoratorMetadata({\n root: options.root,\n tsconfig: options.tsconfig,\n transformers: options.transformers,\n }),\n ...(options.assets?.length\n ? [copyAssets({ workspaceRoot: options.workspaceRoot, outDir, assets: options.assets })]\n : []),\n nodeManifest({\n project: options.project,\n workspaceRoot: options.workspaceRoot,\n outDir,\n }),\n ],\n resolve: { alias: aliases },\n ssr: {\n // See NEST_SERVICE_NO_EXTERNAL: `tslib`, inlined on purpose.\n noExternal: [...NEST_SERVICE_NO_EXTERNAL],\n },\n build: {\n // An SSR build targets Node and leaves real packages external, which is what\n // `webpack-node-externals` did: the image installs them from the generated manifest.\n // `importerExternals` holds that wherever the package is declared, not only at the root.\n ssr: entry,\n outDir,\n emptyOutDir: true,\n sourcemap: true,\n target: 'node20',\n // The bundle is read by humans when a stack trace points into it, and minifying a\n // server bundle buys nothing: it is never downloaded.\n minify: false,\n rollupOptions: {\n output: {\n format: 'cjs',\n // One output file per source module, instead of hoisting everything into one scope.\n //\n // This is not a preference, it is the only shape that keeps the OpenAPI contract.\n // Merging every module into one scope forces Rollup to rename duplicate class names,\n // and `@nestjs/swagger` keys its schemas on `class.name`, so a renamed class silently\n // becomes a renamed schema in the published API. Measured on `network`, which has two\n // such collisions: single bundle renames `InvalidPermissionError` and\n // `PermissionNotFoundError`; preserving modules renames nothing and reproduces the\n // committed contract byte for byte.\n //\n // The cost is 4.5 MB across 2003 files against 2.9 MB in one, still well under\n // webpack's 6.9 MB for the same service, so nothing regresses against what it replaces.\n preserveModules: true,\n // The image runs `./dist/main.js`, so the entry keeps that name at the root while\n // every other module keeps its own path. Under `preserveModules` a plain string here\n // would be applied to all of them, which numbers them (`main962.js`) and loses the\n // entry.\n entryFileNames: (chunk) => (chunk.facadeModuleId === entry ? 'main.js' : '[name].js'),\n },\n // Nest registers metadata as an IMPORT SIDE EFFECT: a decorator writes into a catalog\n // when its module loads, and nothing references that module afterwards. Rollup may\n // drop such a module; webpack never did.\n //\n // Measured on the first migrated service this changes nothing, so it is insurance\n // rather than a fix, and it is recorded as such rather than credited with the smaller\n // bundle (that comes from barrel re-exports the service does not use).\n treeshake: { moduleSideEffects: true },\n },\n },\n }\n}\n\nexport const nestService = (options: NestServiceOptions): UserConfig =>\n options.overrides === undefined\n ? baseConfig(options)\n : mergeConfig(baseConfig(options), options.overrides)\n","/**\n * The files a service ships beside its bundle, which webpack copied and a bundler does not.\n *\n * `@nx/webpack` takes an `assets` list and copies each match into the output. Nothing in a Vite\n * build does that for a Node target: `publicDir` is a browser concept and is disabled for SSR\n * builds, so an unmigrated `assets` entry is not a smaller output, it is a service that starts\n * and then fails the first time it reaches for a file that is not there.\n *\n * One service in this repo declares it. `planning-period` ships the pug templates, stylesheet and\n * font it renders printed documents from, under `templates/`. Dropping them leaves a build that\n * succeeds, an image that boots, and a printing feature that throws.\n *\n * ## Copied at `closeBundle`, and only what the target declared\n *\n * The declaration is carried through from the webpack target unchanged, globs and all, so this\n * plugin has nothing to decide: it resolves each `input` against the workspace root, matches the\n * glob, and writes under `output` inside the bundle's directory. `closeBundle` because that is\n * when the output directory exists and Vite has finished emptying it.\n *\n * An entry matching nothing FAILS the build. A glob that has quietly stopped matching is the same\n * silent loss as no glob at all, and the point of this file is that this class of loss is loud.\n */\nimport { cpSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs'\nimport { dirname, join, relative, sep } from 'node:path'\n\nimport type { Plugin } from 'vite'\n\nimport { globToRegExp } from '../../../shared/glob.js'\n\nimport type { AssetDeclaration } from './nx-target.js'\n\nexport interface CopyAssetsOptions {\n /** Absolute path to the workspace root, which `input` is relative to. */\n workspaceRoot: string\n /** Absolute path to the build's output directory. */\n outDir: string\n assets: readonly AssetDeclaration[]\n}\n\n/** Every file under `root`, as paths relative to it and with forward slashes. */\nfunction filesUnder(root: string): string[] {\n const found: string[] = []\n const walk = (dir: string): void => {\n for (const entry of readdirSync(dir)) {\n const full = join(dir, entry)\n if (statSync(full).isDirectory()) walk(full)\n else found.push(relative(root, full).split(sep).join('/'))\n }\n }\n walk(root)\n return found\n}\n\n/** What each declaration copies, or the reason it cannot. */\nexport function resolveAssets(options: CopyAssetsOptions): { from: string; to: string }[] {\n const copies: { from: string; to: string }[] = []\n for (const asset of options.assets) {\n const input = join(options.workspaceRoot, asset.input)\n if (!existsSync(input)) {\n throw new Error(\n `sentinel build(nest): the build target declares an asset from \\`${asset.input}\\`, which ` +\n `does not exist. webpack copied it into the output, so the built service would be ` +\n `missing files it reads at runtime.`,\n )\n }\n const matcher = globToRegExp(asset.glob)\n const matched = filesUnder(input).filter((file) => matcher.test(file))\n if (matched.length === 0) {\n throw new Error(\n `sentinel build(nest): the asset glob \\`${asset.glob}\\` under \\`${asset.input}\\` matches ` +\n `no file. An entry that matches nothing is the same silent loss as no entry at all.`,\n )\n }\n for (const file of matched) {\n copies.push({ from: join(input, file), to: join(options.outDir, asset.output, file) })\n }\n }\n return copies\n}\n\nexport const copyAssets = (options: CopyAssetsOptions): Plugin => ({\n name: 'sentinel:copy-assets',\n // After the bundle is written and the output directory has stopped being emptied.\n closeBundle() {\n for (const { from, to } of resolveAssets(options)) {\n mkdirSync(dirname(to), { recursive: true })\n cpSync(from, to)\n }\n },\n})\n","/**\n * Keep a real package external when Vite would inline it only because the service does not\n * declare it.\n *\n * Vite's SSR build decides externalisation from the service's OWN directory. In hublo/monorepo that\n * held because the root manifest declared nearly every package, so the lookup walked up to\n * `<repo>/node_modules`. Once a package moves off the root to the projects that import it, one\n * declared only by a workspace lib (`@nestjs/jwt`, declared by `libs/nest/auth`, not by `counter`)\n * no longer passes that check, and Vite INLINES it, `node_modules/.pnpm` path included. The build\n * stays green and `assertManifestCovers` cannot see it, because an inlined package is no longer an\n * import. Measured on the 9 Vite Nest services with the root drop applied: `@nestjs/jwt` inlined,\n * `@nestjs/core/*` subpaths inlined, and `require` order shuffled in files that did not change.\n *\n * Vite still RESOLVES such a package correctly, from the importer: only the externalise decision\n * is wrong. So the resolution is delegated to Vite (`this.resolve`), and this plugin only turns an\n * inlined package from `node_modules` into the external Vite would have emitted. A first version\n * resolved with `require.resolve` and built the id itself: it changed 38 to 315 files per service on\n * `main`, because Vite keeps an `exports` subpath as written (`rxjs/operators`, not\n * `rxjs/dist/cjs/operators/index.js`) and carries the package's `sideEffects`, without which\n * Rollup kept barrel modules it used to drop.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { isBuiltin } from 'node:module'\nimport { dirname, extname, join, sep } from 'node:path'\n\nimport type { Plugin } from 'vite'\n\nimport type { Alias } from './tsconfig-aliases.js'\n\nexport interface ImporterExternalsOptions {\n /**\n * Packages that must stay INLINED, the same list `ssr.noExternal` receives.\n *\n * Checked before anything else. This plugin runs `enforce: 'pre'`, and a `resolveId` there\n * wins against `ssr.noExternal`: measured, `tslib` then comes out as `require(\"tslib\")`, which\n * is the exact incident `noExternal` exists for. The image does not install `tslib`, because\n * no module declares it, and the service died on its first require.\n */\n noExternal: readonly string[]\n /** The workspace's tsconfig `paths`: those are source, and Vite bundles them. */\n aliases: readonly Alias[]\n}\n\n/** `@scope/name/sub/path` → `@scope/name`, `name/sub` → `name`. */\nexport const packageName = (specifier: string): string => {\n const parts = specifier.split('/')\n return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : (parts[0] ?? specifier)\n}\n\nconst isBareSpecifier = (specifier: string): boolean =>\n !specifier.startsWith('.') &&\n !specifier.startsWith('/') &&\n !specifier.startsWith('\\0') &&\n !isBuiltin(specifier)\n\n/** The package's own manifest, walked up from a file inside it. */\nconst packageManifest = (file: string, name: string): { exports?: unknown } | undefined => {\n let directory = dirname(file)\n while (directory !== dirname(directory)) {\n const manifest = join(directory, 'package.json')\n if (existsSync(manifest)) {\n try {\n const data = JSON.parse(readFileSync(manifest, 'utf8')) as {\n name?: string\n exports?: unknown\n }\n if (data.name === name) return data\n } catch {\n // A manifest that does not parse is not the package's own; keep walking.\n }\n }\n directory = dirname(directory)\n }\n return undefined\n}\n\n/**\n * The id Vite's `tryNodeResolve` gives an external, reproduced so the output does not move: the\n * specifier as written, except a deep import into a package WITHOUT an `exports` map whose\n * extension the resolution changed, which becomes the resolved file\n * (`@nestjs/core/injector/container` → `@nestjs/core/injector/container.js`).\n */\nconst externalId = (specifier: string, name: string, resolved: string): string => {\n if (specifier === name) return specifier\n if (extname(specifier) === extname(resolved)) return specifier\n if (packageManifest(resolved, name)?.exports !== undefined) return specifier\n const index = resolved.split(sep).join('/').indexOf(specifier)\n return index === -1 ? specifier : resolved.split(sep).join('/').slice(index)\n}\n\nexport const importerExternals = (options: ImporterExternalsOptions): Plugin => ({\n name: 'sentinel:importer-externals',\n enforce: 'pre',\n async resolveId(source, importer, resolveOptions) {\n if (!importer || !isBareSpecifier(source)) return null\n const name = packageName(source)\n // FIRST: a package `ssr.noExternal` inlines is never made external here (see the option).\n if (options.noExternal.includes(name)) return null\n if (options.aliases.some((alias) => alias.find.test(source))) return null\n const resolved = await this.resolve(source, importer, { ...resolveOptions, skipSelf: true })\n // Unresolved, or already external: Vite's own decision stands, byte for byte.\n if (!resolved || resolved.external) return null\n const file = resolved.id.split('?')[0] ?? resolved.id\n // A workspace package linked into `node_modules` resolves to its real path, outside it:\n // that is source, and it stays bundled as it is today.\n if (!file.split(sep).includes('node_modules')) return null\n return {\n id: externalId(source, name, file),\n external: true,\n moduleSideEffects: resolved.moduleSideEffects,\n }\n },\n})\n","/**\n * The pruned `package.json` and lockfile a Node image installs from.\n *\n * This is the half that made the nx executor look load-bearing. `--generatePackageJson` was an\n * option of `@nx/webpack:webpack`, and the backend image is built on its two outputs:\n *\n * COPY --from=build /app/dist/apps/nest/<service>/package.json /app/package.json\n * COPY --from=build /app/dist/apps/nest/<service>/pnpm-lock.yaml /app/pnpm-lock.yaml\n * RUN pnpm i --prod=true --frozen-lockfile\n *\n * It is not bound to the executor. The executor supplies one thing, the project graph, and\n * every function that does the work is exported by `@nx/js`. So the same two files can be\n * produced from a Vite plugin, and `--frozen-lockfile` accepting them afterwards is the proof\n * that they agree with each other: pnpm refuses the install otherwise.\n *\n * ## Why the graph, and not something simpler\n *\n * A Nest service here declares almost nothing of its own: measured, one dependency in its\n * manifest against 1463 installed in its image. Everything it uses is declared at the\n * workspace root and reaches it through source imports. So the dependency list can only be\n * computed from what the code imports, which is what the graph knows.\n *\n * Deriving it from the bundle's own externals is not equivalent either: measured on the first\n * service, the bundle statically requires 42 packages while the correct manifest holds 65. The\n * 23 missing ones are transitive or required dynamically at runtime (`fastify` behind\n * `@nestjs/platform-fastify`, `jsonwebtoken`, the LaunchDarkly SDK). Shipping the short list\n * fails in production, not in the build.\n */\nimport { existsSync, writeFileSync } from 'node:fs'\nimport { isBuiltin } from 'node:module'\nimport { join } from 'node:path'\n\nimport type { Plugin, Rollup } from 'vite'\n\nexport interface NodeManifestOptions {\n /** The nx project name, which is how the graph is keyed. */\n project: string\n /** Absolute path to the workspace root. */\n workspaceRoot: string\n /** Where the bundle is written; the two files land beside it. */\n outDir: string\n /** Entry file name, written as `main` so `node .` resolves inside the image. */\n entry?: string\n /**\n * Packages the IMAGE provides, which are therefore allowed to be required without being\n * declared in the manifest.\n *\n * The generated Prisma clients are the case this exists for: the Dockerfile copies\n * `node_modules/@prisma` from its own stage, so they resolve at runtime while no module\n * declares them. Everything else that is required and undeclared is a bug, and the check\n * below refuses the build.\n */\n providedByImage?: readonly string[]\n}\n\n/** What the Dockerfile copies in itself, so requiring it without declaring it is legitimate. */\nconst DEFAULT_PROVIDED_BY_IMAGE = ['@prisma'] as const\n\n/**\n * Every real package the emitted output requires, from Rollup's own record rather than a scan\n * of the text.\n *\n * `chunk.imports` mixes three things, and only the third is a dependency:\n *\n * - other EMITTED chunks. Under `preserveModules` these are relative output paths that do not\n * begin with `.`, so `apps/…`, `libs/…` and `_virtual/…` read exactly like package names.\n * They are recognised by being keys of the bundle itself.\n * - Node BUILTINS, which appear both bare (`crypto`) and prefixed (`node:crypto`).\n * - genuine external packages, which is what the manifest has to cover.\n */\nconst externalPackages = (bundle: Rollup.OutputBundle): Set<string> => {\n const emitted = new Set(Object.keys(bundle))\n const packages = new Set<string>()\n\n for (const emittedFile of Object.values(bundle)) {\n // Assets carry no imports, and the bundle holds both. Narrowing on the discriminant is what\n // replaced a cast through `unknown`, which asserted the same thing without checking it.\n if (emittedFile.type !== 'chunk') continue\n\n for (const imported of emittedFile.imports) {\n if (emitted.has(imported)) continue\n if (imported.startsWith('.') || imported.startsWith('/')) continue\n if (isBuiltin(imported)) continue\n\n const parts = imported.split('/')\n const name = imported.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]\n if (name) packages.add(name)\n }\n }\n return packages\n}\n\n/**\n * Writes the manifest and lockfile once the bundle is on disk.\n *\n * `closeBundle` rather than `writeBundle`, so the files land after Vite has finished with the\n * directory and cannot be cleared by `emptyOutDir`.\n *\n * `closeBundle` also runs after a FAILED build, where there is no directory to write into. Left\n * alone this hook then threw `ENOENT` on the manifest, and since it is the last error raised it\n * became the one Vite printed, hiding the failure that actually stopped the build. It cost two\n * diagnoses before being recognised, so the missing directory is now read as what it is: the\n * bundle was never written, and this plugin has nothing to say about why.\n */\nexport const nodeManifest = (options: NodeManifestOptions): Plugin => {\n /*\n * Captured while the bundle still exists in memory, and read back once the manifest is built.\n *\n * `undefined` until `generateBundle` runs, deliberately: an empty SET would make the coverage\n * check below pass by having seen nothing, which is the worst way for a guard to succeed. The\n * two states have to be told apart.\n */\n let required: Set<string> | undefined\n\n return {\n name: 'sentinel:node-manifest',\n apply: 'build',\n\n generateBundle(_outputOptions, bundle) {\n required = externalPackages(bundle)\n },\n\n async closeBundle() {\n // `closeBundle` runs after a FAILED build too. The ENTRY is what says a bundle was really\n // written: `emptyOutDir` leaves the directory in place, so its existence alone would let a\n // failed build still produce a manifest describing nothing.\n const entry = options.entry ?? 'main.js'\n if (!existsSync(join(options.outDir, entry))) return\n\n // Imported here rather than at module scope: a front config importing this file must not\n // pay for loading the nx graph machinery it will never call.\n const { createProjectGraphAsync } = await import('nx/src/devkit-exports.js')\n const { createPackageJson, createLockFile, getLockFileName } = await import('@nx/js')\n\n const graph = await createProjectGraphAsync({ exitOnError: false })\n const manifest = createPackageJson(options.project, graph, {\n root: options.workspaceRoot,\n isProduction: true,\n })\n manifest.main = entry\n\n if (required === undefined) {\n throw new Error(\n `sentinel build(nest): the bundle was written but never inspected, so the manifest ` +\n `could not be checked against what it requires. Refusing to write one that might ` +\n `not install.`,\n )\n }\n assertManifestCovers(required, manifest, options)\n\n writeFileSync(join(options.outDir, 'package.json'), `${JSON.stringify(manifest, null, 2)}\\n`)\n writeFileSync(\n join(options.outDir, getLockFileName('pnpm')),\n createLockFile(manifest, graph, 'pnpm'),\n )\n },\n }\n}\n\n/**\n * Refuse a bundle that requires something the image will not install.\n *\n * The manifest is derived from the project GRAPH, so it lists what modules declare. The bundle\n * requires what the bundler left external. Those two sets agreeing is an assumption, and it was\n * wrong: `tslib` arrives through `importHelpers` in the workspace tsconfig without any module\n * declaring it, so the manifest omitted it and the service died on its first require.\n *\n * It died only in the image. Locally and in CI the workspace root has the package, so the gap is\n * invisible until a container starts, which is the most expensive place to discover it. Checking\n * here turns that into a build failure naming the package.\n */\nconst assertManifestCovers = (\n required: ReadonlySet<string>,\n manifest: { dependencies?: Record<string, string> },\n options: NodeManifestOptions,\n): void => {\n const declared = new Set(Object.keys(manifest.dependencies ?? {}))\n const provided = options.providedByImage ?? DEFAULT_PROVIDED_BY_IMAGE\n const missing = [...required]\n .filter((name) => !declared.has(name))\n .filter((name) => !provided.some((prefix) => name === prefix || name.startsWith(`${prefix}/`)))\n .sort()\n\n if (missing.length === 0) return\n\n throw new Error(\n `sentinel build(nest): the bundle requires ${missing.length} package(s) the generated ` +\n `manifest does not declare, so the image would not install them: ${missing.join(', ')}. ` +\n `Either declare them in the module's package.json, inline them with ` +\n `\\`ssr.noExternal\\`, or list them in \\`providedByImage\\` if the Dockerfile copies them in.`,\n )\n}\n","/**\n * What `@hublo/sentinel/build/nest` gives an adopted service.\n *\n * The sibling `build/react` entry is a re-export surface: the module keeps its own config and\n * only its import lines move. This one carries a shape as well, because 38 Nest services share\n * one config and have nothing of their own to preserve. See `nest-service.ts` for why the two\n * answers differ, and why that is one rule rather than two.\n *\n * Its own entry point, like the React one, so importing it at build time never drags the CLI\n * and its adapters into a Vite config.\n */\nexport { nestService, type NestServiceOptions } from './nest-service.js'\n\n// The pieces the shape is built from, exported individually so a service that needs something\n// the shape does not give it can compose its own without leaving sentinel.\nexport { decoratorMetadata, type DecoratorMetadataOptions } from './decorator-metadata.js'\nexport { nodeManifest, type NodeManifestOptions } from './node-manifest.js'\nexport { tsconfigAliases, type Alias } from './tsconfig-aliases.js'\n\n// Vite's own, so an adopted config imports everything from one place and the module can drop\n// `vite` from its dependencies.\nexport { defineConfig, loadEnv, mergeConfig } from 'vite'\nexport type { Plugin, PluginOption, UserConfig, UserConfigExport } from 'vite'\n"],"mappings":";;;;;;;;;;;AA0BA,SAAS,QAAAA,aAAY;AAErB,SAAS,mBAAoC;;;ACN7C,SAAS,QAAQ,YAAY,WAAW,aAAa,gBAAgB;AACrE,SAAS,SAAS,MAAM,UAAU,WAAW;AAiB7C,SAAS,WAAW,MAAwB;AAC1C,QAAM,QAAkB,CAAC;AACzB,QAAM,OAAO,CAAC,QAAsB;AAClC,eAAW,SAAS,YAAY,GAAG,GAAG;AACpC,YAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,UAAI,SAAS,IAAI,EAAE,YAAY,EAAG,MAAK,IAAI;AAAA,UACtC,OAAM,KAAK,SAAS,MAAM,IAAI,EAAE,MAAM,GAAG,EAAE,KAAK,GAAG,CAAC;AAAA,IAC3D;AAAA,EACF;AACA,OAAK,IAAI;AACT,SAAO;AACT;AAGO,SAAS,cAAc,SAA4D;AACxF,QAAM,SAAyC,CAAC;AAChD,aAAW,SAAS,QAAQ,QAAQ;AAClC,UAAM,QAAQ,KAAK,QAAQ,eAAe,MAAM,KAAK;AACrD,QAAI,CAAC,WAAW,KAAK,GAAG;AACtB,YAAM,IAAI;AAAA,QACR,mEAAmE,MAAM,KAAK;AAAA,MAGhF;AAAA,IACF;AACA,UAAM,UAAU,aAAa,MAAM,IAAI;A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;;;AI/JxD,SAAS,cAAc,SAAS,eAAAC,oBAAmB;","names":["join","existsSync","dirname","join","sep","existsSync","isBuiltin","join","join","mergeConfig"]}
1
+ {"version":3,"sources":["../../../../src/roles/build/nest/nest-service.ts","../../../../src/roles/build/nest/copy-assets.ts","../../../../src/roles/build/nest/importer-externals.ts","../../../../src/roles/build/nest/node-manifest.ts","../../../../src/roles/build/nest/toolchain.ts"],"sourcesContent":["/**\n * The whole Vite config for a Nest service, so an adopted module holds two lines.\n *\n * ## Why a shape here, and pieces on the React side\n *\n * It looks inconsistent until you measure the two families. The four React apps each carry a\n * heavy, genuinely different config: one has a plugin wedged between two shared ones, another\n * has two different route-tree footers on the branches of one ternary. Two attempts at a\n * shared shape for them were abandoned, and the rule that survived is that sentinel rewrites\n * their IMPORTS and touches nothing else.\n *\n * The Nest side is the opposite by measurement: 38 services, one shared 25-line webpack config\n * between them, and nothing per-module to preserve. Owning the shape there is not a different\n * philosophy, it is the same one applied to a different fact: sentinel provides the FORM where\n * the form is shared, and the PIECES where it is not.\n *\n * The consequences are the point. An adopted module is readable in review. A correction to the\n * form is one publish instead of 38 diffs. And the day Nest becomes ESM-native, `format`\n * changes here rather than in 38 configs.\n *\n * ## It is a composition, not a block\n *\n * `nestService` assembles the same plugins this module exports individually. A service that\n * needs something else can pass `overrides`, or drop to the pieces entirely. And if the React\n * configs ever converge, a `reactApp()` can be built the same way with no new mechanism.\n */\nimport { join } from 'node:path'\n\nimport { mergeConfig, type UserConfig } from 'vite'\n\nimport { copyAssets } from './copy-assets.js'\nimport { decoratorMetadata } from './decorator-metadata.js'\nimport { importerExternals } from './importer-externals.js'\nimport { nodeManifest } from './node-manifest.js'\nimport type { AssetDeclaration, TransformerDeclaration } from './nx-target.js'\nimport { tsconfigAliases } from './tsconfig-aliases.js'\n\nexport interface NestServiceOptions {\n /** The nx project name. Keys the dependency graph, and names the module in messages. */\n project: string\n /** Absolute path to the module's directory, normally `__dirname`. */\n root: string\n /** Absolute path to the workspace root. */\n workspaceRoot: string\n /** Entry point, relative to `root`. */\n entry?: string\n /**\n * The tsconfig whose emit must be preserved, when the service uses neither conventional name.\n *\n * Relative to `root`. Defaults to `tsconfig.app.json`, then `tsconfig.json`.\n */\n tsconfig?: string\n /** Output directory, relative to `workspaceRoot`. */\n outDir?: string\n /**\n * TypeScript transformers this service compiles with, as its build target declared them.\n *\n * Read off the webpack target by `--init` and written here, never inferred: what a service\n * compiles with is the service's own. Eight services and BFFs run `@nestjs/swagger/plugin`,\n * which writes the `@ApiProperty` decorators their DTOs do not declare by hand. Building\n * without it succeeds and silently costs them most of their published contract (measured on\n * `institution`: 385 insertions, 1378 deletions in the committed OpenAPI document).\n */\n transformers?: readonly TransformerDeclaration[]\n /**\n * Files copied into the output beside the bundle, in the shape `@nx/webpack` declared them.\n *\n * One service here uses it: `planning-period` ships the pug, css and ttf templates it renders\n * printed documents from. Without them the service starts and fails on its first print.\n */\n assets?: readonly AssetDeclaration[]\n /**\n * Anything this service needs that the shape does not give it.\n *\n * Merged with Vite's own `mergeConfig`, never with a merge of our own: plugins concatenate\n * and aliases stack the way Vite does it everywhere else, so there is no second set of\n * semantics to learn or to document.\n */\n overrides?: UserConfig\n}\n\n/**\n * Packages the bundle INLINES rather than requires.\n *\n * `importHelpers: true` in the workspace tsconfig makes TypeScript emit `require(\"tslib\")` for\n * `__decorate` and `__metadata`, so every decorated file depends on it. Hoisted into one scope\n * Rollup inlined it and nobody noticed; preserving modules left it external, and the manifest nx\n * generates from the project graph does not list it, because no module DECLARES tslib. The image\n * therefore did not install it and the service died on its first require, only in the image:\n * locally and in CI the workspace root has tslib.\n *\n * One list, read by both `ssr.noExternal` and `importerExternals`, because the second runs\n * `enforce: 'pre'` and would otherwise win against the first and bring the incident back.\n */\nexport const NEST_SERVICE_NO_EXTERNAL: readonly string[] = ['tslib']\n\nconst baseConfig = (options: NestServiceOptions): UserConfig => {\n const outDir = join(options.workspaceRoot, options.outDir ?? `dist/${options.project}`)\n const entry = join(options.root, options.entry ?? 'src/main.ts')\n const aliases = tsconfigAliases(options.workspaceRoot)\n return {\n plugins: [\n importerExternals({ noExternal: NEST_SERVICE_NO_EXTERNAL, aliases }),\n decoratorMetadata({\n root: options.root,\n tsconfig: options.tsconfig,\n transformers: options.transformers,\n }),\n ...(options.assets?.length\n ? [copyAssets({ workspaceRoot: options.workspaceRoot, outDir, assets: options.assets })]\n : []),\n nodeManifest({\n project: options.project,\n workspaceRoot: options.workspaceRoot,\n outDir,\n }),\n ],\n resolve: { alias: aliases },\n ssr: {\n // See NEST_SERVICE_NO_EXTERNAL: `tslib`, inlined on purpose.\n noExternal: [...NEST_SERVICE_NO_EXTERNAL],\n },\n build: {\n // An SSR build targets Node and leaves real packages external, which is what\n // `webpack-node-externals` did: the image installs them from the generated manifest.\n // `importerExternals` holds that wherever the package is declared, not only at the root.\n ssr: entry,\n outDir,\n emptyOutDir: true,\n sourcemap: true,\n target: 'node20',\n // The bundle is read by humans when a stack trace points into it, and minifying a\n // server bundle buys nothing: it is never downloaded.\n minify: false,\n rollupOptions: {\n output: {\n format: 'cjs',\n // One output file per source module, instead of hoisting everything into one scope.\n //\n // This is not a preference, it is the only shape that keeps the OpenAPI contract.\n // Merging every module into one scope forces Rollup to rename duplicate class names,\n // and `@nestjs/swagger` keys its schemas on `class.name`, so a renamed class silently\n // becomes a renamed schema in the published API. Measured on `network`, which has two\n // such collisions: single bundle renames `InvalidPermissionError` and\n // `PermissionNotFoundError`; preserving modules renames nothing and reproduces the\n // committed contract byte for byte.\n //\n // The cost is 4.5 MB across 2003 files against 2.9 MB in one, still well under\n // webpack's 6.9 MB for the same service, so nothing regresses against what it replaces.\n preserveModules: true,\n // The image runs `./dist/main.js`, so the entry keeps that name at the root while\n // every other module keeps its own path. Under `preserveModules` a plain string here\n // would be applied to all of them, which numbers them (`main962.js`) and loses the\n // entry.\n entryFileNames: (chunk) => (chunk.facadeModuleId === entry ? 'main.js' : '[name].js'),\n },\n // Nest registers metadata as an IMPORT SIDE EFFECT: a decorator writes into a catalog\n // when its module loads, and nothing references that module afterwards. Rollup may\n // drop such a module; webpack never did.\n //\n // Measured on the first migrated service this changes nothing, so it is insurance\n // rather than a fix, and it is recorded as such rather than credited with the smaller\n // bundle (that comes from barrel re-exports the service does not use).\n treeshake: { moduleSideEffects: true },\n },\n },\n }\n}\n\nexport const nestService = (options: NestServiceOptions): UserConfig =>\n options.overrides === undefined\n ? baseConfig(options)\n : mergeConfig(baseConfig(options), options.overrides)\n","/**\n * The files a service ships beside its bundle, which webpack copied and a bundler does not.\n *\n * `@nx/webpack` takes an `assets` list and copies each match into the output. Nothing in a Vite\n * build does that for a Node target: `publicDir` is a browser concept and is disabled for SSR\n * builds, so an unmigrated `assets` entry is not a smaller output, it is a service that starts\n * and then fails the first time it reaches for a file that is not there.\n *\n * One service in this repo declares it. `planning-period` ships the pug templates, stylesheet and\n * font it renders printed documents from, under `templates/`. Dropping them leaves a build that\n * succeeds, an image that boots, and a printing feature that throws.\n *\n * ## Copied at `closeBundle`, and only what the target declared\n *\n * The declaration is carried through from the webpack target unchanged, globs and all, so this\n * plugin has nothing to decide: it resolves each `input` against the workspace root, matches the\n * glob, and writes under `output` inside the bundle's directory. `closeBundle` because that is\n * when the output directory exists and Vite has finished emptying it.\n *\n * An entry matching nothing FAILS the build. A glob that has quietly stopped matching is the same\n * silent loss as no glob at all, and the point of this file is that this class of loss is loud.\n */\nimport { cpSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs'\nimport { dirname, join, relative, sep } from 'node:path'\n\nimport type { Plugin } from 'vite'\n\nimport { globToRegExp } from '../../../shared/glob.js'\n\nimport type { AssetDeclaration } from './nx-target.js'\n\nexport interface CopyAssetsOptions {\n /** Absolute path to the workspace root, which `input` is relative to. */\n workspaceRoot: string\n /** Absolute path to the build's output directory. */\n outDir: string\n assets: readonly AssetDeclaration[]\n}\n\n/** Every file under `root`, as paths relative to it and with forward slashes. */\nfunction filesUnder(root: string): string[] {\n const found: string[] = []\n const walk = (dir: string): void => {\n for (const entry of readdirSync(dir)) {\n const full = join(dir, entry)\n if (statSync(full).isDirectory()) walk(full)\n else found.push(relative(root, full).split(sep).join('/'))\n }\n }\n walk(root)\n return found\n}\n\n/** What each declaration copies, or the reason it cannot. */\nexport function resolveAssets(options: CopyAssetsOptions): { from: string; to: string }[] {\n const copies: { from: string; to: string }[] = []\n for (const asset of options.assets) {\n const input = join(options.workspaceRoot, asset.input)\n if (!existsSync(input)) {\n throw new Error(\n `sentinel build(nest): the build target declares an asset from \\`${asset.input}\\`, which ` +\n `does not exist. webpack copied it into the output, so the built service would be ` +\n `missing files it reads at runtime.`,\n )\n }\n const matcher = globToRegExp(asset.glob)\n const matched = filesUnder(input).filter((file) => matcher.test(file))\n if (matched.length === 0) {\n throw new Error(\n `sentinel build(nest): the asset glob \\`${asset.glob}\\` under \\`${asset.input}\\` matches ` +\n `no file. An entry that matches nothing is the same silent loss as no entry at all.`,\n )\n }\n for (const file of matched) {\n copies.push({ from: join(input, file), to: join(options.outDir, asset.output, file) })\n }\n }\n return copies\n}\n\nexport const copyAssets = (options: CopyAssetsOptions): Plugin => ({\n name: 'sentinel:copy-assets',\n // After the bundle is written and the output directory has stopped being emptied.\n closeBundle() {\n for (const { from, to } of resolveAssets(options)) {\n mkdirSync(dirname(to), { recursive: true })\n cpSync(from, to)\n }\n },\n})\n","/**\n * Keep a real package external when Vite would inline it only because the service does not\n * declare it.\n *\n * Vite's SSR build decides externalisation from the service's OWN directory. In hublo/monorepo that\n * held because the root manifest declared nearly every package, so the lookup walked up to\n * `<repo>/node_modules`. Once a package moves off the root to the projects that import it, one\n * declared only by a workspace lib (`@nestjs/jwt`, declared by `libs/nest/auth`, not by `counter`)\n * no longer passes that check, and Vite INLINES it, `node_modules/.pnpm` path included. The build\n * stays green and `assertManifestCovers` cannot see it, because an inlined package is no longer an\n * import. Measured on the 9 Vite Nest services with the root drop applied: `@nestjs/jwt` inlined,\n * `@nestjs/core/*` subpaths inlined, and `require` order shuffled in files that did not change.\n *\n * Vite still RESOLVES such a package correctly, from the importer: only the externalise decision\n * is wrong. So the resolution is delegated to Vite (`this.resolve`), and this plugin only turns an\n * inlined package from `node_modules` into the external Vite would have emitted. A first version\n * resolved with `require.resolve` and built the id itself: it changed 38 to 315 files per service on\n * `main`, because Vite keeps an `exports` subpath as written (`rxjs/operators`, not\n * `rxjs/dist/cjs/operators/index.js`) and carries the package's `sideEffects`, without which\n * Rollup kept barrel modules it used to drop.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { isBuiltin } from 'node:module'\nimport { dirname, extname, join, sep } from 'node:path'\n\nimport type { Plugin } from 'vite'\n\nimport type { Alias } from './tsconfig-aliases.js'\n\nexport interface ImporterExternalsOptions {\n /**\n * Packages that must stay INLINED, the same list `ssr.noExternal` receives.\n *\n * Checked before anything else. This plugin runs `enforce: 'pre'`, and a `resolveId` there\n * wins against `ssr.noExternal`: measured, `tslib` then comes out as `require(\"tslib\")`, which\n * is the exact incident `noExternal` exists for. The image does not install `tslib`, because\n * no module declares it, and the service died on its first require.\n */\n noExternal: readonly string[]\n /** The workspace's tsconfig `paths`: those are source, and Vite bundles them. */\n aliases: readonly Alias[]\n}\n\n/** `@scope/name/sub/path` → `@scope/name`, `name/sub` → `name`. */\nexport const packageName = (specifier: string): string => {\n const parts = specifier.split('/')\n return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : (parts[0] ?? specifier)\n}\n\nconst isBareSpecifier = (specifier: string): boolean =>\n !specifier.startsWith('.') &&\n !specifier.startsWith('/') &&\n !specifier.startsWith('\\0') &&\n !isBuiltin(specifier)\n\n/** The package's own manifest, walked up from a file inside it. */\nconst packageManifest = (file: string, name: string): { exports?: unknown } | undefined => {\n let directory = dirname(file)\n while (directory !== dirname(directory)) {\n const manifest = join(directory, 'package.json')\n if (existsSync(manifest)) {\n try {\n const data = JSON.parse(readFileSync(manifest, 'utf8')) as {\n name?: string\n exports?: unknown\n }\n if (data.name === name) return data\n } catch {\n // A manifest that does not parse is not the package's own; keep walking.\n }\n }\n directory = dirname(directory)\n }\n return undefined\n}\n\n/**\n * The id Vite's `tryNodeResolve` gives an external, reproduced so the output does not move: the\n * specifier as written, except a deep import into a package WITHOUT an `exports` map whose\n * extension the resolution changed, which becomes the resolved file\n * (`@nestjs/core/injector/container` → `@nestjs/core/injector/container.js`).\n */\nconst externalId = (specifier: string, name: string, resolved: string): string => {\n if (specifier === name) return specifier\n if (extname(specifier) === extname(resolved)) return specifier\n if (packageManifest(resolved, name)?.exports !== undefined) return specifier\n const index = resolved.split(sep).join('/').indexOf(specifier)\n return index === -1 ? specifier : resolved.split(sep).join('/').slice(index)\n}\n\nexport const importerExternals = (options: ImporterExternalsOptions): Plugin => ({\n name: 'sentinel:importer-externals',\n enforce: 'pre',\n async resolveId(source, importer, resolveOptions) {\n if (!importer || !isBareSpecifier(source)) return null\n const name = packageName(source)\n // FIRST: a package `ssr.noExternal` inlines is never made external here (see the option).\n if (options.noExternal.includes(name)) return null\n if (options.aliases.some((alias) => alias.find.test(source))) return null\n const resolved = await this.resolve(source, importer, { ...resolveOptions, skipSelf: true })\n // Unresolved, or already external: Vite's own decision stands, byte for byte.\n if (!resolved || resolved.external) return null\n const file = resolved.id.split('?')[0] ?? resolved.id\n // A workspace package linked into `node_modules` resolves to its real path, outside it:\n // that is source, and it stays bundled as it is today.\n if (!file.split(sep).includes('node_modules')) return null\n return {\n id: externalId(source, name, file),\n external: true,\n moduleSideEffects: resolved.moduleSideEffects,\n }\n },\n})\n","/**\n * The pruned `package.json` and lockfile a Node image installs from.\n *\n * This is the half that made the nx executor look load-bearing. `--generatePackageJson` was an\n * option of `@nx/webpack:webpack`, and the backend image is built on its two outputs:\n *\n * COPY --from=build /app/dist/apps/nest/<service>/package.json /app/package.json\n * COPY --from=build /app/dist/apps/nest/<service>/pnpm-lock.yaml /app/pnpm-lock.yaml\n * RUN pnpm i --prod=true --frozen-lockfile\n *\n * It is not bound to the executor. The executor supplies one thing, the project graph, and\n * every function that does the work is exported by `@nx/js`. So the same two files can be\n * produced from a Vite plugin, and `--frozen-lockfile` accepting them afterwards is the proof\n * that they agree with each other: pnpm refuses the install otherwise.\n *\n * ## Why the graph, and not something simpler\n *\n * A Nest service here declares almost nothing of its own: measured, one dependency in its\n * manifest against 1463 installed in its image. Everything it uses is declared at the\n * workspace root and reaches it through source imports. So the dependency list can only be\n * computed from what the code imports, which is what the graph knows.\n *\n * Deriving it from the bundle's own externals is not equivalent either: measured on the first\n * service, the bundle statically requires 42 packages while the correct manifest holds 65. The\n * 23 missing ones are transitive or required dynamically at runtime (`fastify` behind\n * `@nestjs/platform-fastify`, `jsonwebtoken`, the LaunchDarkly SDK). Shipping the short list\n * fails in production, not in the build.\n */\nimport { existsSync, writeFileSync } from 'node:fs'\nimport { isBuiltin } from 'node:module'\nimport { join } from 'node:path'\n\nimport type { Plugin, Rollup } from 'vite'\n\nexport interface NodeManifestOptions {\n /** The nx project name, which is how the graph is keyed. */\n project: string\n /** Absolute path to the workspace root. */\n workspaceRoot: string\n /** Where the bundle is written; the two files land beside it. */\n outDir: string\n /** Entry file name, written as `main` so `node .` resolves inside the image. */\n entry?: string\n /**\n * Packages the IMAGE provides, which are therefore allowed to be required without being\n * declared in the manifest.\n *\n * The generated Prisma clients are the case this exists for: the Dockerfile copies\n * `node_modules/@prisma` from its own stage, so they resolve at runtime while no module\n * declares them. Everything else that is required and undeclared is a bug, and the check\n * below refuses the build.\n */\n providedByImage?: readonly string[]\n}\n\n/** What the Dockerfile copies in itself, so requiring it without declaring it is legitimate. */\nconst DEFAULT_PROVIDED_BY_IMAGE = ['@prisma'] as const\n\n/**\n * Every real package the emitted output requires, from Rollup's own record rather than a scan\n * of the text.\n *\n * `chunk.imports` mixes three things, and only the third is a dependency:\n *\n * - other EMITTED chunks. Under `preserveModules` these are relative output paths that do not\n * begin with `.`, so `apps/…`, `libs/…` and `_virtual/…` read exactly like package names.\n * They are recognised by being keys of the bundle itself.\n * - Node BUILTINS, which appear both bare (`crypto`) and prefixed (`node:crypto`).\n * - genuine external packages, which is what the manifest has to cover.\n */\nconst externalPackages = (bundle: Rollup.OutputBundle): Set<string> => {\n const emitted = new Set(Object.keys(bundle))\n const packages = new Set<string>()\n\n for (const emittedFile of Object.values(bundle)) {\n // Assets carry no imports, and the bundle holds both. Narrowing on the discriminant is what\n // replaced a cast through `unknown`, which asserted the same thing without checking it.\n if (emittedFile.type !== 'chunk') continue\n\n for (const imported of emittedFile.imports) {\n if (emitted.has(imported)) continue\n if (imported.startsWith('.') || imported.startsWith('/')) continue\n if (isBuiltin(imported)) continue\n\n const parts = imported.split('/')\n const name = imported.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]\n if (name) packages.add(name)\n }\n }\n return packages\n}\n\n/**\n * Writes the manifest and lockfile once the bundle is on disk.\n *\n * `closeBundle` rather than `writeBundle`, so the files land after Vite has finished with the\n * directory and cannot be cleared by `emptyOutDir`.\n *\n * `closeBundle` also runs after a FAILED build, where there is no directory to write into. Left\n * alone this hook then threw `ENOENT` on the manifest, and since it is the last error raised it\n * became the one Vite printed, hiding the failure that actually stopped the build. It cost two\n * diagnoses before being recognised, so the missing directory is now read as what it is: the\n * bundle was never written, and this plugin has nothing to say about why.\n */\nexport const nodeManifest = (options: NodeManifestOptions): Plugin => {\n /*\n * Captured while the bundle still exists in memory, and read back once the manifest is built.\n *\n * `undefined` until `generateBundle` runs, deliberately: an empty SET would make the coverage\n * check below pass by having seen nothing, which is the worst way for a guard to succeed. The\n * two states have to be told apart.\n */\n let required: Set<string> | undefined\n\n return {\n name: 'sentinel:node-manifest',\n apply: 'build',\n\n generateBundle(_outputOptions, bundle) {\n required = externalPackages(bundle)\n },\n\n async closeBundle() {\n // `closeBundle` runs after a FAILED build too. The ENTRY is what says a bundle was really\n // written: `emptyOutDir` leaves the directory in place, so its existence alone would let a\n // failed build still produce a manifest describing nothing.\n const entry = options.entry ?? 'main.js'\n if (!existsSync(join(options.outDir, entry))) return\n\n // Imported here rather than at module scope: a front config importing this file must not\n // pay for loading the nx graph machinery it will never call.\n const { createProjectGraphAsync } = await import('nx/src/devkit-exports.js')\n const { createPackageJson, createLockFile, getLockFileName } = await import('@nx/js')\n\n const graph = await createProjectGraphAsync({ exitOnError: false })\n const manifest = createPackageJson(options.project, graph, {\n root: options.workspaceRoot,\n isProduction: true,\n })\n manifest.main = entry\n\n if (required === undefined) {\n throw new Error(\n `sentinel build(nest): the bundle was written but never inspected, so the manifest ` +\n `could not be checked against what it requires. Refusing to write one that might ` +\n `not install.`,\n )\n }\n assertManifestCovers(required, manifest, options)\n\n writeFileSync(join(options.outDir, 'package.json'), `${JSON.stringify(manifest, null, 2)}\\n`)\n writeFileSync(\n join(options.outDir, getLockFileName('pnpm')),\n createLockFile(manifest, graph, 'pnpm'),\n )\n },\n }\n}\n\n/**\n * Refuse a bundle that requires something the image will not install.\n *\n * The manifest is derived from the project GRAPH, so it lists what modules declare. The bundle\n * requires what the bundler left external. Those two sets agreeing is an assumption, and it was\n * wrong: `tslib` arrives through `importHelpers` in the workspace tsconfig without any module\n * declaring it, so the manifest omitted it and the service died on its first require.\n *\n * It died only in the image. Locally and in CI the workspace root has the package, so the gap is\n * invisible until a container starts, which is the most expensive place to discover it. Checking\n * here turns that into a build failure naming the package.\n */\nconst assertManifestCovers = (\n required: ReadonlySet<string>,\n manifest: { dependencies?: Record<string, string> },\n options: NodeManifestOptions,\n): void => {\n const declared = new Set(Object.keys(manifest.dependencies ?? {}))\n const provided = options.providedByImage ?? DEFAULT_PROVIDED_BY_IMAGE\n const missing = [...required]\n .filter((name) => !declared.has(name))\n .filter((name) => !provided.some((prefix) => name === prefix || name.startsWith(`${prefix}/`)))\n .sort()\n\n if (missing.length === 0) return\n\n throw new Error(\n `sentinel build(nest): the bundle requires ${missing.length} package(s) the generated ` +\n `manifest does not declare, so the image would not install them: ${missing.join(', ')}. ` +\n `Either declare them in the module's package.json, inline them with ` +\n `\\`ssr.noExternal\\`, or list them in \\`providedByImage\\` if the Dockerfile copies them in.`,\n )\n}\n","/**\n * What `@hublo/sentinel/build/nest` gives an adopted service.\n *\n * The sibling `build/react` entry is a re-export surface: the module keeps its own config and\n * only its import lines move. This one carries a shape as well, because 38 Nest services share\n * one config and have nothing of their own to preserve. See `nest-service.ts` for why the two\n * answers differ, and why that is one rule rather than two.\n *\n * Its own entry point, like the React one, so importing it at build time never drags the CLI\n * and its adapters into a Vite config.\n */\nexport { nestService, type NestServiceOptions } from './nest-service.js'\n\n// The pieces the shape is built from, exported individually so a service that needs something\n// the shape does not give it can compose its own without leaving sentinel.\nexport { decoratorMetadata, type DecoratorMetadataOptions } from './decorator-metadata.js'\nexport { nodeManifest, type NodeManifestOptions } from './node-manifest.js'\nexport { tsconfigAliases, type Alias } from './tsconfig-aliases.js'\n\n// Vite's own, so an adopted config imports everything from one place and the module can drop\n// `vite` from its dependencies.\nexport { defineConfig, loadEnv, mergeConfig } from 'vite'\nexport type { Plugin, PluginOption, UserConfig, UserConfigExport } from 'vite'\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,QAAAA,aAAY;AAErB,SAAS,mBAAoC;;;ACN7C,SAAS,QAAQ,YAAY,WAAW,aAAa,gBAAgB;AACrE,SAAS,SAAS,MAAM,UAAU,WAAW;AAiB7C,SAAS,WAAW,MAAwB;AAC1C,QAAM,QAAkB,CAAC;AACzB,QAAM,OAAO,CAAC,QAAsB;AAClC,eAAW,SAAS,YAAY,GAAG,GAAG;AACpC,YAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,UAAI,SAAS,IAAI,EAAE,YAAY,EAAG,MAAK,IAAI;AAAA,UACtC,OAAM,KAAK,SAAS,MAAM,IAAI,EAAE,MAAM,GAAG,EAAE,KAAK,GAAG,CAAC;AAAA,IAC3D;AAAA,EACF;AACA,OAAK,IAAI;AACT,SAAO;AACT;AAGO,SAAS,cAAc,SAA4D;AACxF,QAAM,SAAyC,CAAC;AAChD,aAAW,SAAS,QAAQ,QAAQ;AAClC,UAAM,QAAQ,KAAK,QAAQ,eAAe,MAAM,KAA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WAAW,OAAO,IAClB,YAAY,WAAW,OAAO,GAAG,QAAQ,SAAS;;;AIvJxD,SAAS,cAAc,SAAS,eAAAC,oBAAmB;","names":["join","existsSync","dirname","join","sep","existsSync","isBuiltin","join","join","mergeConfig"]}
@@ -0,0 +1,68 @@
1
+ /** A rule's level. `off` is a module's decision, and the report prints it as one. */
2
+ type Severity = 'off' | 'warn' | 'error';
3
+ interface SqlDefaults {
4
+ /** The migration files squawk reads, as globs relative to the module. */
5
+ migrations: {
6
+ /**
7
+ * ⛔ `migration.sql` BY NAME, and that is what keeps the rollback scripts out. Beside the 871
8
+ * migrations sit 385 `down.sql`, 2 `drop.sql` and one `donw.sql`: scripts a human runs by hand,
9
+ * which Prisma never applies. Reading them would report every `DROP` they are made of, for a
10
+ * file that never reaches production through a deploy. Naming the file Prisma applies, rather
11
+ * than excluding the others, also keeps out the misspelling nobody would think to exclude.
12
+ */
13
+ include: string[];
14
+ /** Migrations a module chooses not to read. Empty by default. */
15
+ exclude: string[];
16
+ };
17
+ /** What the `Unsafe` rule reads. */
18
+ unsafe: {
19
+ /**
20
+ * Read the tests too. ON by default: 203 of the 226 `Unsafe` calls are in tests, and a call
21
+ * that is safe today is not safe by construction tomorrow. A module that decides otherwise sets
22
+ * it to false, and the report says so; the decision is the team's.
23
+ */
24
+ includeTests: boolean;
25
+ /**
26
+ * What counts as a test, by PATH. Measured on the monorepo before it was written: the filter
27
+ * `*.spec.*` alone let 149 test calls through as production, because `*.integration-spec.ts`,
28
+ * `*.steps.ts`, `tests/database/` and `*.test-util.ts` are all test code and none of them
29
+ * matches it.
30
+ */
31
+ tests: string[];
32
+ };
33
+ /** Directories never read, whatever the includes say. */
34
+ ignore: string[];
35
+ /**
36
+ * The PostgreSQL version squawk checks against, since some rules depend on it.
37
+ *
38
+ * 16.8 is the version the monorepo pins (`postgres:16.8`, in its integration tests and its
39
+ * database tooling). The role reads what the repository declares and never asks production.
40
+ */
41
+ pgVersion: string;
42
+ /**
43
+ * Each rule's level, by name. Empty means every rule at its default, `warn` in this version: the
44
+ * role refuses nothing while its adoption runs.
45
+ */
46
+ rules: Record<string, Severity>;
47
+ }
48
+
49
+ type DeepPartial<T> = {
50
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
51
+ };
52
+ /** What a module's config file passes. Everything is optional, including the file itself. */
53
+ interface SqlInput {
54
+ /** The module's own directory, normally `import.meta.dirname`. */
55
+ root?: string;
56
+ /** The seam. Replaces whatever it names, and every path it sets lands in `moved`. */
57
+ overrides?: DeepPartial<SqlDefaults>;
58
+ }
59
+ interface ResolvedSqlConfig extends SqlDefaults {
60
+ /** The module's directory, or null when its config file did not say. */
61
+ root: string | null;
62
+ /** Dotted paths the module set through `overrides`, sorted so two runs print the same report. */
63
+ moved: string[];
64
+ }
65
+ /** Resolve a module's declaration against this role's defaults. */
66
+ declare function defineSql(input?: SqlInput): ResolvedSqlConfig;
67
+
68
+ export { type ResolvedSqlConfig, type SqlInput, defineSql };
@@ -0,0 +1,8 @@
1
+ import {
2
+ defineSql
3
+ } from "../../chunk-NGLEGAEN.js";
4
+ import "../../chunk-PXTU5MPW.js";
5
+ export {
6
+ defineSql
7
+ };
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  defineStaticAnalysis
3
- } from "../../chunk-THTXP2QU.js";
3
+ } from "../../chunk-LX7EG6PJ.js";
4
+ import "../../chunk-PXTU5MPW.js";
4
5
  export {
5
6
  defineStaticAnalysis
6
7
  };
@@ -2,7 +2,7 @@ import { ViteUserConfig } from 'vitest/config';
2
2
  export { ConfigEnv, TestUserConfig, ViteUserConfig, defineConfig, mergeConfig } from 'vitest/config';
3
3
  export { loadEnv } from 'vite';
4
4
  import { SharedTestOptions } from '../shared-test-config.js';
5
- export { A as Alias, D as DecoratorMetadataOptions, d as decoratorMetadata, t as tsconfigAliases } from '../../../tsconfig-aliases-C_PxuZni.js';
5
+ export { A as Alias, D as DecoratorMetadataOptions, d as decoratorMetadata, t as tsconfigAliases } from '../../../tsconfig-aliases-Ce6axdJ4.js';
6
6
 
7
7
  declare function nestTestConfig(options: SharedTestOptions): ViteUserConfig;
8
8
 
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  sharedTestConfig
3
- } from "../../../chunk-DLGBRLUU.js";
3
+ } from "../../../chunk-EESVRILJ.js";
4
4
  import {
5
5
  decoratorMetadata,
6
6
  tsconfigAliases
7
- } from "../../../chunk-LNFGVGLE.js";
8
- import "../../../chunk-H4HAFJFZ.js";
7
+ } from "../../../chunk-SWWQ7X7B.js";
9
8
  import "../../../chunk-QXFCZON7.js";
10
9
 
11
10
  // src/roles/test/nest/toolchain.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/roles/test/nest/toolchain.ts","../../../../src/roles/test/nest/nest-test-config.ts"],"sourcesContent":["/**\n * What `@hublo/sentinel/test/nest` gives an adopted module.\n *\n * Its own entry point, like the build ones, so importing it from a config never drags the CLI and\n * its adapters into a test run.\n *\n * It differs from `test/react` in one way that matters, and the difference is not decoration.\n * React modules already had a Vitest config carrying decisions their owners made and justified, so\n * that preset is a pure re-export surface and moves nothing. Nest modules have NO Vitest config:\n * one has to be written, and four of its lines are load-bearing in ways nobody would guess from a\n * migration guide. Those four live in `nestTestConfig` rather than in 133 copies.\n */\n\n/**\n * From `vitest/config`, and NOT from `vite`, which also exports a `defineConfig`.\n *\n * They are different functions: `vitest/config`'s knows the `test` key, vite's does not. A config\n * built with vite's would load and quietly drop its entire test block, which is the kind of\n * failure that reads as \"vitest found no tests\" and sends someone hunting through globs.\n *\n * The BUILD role's nest entry point re-exports vite's, correctly for its purpose. Importing that\n * one here would be the exact mistake this comment exists to prevent.\n */\nexport { defineConfig, mergeConfig } from 'vitest/config'\n\n/**\n * From `vite`, because `vitest/config` does not export it. Two of the six already-Vitest configs\n * build their test env with it, and Nest services read their env the same way.\n *\n * Re-exported rather than claimed: the `vite` package belongs to the build role, and a module\n * adopting only this one keeps its own.\n */\nexport { loadEnv } from 'vite'\n\n/** The whole config, as one call. See `nest-test-config.ts` for why each line is there. */\nexport { nestTestConfig, type NestTestOptions } from './nest-test-config.js'\n\n/**\n * Re-exported so a module that needs to compose rather than override can reach them without\n * importing the BUILD role's entry point from a test config, which would pull vite's\n * `defineConfig` into scope beside vitest's and invite the mistake above.\n */\nexport {\n decoratorMetadata,\n type DecoratorMetadataOptions,\n} from '../../build/nest/decorator-metadata.js'\nexport { tsconfigAliases, type Alias } from '../../build/nest/tsconfig-aliases.js'\n\nexport type { ConfigEnv, TestUserConfig, ViteUserConfig } from 'vitest/config'\n","import type { ViteUserConfig } from 'vitest/config'\n\n/**\n * The Vitest config a NEST module gets: the shared one, plus the three things that are not shared.\n *\n * Everything load-bearing lives in `shared-test-config.ts`, because almost everything IS shared.\n * Measured across this repo before splitting, so the line falls where the code does and not where\n * the names suggest:\n *\n * jest-mock-extended front 21 nest 2542 shared\n * msw front 848 nest 517 shared\n * axios front 692 nest 863 shared\n * @prisma/ front 0 nest 1186 NEST ONLY\n *\n * So the nest side is three things: the generated Prisma client's runtime alias, `isolate` (a Nest\n * module registers metadata as an import side effect, so a shared module registry lets one suite\n * see what another registered), and the decorator plugin for the one module that needs it.\n */\nimport { sharedTestConfig, type SharedTestOptions } from '../shared-test-config.js'\n\nexport type { SharedTestOptions as NestTestOptions }\n\nexport function nestTestConfig(options: SharedTestOptions): ViteUserConfig {\n return sharedTestConfig({ ...options, flavour: 'nest' })\n}\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,cAAc,mBAAmB;AAS1C,SAAS,eAAe;;;ACVjB,SAAS,eAAe,SAA4C;AACzE,SAAO,iBAAiB,EAAE,GAAG,SAAS,SAAS,OAAO,CAAC;AACzD;","names":[]}
1
+ {"version":3,"sources":["../../../../src/roles/test/nest/toolchain.ts","../../../../src/roles/test/nest/nest-test-config.ts"],"sourcesContent":["/**\n * What `@hublo/sentinel/test/nest` gives an adopted module.\n *\n * Its own entry point, like the build ones, so importing it from a config never drags the CLI and\n * its adapters into a test run.\n *\n * It differs from `test/react` in one way that matters, and the difference is not decoration.\n * React modules already had a Vitest config carrying decisions their owners made and justified, so\n * that preset is a pure re-export surface and moves nothing. Nest modules have NO Vitest config:\n * one has to be written, and four of its lines are load-bearing in ways nobody would guess from a\n * migration guide. Those four live in `nestTestConfig` rather than in 133 copies.\n */\n\n/**\n * From `vitest/config`, and NOT from `vite`, which also exports a `defineConfig`.\n *\n * They are different functions: `vitest/config`'s knows the `test` key, vite's does not. A config\n * built with vite's would load and quietly drop its entire test block, which is the kind of\n * failure that reads as \"vitest found no tests\" and sends someone hunting through globs.\n *\n * The BUILD role's nest entry point re-exports vite's, correctly for its purpose. Importing that\n * one here would be the exact mistake this comment exists to prevent.\n */\nexport { defineConfig, mergeConfig } from 'vitest/config'\n\n/**\n * From `vite`, because `vitest/config` does not export it. Two of the six already-Vitest configs\n * build their test env with it, and Nest services read their env the same way.\n *\n * Re-exported rather than claimed: the `vite` package belongs to the build role, and a module\n * adopting only this one keeps its own.\n */\nexport { loadEnv } from 'vite'\n\n/** The whole config, as one call. See `nest-test-config.ts` for why each line is there. */\nexport { nestTestConfig, type NestTestOptions } from './nest-test-config.js'\n\n/**\n * Re-exported so a module that needs to compose rather than override can reach them without\n * importing the BUILD role's entry point from a test config, which would pull vite's\n * `defineConfig` into scope beside vitest's and invite the mistake above.\n */\nexport {\n decoratorMetadata,\n type DecoratorMetadataOptions,\n} from '../../build/nest/decorator-metadata.js'\nexport { tsconfigAliases, type Alias } from '../../build/nest/tsconfig-aliases.js'\n\nexport type { ConfigEnv, TestUserConfig, ViteUserConfig } from 'vitest/config'\n","import type { ViteUserConfig } from 'vitest/config'\n\n/**\n * The Vitest config a NEST module gets: the shared one, plus the three things that are not shared.\n *\n * Everything load-bearing lives in `shared-test-config.ts`, because almost everything IS shared.\n * Measured across this repo before splitting, so the line falls where the code does and not where\n * the names suggest:\n *\n * jest-mock-extended front 21 nest 2542 shared\n * msw front 848 nest 517 shared\n * axios front 692 nest 863 shared\n * @prisma/ front 0 nest 1186 NEST ONLY\n *\n * So the nest side is three things: the generated Prisma client's runtime alias, `isolate` (a Nest\n * module registers metadata as an import side effect, so a shared module registry lets one suite\n * see what another registered), and the decorator plugin for the one module that needs it.\n */\nimport { sharedTestConfig, type SharedTestOptions } from '../shared-test-config.js'\n\nexport type { SharedTestOptions as NestTestOptions }\n\nexport function nestTestConfig(options: SharedTestOptions): ViteUserConfig {\n return sharedTestConfig({ ...options, flavour: 'nest' })\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAS,cAAc,mBAAmB;AAS1C,SAAS,eAAe;;;ACVjB,SAAS,eAAe,SAA4C;AACzE,SAAO,iBAAiB,EAAE,GAAG,SAAS,SAAS,OAAO,CAAC;AACzD;","names":[]}
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  jestExportConditions,
3
3
  sharedTestConfig
4
- } from "../../../chunk-DLGBRLUU.js";
5
- import "../../../chunk-LNFGVGLE.js";
6
- import "../../../chunk-H4HAFJFZ.js";
4
+ } from "../../../chunk-EESVRILJ.js";
5
+ import "../../../chunk-SWWQ7X7B.js";
7
6
  import "../../../chunk-QXFCZON7.js";
8
7
 
9
8
  // src/roles/test/react/toolchain.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/roles/test/react/toolchain.ts","../../../../src/roles/test/react/react-test-config.ts"],"sourcesContent":["/**\n * What `@hublo/sentinel/test/react` gives an adopted module.\n *\n * A re-export surface, not a shape, and that is the measured answer rather than a preference.\n * The six configs already on Vitest fall into two groups: three React apps that converge on one\n * skeleton, and three modules of twelve to twenty lines that share almost nothing. A shared form\n * would serve half of them.\n *\n * More decisive: those configs carry decisions their owners made and justified in comments, a\n * `pool: 'threads'` measured on 1100 test files, an `experimental.fsModuleCache` measured against\n * transform and import time. Moving them is not a tooling migration, so the role moves the\n * imports and leaves every line of judgement where it is.\n *\n * Its own entry point, like the build ones, so importing it from a config never drags the CLI\n * and its adapters into a test run.\n */\n\n/**\n * From `vitest/config`, and NOT from `vite`, which also exports a `defineConfig`.\n *\n * They are different functions: measured, `vitest/config`'s `defineConfig` is not the same object\n * as vite's, and only it knows the `test` key. A config built with vite's would load and quietly\n * drop its entire test block. `mergeConfig` IS the same function in both, so its source does not\n * matter and it is taken from here for consistency.\n */\nexport { defineConfig, mergeConfig } from 'vitest/config'\n\n/**\n * From `vite`, because `vitest/config` does not export it. Measured, not assumed.\n *\n * Two of the six configs build their test env with it. Re-exported rather than claimed: the\n * `vite` package belongs to the build role, and a module adopting only this one keeps its own.\n */\nexport { loadEnv } from 'vite'\n\n/**\n * The names `vitest/config` actually exports, checked against its own declarations rather than\n * guessed: vite's `UserConfig` is re-exported there AS `ViteUserConfig`, and the test-side one is\n * `TestUserConfig`. Importing `UserConfig` from it compiles nowhere.\n */\nexport type { ConfigEnv, TestUserConfig, ViteUserConfig } from 'vitest/config'\n\n/**\n * The one thing this surface ADDS rather than re-exports, and only because a module cannot write\n * it for itself: Vite appends its own export conditions back over anything a config declares, so\n * restoring jest's resolution takes a plugin. Its own file carries the measurement.\n */\nexport { jestExportConditions } from './jest-export-conditions.js'\n\n/**\n * The config a MIGRATED React module gets, written by `--init --test`.\n *\n * Added on 23/09, because until then a front module being migrated received `nestTestConfig` while\n * the report announced `preset=react`. The re-export surface above is for the six modules that\n * already had a Vitest config and keep their own decisions; this is for the ones that had none and\n * need one written.\n */\nexport { reactTestConfig, type ReactTestOptions } from './react-test-config.js'\n","import type { ViteUserConfig } from 'vitest/config'\n\n/**\n * The Vitest config a REACT module gets: the shared one, without the Nest-only parts.\n *\n * ⚠️ This exists because a front module was being migrated with `nestTestConfig`, and the report\n * then said `preset=react` while the file it had just written imported `test/nest`. A tool that\n * contradicts itself in the same run is worse than one that is simply incomplete.\n *\n * What it does NOT carry, each measured rather than assumed: the `@prisma/*` runtime alias (1186\n * files mention it under nest, ZERO under front) and `isolate` (Nest registers metadata as an\n * import side effect; React has no such catalog, and isolation is not free).\n *\n * What it DOES carry is everything else, which is most of it: the workspace tsconfig path aliases,\n * jest's export conditions, the four test-file extensions, the concurrency this repo runs with, and\n * the msw, axios and jest-mock-extended aliases, all three of which the front uses heavily.\n *\n * Deliberately NOT here: a React plugin. Vite's own transform handles JSX in a test run, and the\n * front suites pass without one, so adding it would be paying for something nothing asked for.\n */\nimport { sharedTestConfig, type SharedTestOptions } from '../shared-test-config.js'\n\nexport type { SharedTestOptions as ReactTestOptions }\n\nexport function reactTestConfig(options: SharedTestOptions): ViteUserConfig {\n return sharedTestConfig({ ...options, flavour: 'react' })\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAS,cAAc,mBAAmB;AAQ1C,SAAS,eAAe;;;ACTjB,SAAS,gBAAgB,SAA4C;AAC1E,SAAO,iBAAiB,EAAE,GAAG,SAAS,SAAS,QAAQ,CAAC;AAC1D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/roles/test/react/toolchain.ts","../../../../src/roles/test/react/react-test-config.ts"],"sourcesContent":["/**\n * What `@hublo/sentinel/test/react` gives an adopted module.\n *\n * A re-export surface, not a shape, and that is the measured answer rather than a preference.\n * The six configs already on Vitest fall into two groups: three React apps that converge on one\n * skeleton, and three modules of twelve to twenty lines that share almost nothing. A shared form\n * would serve half of them.\n *\n * More decisive: those configs carry decisions their owners made and justified in comments, a\n * `pool: 'threads'` measured on 1100 test files, an `experimental.fsModuleCache` measured against\n * transform and import time. Moving them is not a tooling migration, so the role moves the\n * imports and leaves every line of judgement where it is.\n *\n * Its own entry point, like the build ones, so importing it from a config never drags the CLI\n * and its adapters into a test run.\n */\n\n/**\n * From `vitest/config`, and NOT from `vite`, which also exports a `defineConfig`.\n *\n * They are different functions: measured, `vitest/config`'s `defineConfig` is not the same object\n * as vite's, and only it knows the `test` key. A config built with vite's would load and quietly\n * drop its entire test block. `mergeConfig` IS the same function in both, so its source does not\n * matter and it is taken from here for consistency.\n */\nexport { defineConfig, mergeConfig } from 'vitest/config'\n\n/**\n * From `vite`, because `vitest/config` does not export it. Measured, not assumed.\n *\n * Two of the six configs build their test env with it. Re-exported rather than claimed: the\n * `vite` package belongs to the build role, and a module adopting only this one keeps its own.\n */\nexport { loadEnv } from 'vite'\n\n/**\n * The names `vitest/config` actually exports, checked against its own declarations rather than\n * guessed: vite's `UserConfig` is re-exported there AS `ViteUserConfig`, and the test-side one is\n * `TestUserConfig`. Importing `UserConfig` from it compiles nowhere.\n */\nexport type { ConfigEnv, TestUserConfig, ViteUserConfig } from 'vitest/config'\n\n/**\n * The one thing this surface ADDS rather than re-exports, and only because a module cannot write\n * it for itself: Vite appends its own export conditions back over anything a config declares, so\n * restoring jest's resolution takes a plugin. Its own file carries the measurement.\n */\nexport { jestExportConditions } from './jest-export-conditions.js'\n\n/**\n * The config a MIGRATED React module gets, written by `--init --test`.\n *\n * Added on 23/09, because until then a front module being migrated received `nestTestConfig` while\n * the report announced `preset=react`. The re-export surface above is for the six modules that\n * already had a Vitest config and keep their own decisions; this is for the ones that had none and\n * need one written.\n */\nexport { reactTestConfig, type ReactTestOptions } from './react-test-config.js'\n","import type { ViteUserConfig } from 'vitest/config'\n\n/**\n * The Vitest config a REACT module gets: the shared one, without the Nest-only parts.\n *\n * ⚠️ This exists because a front module was being migrated with `nestTestConfig`, and the report\n * then said `preset=react` while the file it had just written imported `test/nest`. A tool that\n * contradicts itself in the same run is worse than one that is simply incomplete.\n *\n * What it does NOT carry, each measured rather than assumed: the `@prisma/*` runtime alias (1186\n * files mention it under nest, ZERO under front) and `isolate` (Nest registers metadata as an\n * import side effect; React has no such catalog, and isolation is not free).\n *\n * What it DOES carry is everything else, which is most of it: the workspace tsconfig path aliases,\n * jest's export conditions, the four test-file extensions, the concurrency this repo runs with, and\n * the msw, axios and jest-mock-extended aliases, all three of which the front uses heavily.\n *\n * Deliberately NOT here: a React plugin. Vite's own transform handles JSX in a test run, and the\n * front suites pass without one, so adding it would be paying for something nothing asked for.\n */\nimport { sharedTestConfig, type SharedTestOptions } from '../shared-test-config.js'\n\nexport type { SharedTestOptions as ReactTestOptions }\n\nexport function reactTestConfig(options: SharedTestOptions): ViteUserConfig {\n return sharedTestConfig({ ...options, flavour: 'react' })\n}\n"],"mappings":";;;;;;;;AAyBA,SAAS,cAAc,mBAAmB;AAQ1C,SAAS,eAAe;;;ACTjB,SAAS,gBAAgB,SAA4C;AAC1E,SAAO,iBAAiB,EAAE,GAAG,SAAS,SAAS,QAAQ,CAAC;AAC1D;","names":[]}
@@ -7,9 +7,9 @@ import {
7
7
  } from "../../../chunk-NUOQXAYR.js";
8
8
  import {
9
9
  installWorkspaceSetup
10
- } from "../../../chunk-4YQXLPJ5.js";
10
+ } from "../../../chunk-PMRL4MH6.js";
11
11
  import "../../../chunk-ELZHIN6E.js";
12
- import "../../../chunk-ZNANJEMK.js";
12
+ import "../../../chunk-JT7ZMH44.js";
13
13
 
14
14
  // src/roles/test/setup/jest-parity.ts
15
15
  import { expect, vi } from "vitest";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  pinWorkspaceTimezone
3
- } from "../../../chunk-4YQXLPJ5.js";
3
+ } from "../../../chunk-PMRL4MH6.js";
4
4
  import "../../../chunk-ELZHIN6E.js";
5
- import "../../../chunk-ZNANJEMK.js";
5
+ import "../../../chunk-JT7ZMH44.js";
6
6
 
7
7
  // src/roles/test/setup/workspace-entry.ts
8
8
  await pinWorkspaceTimezone();
@@ -7,7 +7,7 @@ interface SharedTestOptions {
7
7
  flavour?: TestFlavour;
8
8
  /** The module's own directory: where its specs live and what its config is relative to. */
9
9
  root: string;
10
- /** The workspace root: where `tsconfig.base.json` is, the aliases' fallback for a module without `paths`. */
10
+ /** The workspace root, which is where `tsconfig.base.json` and its path aliases are. */
11
11
  workspaceRoot: string;
12
12
  /**
13
13
  * Lower decorators with TypeScript before oxc sees them, for a module that needs it.
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  sharedTestConfig
3
- } from "../../chunk-DLGBRLUU.js";
4
- import "../../chunk-LNFGVGLE.js";
5
- import "../../chunk-H4HAFJFZ.js";
3
+ } from "../../chunk-EESVRILJ.js";
4
+ import "../../chunk-SWWQ7X7B.js";
6
5
  import "../../chunk-QXFCZON7.js";
7
6
  export {
8
7
  sharedTestConfig
@@ -6,9 +6,6 @@
6
6
  "forceConsistentCasingInFileNames": true,
7
7
  "esModuleInterop": true,
8
8
  "skipLibCheck": true,
9
- "verbatimModuleSyntax": true,
10
- "resolveJsonModule": true,
11
- "skipDefaultLibCheck": true,
12
9
  "module": "esnext",
13
10
  "moduleResolution": "bundler",
14
11
  "types": [
@@ -17,12 +14,6 @@
17
14
  "experimentalDecorators": true,
18
15
  "emitDecoratorMetadata": true,
19
16
  "declaration": true,
20
- "sourceMap": true,
21
- "importHelpers": true,
22
- "target": "es2021",
23
- "lib": [
24
- "es2023",
25
- "dom"
26
- ]
17
+ "sourceMap": true
27
18
  }
28
19
  }
@@ -6,21 +6,11 @@
6
6
  "forceConsistentCasingInFileNames": true,
7
7
  "esModuleInterop": true,
8
8
  "skipLibCheck": true,
9
- "verbatimModuleSyntax": true,
10
- "resolveJsonModule": true,
11
- "skipDefaultLibCheck": true,
12
9
  "module": "esnext",
13
10
  "moduleResolution": "bundler",
14
11
  "types": [
15
12
  "node"
16
13
  ],
17
- "declaration": true,
18
- "importHelpers": true,
19
- "target": "es2021",
20
- "lib": [
21
- "es2023",
22
- "dom"
23
- ],
24
- "sourceMap": true
14
+ "declaration": true
25
15
  }
26
16
  }
@@ -6,9 +6,6 @@
6
6
  "forceConsistentCasingInFileNames": true,
7
7
  "esModuleInterop": true,
8
8
  "skipLibCheck": true,
9
- "verbatimModuleSyntax": true,
10
- "resolveJsonModule": true,
11
- "skipDefaultLibCheck": true,
12
9
  "target": "ES2023",
13
10
  "lib": [
14
11
  "ES2023",
@@ -25,27 +25,12 @@ interface Alias {
25
25
  find: RegExp;
26
26
  replacement: string;
27
27
  }
28
- /** Read the module's own chain rather than one workspace file. */
29
- interface ModuleAliasSource {
30
- /** The module's directory, where its tsconfig lives. */
31
- moduleRoot: string;
32
- /** Its tsconfig names to try, most specific first, relative to `moduleRoot`. */
33
- candidates?: readonly (string | undefined)[];
34
- }
35
28
  /**
36
- * The aliases a module resolves through.
29
+ * Read the mappings from the workspace's base tsconfig.
37
30
  *
38
31
  * Longest pattern first, because Vite takes the first alias that matches and the mappings
39
32
  * overlap by design: `@front/theme/node` must not be swallowed by `@front/theme`.
40
- *
41
- * Two ways to call it, and the first is kept for what it always did:
42
- * - `tsconfigAliases(workspaceRoot)` or with a file name: that one workspace file, read on its
43
- * own, its targets relative to `workspaceRoot`. Unchanged, because it is exported from the
44
- * `build/nest` and `test/nest` toolchains and a module's config may call it.
45
- * - `tsconfigAliases(workspaceRoot, { moduleRoot })`: the module's own chain, the way tsc reads
46
- * it, falling back to the workspace base when the chain declares no `paths`. See
47
- * `shared/tsconfig-paths.ts` for the rules and why the fallback is a transition.
48
33
  */
49
- declare function tsconfigAliases(workspaceRoot: string, source?: string | ModuleAliasSource): Alias[];
34
+ declare const tsconfigAliases: (workspaceRoot: string, file?: string) => Alias[];
50
35
 
51
36
  export { type Alias as A, type DecoratorMetadataOptions as D, decoratorMetadata as d, tsconfigAliases as t };
@@ -7,11 +7,9 @@ import {
7
7
  readTestAdoption,
8
8
  resolveVitest,
9
9
  suiteOf
10
- } from "./chunk-Z3JI7ZWX.js";
11
- import "./chunk-4UUL4SEW.js";
12
- import "./chunk-ZNANJEMK.js";
10
+ } from "./chunk-AVT5FSPO.js";
11
+ import "./chunk-JT7ZMH44.js";
13
12
  import "./chunk-O7REVMOC.js";
14
- import "./chunk-H4HAFJFZ.js";
15
13
  import "./chunk-QXFCZON7.js";
16
14
 
17
15
  // src/roles/test/validate.ts
@@ -466,13 +466,6 @@ export default nestService({
466
466
  Or drop to the pieces, which the same entry point exports individually: `decoratorMetadata`,
467
467
  `nodeManifest`, `tsconfigAliases`, plus Vite's `defineConfig`, `loadEnv` and `mergeConfig`.
468
468
 
469
- **Which aliases a service is bundled with.** `nestService` reads the module's own tsconfig chain
470
- (`tsconfig`, then `tsconfig.app.json`, then `tsconfig.json`), the way tsc reads it, so a service
471
- that declares its own `paths` is bundled with the aliases it type-checks with. When the chain
472
- declares no `paths`, it falls back to `tsconfig.base.json`, which is what it always read: a service
473
- that still extends the base sees no change. The fallback is a transition, not the end state.
474
- `tsconfigAliases(workspaceRoot)` called on its own still reads that one workspace file. One difference with tsc 7 is deliberate: a `baseUrl` in the chain is honoured, as ts-jest, Vite and TypeScript 5 and 6 read it, so a chain whose `baseUrl` is not the directory of the file declaring `paths` resolves differently at runtime than in the typecheck. None exists in the monorepo today.
475
-
476
469
  # Both families
477
470
 
478
471
  ## Svelte modules, and what they need first