@hublo/sentinel 1.7.0-alpha.1 → 1.7.0-alpha.3

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 (35) hide show
  1. package/dist/bin/sentinel.js +74 -13
  2. package/dist/{chunk-XGMMTX2N.js → chunk-DLGBRLUU.js} +2 -2
  3. package/dist/{chunk-7CRRGBHI.js → chunk-F6ART7RH.js} +93 -36
  4. package/dist/{chunk-ZVHUG6CA.js → chunk-H4HAFJFZ.js} +4 -13
  5. package/dist/chunk-H4HAFJFZ.js.map +1 -0
  6. package/dist/{chunk-POZDYETY.js → chunk-LNFGVGLE.js} +5 -3
  7. package/dist/{chunk-POZDYETY.js.map → chunk-LNFGVGLE.js.map} +1 -1
  8. package/dist/{chunk-4HYOGCOX.js → chunk-P6KTBQ2Q.js} +161 -460
  9. package/dist/chunk-QXFCZON7.js +16 -0
  10. package/dist/chunk-QXFCZON7.js.map +1 -0
  11. package/dist/{chunk-7E6YTTAK.js → chunk-THTXP2QU.js} +1 -1
  12. package/dist/chunk-THTXP2QU.js.map +1 -0
  13. package/dist/chunk-ZFG6P27V.js +313 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +6 -4
  16. package/dist/migrate-NWQ3LYER.js +544 -0
  17. package/dist/roles/build/nest/toolchain.js +3 -2
  18. package/dist/roles/build/nest/toolchain.js.map +1 -1
  19. package/dist/roles/static-analysis/config.js +1 -1
  20. package/dist/roles/test/nest/toolchain.js +4 -3
  21. package/dist/roles/test/nest/toolchain.js.map +1 -1
  22. package/dist/roles/test/react/toolchain.js +4 -3
  23. package/dist/roles/test/react/toolchain.js.map +1 -1
  24. package/dist/roles/test/shared-test-config.js +4 -3
  25. package/dist/tsconfig/legacy.json +21 -0
  26. package/dist/tsconfig/nest.json +10 -1
  27. package/dist/tsconfig/node.json +11 -1
  28. package/dist/tsconfig/react.json +3 -0
  29. package/dist/{validate-LMGBKN6L.js → validate-4V3EGTXN.js} +4 -2
  30. package/docs/typescript-adoption.md +55 -13
  31. package/docs/typescript-traces.md +1 -1
  32. package/package.json +4 -1
  33. package/dist/chunk-7E6YTTAK.js.map +0 -1
  34. package/dist/chunk-ZVHUG6CA.js.map +0 -1
  35. /package/dist/{chunk-XGMMTX2N.js.map → chunk-DLGBRLUU.js.map} +0 -0
@@ -12,11 +12,12 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-7CRRGBHI.js";
15
+ } from "../chunk-F6ART7RH.js";
16
16
  import {
17
17
  resolveContext,
18
18
  separateToolArgs
19
- } from "../chunk-4HYOGCOX.js";
19
+ } from "../chunk-P6KTBQ2Q.js";
20
+ import "../chunk-ZFG6P27V.js";
20
21
  import {
21
22
  ensureWorkspacePrep,
22
23
  findWorkspaceRoot,
@@ -34,10 +35,11 @@ import {
34
35
  SWEEPABLE_TARGETS,
35
36
  TARGETS,
36
37
  VERBS
37
- } from "../chunk-7E6YTTAK.js";
38
+ } from "../chunk-THTXP2QU.js";
38
39
  import "../chunk-4EIY7TTR.js";
39
40
  import "../chunk-O7REVMOC.js";
40
- import "../chunk-ZVHUG6CA.js";
41
+ import "../chunk-H4HAFJFZ.js";
42
+ import "../chunk-QXFCZON7.js";
41
43
 
42
44
  // bin/sentinel.ts
43
45
  import { program } from "commander";
@@ -573,6 +575,65 @@ sentinel (${type}): ${asMessage(error)}
573
575
  return worst;
574
576
  }
575
577
 
578
+ // src/cli/run-migrate.ts
579
+ async function runMigrate(ctx) {
580
+ const { modules, scope } = resolveContext(ctx.cwd, { module: ctx.module, ci: false });
581
+ const [module] = modules;
582
+ if (scope === "all" || scope === "affected" || module === void 0) {
583
+ ctx.fail(
584
+ "--migrate writes files: target one module (run from its directory, or pass --module). Migrating every module at once is intentionally not allowed."
585
+ );
586
+ }
587
+ const unsupported = ctx.targets.filter((target) => target !== "typescript");
588
+ if (unsupported.length > 0) {
589
+ const named = unsupported.map((target) => `--${target}`).join(", ");
590
+ process.stdout.write(
591
+ ` \xB7 ${named}: not available yet. \`--migrate\` answers \`--typescript\` today, by detaching the module from tsconfig.base.json. Nothing was migrated for ${named}.
592
+ `
593
+ );
594
+ }
595
+ if (!ctx.targets.includes("typescript")) return 1;
596
+ const { migrateModule } = await import("../migrate-NWQ3LYER.js");
597
+ const migration = migrateModule(module.root, {
598
+ write: !ctx.dryRun,
599
+ workspaceRoot: findWorkspaceRoot(module.root) ?? module.root
600
+ });
601
+ if (ctx.json) {
602
+ process.stdout.write(
603
+ `${JSON.stringify({ module: module.name, target: "typescript", ...migration }, null, 2)}
604
+ `
605
+ );
606
+ } else {
607
+ const mark = migration.outcome === "migrated" || migration.outcome === "proved" ? "\u2713" : migration.outcome === "skipped" ? "\xB7" : "\u2717";
608
+ process.stdout.write(` ${mark} ${module.name} \u2014 ${migration.message}
609
+ `);
610
+ for (const file of migration.files) {
611
+ process.stdout.write(
612
+ ` ${file.kept ? "\u2713" : "\xB7"} ${file.file}${file.reason ? `: ${file.reason}` : ""}
613
+ `
614
+ );
615
+ if (file.aliases !== void 0) {
616
+ process.stdout.write(
617
+ ` ${file.legacy ? "extends legacy, " : ""}${file.aliases.kept} of ${file.aliases.of} aliases, ${file.resolutions ?? 0} resolutions compared${file.written && file.written.length > 0 ? `, wrote ${file.written.join(", ")}` : ""}
618
+ `
619
+ );
620
+ }
621
+ for (const line of [
622
+ ...(file.configDifferences ?? []).map(
623
+ (d) => `${d.key}: ${d.before ?? "unset"} -> ${d.after ?? "unset"}`
624
+ ),
625
+ ...file.resolutionDifferences ?? []
626
+ ].slice(0, 20)) {
627
+ process.stdout.write(` ${line}
628
+ `);
629
+ }
630
+ }
631
+ for (const note of migration.notes) process.stdout.write(` note: ${note}
632
+ `);
633
+ }
634
+ return migration.outcome === "migrated" || migration.outcome === "proved" || migration.outcome === "skipped" ? 0 : 1;
635
+ }
636
+
576
637
  // src/cli/run-validate.ts
577
638
  async function runValidate(ctx) {
578
639
  const { modules } = resolveContext(ctx.cwd, { module: ctx.module, ci: ctx.ci });
@@ -585,7 +646,7 @@ async function runValidate(ctx) {
585
646
  );
586
647
  }
587
648
  if (!ctx.targets.includes("test")) return 1;
588
- const { validateModuleTests } = await import("../validate-LMGBKN6L.js");
649
+ const { validateModuleTests } = await import("../validate-4V3EGTXN.js");
589
650
  const outcomes = modules.flatMap(
590
651
  (module) => validateModuleTests(module.name, module.root)
591
652
  );
@@ -926,13 +987,16 @@ program.name("sentinel").description("One CLI that guards code health: presets,
926
987
  "before",
927
988
  [
928
989
  "A check composes: verb + type + location.",
929
- " verb what to do: --run --inspect --report --status --init --validate (--migrate: planned)",
990
+ " verb what to do: --run --inspect --report --status --init --migrate --validate",
930
991
  " type which check: --lint --typescript ... (omit = all types; or --all)",
931
992
  " where run from a MODULE dir \u2192 that module; from the ROOT \u2192 --module <name>,",
932
993
  " --ci (affected), or all modules. --init targets one module only.",
933
994
  ""
934
995
  ].join("\n")
935
- ).option("--run", "execute the target tool").option("--inspect", "show the resolved configuration").option("--init", "set up a module: write its config stubs + the workspace prep it needs").option("--migrate", "planned: change an already-initialized setup (not available yet)").option(
996
+ ).option("--run", "execute the target tool").option("--inspect", "show the resolved configuration").option("--init", "set up a module: write its config stubs + the workspace prep it needs").option(
997
+ "--migrate",
998
+ "change an already-initialized setup: --typescript detaches the module from tsconfig.base.json"
999
+ ).option(
936
1000
  "--validate",
937
1001
  "prove a migration kept the suite: record the reference, then compare against it"
938
1002
  ).option("--report", "deprecated: use --run --json").option("--status", "deprecated: use --inspect").option(
@@ -1111,8 +1175,8 @@ if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
1111
1175
  `--max-diagnostics must be a non-negative integer (0 = no cap); got ${JSON.stringify(opts.maxDiagnostics)}.`
1112
1176
  );
1113
1177
  }
1114
- if (opts.dryRun && verb !== "init") {
1115
- program.error("--dry-run only applies to --init (the read verbs never write).");
1178
+ if (opts.dryRun && verb !== "init" && verb !== "migrate") {
1179
+ program.error("--dry-run only applies to --init and --migrate (the read verbs never write).");
1116
1180
  }
1117
1181
  if (opts.rehearse && !opts.dryRun) {
1118
1182
  program.error(
@@ -1138,9 +1202,6 @@ async function exitWithoutTruncating(code) {
1138
1202
  await new Promise((resolve2) => stream.once("drain", () => resolve2()));
1139
1203
  }
1140
1204
  async function main() {
1141
- if (verb === "migrate") {
1142
- program.error("--migrate is planned and not available yet; use --init to set a module up.");
1143
- }
1144
1205
  const context = {
1145
1206
  verb,
1146
1207
  cwd,
@@ -1165,7 +1226,7 @@ async function main() {
1165
1226
  githubActions,
1166
1227
  fail: (message) => program.error(message)
1167
1228
  };
1168
- const exitCode = verb === "init" ? await runInit(context) : verb === "validate" ? await runValidate(context) : await runVerb(context);
1229
+ const exitCode = verb === "init" ? await runInit(context) : verb === "validate" ? await runValidate(context) : verb === "migrate" ? await runMigrate(context) : await runVerb(context);
1169
1230
  await exitWithoutTruncating(exitCode);
1170
1231
  }
1171
1232
  main().catch((error) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  decoratorMetadata,
3
3
  tsconfigAliases
4
- } from "./chunk-POZDYETY.js";
4
+ } from "./chunk-LNFGVGLE.js";
5
5
 
6
6
  // src/roles/test/shared-test-config.ts
7
7
  import { existsSync } from "node:fs";
@@ -618,4 +618,4 @@ export {
618
618
  jestExportConditions,
619
619
  sharedTestConfig
620
620
  };
621
- //# sourceMappingURL=chunk-XGMMTX2N.js.map
621
+ //# sourceMappingURL=chunk-DLGBRLUU.js.map
@@ -1,25 +1,15 @@
1
1
  import {
2
- ALWAYS_LOCAL_KEYS,
3
2
  BaseAdapter,
4
3
  ESLINT_CONFIG_FILES,
5
- FORMAT_CONFIG_FILE,
6
- FORMAT_DEFAULT_IGNORES,
7
- FORMAT_SCRIPT_NAME,
8
4
  LINT_BASELINE_FILE,
9
5
  LINT_BASELINE_SPECIFIER,
10
6
  LINT_CONFIG_FILE,
11
7
  LINT_MEASURE_FILE,
12
8
  LINT_PRESETS,
13
9
  LINT_SCRIPT_NAME,
14
- OWNED_WHEN_SET_KEYS,
15
- PERMITTED_LOCAL_KEYS,
16
- PRETTIER_CONFIG_FILES,
17
- PROVENANCE_KEY,
18
10
  RESOLVABLE_EXTENSIONS,
19
11
  VitestAdapter,
20
12
  adoptedPackageName,
21
- binFromOwnInstall,
22
- binSearchPath,
23
13
  canRunTypeAware,
24
14
  canonicalRuleName,
25
15
  describeHolds,
@@ -28,9 +18,6 @@ import {
28
18
  downgradedFor,
29
19
  extendsWithBaseline,
30
20
  extendsWithPreset,
31
- formatPresetFor,
32
- formatPresetName,
33
- formatTargets,
34
21
  governedRules,
35
22
  hasLintPreset,
36
23
  heldRules,
@@ -44,7 +31,6 @@ import {
44
31
  moduleOwnBlocks,
45
32
  moduleScripts,
46
33
  nxTargetOperations,
47
- oxfmtRejects,
48
34
  oxlintPath,
49
35
  oxlintSearchPath,
50
36
  presetNameFromPath,
@@ -54,22 +40,38 @@ import {
54
40
  presetVariant,
55
41
  projectTargets,
56
42
  readAdoption,
57
- readFormatAdoption,
58
43
  readLintAdoption,
59
44
  readModuleAdditions,
60
45
  renderBaseline,
61
- resolveBin,
62
46
  resolveConfigTarget,
63
- resolveOxfmt,
64
47
  resolveOxlint,
65
48
  rewriteToolchainImports,
66
- scriptPath,
67
49
  selfCommand,
68
50
  splitToolArgs,
69
51
  uncoveredFor,
70
- walk,
52
+ walk
53
+ } from "./chunk-P6KTBQ2Q.js";
54
+ import {
55
+ ALWAYS_LOCAL_KEYS,
56
+ FORMAT_CONFIG_FILE,
57
+ FORMAT_DEFAULT_IGNORES,
58
+ FORMAT_SCRIPT_NAME,
59
+ OWNED_WHEN_SET_KEYS,
60
+ PERMITTED_LOCAL_KEYS,
61
+ PRETTIER_CONFIG_FILES,
62
+ PROVENANCE_KEY,
63
+ binFromOwnInstall,
64
+ binSearchPath,
65
+ formatPresetFor,
66
+ formatPresetName,
67
+ formatTargets,
68
+ oxfmtRejects,
69
+ readFormatAdoption,
70
+ resolveBin,
71
+ resolveOxfmt,
72
+ scriptPath,
71
73
  writtenFileFormatter
72
- } from "./chunk-4HYOGCOX.js";
74
+ } from "./chunk-ZFG6P27V.js";
73
75
  import {
74
76
  DEFAULT_MAX_DIAGNOSTICS,
75
77
  WORKSPACE_ROOT_MARKER,
@@ -91,7 +93,7 @@ import {
91
93
  extensionsOf,
92
94
  isPlainObject,
93
95
  overridableSettings
94
- } from "./chunk-7E6YTTAK.js";
96
+ } from "./chunk-THTXP2QU.js";
95
97
  import {
96
98
  defineEnv
97
99
  } from "./chunk-4EIY7TTR.js";
@@ -101,9 +103,11 @@ import {
101
103
  import {
102
104
  WORKSPACE_TSCONFIG,
103
105
  chainPaths,
104
- effectivePaths,
106
+ effectivePaths
107
+ } from "./chunk-H4HAFJFZ.js";
108
+ import {
105
109
  parseJsonc
106
- } from "./chunk-ZVHUG6CA.js";
110
+ } from "./chunk-QXFCZON7.js";
107
111
 
108
112
  // src/core/registry.ts
109
113
  var adapters = [];
@@ -8337,12 +8341,18 @@ var nest_default = {
8337
8341
  experimentalDecorators: true,
8338
8342
  emitDecoratorMetadata: true,
8339
8343
  declaration: true,
8340
- sourceMap: true
8344
+ sourceMap: true,
8345
+ importHelpers: true,
8346
+ target: "es2021",
8347
+ lib: ["es2023", "dom"]
8341
8348
  },
8342
8349
  notes: {
8343
8350
  module: "the backends are webpack-bundled and tsc only typechecks, so the module format is the bundler's concern; `bundler` resolution is what the repo already uses, and the only Node-friendly option TS7 still accepts since it removed classic `node`",
8344
- target: "deliberately NOT set, here or in lib: those are environment the repo base owns. Overriding target flips useDefineForClassFields (TS2612) and narrowing lib drops DOM (GLfloat); both REPLACE the base rather than merge"
8345
- }
8351
+ target: "raised from tsconfig.base.json (sentinel#147) with the value every nest module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
8352
+ lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
8353
+ importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base"
8354
+ },
8355
+ fromBase: ["importHelpers", "target", "lib"]
8346
8356
  };
8347
8357
 
8348
8358
  // src/roles/typescript/presets/node.json
@@ -8351,11 +8361,20 @@ var node_default = {
8351
8361
  module: "esnext",
8352
8362
  moduleResolution: "bundler",
8353
8363
  types: ["node"],
8354
- declaration: true
8364
+ declaration: true,
8365
+ importHelpers: true,
8366
+ target: "es2021",
8367
+ lib: ["es2023", "dom"],
8368
+ sourceMap: true
8355
8369
  },
8356
8370
  notes: {
8357
- module: "esnext/bundler like the react and nest presets, matching a monorepo whose libs are bundler-resolved in practice. NOT NodeNext: that would force its stricter ESM rules onto libs the repo resolves through a bundler"
8358
- }
8371
+ module: "esnext/bundler like the react and nest presets, matching a monorepo whose libs are bundler-resolved in practice. NOT NodeNext: that would force its stricter ESM rules onto libs the repo resolves through a bundler",
8372
+ target: "raised from tsconfig.base.json (sentinel#147) with the value every node module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
8373
+ lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
8374
+ importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base",
8375
+ sourceMap: "raised from tsconfig.base.json (sentinel#147): `true` in every node module, through the base; nest already set it"
8376
+ },
8377
+ fromBase: ["importHelpers", "target", "lib", "sourceMap"]
8359
8378
  };
8360
8379
 
8361
8380
  // src/roles/typescript/presets/react.json
@@ -8385,7 +8404,10 @@ var shared_default2 = {
8385
8404
  noFallthroughCasesInSwitch: true,
8386
8405
  forceConsistentCasingInFileNames: true,
8387
8406
  esModuleInterop: true,
8388
- skipLibCheck: true
8407
+ skipLibCheck: true,
8408
+ verbatimModuleSyntax: true,
8409
+ resolveJsonModule: true,
8410
+ skipDefaultLibCheck: true
8389
8411
  },
8390
8412
  deferred: {
8391
8413
  noImplicitAny: {
@@ -8400,7 +8422,13 @@ var shared_default2 = {
8400
8422
  phase: 2,
8401
8423
  reason: "unused-parameter cleanup (TS6133)"
8402
8424
  }
8403
- }
8425
+ },
8426
+ notes: {
8427
+ verbatimModuleSyntax: "raised from tsconfig.base.json (HUB-43866, sentinel#147): every sentinel module applied `true` through the base, so a module that stops extending it keeps it. A module that sets `false` itself keeps its own value, and `--init` does not strip it (see fromBase)",
8428
+ resolveJsonModule: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base",
8429
+ skipDefaultLibCheck: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base"
8430
+ },
8431
+ fromBase: ["verbatimModuleSyntax", "resolveJsonModule", "skipDefaultLibCheck"]
8404
8432
  };
8405
8433
 
8406
8434
  // src/roles/typescript/preset-data.ts
@@ -8439,6 +8467,9 @@ function validate() {
8439
8467
  }
8440
8468
  }
8441
8469
  validate();
8470
+ function raisedFromBase(preset) {
8471
+ return [...SHARED.fromBase ?? [], ...LAYERS[preset]?.fromBase ?? []];
8472
+ }
8442
8473
  function hasShippedPreset(preset) {
8443
8474
  return preset in LAYERS;
8444
8475
  }
@@ -8469,12 +8500,29 @@ function presetCompilerOptionKeys(preset) {
8469
8500
  return Object.keys(tsPresetFor(preset).compilerOptions);
8470
8501
  }
8471
8502
  function presetOwnedKeys2(compilerOptions, preset) {
8472
- return presetOwnedKeys(compilerOptions, PERMITTED_COMPILER_OPTIONS, presetCompilerOptionKeys(preset));
8503
+ const owned = presetOwnedKeys(
8504
+ compilerOptions,
8505
+ PERMITTED_COMPILER_OPTIONS,
8506
+ presetCompilerOptionKeys(preset)
8507
+ );
8508
+ if (preset === void 0 || !hasShippedPreset(preset)) return owned;
8509
+ const raised = raisedFromBase(preset);
8510
+ const presetOptions = tsPresetFor(preset).compilerOptions;
8511
+ return owned.filter(
8512
+ (key) => !raised.includes(key) || sameOptionValue(compilerOptions?.[key], presetOptions[key])
8513
+ );
8514
+ }
8515
+ function sameOptionValue(left, right) {
8516
+ return JSON.stringify(left)?.toLowerCase() === JSON.stringify(right)?.toLowerCase();
8473
8517
  }
8474
8518
  function localOnlyCompilerOptions(compilerOptions, preset) {
8475
8519
  const sets = presetCompilerOptionKeys(preset);
8476
8520
  if (sets === void 0) return [];
8477
- return localOnlyKeys(compilerOptions, PERMITTED_COMPILER_OPTIONS, sets);
8521
+ const owned = presetOwnedKeys2(compilerOptions, preset);
8522
+ const keptOverrides = Object.keys(compilerOptions ?? {}).filter(
8523
+ (key) => sets.includes(key) && !PERMITTED_COMPILER_OPTIONS.includes(key) && !owned.includes(key)
8524
+ );
8525
+ return [...localOnlyKeys(compilerOptions, PERMITTED_COMPILER_OPTIONS, sets), ...keptOverrides];
8478
8526
  }
8479
8527
 
8480
8528
  // src/roles/typescript/resolve-tsconfig-target.ts
@@ -8494,7 +8542,7 @@ function resolveTsconfigTarget(moduleDir) {
8494
8542
  }
8495
8543
 
8496
8544
  // src/roles/typescript/read-adoption.ts
8497
- var SENTINEL_PRESET = /^@hublo\/sentinel\/(?:typescript|tsconfig)\/[a-z-]+$/;
8545
+ var SENTINEL_PRESET = /^@hublo\/sentinel\/(?:typescript|tsconfig)\/(?!legacy$)[a-z-]+$/;
8498
8546
  function readTsconfigAdoption(cwd) {
8499
8547
  return readAdoption(cwd, {
8500
8548
  candidates: TSCONFIG_CANDIDATES,
@@ -8506,7 +8554,13 @@ function readTsconfigAdoption(cwd) {
8506
8554
  // Drift is measured against what the preset SETS, not against the allowlist alone: see
8507
8555
  // `presetOwnedKeys`. Without this a module overriding the workspace base reads as
8508
8556
  // non-conformant forever, since re-running `--init` would not (and should not) fix it.
8509
- presetOwns: (path2) => presetCompilerOptionKeys(path2.slice(path2.lastIndexOf("/") + 1)) ?? []
8557
+ presetOwns: (path2) => presetCompilerOptionKeys(path2.slice(path2.lastIndexOf("/") + 1)) ?? [],
8558
+ // Same rule as `--init`: an option raised from the base and set to another value is an
8559
+ // override the module keeps, so it is not reported as drift either.
8560
+ refineDrift: (drift, settings, path2) => {
8561
+ const owned = presetOwnedKeys2(settings, path2.slice(path2.lastIndexOf("/") + 1));
8562
+ return drift.filter((key) => owned.includes(key));
8563
+ }
8510
8564
  });
8511
8565
  }
8512
8566
 
@@ -8547,9 +8601,12 @@ function typecheckScripts(cwd) {
8547
8601
  };
8548
8602
  }
8549
8603
  var SENTINEL_TS_PRESET = /@hublo\/sentinel\/(?:typescript|tsconfig)\//;
8604
+ var SENTINEL_LEGACY = /@hublo\/sentinel\/(?:typescript|tsconfig)\/legacy$/;
8550
8605
  function composeExtends(current, preset) {
8551
8606
  const chain = typeof current === "string" ? [current] : Array.isArray(current) ? current.filter((entry) => typeof entry === "string") : [];
8552
- const withoutOwn = chain.filter((entry) => entry !== preset && !SENTINEL_TS_PRESET.test(entry));
8607
+ const withoutOwn = chain.filter(
8608
+ (entry) => entry !== preset && (!SENTINEL_TS_PRESET.test(entry) || SENTINEL_LEGACY.test(entry))
8609
+ );
8553
8610
  return [...withoutOwn, preset];
8554
8611
  }
8555
8612
  function declaredPreset(cwd) {
@@ -1,14 +1,6 @@
1
- // src/shared/jsonc.ts
2
- import { parse, printParseErrorCode } from "jsonc-parser";
3
- function parseJsonc(text, source = "config") {
4
- const errors = [];
5
- const value = parse(text, errors, { allowTrailingComma: true });
6
- if (errors.length > 0) {
7
- const details = errors.map((error) => printParseErrorCode(error.error)).join(", ");
8
- throw new Error(`${source}: malformed JSONC (${details}).`);
9
- }
10
- return value;
11
- }
1
+ import {
2
+ parseJsonc
3
+ } from "./chunk-QXFCZON7.js";
12
4
 
13
5
  // src/shared/tsconfig-paths.ts
14
6
  import { existsSync, readFileSync } from "node:fs";
@@ -80,9 +72,8 @@ function effectivePaths(moduleRoot, workspaceRoot, candidates = ["tsconfig.json"
80
72
  }
81
73
 
82
74
  export {
83
- parseJsonc,
84
75
  WORKSPACE_TSCONFIG,
85
76
  chainPaths,
86
77
  effectivePaths
87
78
  };
88
- //# sourceMappingURL=chunk-ZVHUG6CA.js.map
79
+ //# sourceMappingURL=chunk-H4HAFJFZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/tsconfig-paths.ts"],"sourcesContent":["/**\n * The `paths` a module's tsconfig chain resolves to, the way tsc reads them.\n *\n * ## Why one reader, and why it follows the chain\n *\n * Three readers in this package used to parse `tsconfig.base.json` at the workspace root, each on\n * its own: the runtime aliases of `build/nest` and of the test presets, the consumer index of\n * static analysis, and the workspace specifier of the `--init --test` codemod. tsc does not read\n * it that way. It reads the `paths` of the MODULE's tsconfig, following `extends`. The two agree\n * while a module extends the base, and they part silently the day a module declares its own\n * `paths` and stops extending it: it type-checks with its aliases while its build, its tests and\n * the consumer index resolve through the base. Measured on the monorepo when this was written:\n * 112 sentinel tsconfigs extend the base, and the plan is for each to stop.\n *\n * ## tsc's rules, reproduced rather than guessed\n *\n * - `extends` is a relative file or a package specifier, resolved like Node. In an array, the\n * RIGHTMOST entry wins, so the search runs from the last entry to the first.\n * - The first `paths` found REPLACES the inherited ones; tsc never merges two `paths` objects. A\n * module that declares one entry and extends the base keeps that one entry, not the base's 372.\n * - Targets are relative to `baseUrl` when the chain declares one, and otherwise to the file that\n * declares `paths`. ts-jest, Vite and the TypeScript 5 and 6 still in the repository read\n * `baseUrl`, and this reader serves the build and the tests, so it follows them. ⚠️ tsc 7 no\n * longer reads it: for a chain whose `baseUrl` is NOT the directory of the file declaring\n * `paths`, the typecheck and the runtime resolve differently. No such chain exists in the\n * monorepo today (the only `baseUrl`, in `libs/front/analytics`, is `./`, its own directory), and\n * a test pins this choice so that changing it is a decision, not an accident.\n * - `${configDir}` is the directory of the leaf tsconfig, the one the module was asked for.\n *\n * ## The fallback, and why it is a transition\n *\n * When the chain declares no `paths` at all, this reads `tsconfig.base.json` at the workspace\n * root, which is what every reader did before. That keeps a module that still extends the base\n * exactly where it was, and it is what makes this a minor. It is not where this ends: once no\n * module extends the base, a module without `paths` has no aliases, as in tsc.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, isAbsolute, join, resolve } from 'node:path'\n\nimport { parseJsonc } from './jsonc.js'\n\n/** The workspace file every reader used before it followed the module's chain. */\nexport const WORKSPACE_TSCONFIG = 'tsconfig.base.json'\n\nexport interface EffectivePaths {\n /** The `paths` object, as declared: keys and targets untouched, `${configDir}` substituted. */\n paths: Record<string, string[]>\n /** The absolute directory the targets are relative to: `baseUrl`, or the declaring file's. */\n baseDirectory: string\n /** The absolute file that declared `paths`, which is what a report should name. */\n declaredIn: string\n /** True when the chain declared none and the workspace base answered instead. */\n fromWorkspaceFallback: boolean\n}\n\nexport interface RawTsconfig {\n extends?: string | string[]\n compilerOptions?: { paths?: Record<string, string[]>; baseUrl?: string }\n}\n\ninterface Found<T> {\n value: T\n file: string\n}\n\n/**\n * Parsed tsconfig files, shared by the reads of one caller.\n *\n * Optional, and owned by the CALLER rather than kept here, because the right lifetime is the\n * caller's: the consumer index reads the chains of 444 modules in one pass, and most of them end\n * in the same base of more than a thousand lines, while a dev server must see an edited tsconfig\n * on its next read.\n */\nexport type TsconfigReadCache = Map<string, RawTsconfig>\n\nfunction readTsconfig(file: string, cache?: TsconfigReadCache): RawTsconfig {\n const known = cache?.get(file)\n if (known !== undefined) return known\n const parsed = parseJsonc<RawTsconfig>(readFileSync(file, 'utf8'), file)\n cache?.set(file, parsed)\n return parsed\n}\n\n/**\n * Where an `extends` entry points, or undefined when it resolves to nothing tsc could read.\n *\n * ⚠️ A package specifier is resolved from the EXTENDING file's directory, like Node and like tsc,\n * not from this package: `@hublo/sentinel/typescript/nest` is the module's own pinned copy.\n */\nfunction resolveExtends(specifier: string, fromFile: string): string | undefined {\n const directory = dirname(fromFile)\n if (specifier.startsWith('.') || isAbsolute(specifier)) {\n const target = resolve(directory, specifier)\n if (existsSync(target) && target.endsWith('.json')) return target\n if (existsSync(`${target}.json`)) return `${target}.json`\n return existsSync(target) ? target : undefined\n }\n const require = createRequire(join(directory, 'noop.js'))\n for (const candidate of [specifier, `${specifier}.json`, `${specifier}/tsconfig.json`]) {\n try {\n return require.resolve(candidate)\n } catch {\n // Try the next spelling, which is the order tsc tries them in.\n }\n }\n return undefined\n}\n\n/**\n * The nearest definition of one compiler option along the chain, rightmost `extends` first.\n *\n * `seen` guards a cycle: tsc reports one and stops, and a reader that recursed would never return.\n */\nfunction nearest<T>(\n file: string,\n pick: (config: RawTsconfig) => T | undefined,\n cache: TsconfigReadCache | undefined,\n seen: Set<string> = new Set(),\n): Found<T> | undefined {\n if (seen.has(file)) return undefined\n seen.add(file)\n\n const config = readTsconfig(file, cache)\n const own = pick(config)\n if (own !== undefined) return { value: own, file }\n\n const parents = config.extends === undefined ? [] : [config.extends].flat()\n for (const specifier of [...parents].reverse()) {\n const parent = resolveExtends(specifier, file)\n if (parent === undefined) continue\n const found = nearest(parent, pick, cache, seen)\n if (found !== undefined) return found\n }\n return undefined\n}\n\nconst substituteConfigDirectory = (value: string, leafDirectory: string): string =>\n value.replaceAll('${configDir}', leafDirectory)\n\n/** The `paths` of one tsconfig file's chain, without the workspace fallback. */\nexport function chainPaths(\n tsconfigFile: string,\n cache?: TsconfigReadCache,\n): Omit<EffectivePaths, 'fromWorkspaceFallback'> | undefined {\n const leafDirectory = dirname(tsconfigFile)\n const paths = nearest(tsconfigFile, (config) => config.compilerOptions?.paths, cache)\n if (paths === undefined) return undefined\n\n const baseUrl = nearest(tsconfigFile, (config) => config.compilerOptions?.baseUrl, cache)\n const baseDirectory =\n baseUrl === undefined\n ? dirname(paths.file)\n : resolve(dirname(baseUrl.file), substituteConfigDirectory(baseUrl.value, leafDirectory))\n\n const substituted = Object.fromEntries(\n Object.entries(paths.value).map(([key, targets]) => [\n key,\n targets.map((target) => substituteConfigDirectory(target, leafDirectory)),\n ]),\n )\n return { paths: substituted, baseDirectory, declaredIn: paths.file }\n}\n\n/**\n * The `paths` a module resolves through: its own chain, or the workspace base when it has none.\n *\n * @param candidates the module's tsconfig names to try, most specific first, relative to\n * `moduleRoot`. The first that exists is the one read, which is what tsc is pointed at.\n * @returns undefined only when neither the module nor the workspace declares any `paths`.\n */\nexport function effectivePaths(\n moduleRoot: string,\n workspaceRoot: string,\n candidates: readonly string[] = ['tsconfig.json'],\n cache?: TsconfigReadCache,\n): EffectivePaths | undefined {\n const leaf = candidates.map((name) => join(moduleRoot, name)).find((file) => existsSync(file))\n const own = leaf === undefined ? undefined : chainPaths(leaf, cache)\n if (own !== undefined) return { ...own, fromWorkspaceFallback: false }\n\n const workspaceFile = join(workspaceRoot, WORKSPACE_TSCONFIG)\n if (!existsSync(workspaceFile)) return undefined\n const fallback = chainPaths(workspaceFile, cache)\n return fallback === undefined ? undefined : { ...fallback, fromWorkspaceFallback: true }\n}\n"],"mappings":";;;;;AAoCA,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY,MAAM,eAAe;AAK5C,IAAM,qBAAqB;AAiClC,SAAS,aAAa,MAAc,OAAwC;AAC1E,QAAM,QAAQ,OAAO,IAAI,IAAI;AAC7B,MAAI,UAAU,OAAW,QAAO;AAChC,QAAM,SAAS,WAAwB,aAAa,MAAM,MAAM,GAAG,IAAI;AACvE,SAAO,IAAI,MAAM,MAAM;AACvB,SAAO;AACT;AAQA,SAAS,eAAe,WAAmB,UAAsC;AAC/E,QAAM,YAAY,QAAQ,QAAQ;AAClC,MAAI,UAAU,WAAW,GAAG,KAAK,WAAW,SAAS,GAAG;AACtD,UAAM,SAAS,QAAQ,WAAW,SAAS;AAC3C,QAAI,WAAW,MAAM,KAAK,OAAO,SAAS,OAAO,EAAG,QAAO;AAC3D,QAAI,WAAW,GAAG,MAAM,OAAO,EAAG,QAAO,GAAG,MAAM;AAClD,WAAO,WAAW,MAAM,IAAI,SAAS;AAAA,EACvC;AACA,QAAMA,WAAU,cAAc,KAAK,WAAW,SAAS,CAAC;AACxD,aAAW,aAAa,CAAC,WAAW,GAAG,SAAS,SAAS,GAAG,SAAS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,IAAI,CAAC,WAAW,0BAA0B,QAAQ,aAAa,CAAC;AAAA,IAC1E,CAAC;AAAA,EACH;AACA,SAAO,EAAE,OAAO,aAAa,eAAe,YAAY,MAAM,KAAK;AACrE;AASO,SAAS,eACd,YACA,eACA,aAAgC,CAAC,eAAe,GAChD,OAC4B;AAC5B,QAAM,OAAO,WAAW,IAAI,CAAC,SAAS,KAAK,YAAY,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,WAAW,IAAI,CAAC;AAC7F,QAAM,MAAM,SAAS,SAAY,SAAY,WAAW,MAAM,KAAK;AACnE,MAAI,QAAQ,OAAW,QAAO,EAAE,GAAG,KAAK,uBAAuB,MAAM;AAErE,QAAM,gBAAgB,KAAK,eAAe,kBAAkB;AAC5D,MAAI,CAAC,WAAW,aAAa,EAAG,QAAO;AACvC,QAAM,WAAW,WAAW,eAAe,KAAK;AAChD,SAAO,aAAa,SAAY,SAAY,EAAE,GAAG,UAAU,uBAAuB,KAAK;AACzF;","names":["require"]}
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  WORKSPACE_TSCONFIG,
3
- effectivePaths,
3
+ effectivePaths
4
+ } from "./chunk-H4HAFJFZ.js";
5
+ import {
4
6
  parseJsonc
5
- } from "./chunk-ZVHUG6CA.js";
7
+ } from "./chunk-QXFCZON7.js";
6
8
 
7
9
  // src/roles/build/nest/decorator-metadata.ts
8
10
  import { existsSync } from "node:fs";
@@ -188,4 +190,4 @@ export {
188
190
  decoratorMetadata,
189
191
  tsconfigAliases
190
192
  };
191
- //# sourceMappingURL=chunk-POZDYETY.js.map
193
+ //# sourceMappingURL=chunk-LNFGVGLE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/roles/build/nest/decorator-metadata.ts","../src/roles/build/nest/tsconfig-aliases.ts"],"sourcesContent":["/**\n * Decorator metadata, which esbuild cannot emit and Nest cannot live without, plus the TypeScript\n * transformers a service declared on its webpack target.\n *\n * Vite's default transformer is esbuild, and esbuild does not implement `emitDecoratorMetadata`.\n * Nest resolves a constructor's parameters from exactly that metadata, so without it the DI\n * container comes up empty and the application fails on its first module. Measured in the\n * monorepo this ships to: `emitDecoratorMetadata: true` in `tsconfig.base.json`, and 7365 files\n * carrying `@Injectable`, `@Module` or `@Controller`.\n *\n * ## TWO modes, chosen exactly as nx chooses them\n *\n * This is the one decision in this file that is not ours, and trying to make it ours cost a day.\n *\n * `@nx/webpack` configures ts-loader with one line:\n *\n * transpileOnly: !hasPlugin // hasPlugin = this target declares `transformers`\n *\n * So webpack already had two behaviours. A service with no transformers compiled with\n * `transpileOnly`, which is `ts.transpileModule` semantics: no type checker, one file at a time.\n * A service WITH transformers compiled through a full `ts.Program`, because that is the only way\n * a TypeScript transformer can run at all.\n *\n * The difference is visible, and measured. On a property typed by an imported string enum:\n *\n * Program : __metadata(\"design:type\", String)\n * transpileModule : __metadata(\"design:type\", typeof (_a = ...) === \"function\" ? _a : Object)\n *\n * and on a `@Body()` whose DTO arrives through `import type`, a Program emits `Function` where\n * transpileOnly emits `Object`, which `@nestjs/swagger` turns into four `$ref: Function` request\n * bodies that the published contract does not have.\n *\n * This plugin used only the first mode and this file claimed it was \"the serializer ts-loader was\n * already using\". Half true, and the wrong half: it is what ts-loader uses for the 29 services\n * with no transformers, and those came back byte-identical. Then a Program was used for ALL of\n * them, which fixed the eight and moved the contract of `network`, which had been correct.\n *\n * Both were the same mistake: choosing one mode for everyone, when the tool being replaced chose\n * per service. So the condition is copied rather than invented, and there is no third case to\n * discover: nx has two, and both are reproduced here.\n *\n * The Program costs about six seconds more on the largest service (1419 files: ~1.9s to build it,\n * ~3.3ms per file against ~0.9ms). Only the services that declare a transformer pay it, which is\n * also what webpack did.\n *\n * ## The transformers, which are configuration and are read, never invented\n *\n * Eight services and BFFs declare `@nestjs/swagger/plugin` on their webpack target, with\n * `introspectComments` and `classValidatorShim`. It writes the `@ApiProperty` decorators a\n * developer would otherwise write by hand, turns JSDoc into descriptions, and projects\n * class-validator rules into the schema.\n *\n * Dropping it does not fail a build. Measured on `institution` by regenerating its committed\n * contract after a sentinel build: 385 insertions and 1378 deletions. Response schemas and every\n * `minItems`, `minimum`, `maximum`, `minLength` and `format` disappeared, silently.\n *\n * So `--init` reads the declaration off the webpack target and writes it into the generated Vite\n * config, and this plugin loads it. Nothing here decides which transformers a service runs.\n *\n * ## Why the MODULE's compiler now, and not sentinel's own\n *\n * This plugin used to pin sentinel's TypeScript, on the grounds that `typescript` in the consumer\n * could resolve to the 7.x native port, which exports a version and no compiler API. Measured\n * from a service today it resolves to `@typescript/typescript6` 6.0.2, with the full API.\n *\n * The pin cannot survive the transformers anyway: a plugin loaded from the module's\n * `node_modules` imports the module's TypeScript, and a transformer built against one compiler\n * cannot be handed a Program built by another. One compiler, the module's, is also what ts-loader\n * used, so it is the faithful answer rather than merely the workable one. The API is asserted at\n * `buildStart`, where a failure is reported.\n *\n * ## Why the module's own tsconfig, and not options chosen here\n *\n * Emit follows compiler options, so options invented here would be a second, silent source of\n * divergence from what ts-loader produced. `target` alone decides how classes and fields are\n * downlevelled: this workspace is on `es2021`, where `useDefineForClassFields` defaults to false\n * and a declared-but-unassigned DTO field is therefore NOT emitted. Defaulting to `es2022` here\n * would flip that, `Object.defineProperty` would write `undefined` over every field, and\n * `class-transformer` payloads would arrive empty at runtime with nothing in the build to explain\n * it.\n *\n * So the config is read, `extends` resolved by the compiler itself, and only what this plugin\n * genuinely owns is overridden.\n *\n * ## Still no type CHECKING, which is a different thing from having types\n *\n * The Program gives this plugin a type checker; it does not use it to report errors. Every Nest\n * project already runs `tsc -b` in its own `typecheck` target, and the build never was the thing\n * that type-checked. Emitting with type information and refusing to type-check are independent,\n * and only the first is needed to reproduce what ts-loader wrote.\n */\nimport { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\n\nimport type TS from 'typescript'\nimport type { Plugin } from 'vite'\n\n/** Files this transform owns: TypeScript sources, never a dependency's compiled output. */\nconst TYPESCRIPT_SOURCE = /\\.ts$/\n\n/**\n * Where a Nest service keeps the config it builds with, most specific first.\n *\n * `tsconfig.app.json` is the one Nx generates for the application's own sources and the one\n * ts-loader was pointed at; `tsconfig.json` is the fallback for a service that never split them.\n * Measured on `main`: all 37 services still on webpack name `tsconfig.app.json`.\n */\nconst TSCONFIG_CANDIDATES = ['tsconfig.app.json', 'tsconfig.json']\n\n/** A TypeScript transformer a service runs at build time, as its build target declares it. */\nexport interface TransformerDeclaration {\n /** The package to load it from, e.g. `@nestjs/swagger/plugin`. */\n name: string\n /** Passed to the transformer's own factory, unread here. */\n options?: Record<string, unknown>\n}\n\nexport interface DecoratorMetadataOptions {\n /** The module being built. Its tsconfig is the one whose emit must be preserved. */\n root: string\n /**\n * An explicit tsconfig, when the service does not use either conventional name.\n *\n * Relative paths resolve against `root`.\n */\n tsconfig?: string\n /** The transformers this service declared, translated from its webpack target. */\n transformers?: readonly TransformerDeclaration[]\n}\n\n/**\n * The module's own TypeScript, with its emit API asserted.\n *\n * Resolved from `root` rather than from here, because a transformer loaded from the module binds\n * to the compiler the module resolves, and Programs are not interchangeable between compilers.\n */\nfunction loadCompiler(root: string): typeof TS {\n const require = createRequire(path.join(root, 'noop.js'))\n let compiler: typeof TS\n try {\n compiler = require('typescript') as typeof TS\n } catch {\n throw new Error(\n `sentinel build(nest): no \\`typescript\\` resolvable from ${root}. The build emits decorator ` +\n `metadata with the module's own compiler, so one has to be installed there.`,\n )\n }\n if (typeof compiler.createProgram !== 'function') {\n throw new Error(\n `sentinel build(nest): the typescript resolved from ${root} (${compiler.version ?? 'unknown'}) ` +\n `has no createProgram API. TypeScript 7 is the native port and exposes none; the emit API ` +\n `lives under @typescript/typescript6. Point this module's \\`typescript\\` at a compiler ` +\n `with an emit API, which is the one its \\`typecheck\\` target already uses.`,\n )\n }\n return compiler\n}\n\nfunction resolveTsconfig(options: DecoratorMetadataOptions): string {\n if (options.tsconfig) {\n const explicit = path.resolve(options.root, options.tsconfig)\n if (!existsSync(explicit)) {\n throw new Error(`sentinel build(nest): tsconfig not found at ${explicit}`)\n }\n return explicit\n }\n for (const candidate of TSCONFIG_CANDIDATES) {\n const found = path.join(options.root, candidate)\n if (existsSync(found)) return found\n }\n throw new Error(\n `sentinel build(nest): no ${TSCONFIG_CANDIDATES.join(' or ')} in ${options.root}. ` +\n `Pass \\`tsconfig\\` if this service keeps it elsewhere.`,\n )\n}\n\n/** The module's compiler options, with `extends` already resolved, plus what this plugin owns. */\nfunction readConfig(\n ts: typeof TS,\n options: DecoratorMetadataOptions,\n): { fileNames: string[]; compilerOptions: TS.CompilerOptions } {\n const configPath = resolveTsconfig(options)\n const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, {\n ...ts.sys,\n onUnRecoverableConfigFileDiagnostic: (diagnostic) => {\n throw new Error(\n `sentinel build(nest): could not read ${configPath}: ` +\n ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '),\n )\n },\n } as TS.ParseConfigFileHost)\n\n return {\n fileNames: parsed?.fileNames ?? [],\n compilerOptions: {\n ...parsed?.options,\n // ESM out, so Rollup sees imports and exports rather than an opaque `require` it cannot\n // follow. The service still SHIPS as CJS: that conversion is the bundler's, further down.\n module: ts.ModuleKind.ESNext,\n // Vite consumes the map; the tsconfig's own answer is about a different pipeline.\n sourceMap: true,\n inlineSourceMap: false,\n inlineSources: false,\n // Types are another target's job, and emitting them here would write into the source tree.\n declaration: false,\n declarationMap: false,\n emitDeclarationOnly: false,\n noEmit: false,\n // `composite` projects refuse to emit without a `tsBuildInfoFile`, and there is no\n // incremental build here to inform.\n composite: false,\n incremental: false,\n },\n }\n}\n\n/**\n * The declared transformers, loaded from the MODULE so each binds to the compiler it expects.\n *\n * A name that cannot be loaded, or a package that exports no `before`, fails the build here\n * rather than producing a bundle quietly missing what the transformer contributes. That failure\n * mode is the reason this exists: dropping `@nestjs/swagger/plugin` costs a service most of its\n * published contract and nothing in the build says so.\n */\nfunction loadTransformers(\n root: string,\n program: TS.Program,\n declared: readonly TransformerDeclaration[],\n): TS.TransformerFactory<TS.SourceFile>[] {\n const require = createRequire(path.join(root, 'noop.js'))\n return declared.map(({ name, options }) => {\n let loaded: { before?: unknown }\n try {\n loaded = require(name) as { before?: unknown }\n } catch (error) {\n throw new Error(\n `sentinel build(nest): the build target declares the transformer \\`${name}\\`, which ` +\n `cannot be loaded from ${root}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\n }\n if (typeof loaded.before !== 'function') {\n throw new Error(\n `sentinel build(nest): \\`${name}\\` exports no \\`before\\` factory, so it cannot run as a ` +\n `TypeScript transformer. Building without it would drop whatever it contributes.`,\n )\n }\n const factory = loaded.before as (\n options: Record<string, unknown> | undefined,\n program: TS.Program,\n ) => TS.TransformerFactory<TS.SourceFile>\n return factory(options, program)\n })\n}\n\nexport const decoratorMetadata = (options: DecoratorMetadataOptions): Plugin => {\n /*\n * Everything is prepared in `buildStart`, and that placement is the whole point.\n *\n * It used to be resolved lazily inside `transform`, on the reasoning that an error belongs to\n * the build rather than to importing the preset. Half right: it belongs to the build, but\n * Rollup SWALLOWS a throwing `transform` hook. The wrong compiler, an unreadable tsconfig and a\n * missing one all produced the same symptom instead of their own message: \"1 modules\n * transformed\", nothing written, then an unrelated error from whichever later hook tripped over\n * the empty output directory. It cost two diagnoses to recognise.\n *\n * `buildStart` is reported. So the compiler is loaded, the config read, the Program built and\n * the transformers resolved exactly once, before a single file is transformed, where failing\n * says what failed.\n */\n /** `hasPlugin` in nx's own words: this service declares transformers, so it needs a Program. */\n const typeAware = (options.transformers ?? []).length > 0\n\n let ts: typeof TS | undefined\n let program: TS.Program | undefined\n let compilerOptions: TS.CompilerOptions | undefined\n let before: TS.TransformerFactory<TS.SourceFile>[] = []\n /** Files emitted without the Program, which is a fidelity gap and is reported, never silent. */\n const withoutTypes: string[] = []\n\n return {\n name: 'sentinel:decorator-metadata',\n // Before Vite's own transform, so esbuild never sees the decorators it cannot handle, and so\n // the source this plugin reads from the Program is still the source on disk.\n enforce: 'pre',\n buildStart() {\n ts = loadCompiler(options.root)\n const config = readConfig(ts, options)\n compilerOptions = config.compilerOptions\n // Built only in the type-aware mode. It costs ~1.9s on the largest service here and buys\n // nothing a service without transformers can use, which is why nx does not build one either.\n if (!typeAware) return\n program = ts.createProgram(config.fileNames, config.compilerOptions)\n before = loadTransformers(options.root, program, options.transformers ?? [])\n },\n transform(code, id) {\n if (!TYPESCRIPT_SOURCE.test(id) || id.includes('node_modules')) return null\n // Only reachable if `buildStart` did not run, which no Rollup build does. Named rather than\n // defaulted, so it cannot silently emit with TypeScript's defaults instead of the module's.\n if (ts === undefined || compilerOptions === undefined) {\n throw new Error(\n `sentinel build(nest): the compiler was never prepared, so ${id} would be emitted with ` +\n `defaults rather than this module's tsconfig.`,\n )\n }\n\n /*\n * The Program's own SourceFile, which is what carries the type information.\n *\n * Three cases emit without it. The service declares no transformer, which is `transpileOnly`\n * and is what ts-loader did for it. A file the Program never reached, because nothing\n * imports it from the entry. And a file another plugin has already rewritten, where the\n * Program's copy is no longer the truth: emitting that stale copy over someone else's\n * transform would be the worse failure.\n *\n * The last two are counted and reported at the end. The first is not a gap, it is the mode.\n *\n * Measured on the largest service here: neither of the last two fires, on any of its 5594\n * files. That is the point of reporting them rather than tolerating them quietly — a warning\n * from this build means something genuinely new, not a known rough edge.\n */\n const sourceFile = program?.getSourceFile(id)\n if (program === undefined || sourceFile === undefined || sourceFile.text !== code) {\n if (typeAware) withoutTypes.push(id)\n const output = ts.transpileModule(code, { fileName: id, compilerOptions })\n return { code: output.outputText, map: output.sourceMapText ?? null }\n }\n\n let emitted: string | undefined\n let map: string | undefined\n program.emit(\n sourceFile,\n (fileName, text) => {\n if (fileName.endsWith('.map')) map = text\n else emitted = text\n },\n undefined,\n false,\n { before },\n )\n if (emitted === undefined) {\n throw new Error(`sentinel build(nest): TypeScript emitted nothing for ${id}.`)\n }\n return { code: emitted, map: map ?? null }\n },\n closeBundle() {\n if (withoutTypes.length === 0) return\n const shown = withoutTypes.slice(0, 5).map((file) => path.relative(options.root, file))\n this.warn(\n `sentinel build(nest): ${withoutTypes.length} file(s) were emitted without type ` +\n `information, so their decorator metadata may differ from what ts-loader produced ` +\n `(${shown.join(', ')}${withoutTypes.length > shown.length ? ', …' : ''}). They are ` +\n `outside this module's tsconfig, or another plugin rewrote them first.`,\n )\n },\n }\n}\n","/**\n * The workspace's `paths` mappings, as Vite resolve aliases.\n *\n * They matter more than they look. The mappings point at SOURCE files, and that is what makes\n * a workspace library get BUNDLED rather than externalised: Vite treats anything outside\n * `node_modules` as source. Drop them and every `@hublo/nest/*` import becomes an external the\n * runtime cannot resolve, because those packages are never published.\n *\n * This reproduces what webpack did through `tsconfig-paths-webpack-plugin`, alongside\n * `webpack-node-externals` which only ever externalised real packages. Measured on the first\n * migrated service: 45 externals under Vite against 47 under webpack, and nothing externalised\n * by Vite that webpack did not.\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { parseJsonc } from '../../../shared/jsonc.js'\nimport { effectivePaths, WORKSPACE_TSCONFIG } from '../../../shared/tsconfig-paths.js'\n\nexport interface Alias {\n find: RegExp\n replacement: string\n}\n\n/** Read the module's own chain rather than one workspace file. */\nexport interface ModuleAliasSource {\n /** The module's directory, where its tsconfig lives. */\n moduleRoot: string\n /** Its tsconfig names to try, most specific first, relative to `moduleRoot`. */\n candidates?: readonly (string | undefined)[]\n}\n\nconst toAlias = (baseDirectory: string, pattern: string, target: string): Alias => {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\\\\\*/g, '(.*)')\n return {\n find: new RegExp(`^${escaped}$`),\n replacement: join(baseDirectory, target.replace(/\\*/g, '$1')),\n }\n}\n\n/** Longest pattern first, because Vite takes the first alias that matches. */\nconst toAliases = (baseDirectory: string, paths: Record<string, string[]>): Alias[] =>\n Object.entries(paths)\n .flatMap(([pattern, targets]) => {\n const [target] = targets\n return target === undefined ? [] : [toAlias(baseDirectory, pattern, target)]\n })\n .sort((a, b) => b.find.source.length - a.find.source.length)\n\n/**\n * The aliases a module resolves through.\n *\n * Longest pattern first, because Vite takes the first alias that matches and the mappings\n * overlap by design: `@front/theme/node` must not be swallowed by `@front/theme`.\n *\n * Two ways to call it, and the first is kept for what it always did:\n * - `tsconfigAliases(workspaceRoot)` or with a file name: that one workspace file, read on its\n * own, its targets relative to `workspaceRoot`. Unchanged, because it is exported from the\n * `build/nest` and `test/nest` toolchains and a module's config may call it.\n * - `tsconfigAliases(workspaceRoot, { moduleRoot })`: the module's own chain, the way tsc reads\n * it, falling back to the workspace base when the chain declares no `paths`. See\n * `shared/tsconfig-paths.ts` for the rules and why the fallback is a transition.\n */\nexport function tsconfigAliases(\n workspaceRoot: string,\n source: string | ModuleAliasSource = WORKSPACE_TSCONFIG,\n): Alias[] {\n if (typeof source !== 'string') {\n const candidates = (source.candidates ?? ['tsconfig.json']).filter(\n (name): name is string => name !== undefined,\n )\n const found = effectivePaths(source.moduleRoot, workspaceRoot, candidates)\n return found === undefined ? [] : toAliases(found.baseDirectory, found.paths)\n }\n\n /*\n * ⚠️ JSONC, through the shared reader. This stripped `//` comments by hand and then called\n * `JSON.parse`, which handled a comment on its OWN line and nothing else: a trailing comment\n * after a value, a block comment, or a trailing comma, all legal in a tsconfig, would throw a\n * raw SyntaxError naming a character offset. Latent on this repo's base config today, and\n * `shared/jsonc.ts` already existed for exactly this.\n */\n const raw = readFileSync(join(workspaceRoot, source), 'utf8')\n const { compilerOptions } = parseJsonc<{\n compilerOptions?: { paths?: Record<string, string[]> }\n }>(raw, source)\n return toAliases(workspaceRoot, compilerOptions?.paths ?? {})\n}\n"],"mappings":";;;;;;;AA2FA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAMjB,IAAM,oBAAoB;AAS1B,IAAM,sBAAsB,CAAC,qBAAqB,eAAe;AA6BjE,SAAS,aAAa,MAAyB;AAC7C,QAAMA,WAAU,cAAc,KAAK,KAAK,MAAM,SAAS,CAAC;AACxD,MAAI;AACJ,MAAI;AACF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AE,QAAQ,SAAS,MAAM;AACtF,SAAO;AAAA,IACL,MAAM,IAAI,OAAO,IAAI,OAAO,GAAG;AAAA,IAC/B,aAAa,KAAK,eAAe,OAAO,QAAQ,OAAO,IAAI,CAAC;AAAA,EAC9D;AACF;AAGA,IAAM,YAAY,CAAC,eAAuB,UACxC,OAAO,QAAQ,KAAK,EACjB,QAAQ,CAAC,CAAC,SAAS,OAAO,MAAM;AAC/B,QAAM,CAAC,MAAM,IAAI;AACjB,SAAO,WAAW,SAAY,CAAC,IAAI,CAAC,QAAQ,eAAe,SAAS,MAAM,CAAC;AAC7E,CAAC,EACA,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,OAAO,SAAS,EAAE,KAAK,OAAO,MAAM;AAgBxD,SAAS,gBACd,eACA,SAAqC,oBAC5B;AACT,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,cAAc,OAAO,cAAc,CAAC,eAAe,GAAG;AAAA,MAC1D,CAAC,SAAyB,SAAS;AAAA,IACrC;AACA,UAAM,QAAQ,eAAe,OAAO,YAAY,eAAe,UAAU;AACzE,WAAO,UAAU,SAAY,CAAC,IAAI,UAAU,MAAM,eAAe,MAAM,KAAK;AAAA,EAC9E;AASA,QAAM,MAAM,aAAa,KAAK,eAAe,MAAM,GAAG,MAAM;AAC5D,QAAM,EAAE,gBAAgB,IAAI,WAEzB,KAAK,MAAM;AACd,SAAO,UAAU,eAAe,iBAAiB,SAAS,CAAC,CAAC;AAC9D;","names":["require"]}
1
+ {"version":3,"sources":["../src/roles/build/nest/decorator-metadata.ts","../src/roles/build/nest/tsconfig-aliases.ts"],"sourcesContent":["/**\n * Decorator metadata, which esbuild cannot emit and Nest cannot live without, plus the TypeScript\n * transformers a service declared on its webpack target.\n *\n * Vite's default transformer is esbuild, and esbuild does not implement `emitDecoratorMetadata`.\n * Nest resolves a constructor's parameters from exactly that metadata, so without it the DI\n * container comes up empty and the application fails on its first module. Measured in the\n * monorepo this ships to: `emitDecoratorMetadata: true` in `tsconfig.base.json`, and 7365 files\n * carrying `@Injectable`, `@Module` or `@Controller`.\n *\n * ## TWO modes, chosen exactly as nx chooses them\n *\n * This is the one decision in this file that is not ours, and trying to make it ours cost a day.\n *\n * `@nx/webpack` configures ts-loader with one line:\n *\n * transpileOnly: !hasPlugin // hasPlugin = this target declares `transformers`\n *\n * So webpack already had two behaviours. A service with no transformers compiled with\n * `transpileOnly`, which is `ts.transpileModule` semantics: no type checker, one file at a time.\n * A service WITH transformers compiled through a full `ts.Program`, because that is the only way\n * a TypeScript transformer can run at all.\n *\n * The difference is visible, and measured. On a property typed by an imported string enum:\n *\n * Program : __metadata(\"design:type\", String)\n * transpileModule : __metadata(\"design:type\", typeof (_a = ...) === \"function\" ? _a : Object)\n *\n * and on a `@Body()` whose DTO arrives through `import type`, a Program emits `Function` where\n * transpileOnly emits `Object`, which `@nestjs/swagger` turns into four `$ref: Function` request\n * bodies that the published contract does not have.\n *\n * This plugin used only the first mode and this file claimed it was \"the serializer ts-loader was\n * already using\". Half true, and the wrong half: it is what ts-loader uses for the 29 services\n * with no transformers, and those came back byte-identical. Then a Program was used for ALL of\n * them, which fixed the eight and moved the contract of `network`, which had been correct.\n *\n * Both were the same mistake: choosing one mode for everyone, when the tool being replaced chose\n * per service. So the condition is copied rather than invented, and there is no third case to\n * discover: nx has two, and both are reproduced here.\n *\n * The Program costs about six seconds more on the largest service (1419 files: ~1.9s to build it,\n * ~3.3ms per file against ~0.9ms). Only the services that declare a transformer pay it, which is\n * also what webpack did.\n *\n * ## The transformers, which are configuration and are read, never invented\n *\n * Eight services and BFFs declare `@nestjs/swagger/plugin` on their webpack target, with\n * `introspectComments` and `classValidatorShim`. It writes the `@ApiProperty` decorators a\n * developer would otherwise write by hand, turns JSDoc into descriptions, and projects\n * class-validator rules into the schema.\n *\n * Dropping it does not fail a build. Measured on `institution` by regenerating its committed\n * contract after a sentinel build: 385 insertions and 1378 deletions. Response schemas and every\n * `minItems`, `minimum`, `maximum`, `minLength` and `format` disappeared, silently.\n *\n * So `--init` reads the declaration off the webpack target and writes it into the generated Vite\n * config, and this plugin loads it. Nothing here decides which transformers a service runs.\n *\n * ## Why the MODULE's compiler now, and not sentinel's own\n *\n * This plugin used to pin sentinel's TypeScript, on the grounds that `typescript` in the consumer\n * could resolve to the 7.x native port, which exports a version and no compiler API. Measured\n * from a service today it resolves to `@typescript/typescript6` 6.0.2, with the full API.\n *\n * The pin cannot survive the transformers anyway: a plugin loaded from the module's\n * `node_modules` imports the module's TypeScript, and a transformer built against one compiler\n * cannot be handed a Program built by another. One compiler, the module's, is also what ts-loader\n * used, so it is the faithful answer rather than merely the workable one. The API is asserted at\n * `buildStart`, where a failure is reported.\n *\n * ## Why the module's own tsconfig, and not options chosen here\n *\n * Emit follows compiler options, so options invented here would be a second, silent source of\n * divergence from what ts-loader produced. `target` alone decides how classes and fields are\n * downlevelled: this workspace is on `es2021`, where `useDefineForClassFields` defaults to false\n * and a declared-but-unassigned DTO field is therefore NOT emitted. Defaulting to `es2022` here\n * would flip that, `Object.defineProperty` would write `undefined` over every field, and\n * `class-transformer` payloads would arrive empty at runtime with nothing in the build to explain\n * it.\n *\n * So the config is read, `extends` resolved by the compiler itself, and only what this plugin\n * genuinely owns is overridden.\n *\n * ## Still no type CHECKING, which is a different thing from having types\n *\n * The Program gives this plugin a type checker; it does not use it to report errors. Every Nest\n * project already runs `tsc -b` in its own `typecheck` target, and the build never was the thing\n * that type-checked. Emitting with type information and refusing to type-check are independent,\n * and only the first is needed to reproduce what ts-loader wrote.\n */\nimport { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\n\nimport type TS from 'typescript'\nimport type { Plugin } from 'vite'\n\n/** Files this transform owns: TypeScript sources, never a dependency's compiled output. */\nconst TYPESCRIPT_SOURCE = /\\.ts$/\n\n/**\n * Where a Nest service keeps the config it builds with, most specific first.\n *\n * `tsconfig.app.json` is the one Nx generates for the application's own sources and the one\n * ts-loader was pointed at; `tsconfig.json` is the fallback for a service that never split them.\n * Measured on `main`: all 37 services still on webpack name `tsconfig.app.json`.\n */\nconst TSCONFIG_CANDIDATES = ['tsconfig.app.json', 'tsconfig.json']\n\n/** A TypeScript transformer a service runs at build time, as its build target declares it. */\nexport interface TransformerDeclaration {\n /** The package to load it from, e.g. `@nestjs/swagger/plugin`. */\n name: string\n /** Passed to the transformer's own factory, unread here. */\n options?: Record<string, unknown>\n}\n\nexport interface DecoratorMetadataOptions {\n /** The module being built. Its tsconfig is the one whose emit must be preserved. */\n root: string\n /**\n * An explicit tsconfig, when the service does not use either conventional name.\n *\n * Relative paths resolve against `root`.\n */\n tsconfig?: string\n /** The transformers this service declared, translated from its webpack target. */\n transformers?: readonly TransformerDeclaration[]\n}\n\n/**\n * The module's own TypeScript, with its emit API asserted.\n *\n * Resolved from `root` rather than from here, because a transformer loaded from the module binds\n * to the compiler the module resolves, and Programs are not interchangeable between compilers.\n */\nfunction loadCompiler(root: string): typeof TS {\n const require = createRequire(path.join(root, 'noop.js'))\n let compiler: typeof TS\n try {\n compiler = require('typescript') as typeof TS\n } catch {\n throw new Error(\n `sentinel build(nest): no \\`typescript\\` resolvable from ${root}. The build emits decorator ` +\n `metadata with the module's own compiler, so one has to be installed there.`,\n )\n }\n if (typeof compiler.createProgram !== 'function') {\n throw new Error(\n `sentinel build(nest): the typescript resolved from ${root} (${compiler.version ?? 'unknown'}) ` +\n `has no createProgram API. TypeScript 7 is the native port and exposes none; the emit API ` +\n `lives under @typescript/typescript6. Point this module's \\`typescript\\` at a compiler ` +\n `with an emit API, which is the one its \\`typecheck\\` target already uses.`,\n )\n }\n return compiler\n}\n\nfunction resolveTsconfig(options: DecoratorMetadataOptions): string {\n if (options.tsconfig) {\n const explicit = path.resolve(options.root, options.tsconfig)\n if (!existsSync(explicit)) {\n throw new Error(`sentinel build(nest): tsconfig not found at ${explicit}`)\n }\n return explicit\n }\n for (const candidate of TSCONFIG_CANDIDATES) {\n const found = path.join(options.root, candidate)\n if (existsSync(found)) return found\n }\n throw new Error(\n `sentinel build(nest): no ${TSCONFIG_CANDIDATES.join(' or ')} in ${options.root}. ` +\n `Pass \\`tsconfig\\` if this service keeps it elsewhere.`,\n )\n}\n\n/** The module's compiler options, with `extends` already resolved, plus what this plugin owns. */\nfunction readConfig(\n ts: typeof TS,\n options: DecoratorMetadataOptions,\n): { fileNames: string[]; compilerOptions: TS.CompilerOptions } {\n const configPath = resolveTsconfig(options)\n const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, {\n ...ts.sys,\n onUnRecoverableConfigFileDiagnostic: (diagnostic) => {\n throw new Error(\n `sentinel build(nest): could not read ${configPath}: ` +\n ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '),\n )\n },\n } as TS.ParseConfigFileHost)\n\n return {\n fileNames: parsed?.fileNames ?? [],\n compilerOptions: {\n ...parsed?.options,\n // ESM out, so Rollup sees imports and exports rather than an opaque `require` it cannot\n // follow. The service still SHIPS as CJS: that conversion is the bundler's, further down.\n module: ts.ModuleKind.ESNext,\n // Vite consumes the map; the tsconfig's own answer is about a different pipeline.\n sourceMap: true,\n inlineSourceMap: false,\n inlineSources: false,\n // Types are another target's job, and emitting them here would write into the source tree.\n declaration: false,\n declarationMap: false,\n emitDeclarationOnly: false,\n noEmit: false,\n // `composite` projects refuse to emit without a `tsBuildInfoFile`, and there is no\n // incremental build here to inform.\n composite: false,\n incremental: false,\n },\n }\n}\n\n/**\n * The declared transformers, loaded from the MODULE so each binds to the compiler it expects.\n *\n * A name that cannot be loaded, or a package that exports no `before`, fails the build here\n * rather than producing a bundle quietly missing what the transformer contributes. That failure\n * mode is the reason this exists: dropping `@nestjs/swagger/plugin` costs a service most of its\n * published contract and nothing in the build says so.\n */\nfunction loadTransformers(\n root: string,\n program: TS.Program,\n declared: readonly TransformerDeclaration[],\n): TS.TransformerFactory<TS.SourceFile>[] {\n const require = createRequire(path.join(root, 'noop.js'))\n return declared.map(({ name, options }) => {\n let loaded: { before?: unknown }\n try {\n loaded = require(name) as { before?: unknown }\n } catch (error) {\n throw new Error(\n `sentinel build(nest): the build target declares the transformer \\`${name}\\`, which ` +\n `cannot be loaded from ${root}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\n }\n if (typeof loaded.before !== 'function') {\n throw new Error(\n `sentinel build(nest): \\`${name}\\` exports no \\`before\\` factory, so it cannot run as a ` +\n `TypeScript transformer. Building without it would drop whatever it contributes.`,\n )\n }\n const factory = loaded.before as (\n options: Record<string, unknown> | undefined,\n program: TS.Program,\n ) => TS.TransformerFactory<TS.SourceFile>\n return factory(options, program)\n })\n}\n\nexport const decoratorMetadata = (options: DecoratorMetadataOptions): Plugin => {\n /*\n * Everything is prepared in `buildStart`, and that placement is the whole point.\n *\n * It used to be resolved lazily inside `transform`, on the reasoning that an error belongs to\n * the build rather than to importing the preset. Half right: it belongs to the build, but\n * Rollup SWALLOWS a throwing `transform` hook. The wrong compiler, an unreadable tsconfig and a\n * missing one all produced the same symptom instead of their own message: \"1 modules\n * transformed\", nothing written, then an unrelated error from whichever later hook tripped over\n * the empty output directory. It cost two diagnoses to recognise.\n *\n * `buildStart` is reported. So the compiler is loaded, the config read, the Program built and\n * the transformers resolved exactly once, before a single file is transformed, where failing\n * says what failed.\n */\n /** `hasPlugin` in nx's own words: this service declares transformers, so it needs a Program. */\n const typeAware = (options.transformers ?? []).length > 0\n\n let ts: typeof TS | undefined\n let program: TS.Program | undefined\n let compilerOptions: TS.CompilerOptions | undefined\n let before: TS.TransformerFactory<TS.SourceFile>[] = []\n /** Files emitted without the Program, which is a fidelity gap and is reported, never silent. */\n const withoutTypes: string[] = []\n\n return {\n name: 'sentinel:decorator-metadata',\n // Before Vite's own transform, so esbuild never sees the decorators it cannot handle, and so\n // the source this plugin reads from the Program is still the source on disk.\n enforce: 'pre',\n buildStart() {\n ts = loadCompiler(options.root)\n const config = readConfig(ts, options)\n compilerOptions = config.compilerOptions\n // Built only in the type-aware mode. It costs ~1.9s on the largest service here and buys\n // nothing a service without transformers can use, which is why nx does not build one either.\n if (!typeAware) return\n program = ts.createProgram(config.fileNames, config.compilerOptions)\n before = loadTransformers(options.root, program, options.transformers ?? [])\n },\n transform(code, id) {\n if (!TYPESCRIPT_SOURCE.test(id) || id.includes('node_modules')) return null\n // Only reachable if `buildStart` did not run, which no Rollup build does. Named rather than\n // defaulted, so it cannot silently emit with TypeScript's defaults instead of the module's.\n if (ts === undefined || compilerOptions === undefined) {\n throw new Error(\n `sentinel build(nest): the compiler was never prepared, so ${id} would be emitted with ` +\n `defaults rather than this module's tsconfig.`,\n )\n }\n\n /*\n * The Program's own SourceFile, which is what carries the type information.\n *\n * Three cases emit without it. The service declares no transformer, which is `transpileOnly`\n * and is what ts-loader did for it. A file the Program never reached, because nothing\n * imports it from the entry. And a file another plugin has already rewritten, where the\n * Program's copy is no longer the truth: emitting that stale copy over someone else's\n * transform would be the worse failure.\n *\n * The last two are counted and reported at the end. The first is not a gap, it is the mode.\n *\n * Measured on the largest service here: neither of the last two fires, on any of its 5594\n * files. That is the point of reporting them rather than tolerating them quietly — a warning\n * from this build means something genuinely new, not a known rough edge.\n */\n const sourceFile = program?.getSourceFile(id)\n if (program === undefined || sourceFile === undefined || sourceFile.text !== code) {\n if (typeAware) withoutTypes.push(id)\n const output = ts.transpileModule(code, { fileName: id, compilerOptions })\n return { code: output.outputText, map: output.sourceMapText ?? null }\n }\n\n let emitted: string | undefined\n let map: string | undefined\n program.emit(\n sourceFile,\n (fileName, text) => {\n if (fileName.endsWith('.map')) map = text\n else emitted = text\n },\n undefined,\n false,\n { before },\n )\n if (emitted === undefined) {\n throw new Error(`sentinel build(nest): TypeScript emitted nothing for ${id}.`)\n }\n return { code: emitted, map: map ?? null }\n },\n closeBundle() {\n if (withoutTypes.length === 0) return\n const shown = withoutTypes.slice(0, 5).map((file) => path.relative(options.root, file))\n this.warn(\n `sentinel build(nest): ${withoutTypes.length} file(s) were emitted without type ` +\n `information, so their decorator metadata may differ from what ts-loader produced ` +\n `(${shown.join(', ')}${withoutTypes.length > shown.length ? ', …' : ''}). They are ` +\n `outside this module's tsconfig, or another plugin rewrote them first.`,\n )\n },\n }\n}\n","/**\n * The workspace's `paths` mappings, as Vite resolve aliases.\n *\n * They matter more than they look. The mappings point at SOURCE files, and that is what makes\n * a workspace library get BUNDLED rather than externalised: Vite treats anything outside\n * `node_modules` as source. Drop them and every `@hublo/nest/*` import becomes an external the\n * runtime cannot resolve, because those packages are never published.\n *\n * This reproduces what webpack did through `tsconfig-paths-webpack-plugin`, alongside\n * `webpack-node-externals` which only ever externalised real packages. Measured on the first\n * migrated service: 45 externals under Vite against 47 under webpack, and nothing externalised\n * by Vite that webpack did not.\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { parseJsonc } from '../../../shared/jsonc.js'\nimport { effectivePaths, WORKSPACE_TSCONFIG } from '../../../shared/tsconfig-paths.js'\n\nexport interface Alias {\n find: RegExp\n replacement: string\n}\n\n/** Read the module's own chain rather than one workspace file. */\nexport interface ModuleAliasSource {\n /** The module's directory, where its tsconfig lives. */\n moduleRoot: string\n /** Its tsconfig names to try, most specific first, relative to `moduleRoot`. */\n candidates?: readonly (string | undefined)[]\n}\n\nconst toAlias = (baseDirectory: string, pattern: string, target: string): Alias => {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\\\\\*/g, '(.*)')\n return {\n find: new RegExp(`^${escaped}$`),\n replacement: join(baseDirectory, target.replace(/\\*/g, '$1')),\n }\n}\n\n/** Longest pattern first, because Vite takes the first alias that matches. */\nconst toAliases = (baseDirectory: string, paths: Record<string, string[]>): Alias[] =>\n Object.entries(paths)\n .flatMap(([pattern, targets]) => {\n const [target] = targets\n return target === undefined ? [] : [toAlias(baseDirectory, pattern, target)]\n })\n .sort((a, b) => b.find.source.length - a.find.source.length)\n\n/**\n * The aliases a module resolves through.\n *\n * Longest pattern first, because Vite takes the first alias that matches and the mappings\n * overlap by design: `@front/theme/node` must not be swallowed by `@front/theme`.\n *\n * Two ways to call it, and the first is kept for what it always did:\n * - `tsconfigAliases(workspaceRoot)` or with a file name: that one workspace file, read on its\n * own, its targets relative to `workspaceRoot`. Unchanged, because it is exported from the\n * `build/nest` and `test/nest` toolchains and a module's config may call it.\n * - `tsconfigAliases(workspaceRoot, { moduleRoot })`: the module's own chain, the way tsc reads\n * it, falling back to the workspace base when the chain declares no `paths`. See\n * `shared/tsconfig-paths.ts` for the rules and why the fallback is a transition.\n */\nexport function tsconfigAliases(\n workspaceRoot: string,\n source: string | ModuleAliasSource = WORKSPACE_TSCONFIG,\n): Alias[] {\n if (typeof source !== 'string') {\n const candidates = (source.candidates ?? ['tsconfig.json']).filter(\n (name): name is string => name !== undefined,\n )\n const found = effectivePaths(source.moduleRoot, workspaceRoot, candidates)\n return found === undefined ? [] : toAliases(found.baseDirectory, found.paths)\n }\n\n /*\n * ⚠️ JSONC, through the shared reader. This stripped `//` comments by hand and then called\n * `JSON.parse`, which handled a comment on its OWN line and nothing else: a trailing comment\n * after a value, a block comment, or a trailing comma, all legal in a tsconfig, would throw a\n * raw SyntaxError naming a character offset. Latent on this repo's base config today, and\n * `shared/jsonc.ts` already existed for exactly this.\n */\n const raw = readFileSync(join(workspaceRoot, source), 'utf8')\n const { compilerOptions } = parseJsonc<{\n compilerOptions?: { paths?: Record<string, string[]> }\n }>(raw, source)\n return toAliases(workspaceRoot, compilerOptions?.paths ?? {})\n}\n"],"mappings":";;;;;;;;;AA2FA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAMjB,IAAM,oBAAoB;AAS1B,IAAM,sBAAsB,CAAC,qBAAqB,eAAe;AA6BjE,SAAS,aAAa,MAAyB;AAC7C,QAAMA,WAAU,cAAc,KAAK,KAAK,MAAM,SAAS,CAAC;AACxD,MAAI;AACJ,MAAI;AACF,eAAWA,SAAQ,YAAY;AAAA,EACjC,QAAQ;AACN,UAAM,IAAI;AAAA,MACR,2DAA2D,IAAI;AAAA,IAEjE;AAAA,EACF;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