Skip to content

Commit

Permalink
fix(js): normalize excluded paths to task inputs correctly in typescr…
Browse files Browse the repository at this point in the history
…ipt plugin
  • Loading branch information
leosvelperez committed Jul 3, 2024
1 parent 4c76b95 commit 3fd3cd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
24 changes: 16 additions & 8 deletions packages/js/src/plugins/typescript/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,16 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {

it('should add extended config files', async () => {
await applyFilesToTempFsAndContext(tempFs, context, {
'libs/my-lib/tsconfig.json': JSON.stringify({
extends: '../../tsconfig.foo.json',
include: ['src/**/*.ts'],
'tsconfig.base.json': JSON.stringify({
exclude: ['node_modules', 'tmp'],
}),
'tsconfig.foo.json': JSON.stringify({
extends: './tsconfig.base.json',
}),
'tsconfig.base.json': '{}',
'libs/my-lib/tsconfig.json': JSON.stringify({
extends: '../../tsconfig.foo.json',
include: ['src/**/*.ts'],
}),
'libs/my-lib/package.json': `{}`,
});
expect(await invokeCreateNodesOnMatchingFiles(context, {}))
Expand All @@ -467,6 +469,8 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
"{workspaceRoot}/tsconfig.base.json",
"{projectRoot}/tsconfig.json",
"{projectRoot}/src/**/*.ts",
"!{workspaceRoot}/node_modules",
"!{workspaceRoot}/tmp",
"^production",
{
"externalDependencies": [
Expand Down Expand Up @@ -1455,15 +1459,17 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {

it('should add extended config files', async () => {
await applyFilesToTempFsAndContext(tempFs, context, {
'tsconfig.base.json': JSON.stringify({
exclude: ['node_modules', 'tmp'],
}),
'tsconfig.foo.json': JSON.stringify({
extends: './tsconfig.base.json',
}),
'libs/my-lib/tsconfig.json': '{}',
'libs/my-lib/tsconfig.lib.json': JSON.stringify({
extends: '../../tsconfig.foo.json',
include: ['src/**/*.ts'],
}),
'tsconfig.foo.json': JSON.stringify({
extends: './tsconfig.base.json',
}),
'tsconfig.base.json': '{}',
'libs/my-lib/package.json': `{}`,
});
expect(
Expand All @@ -1488,6 +1494,8 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
"{workspaceRoot}/tsconfig.base.json",
"{projectRoot}/tsconfig.lib.json",
"{projectRoot}/src/**/*.ts",
"!{workspaceRoot}/node_modules",
"!{workspaceRoot}/tmp",
"^production",
{
"externalDependencies": [
Expand Down
13 changes: 11 additions & 2 deletions packages/js/src/plugins/typescript/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ function getInputs(
pathToInputOrOutput(p, workspaceRoot, projectRoot)
),
...Array.from(includePaths).map((p: string) =>
joinPathFragments('{projectRoot}', p)
pathToInputOrOutput(
joinPathFragments(projectRoot, p),
workspaceRoot,
projectRoot
)
)
);
} else {
Expand All @@ -294,7 +298,12 @@ function getInputs(
if (excludePaths.size) {
inputs.push(
...Array.from(excludePaths).map(
(p: string) => `!${joinPathFragments('{projectRoot}', p)}`
(p: string) =>
`!${pathToInputOrOutput(
joinPathFragments(projectRoot, p),
workspaceRoot,
projectRoot
)}`
)
);
}
Expand Down

0 comments on commit 3fd3cd9

Please sign in to comment.