Skip to content

Commit 726de02

Browse files
AgentEnderclaudeclaude[bot]nx-cloud[bot]
authored andcommitted
feat(js): add includeIgnoredAssetFiles option and per-asset includeIgnoredFiles (#31813)
## Summary Adds support for including files that are ignored by `.gitignore` and `.nxignore` when copying assets in @nx/js executors. ### Changes Made - **Global option**: Added `includeIgnoredAssetFiles` option to @nx/js:tsc and @nx/js:swc executors - **Per-asset option**: Added `includeIgnoredFiles` option to `AssetGlob` interface for granular control - **Precedence logic**: Per-asset `includeIgnoredFiles` takes precedence over global `includeIgnoredAssetFiles` - **Updated all implementations**: Modified `CopyAssetsHandler`, batch processing, and utility functions ### Usage Examples **Global level** - include ignored files for all assets: ```json { "executor": "@nx/js:tsc", "options": { "includeIgnoredAssetFiles": true, "assets": ["src/assets"] } } ``` **Per-asset level** - include ignored files for specific asset patterns: ```json { "executor": "@nx/js:tsc", "options": { "assets": [ { "glob": "**/*", "input": "src/assets", "output": "assets", "includeIgnoredFiles": true } ] } } ``` ### Test Plan - [x] TypeScript compilation passes - [x] All existing tests pass - [x] Documentation updated automatically - [x] Both TSC and SWC executors support the new options ### Fixes: [20309](#20309) 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Craigory Coppola <AgentEnder@users.noreply.github.com> Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> (cherry picked from commit fc8f9a9)
1 parent b9c4ad6 commit 726de02

File tree

11 files changed

+407
-2
lines changed

11 files changed

+407
-2
lines changed

docs/generated/packages/js/executors/swc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
"output": {
7575
"type": "string",
7676
"description": "Absolute path within the output."
77+
},
78+
"includeIgnoredFiles": {
79+
"type": "boolean",
80+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
81+
"default": false
7782
}
7883
},
7984
"additionalProperties": false,
@@ -135,6 +140,11 @@
135140
"type": "boolean",
136141
"description": "Remove leading directory from output (e.g. src). See: https://swc.rs/docs/usage/cli#--strip-leading-paths",
137142
"default": false
143+
},
144+
"includeIgnoredAssetFiles": {
145+
"type": "boolean",
146+
"description": "Include files that are ignored by .gitignore and .nxignore when copying assets. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
147+
"default": false
138148
}
139149
},
140150
"required": ["main", "outputPath", "tsConfig"],
@@ -160,6 +170,11 @@
160170
"output": {
161171
"type": "string",
162172
"description": "Absolute path within the output."
173+
},
174+
"includeIgnoredFiles": {
175+
"type": "boolean",
176+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
177+
"default": false
163178
}
164179
},
165180
"additionalProperties": false,

docs/generated/packages/js/executors/tsc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
"output": {
7878
"type": "string",
7979
"description": "Absolute path within the output."
80+
},
81+
"includeIgnoredFiles": {
82+
"type": "boolean",
83+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
84+
"default": false
8085
}
8186
},
8287
"additionalProperties": false,
@@ -140,6 +145,11 @@
140145
"type": "boolean",
141146
"description": "Generate package.json file in the output folder.",
142147
"default": true
148+
},
149+
"includeIgnoredAssetFiles": {
150+
"type": "boolean",
151+
"description": "Include files that are ignored by .gitignore and .nxignore when copying assets. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
152+
"default": false
143153
}
144154
},
145155
"required": ["main", "outputPath", "tsConfig"],
@@ -165,6 +175,11 @@
165175
"output": {
166176
"type": "string",
167177
"description": "Absolute path within the output."
178+
},
179+
"includeIgnoredFiles": {
180+
"type": "boolean",
181+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
182+
"default": false
168183
}
169184
},
170185
"additionalProperties": false,

packages/js/src/executors/swc/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@
118118
"type": "boolean",
119119
"description": "Remove leading directory from output (e.g. src). See: https://swc.rs/docs/usage/cli#--strip-leading-paths",
120120
"default": false
121+
},
122+
"includeIgnoredAssetFiles": {
123+
"type": "boolean",
124+
"description": "Include files that are ignored by .gitignore and .nxignore when copying assets. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
125+
"default": false
121126
}
122127
},
123128
"required": ["main", "outputPath", "tsConfig"],
@@ -145,6 +150,11 @@
145150
"output": {
146151
"type": "string",
147152
"description": "Absolute path within the output."
153+
},
154+
"includeIgnoredFiles": {
155+
"type": "boolean",
156+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
157+
"default": false
148158
}
149159
},
150160
"additionalProperties": false,

packages/js/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function createTaskInfo(
9191
rootDir: context.root,
9292
outputDir: taskOptions.outputPath,
9393
assets: taskOptions.assets,
94+
includeIgnoredFiles: taskOptions.includeIgnoredAssetFiles,
9495
});
9596

9697
const {

packages/js/src/executors/tsc/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
"type": "boolean",
112112
"description": "Generate package.json file in the output folder.",
113113
"default": true
114+
},
115+
"includeIgnoredAssetFiles": {
116+
"type": "boolean",
117+
"description": "Include files that are ignored by .gitignore and .nxignore when copying assets. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
118+
"default": false
114119
}
115120
},
116121
"required": ["main", "outputPath", "tsConfig"],
@@ -138,6 +143,11 @@
138143
"output": {
139144
"type": "string",
140145
"description": "Absolute path within the output."
146+
},
147+
"includeIgnoredFiles": {
148+
"type": "boolean",
149+
"description": "Include files that are ignored by .gitignore and .nxignore for this specific asset pattern. WARNING: Ignored files are not automatically considered when calculating the task hash. To ensure Nx tracks these files for caching, add them to your target's inputs using 'dependentTasksOutputs' or 'runtime' configuration.",
150+
"default": false
141151
}
142152
},
143153
"additionalProperties": false,

packages/js/src/executors/tsc/tsc.impl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export async function* tscExecutor(
9292
rootDir: context.root,
9393
outputDir: _options.outputPath,
9494
assets: _options.assets,
95+
includeIgnoredFiles: _options.includeIgnoredAssetFiles,
9596
});
9697

9798
const tsCompilationOptions = createTypeScriptCompilationOptions(

packages/js/src/utils/assets/assets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type AssetGlob = FileInputOutput & {
99
glob: string;
1010
ignore?: string[];
1111
dot?: boolean;
12+
includeIgnoredFiles?: boolean;
1213
};
1314

1415
export function assetGlobsToFiles(

0 commit comments

Comments
 (0)