Skip to content

Commit

Permalink
Merge pull request #9 from fourTheorem/fix/optimize-hashing
Browse files Browse the repository at this point in the history
fix: exclude irrelevant directories from asset hashing
  • Loading branch information
eoinsha authored Jan 7, 2025
2 parents cdd6184 + 45be196 commit 7f4d6bd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions src/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
} from 'aws-cdk-lib/aws-lambda';
import type { BundlingOptions, ICommandHooks } from './types';

export const HASHABLE_DEPENDENCIES_EXCLUDE = ['*.pyc'];
export const HASHABLE_DEPENDENCIES_EXCLUDE = [
'*.pyc',
'cdk/**',
'.git/**',
'.venv/**',
];

export const DEFAULT_ASSET_EXCLUDES = [
'.venv/',
Expand Down Expand Up @@ -62,17 +67,29 @@ export interface BundlingProps extends BundlingOptions {
* @default false
*/
readonly skip?: boolean;

/**
* Glob patterns to exclude from asset hash fingerprinting used for source change
* detection
*
* @default HASHABLE_DEPENDENCIES_EXCLUDE
*/
readonly hashableAssetExclude?: string[];
}

/**
* Bundling options for Python Lambda assets
*/
export class Bundling {
public static bundle(options: BundlingProps): AssetCode {
const {
hashableAssetExclude = HASHABLE_DEPENDENCIES_EXCLUDE,
...bundlingOptions
} = options;
return Code.fromAsset(options.rootDir, {
assetHashType: AssetHashType.SOURCE,
exclude: HASHABLE_DEPENDENCIES_EXCLUDE,
bundling: new Bundling(options),
exclude: hashableAssetExclude,
bundling: new Bundling(bundlingOptions),
});
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f4d6bd

Please sign in to comment.