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: exclude irrelevant directories from asset hashing #9

Merged
merged 3 commits into from
Jan 7, 2025
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
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.

Loading