Skip to content

Commit 7f4d6bd

Browse files
authored
Merge pull request #9 from fourTheorem/fix/optimize-hashing
fix: exclude irrelevant directories from asset hashing
2 parents cdd6184 + 45be196 commit 7f4d6bd

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
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: 20 additions & 3 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,29 @@ 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 {
86+
hashableAssetExclude = HASHABLE_DEPENDENCIES_EXCLUDE,
87+
...bundlingOptions
88+
} = options;
7289
return Code.fromAsset(options.rootDir, {
7390
assetHashType: AssetHashType.SOURCE,
74-
exclude: HASHABLE_DEPENDENCIES_EXCLUDE,
75-
bundling: new Bundling(options),
91+
exclude: hashableAssetExclude,
92+
bundling: new Bundling(bundlingOptions),
7693
});
7794
}
7895

yarn.lock

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

0 commit comments

Comments
 (0)