Skip to content

Commit ec37b1e

Browse files
leosvelperezFrozenPandaz
authored andcommitted
fix(js): normalize excluded paths to task inputs correctly in typescript plugin (#26801)
(cherry picked from commit adb81af)
1 parent 4c76b95 commit ec37b1e

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

packages/js/src/plugins/typescript/plugin.spec.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,16 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
439439

440440
it('should add extended config files', async () => {
441441
await applyFilesToTempFsAndContext(tempFs, context, {
442-
'libs/my-lib/tsconfig.json': JSON.stringify({
443-
extends: '../../tsconfig.foo.json',
444-
include: ['src/**/*.ts'],
442+
'tsconfig.base.json': JSON.stringify({
443+
exclude: ['node_modules', 'tmp'],
445444
}),
446445
'tsconfig.foo.json': JSON.stringify({
447446
extends: './tsconfig.base.json',
448447
}),
449-
'tsconfig.base.json': '{}',
448+
'libs/my-lib/tsconfig.json': JSON.stringify({
449+
extends: '../../tsconfig.foo.json',
450+
include: ['src/**/*.ts'],
451+
}),
450452
'libs/my-lib/package.json': `{}`,
451453
});
452454
expect(await invokeCreateNodesOnMatchingFiles(context, {}))
@@ -467,6 +469,8 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
467469
"{workspaceRoot}/tsconfig.base.json",
468470
"{projectRoot}/tsconfig.json",
469471
"{projectRoot}/src/**/*.ts",
472+
"!{workspaceRoot}/node_modules",
473+
"!{workspaceRoot}/tmp",
470474
"^production",
471475
{
472476
"externalDependencies": [
@@ -1455,15 +1459,17 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
14551459

14561460
it('should add extended config files', async () => {
14571461
await applyFilesToTempFsAndContext(tempFs, context, {
1462+
'tsconfig.base.json': JSON.stringify({
1463+
exclude: ['node_modules', 'tmp'],
1464+
}),
1465+
'tsconfig.foo.json': JSON.stringify({
1466+
extends: './tsconfig.base.json',
1467+
}),
14581468
'libs/my-lib/tsconfig.json': '{}',
14591469
'libs/my-lib/tsconfig.lib.json': JSON.stringify({
14601470
extends: '../../tsconfig.foo.json',
14611471
include: ['src/**/*.ts'],
14621472
}),
1463-
'tsconfig.foo.json': JSON.stringify({
1464-
extends: './tsconfig.base.json',
1465-
}),
1466-
'tsconfig.base.json': '{}',
14671473
'libs/my-lib/package.json': `{}`,
14681474
});
14691475
expect(
@@ -1488,6 +1494,8 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
14881494
"{workspaceRoot}/tsconfig.base.json",
14891495
"{projectRoot}/tsconfig.lib.json",
14901496
"{projectRoot}/src/**/*.ts",
1497+
"!{workspaceRoot}/node_modules",
1498+
"!{workspaceRoot}/tmp",
14911499
"^production",
14921500
{
14931501
"externalDependencies": [

packages/js/src/plugins/typescript/plugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ function getInputs(
282282
pathToInputOrOutput(p, workspaceRoot, projectRoot)
283283
),
284284
...Array.from(includePaths).map((p: string) =>
285-
joinPathFragments('{projectRoot}', p)
285+
pathToInputOrOutput(
286+
joinPathFragments(projectRoot, p),
287+
workspaceRoot,
288+
projectRoot
289+
)
286290
)
287291
);
288292
} else {
@@ -294,7 +298,12 @@ function getInputs(
294298
if (excludePaths.size) {
295299
inputs.push(
296300
...Array.from(excludePaths).map(
297-
(p: string) => `!${joinPathFragments('{projectRoot}', p)}`
301+
(p: string) =>
302+
`!${pathToInputOrOutput(
303+
joinPathFragments(projectRoot, p),
304+
workspaceRoot,
305+
projectRoot
306+
)}`
298307
)
299308
);
300309
}

0 commit comments

Comments
 (0)