diff --git a/API.md b/API.md index 99e61b4..029babb 100644 --- a/API.md +++ b/API.md @@ -1466,6 +1466,7 @@ const bundlingProps: BundlingProps = { ... } | rootDir | string | uv project root (workspace root). | | runtime | aws-cdk-lib.aws_lambda.Runtime | Lambda runtime (must be one of the Python runtimes). | | architecture | aws-cdk-lib.aws_lambda.Architecture | Lambda CPU architecture. | +| hashableAssetExclude | string[] | Glob patterns to exclude from asset hash fingerprinting used for source change detection. | | skip | boolean | Skip bundling process. | | workspacePackage | string | uv package to use for the Lambda Function. | @@ -1778,6 +1779,19 @@ Lambda CPU architecture. --- +##### `hashableAssetExclude`Optional + +```typescript +public readonly hashableAssetExclude: string[]; +``` + +- *Type:* string[] +- *Default:* HASHABLE_DEPENDENCIES_EXCLUDE + +Glob patterns to exclude from asset hash fingerprinting used for source change detection. + +--- + ##### `skip`Optional ```typescript diff --git a/package-lock.json b/package-lock.json index cfbe4b0..81a318b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8967,6 +8967,8 @@ }, "node_modules/projen/node_modules/glob/node_modules/minimatch": { "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "inBundle": true, "license": "ISC", @@ -9057,8 +9059,6 @@ }, "node_modules/projen/node_modules/is-core-module": { "version": "2.16.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", - "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, "inBundle": true, "license": "MIT", @@ -9114,6 +9114,8 @@ }, "node_modules/projen/node_modules/minimatch/node_modules/brace-expansion": { "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "inBundle": true, "license": "MIT", @@ -9200,8 +9202,6 @@ }, "node_modules/projen/node_modules/resolve": { "version": "1.22.10", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", - "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", "dev": true, "inBundle": true, "license": "MIT", @@ -9255,6 +9255,8 @@ }, "node_modules/projen/node_modules/shelljs/node_modules/glob": { "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -9448,6 +9450,8 @@ }, "node_modules/projen/node_modules/yargs/node_modules/yargs-parser": { "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "inBundle": true, "license": "ISC", diff --git a/src/bundling.ts b/src/bundling.ts index 006c1f3..f6e72db 100644 --- a/src/bundling.ts +++ b/src/bundling.ts @@ -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/', @@ -62,6 +67,14 @@ 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[]; } /** @@ -69,10 +82,14 @@ export interface BundlingProps extends BundlingOptions { */ 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), }); } diff --git a/yarn.lock b/yarn.lock index c4a5648..ad31660 100644 --- a/yarn.lock +++ b/yarn.lock @@ -335,7 +335,7 @@ "@biomejs/cli-darwin-arm64@1.9.4": version "1.9.4" - resolved "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz" + resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz#dfa376d23a54a2d8f17133c92f23c1bf2e62509f" integrity sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw== "@biomejs/cli-darwin-x64@1.9.4": @@ -355,12 +355,12 @@ "@biomejs/cli-linux-x64-musl@1.9.4": version "1.9.4" - resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz#f36982b966bd671a36671e1de4417963d7db15fb" + resolved "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz" integrity sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg== "@biomejs/cli-linux-x64@1.9.4": version "1.9.4" - resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz#a0a7f56680c76b8034ddc149dbf398bdd3a462e8" + resolved "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz" integrity sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg== "@biomejs/cli-win32-arm64@1.9.4": @@ -1872,7 +1872,7 @@ fs.realpath@^1.0.0: fsevents@^2.3.2: version "2.3.3" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== function-bind@^1.1.2: