@smoothbricks/nx-plugin 0.4.17 → 0.4.19

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 (34) hide show
  1. package/README.md +12 -11
  2. package/dist/ensure-built.d.ts +7 -4
  3. package/dist/ensure-built.d.ts.map +1 -1
  4. package/dist/ensure-built.js +77 -17
  5. package/dist/executors/typescript-emit/executor.d.ts +1 -1
  6. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  7. package/dist/executors/typescript-emit/executor.js +3 -8
  8. package/dist/index.js +10 -8
  9. package/dist/managed-files/files.d.ts +6 -0
  10. package/dist/managed-files/files.d.ts.map +1 -1
  11. package/dist/managed-files/files.js +11 -0
  12. package/dist/managed-files/managed-content.d.ts +2 -0
  13. package/dist/managed-files/managed-content.d.ts.map +1 -1
  14. package/dist/managed-files/managed-content.js +19 -5
  15. package/dist/typecheck-test-policy.d.ts +2 -0
  16. package/dist/typecheck-test-policy.d.ts.map +1 -1
  17. package/dist/typecheck-test-policy.js +57 -12
  18. package/executors.json +1 -1
  19. package/managed/raw/patches/ttsc@0.30.4.patch +2255 -0
  20. package/managed/raw/tooling/direnv/devenv.smoo.nix +14 -1
  21. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +3 -4
  22. package/package.json +5 -5
  23. package/src/ensure-built.test.ts +41 -5
  24. package/src/ensure-built.ts +127 -43
  25. package/src/executors/typescript-emit/executor.test.ts +64 -115
  26. package/src/executors/typescript-emit/executor.ts +4 -9
  27. package/src/executors/typescript-emit/schema.json +1 -1
  28. package/src/index.test.ts +4 -4
  29. package/src/index.ts +9 -8
  30. package/src/managed-files/files.ts +12 -0
  31. package/src/managed-files/managed-content.test.ts +19 -0
  32. package/src/managed-files/managed-content.ts +23 -6
  33. package/src/typecheck-test-policy.test.ts +56 -5
  34. package/src/typecheck-test-policy.ts +56 -12
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "TypeScript emit executor",
5
- "description": "Emit transformer-generated JavaScript with ttsc and declarations with native tsc",
5
+ "description": "Emit transformed JavaScript and declarations together with ttsc",
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "executableOutputs": {
package/src/index.test.ts CHANGED
@@ -168,7 +168,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
168
168
  }
169
169
  });
170
170
 
171
- it('splits transformed JavaScript emit from native declarations and typechecking', async () => {
171
+ it('uses the transformer-aware compiler for emit and validation', async () => {
172
172
  const workspace = await createWorkspace();
173
173
  try {
174
174
  await workspace.write(
@@ -202,7 +202,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
202
202
  ]);
203
203
  expect(targets['tsc-js']?.outputs).toEqual(['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}']);
204
204
  expect(targets.typecheck?.options).toMatchObject({
205
- command: 'tsc -p tsconfig.lib.json --noEmit',
205
+ command: 'ttsc -p tsconfig.lib.json --noEmit',
206
206
  cwd: 'packages/example',
207
207
  });
208
208
  const checkToolchainInputs = [
@@ -233,7 +233,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
233
233
  expect(targets['typecheck-tests']?.cache).toBe(true);
234
234
  expect(targets['typecheck-tests']?.dependsOn).toEqual(['tsc-js', 'typecheck']);
235
235
  expect(targets['typecheck-tests']?.options).toMatchObject({
236
- command: 'tsc -p tsconfig.test.json --noEmit',
236
+ command: 'ttsc -p tsconfig.test.json --noEmit',
237
237
  cwd: 'packages/example',
238
238
  });
239
239
  expect(targets['typecheck-tests']?.inputs).toEqual([
@@ -246,7 +246,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
246
246
  expect(targets['typecheck-tests:watch']?.executor).toBe('nx:run-commands');
247
247
  expect(targets['typecheck-tests:watch']?.continuous).toBe(true);
248
248
  expect(targets['typecheck-tests:watch']?.options).toMatchObject({
249
- command: 'tsc -p tsconfig.test.json --noEmit --watch',
249
+ command: 'ttsc -p tsconfig.test.json --noEmit --watch',
250
250
  cwd: 'packages/example',
251
251
  });
252
252
 
package/src/index.ts CHANGED
@@ -1051,10 +1051,7 @@ async function createProjectTargets(
1051
1051
  // Build every JavaScript output lane before resolving package exports, without pulling
1052
1052
  // unrelated Wasm, N-API, native, or web outputs onto the compiler critical path.
1053
1053
  //
1054
- // ttsc transforms the source program before declaration emit, so typia's
1055
- // generated implementation identifiers are not valid declaration inputs.
1056
- // The executor gives ttsc a JS-only overlay and emits declarations from the
1057
- // original project with native tsc.
1054
+ // One transformer-aware compiler emits JavaScript and declarations.
1058
1055
  targets['tsc-js'] = {
1059
1056
  executor: '@smoothbricks/nx-plugin:typescript-emit',
1060
1057
  cache: true,
@@ -1074,7 +1071,7 @@ async function createProjectTargets(
1074
1071
  outputs: [],
1075
1072
  dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
1076
1073
  options: {
1077
- command: 'tsc -p tsconfig.lib.json --noEmit',
1074
+ command: 'ttsc -p tsconfig.lib.json --noEmit',
1078
1075
  cwd: projectRoot,
1079
1076
  },
1080
1077
  };
@@ -1087,7 +1084,7 @@ async function createProjectTargets(
1087
1084
  inputs: [selfDefault, dependencyProduction, ...checkInputs, '{projectRoot}/tsconfig.test.json'],
1088
1085
  dependsOn: ['typecheck'],
1089
1086
  options: {
1090
- command: 'tsc -p tsconfig.test.json --noEmit',
1087
+ command: 'ttsc -p tsconfig.test.json --noEmit',
1091
1088
  cwd: projectRoot,
1092
1089
  },
1093
1090
  };
@@ -1095,7 +1092,7 @@ async function createProjectTargets(
1095
1092
  executor: 'nx:run-commands',
1096
1093
  continuous: true,
1097
1094
  options: {
1098
- command: 'tsc -p tsconfig.test.json --noEmit --watch',
1095
+ command: 'ttsc -p tsconfig.test.json --noEmit --watch',
1099
1096
  cwd: projectRoot,
1100
1097
  },
1101
1098
  };
@@ -1382,11 +1379,15 @@ async function createProjectTargets(
1382
1379
  }
1383
1380
  }
1384
1381
 
1385
- if ('test' in declaredTargets && targets.test === undefined) {
1382
+ if (('test' in declaredTargets || typeof packageJson.scripts?.test === 'string') && targets.test === undefined) {
1386
1383
  targets.test = {
1387
1384
  dependsOn: ['^build', 'build'],
1388
1385
  };
1389
1386
  }
1387
+ for (const name of Object.keys(declaredTargets)) {
1388
+ if (name === 'test' || !isTestRunnerTargetName(name) || targets[name] !== undefined) continue;
1389
+ targets[name] = { dependsOn: ['^build', 'build'] };
1390
+ }
1390
1391
 
1391
1392
  // Every `cargoFrozen` command needs a registry cache holding the whole locked
1392
1393
  // graph, and offline cargo checks that at RESOLUTION — so a dev-dependency no
@@ -67,7 +67,19 @@ export interface ManagedFileContext {
67
67
  crossTestArchives: CiCrossTestArchive[];
68
68
  }
69
69
 
70
+ /** Temporary upstream compiler repairs distributed to smoo-managed Bun workspaces. */
71
+ export const managedTtscPatch = {
72
+ version: '0.30.4',
73
+ key: 'ttsc@0.30.4',
74
+ path: 'patches/ttsc@0.30.4.patch',
75
+ } as const;
76
+
70
77
  const managedFiles: ManagedFileDescriptor[] = [
78
+ {
79
+ kind: 'raw',
80
+ source: managedTtscPatch.path,
81
+ target: managedTtscPatch.path,
82
+ },
71
83
  {
72
84
  kind: 'raw',
73
85
  source: 'envrc',
@@ -93,6 +93,25 @@ describe('managed-file inline local blocks', () => {
93
93
  );
94
94
  });
95
95
 
96
+ it('fences a TypeScript managed file with // markers and re-emits the same prefix', () => {
97
+ // setup-environment.ts is a managed TypeScript file; `# smoo-local-begin`
98
+ // is not a comment there. A repo-owned block (the dev-links re-link after
99
+ // install) used `//` fences that the update never recognised and dropped.
100
+ const current = [
101
+ 'const a = 1;',
102
+ '// smoo-local-begin',
103
+ 'linkDevPackages();',
104
+ '// smoo-local-end',
105
+ 'const b = 2;',
106
+ ].join('\n');
107
+ const { withoutInline, blocks } = extractInlineLocalBlocks(current);
108
+ expect(withoutInline).toBe(['const a = 1;', 'const b = 2;'].join('\n'));
109
+ expect(blocks).toEqual([{ anchor: 'const a = 1;', lines: 'linkDevPackages();', markerPrefix: '//' }]);
110
+ expect(reinsertInlineLocalBlocks(['const a = 1;', 'const b = 3;'].join('\n'), blocks)).toBe(
111
+ ['const a = 1;', '// smoo-local-begin', 'linkDevPackages();', '// smoo-local-end', 'const b = 3;'].join('\n'),
112
+ );
113
+ });
114
+
96
115
  it('preserves marker indentation when refreshing nested configuration', () => {
97
116
  const markerIndent = ' ';
98
117
  const current = [
@@ -34,11 +34,25 @@ export function splitLocalSection(current: string): { managed: string; localTail
34
34
  */
35
35
  export const INLINE_LOCAL_BEGIN = '# smoo-local-begin';
36
36
  export const INLINE_LOCAL_END = '# smoo-local-end';
37
+ /**
38
+ * The markers are line comments, so a managed file whose language does not
39
+ * comment with `#` (a TypeScript setup script) fences its repo-owned block
40
+ * with `//` instead: `// smoo-local-begin`. The prefix a block was written
41
+ * with is the prefix it is re-emitted with.
42
+ */
43
+ const INLINE_MARKER = /^\s*(#|\/\/) smoo-local-(begin|end)$/;
44
+
45
+ function inlineMarker(line: string | undefined): { kind: 'begin' | 'end'; prefix: string } | undefined {
46
+ const match = line === undefined ? null : INLINE_MARKER.exec(line);
47
+ return match === null ? undefined : { kind: match[2] === 'begin' ? 'begin' : 'end', prefix: match[1] };
48
+ }
37
49
 
38
50
  export interface InlineLocalBlock {
39
51
  anchor: string;
40
52
  lines: string;
41
53
  markerIndent?: string;
54
+ /** The comment prefix the markers were written with; `#` unless stated. */
55
+ markerPrefix?: string;
42
56
  /** Distinguishes no lines from one deliberately blank line. */
43
57
  empty?: true;
44
58
  }
@@ -53,16 +67,17 @@ export function extractInlineLocalBlocks(managed: string): { withoutInline: stri
53
67
  let i = 0;
54
68
  while (i < lines.length) {
55
69
  const line = lines[i];
56
- if (line !== undefined && line.trim() === INLINE_LOCAL_BEGIN) {
70
+ const marker = inlineMarker(line);
71
+ if (line !== undefined && marker?.kind === 'begin') {
57
72
  const anchor = kept.at(-1);
58
73
  if (anchor === undefined) {
59
74
  throw new ManagedContentConflict(`${INLINE_LOCAL_BEGIN} on line ${i + 1} has no preceding anchor line`);
60
75
  }
61
76
  const blockLines: string[] = [];
62
77
  i += 1;
63
- while (i < lines.length && lines[i]?.trim() !== INLINE_LOCAL_END) {
78
+ while (i < lines.length && inlineMarker(lines[i])?.kind !== 'end') {
64
79
  const blockLine = lines[i];
65
- if (blockLine.trim() === INLINE_LOCAL_BEGIN) {
80
+ if (inlineMarker(blockLine)?.kind === 'begin') {
66
81
  throw new ManagedContentConflict(`${INLINE_LOCAL_BEGIN} on line ${i + 1} is nested`);
67
82
  }
68
83
  blockLines.push(blockLine);
@@ -79,11 +94,12 @@ export function extractInlineLocalBlocks(managed: string): { withoutInline: stri
79
94
  lines: blockLines.join('\n'),
80
95
  ...(blockLines.length === 0 ? { empty: true as const } : {}),
81
96
  ...(markerIndent === '' ? {} : { markerIndent }),
97
+ ...(marker.prefix === '#' ? {} : { markerPrefix: marker.prefix }),
82
98
  });
83
99
  i += 1; // skip the END marker line itself
84
100
  continue;
85
101
  }
86
- if (line.trim() === INLINE_LOCAL_END) {
102
+ if (inlineMarker(line)?.kind === 'end') {
87
103
  throw new ManagedContentConflict(`${INLINE_LOCAL_END} on line ${i + 1} has no matching ${INLINE_LOCAL_BEGIN}`);
88
104
  }
89
105
  kept.push(line);
@@ -109,11 +125,12 @@ export function reinsertInlineLocalBlocks(content: string, blocks: InlineLocalBl
109
125
  }
110
126
  const index = matches[0];
111
127
  const markerIndent = block.markerIndent ?? '';
128
+ const prefix = block.markerPrefix ?? '#';
112
129
  const inserted = additions.get(index) ?? [];
113
130
  inserted.push(
114
- `${markerIndent}${INLINE_LOCAL_BEGIN}`,
131
+ `${markerIndent}${prefix} smoo-local-begin`,
115
132
  ...(block.empty ? [] : block.lines.split('\n')),
116
- `${markerIndent}${INLINE_LOCAL_END}`,
133
+ `${markerIndent}${prefix} smoo-local-end`,
117
134
  );
118
135
  additions.set(index, inserted);
119
136
  }
@@ -204,6 +204,7 @@ describe('applyTypecheckTestDefaults', () => {
204
204
  const changed = applyTypecheckTestDefaults(tsconfigTest, {
205
205
  testRunners: new Set(['bun'] as const),
206
206
  referencePaths: ['./tsconfig.lib.json'],
207
+ isNew: true,
207
208
  });
208
209
  expect(changed).toBe(true);
209
210
  expect(tsconfigTest.extends).toBe('../../tsconfig.base.json');
@@ -224,6 +225,22 @@ describe('applyTypecheckTestDefaults', () => {
224
225
  expect(references).toContainEqual({ path: './tsconfig.lib.json' });
225
226
  });
226
227
 
228
+ it('leaves an inherited include alone: minting one narrows the program to nothing', () => {
229
+ // A package keeping its suites in `test/` inherits src + test + tooling
230
+ // from its tsconfig.json. Writing `include` with src-test globs replaced
231
+ // that with a program of zero files, which passed the gate by compiling
232
+ // nothing (the false green the policy exists to prevent).
233
+ const declared: Record<string, unknown> = { extends: './tsconfig.json', compilerOptions: { noEmit: true } };
234
+ applyTypecheckTestDefaults(declared, { testRunners: new Set(['bun'] as const), referencePaths: [] });
235
+ expect(Object.hasOwn(declared, 'include')).toBe(false);
236
+ // Same for `types`: declaring it would drop the workers types the program inherits.
237
+ expect(Object.hasOwn(expectRecord(declared.compilerOptions), 'types')).toBe(false);
238
+
239
+ const explicit: Record<string, unknown> = { extends: './tsconfig.json', include: ['test/**/*.ts'] };
240
+ applyTypecheckTestDefaults(explicit, { testRunners: new Set(['bun'] as const), referencePaths: [] });
241
+ expect(expectStringArray(explicit.include)).toEqual(expect.arrayContaining(['test/**/*.ts', 'src/**/*.test.ts']));
242
+ });
243
+
227
244
  it('fills compiler options the test program left out and keeps the ones it declared', () => {
228
245
  // A Bun-only test program declaring es2023 says something the library cannot
229
246
  // know: its runtime has change-array-by-copy while the library's output ships
@@ -350,7 +367,7 @@ describe('typecheck test policy (Tree)', () => {
350
367
  });
351
368
  writeJson(tree, 'packages/app/tsconfig.lib.json', {
352
369
  extends: '../../tsconfig.base.json',
353
- compilerOptions: { baseUrl: '.', rootDir: 'src', outDir: 'dist' },
370
+ compilerOptions: { composite: true, baseUrl: '.', rootDir: 'src', outDir: 'dist' },
354
371
  });
355
372
 
356
373
  const changed = applyTypecheckTestPolicyTree(tree);
@@ -372,6 +389,39 @@ describe('typecheck test policy (Tree)', () => {
372
389
  expect(references).toContainEqual({ path: './tsconfig.lib.json' });
373
390
  });
374
391
 
392
+ it('references only composite lib programs (TS6306 otherwise), resolving composite through extends', () => {
393
+ const tree = createTreeWithEmptyWorkspace();
394
+ writeJson(tree, 'tsconfig.composite.json', { compilerOptions: { composite: true } });
395
+ for (const [name, composite] of [
396
+ ['app', 'no'],
397
+ ['lib', 'own'],
398
+ ['inherits', 'base'],
399
+ ] as const) {
400
+ addProjectConfiguration(tree, name, { root: `packages/${name}`, targets: {} });
401
+ if (tree.exists(`packages/${name}/project.json`)) tree.delete(`packages/${name}/project.json`);
402
+ writeJson(tree, `packages/${name}/package.json`, {
403
+ name: `@scope/${name}`,
404
+ scripts: { test: 'bun test' },
405
+ nx: { name },
406
+ ...(name === 'app' ? { dependencies: { '@scope/lib': 'workspace:*', '@scope/inherits': 'workspace:*' } } : {}),
407
+ });
408
+ writeJson(tree, `packages/${name}/tsconfig.lib.json`, {
409
+ extends:
410
+ composite === 'base' ? ['../../tsconfig.base.json', '../../tsconfig.composite'] : '../../tsconfig.base.json',
411
+ compilerOptions: { rootDir: 'src', outDir: 'dist', ...(composite === 'own' ? { composite: true } : {}) },
412
+ });
413
+ }
414
+
415
+ applyTypecheckTestPolicyTree(tree);
416
+ const references = expectReferences(
417
+ readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json').references,
418
+ );
419
+ // The app's own emit program is not composite: its sources are in the
420
+ // test program by glob, not by reference. The composite dependencies are —
421
+ // whether composite is declared on the file or inherited from a base.
422
+ expect(references).toEqual([{ path: '../lib/tsconfig.lib.json' }, { path: '../inherits/tsconfig.lib.json' }]);
423
+ });
424
+
375
425
  it('detects bun test in project.json targets', () => {
376
426
  const tree = createTreeWithEmptyWorkspace();
377
427
  addProjectConfiguration(tree, 'app', {
@@ -513,7 +563,7 @@ describe('typecheck test policy (Tree)', () => {
513
563
  writeJson(tree, 'packages/lib/package.json', { name: '@scope/lib' });
514
564
  writeJson(tree, 'packages/lib/tsconfig.lib.json', {
515
565
  extends: '../../tsconfig.base.json',
516
- compilerOptions: {},
566
+ compilerOptions: { composite: true },
517
567
  });
518
568
 
519
569
  // App that depends on lib
@@ -526,7 +576,7 @@ describe('typecheck test policy (Tree)', () => {
526
576
  });
527
577
  writeJson(tree, 'packages/app/tsconfig.lib.json', {
528
578
  extends: '../../tsconfig.base.json',
529
- compilerOptions: {},
579
+ compilerOptions: { composite: true },
530
580
  });
531
581
 
532
582
  expect(applyTypecheckTestPolicyTree(tree)).toBe(true);
@@ -758,6 +808,7 @@ describe('typecheck test policy', () => {
758
808
  await writeJsonFs(join(root, 'packages/app/tsconfig.lib.json'), {
759
809
  extends: '../../tsconfig.base.json',
760
810
  compilerOptions: {
811
+ composite: true,
761
812
  baseUrl: '.',
762
813
  module: 'esnext',
763
814
  moduleResolution: 'bundler',
@@ -795,7 +846,7 @@ describe('typecheck test policy', () => {
795
846
  });
796
847
  await writeJsonFs(join(root, 'packages/lib/tsconfig.lib.json'), {
797
848
  extends: '../../tsconfig.base.json',
798
- compilerOptions: {},
849
+ compilerOptions: { composite: true },
799
850
  });
800
851
  await writeJsonFs(join(root, 'packages/app/package.json'), {
801
852
  name: '@scope/app',
@@ -804,7 +855,7 @@ describe('typecheck test policy', () => {
804
855
  });
805
856
  await writeJsonFs(join(root, 'packages/app/tsconfig.lib.json'), {
806
857
  extends: '../../tsconfig.base.json',
807
- compilerOptions: {},
858
+ compilerOptions: { composite: true },
808
859
  });
809
860
 
810
861
  expect(applyTypecheckTestPolicy(root)).toBe(true);
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
- import { join, relative } from 'node:path';
2
+ import { dirname, join, relative } from 'node:path';
3
3
  import type { Tree } from 'nx/src/devkit-exports.js';
4
4
  import { getProjects, readJson, readProjectConfiguration } from 'nx/src/devkit-exports.js';
5
5
  import typia from 'typia';
@@ -162,6 +162,8 @@ export function applyTypecheckTestDefaults(
162
162
  tsconfigLibExtends?: string | string[];
163
163
  libCompilerOptions?: Record<string, unknown>;
164
164
  referencePaths: string[];
165
+ /** The file did not exist: a fresh program gets the src-test globs. */
166
+ isNew?: boolean;
165
167
  },
166
168
  ): boolean {
167
169
  let changed = !Object.hasOwn(tsconfigTest, 'extends');
@@ -190,7 +192,11 @@ export function applyTypecheckTestDefaults(
190
192
  changed = setBooleanProperty(compilerOptions, 'emitDeclarationOnly', false) || changed;
191
193
  changed = setBooleanProperty(compilerOptions, 'noEmit', true) || changed;
192
194
 
193
- if (options.testRunners.has('bun')) {
195
+ // `types`, like `include` below, replaces what `extends` provides the
196
+ // moment it is declared: a program inheriting workers + bun types from its
197
+ // tsconfig.json would be left with `["bun"]` alone. Merge only into a
198
+ // declared list or a new file.
199
+ if (options.testRunners.has('bun') && (options.isNew || Object.hasOwn(compilerOptions, 'types'))) {
194
200
  changed = mergeStringListProperty(compilerOptions, 'types', ['bun']) || changed;
195
201
  }
196
202
 
@@ -203,14 +209,22 @@ export function applyTypecheckTestDefaults(
203
209
  changed = true;
204
210
  }
205
211
 
206
- changed =
207
- mergeStringListProperty(tsconfigTest, 'include', [
208
- 'src/**/*.test.ts',
209
- 'src/**/*.spec.ts',
210
- 'src/**/__tests__/**/*.ts',
211
- 'src/**/__tests__/**/*.tsx',
212
- 'src/test-suite-tracer.ts',
213
- ]) || changed;
212
+ // A test program that declares no `include` inherits one from `extends`
213
+ // (a package keeping its suites in `test/` alongside src, tooling and
214
+ // scripts as one program). Minting `include` there REPLACES the inherited
215
+ // set with globs that match nothing, and a program of zero files passes the
216
+ // gate by compiling nothing. Only a program that already declares `include`,
217
+ // or a new file, gets the src-test globs merged in.
218
+ if (options.isNew || Object.hasOwn(tsconfigTest, 'include')) {
219
+ changed =
220
+ mergeStringListProperty(tsconfigTest, 'include', [
221
+ 'src/**/*.test.ts',
222
+ 'src/**/*.spec.ts',
223
+ 'src/**/__tests__/**/*.ts',
224
+ 'src/**/__tests__/**/*.tsx',
225
+ 'src/test-suite-tracer.ts',
226
+ ]) || changed;
227
+ }
214
228
 
215
229
  for (const referencePath of options.referencePaths) {
216
230
  changed = addTsconfigReference(tsconfigTest, referencePath) || changed;
@@ -316,6 +330,7 @@ export function renderTypecheckTestFiles(tree: Tree): ManagedFile[] {
316
330
  tsconfigLibExtends,
317
331
  libCompilerOptions: libCompilerOptions ?? undefined,
318
332
  referencePaths,
333
+ isNew,
319
334
  });
320
335
  files.push(renderTsconfig(tree, tsconfigTestPath, tsconfigTest, changed || isNew));
321
336
 
@@ -506,8 +521,14 @@ function collectReferencePathsTree(
506
521
  workspacePackages: TreeWorkspacePackage[],
507
522
  ): string[] {
508
523
  const paths: string[] = [];
524
+ // A project reference is only legal to a `composite` program (TS6306); a
525
+ // lib tsconfig that is not composite — an application target's emit
526
+ // program — is included by the test program's own globs instead.
527
+ // `composite` is usually inherited from tsconfig.base.json, so the option is
528
+ // resolved through the `extends` chain, not read off the one file.
529
+ const isComposite = (path: string): boolean => resolveTsconfigOption(tree, path, 'composite') === true;
509
530
  const libTsconfigPath = `${packageRoot}/tsconfig.lib.json`;
510
- if (tree.exists(libTsconfigPath)) {
531
+ if (isComposite(libTsconfigPath)) {
511
532
  paths.push('./tsconfig.lib.json');
512
533
  }
513
534
 
@@ -519,7 +540,7 @@ function collectReferencePathsTree(
519
540
  const depPkg = packagesByName.get(depName);
520
541
  if (!depPkg) continue;
521
542
  const depTsconfig = `${depPkg.path}/tsconfig.lib.json`;
522
- if (!tree.exists(depTsconfig)) continue;
543
+ if (!isComposite(depTsconfig)) continue;
523
544
  const refPath = relative(packageRoot, depTsconfig).replaceAll('\\', '/');
524
545
  if (!paths.includes(refPath)) paths.push(refPath);
525
546
  }
@@ -726,6 +747,29 @@ function recordProperty(record: Record<string, unknown> | null, key: string): Re
726
747
  return isRecord(value) ? value : null;
727
748
  }
728
749
 
750
+ /**
751
+ * A tsconfig compiler option as TypeScript would see it: the file's own value,
752
+ * else the nearest base in its `extends` chain (an array extends applies
753
+ * left-to-right, so the last base naming the option wins). Bases that are not
754
+ * relative paths (package configs) are outside the tree and contribute nothing.
755
+ */
756
+ function resolveTsconfigOption(tree: Tree, path: string, option: string): unknown {
757
+ if (!tree.exists(path)) return undefined;
758
+ const config = readJson<Record<string, unknown>>(tree, path);
759
+ const own = recordProperty(config, 'compilerOptions')?.[option];
760
+ if (own !== undefined) return own;
761
+ const bases = config.extends;
762
+ const baseList = typeof bases === 'string' ? [bases] : Array.isArray(bases) ? bases : [];
763
+ for (let i = baseList.length - 1; i >= 0; i--) {
764
+ const base = baseList[i];
765
+ if (typeof base !== 'string' || !base.startsWith('.')) continue;
766
+ const basePath = join(dirname(path), base.endsWith('.json') ? base : `${base}.json`);
767
+ const inherited = resolveTsconfigOption(tree, basePath, option);
768
+ if (inherited !== undefined) return inherited;
769
+ }
770
+ return undefined;
771
+ }
772
+
729
773
  function getOrCreateRecord(record: Record<string, unknown>, key: string): Record<string, unknown> {
730
774
  const value = record[key];
731
775
  if (isRecord(value)) {