Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js): normalize excluded paths to task inputs correctly in typescript plugin #26801

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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