Skip to content

Commit fa1d8be

Browse files
committed
fix(lambda): bundling error with pnpm 8.4.0+ where .modules.yaml doesn’t exist (#25612)
Added -f flag when removing node_modules/.modules.yaml from output dir as part of ES Build bundling step to support both pnpm 8.3.1 and below behaviour where this file is always generated and 8.4.0 and above where this file is not generated if no node_modules exist. Signed-off-by: Damien Hill <damien@damienhill.com>
1 parent 99fd917 commit fa1d8be

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export class Bundling implements cdk.BundlingOptions {
245245
osCommand.copy(lockFilePath, pathJoin(options.outputDir, this.packageManager.lockFile)),
246246
osCommand.changeDirectory(options.outputDir),
247247
this.packageManager.installCommand.join(' '),
248-
isPnpm ? osCommand.remove(pathJoin(options.outputDir, 'node_modules', '.modules.yaml')) : '', // Remove '.modules.yaml' file which changes on each deployment
248+
isPnpm ? osCommand.remove(pathJoin(options.outputDir, 'node_modules', '.modules.yaml')) + ' -f' : '', // Remove '.modules.yaml' file which changes on each deployment
249249
]);
250250
}
251251

packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ test('Detects pnpm-lock.yaml', () => {
432432
assetHashType: AssetHashType.OUTPUT,
433433
bundling: expect.objectContaining({
434434
command: expect.arrayContaining([
435-
expect.stringMatching(/echo '' > "\/asset-output\/pnpm-workspace.yaml\".+pnpm-lock\.yaml.+pnpm install --config.node-linker=hoisted --config.package-import-method=clone-or-copy --no-prefer-frozen-lockfile && rm "\/asset-output\/node_modules\/.modules.yaml"/),
435+
expect.stringMatching(/echo '' > "\/asset-output\/pnpm-workspace.yaml\".+pnpm-lock\.yaml.+pnpm install --config.node-linker=hoisted --config.package-import-method=clone-or-copy --no-prefer-frozen-lockfile && rm "\/asset-output\/node_modules\/.modules.yaml" -f/),
436436
]),
437437
}),
438438
});

0 commit comments

Comments
 (0)