Skip to content

Commit ea244ea

Browse files
committed
fix: exclude irrelevant directories from asset hashing
1 parent cdd6184 commit ea244ea

File tree

4 files changed

+262
-144
lines changed

4 files changed

+262
-144
lines changed

API.md

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bundling.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {
1414
} from 'aws-cdk-lib/aws-lambda';
1515
import type { BundlingOptions, ICommandHooks } from './types';
1616

17-
export const HASHABLE_DEPENDENCIES_EXCLUDE = ['*.pyc'];
17+
export const HASHABLE_DEPENDENCIES_EXCLUDE = [
18+
'*.pyc',
19+
"cdk/**",
20+
".git/**",
21+
".venv/**",
22+
];
1823

1924
export const DEFAULT_ASSET_EXCLUDES = [
2025
'.venv/',
@@ -62,17 +67,26 @@ export interface BundlingProps extends BundlingOptions {
6267
* @default false
6368
*/
6469
readonly skip?: boolean;
70+
71+
/**
72+
* Glob patterns to exclude from asset hash fingerprinting used for source change
73+
* detection
74+
*
75+
* @default HASHABLE_DEPENDENCIES_EXCLUDE
76+
*/
77+
readonly hashableAssetExclude?: string[];
6578
}
6679

6780
/**
6881
* Bundling options for Python Lambda assets
6982
*/
7083
export class Bundling {
7184
public static bundle(options: BundlingProps): AssetCode {
85+
const { hashableAssetExclude = HASHABLE_DEPENDENCIES_EXCLUDE, ...bundlingOptions } = options;
7286
return Code.fromAsset(options.rootDir, {
7387
assetHashType: AssetHashType.SOURCE,
74-
exclude: HASHABLE_DEPENDENCIES_EXCLUDE,
75-
bundling: new Bundling(options),
88+
exclude: hashableAssetExclude,
89+
bundling: new Bundling(bundlingOptions),
7690
});
7791
}
7892

@@ -100,13 +114,13 @@ export class Bundling {
100114
const bundlingCommands = props.skip
101115
? []
102116
: this.createBundlingCommands({
103-
rootDir,
104-
workspacePackage,
105-
assetExcludes,
106-
commandHooks,
107-
inputDir: AssetStaging.BUNDLING_INPUT_DIR,
108-
outputDir: AssetStaging.BUNDLING_OUTPUT_DIR,
109-
});
117+
rootDir,
118+
workspacePackage,
119+
assetExcludes,
120+
commandHooks,
121+
inputDir: AssetStaging.BUNDLING_INPUT_DIR,
122+
outputDir: AssetStaging.BUNDLING_OUTPUT_DIR,
123+
});
110124

111125
this.image = image ?? this.createDockerImage(props);
112126

0 commit comments

Comments
 (0)