Skip to content

Commit

Permalink
Merge branch 'main' into corymhall/fix-integ-runner-snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 20, 2023
2 parents de0e52a + 8a7dffd commit 043ac52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,5 @@ function isSdkV2Runtime(runtime: Runtime): boolean {
Runtime.NODEJS_14_X,
Runtime.NODEJS_16_X,
];
return sdkV2RuntimeList.includes(runtime);
return sdkV2RuntimeList.some((r) => {return r.family === runtime.family && r.name === runtime.name;});
}
26 changes: 25 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as child_process from 'child_process';
import * as os from 'os';
import * as path from 'path';
import { Architecture, Code, Runtime } from '@aws-cdk/aws-lambda';
import { Architecture, Code, Runtime, RuntimeFamily } from '@aws-cdk/aws-lambda';
import { AssetHashType, DockerImage } from '@aws-cdk/core';
import { version as delayVersion } from 'delay/package.json';
import { Bundling } from '../lib/bundling';
Expand Down Expand Up @@ -329,6 +329,30 @@ test('esbuild bundling source map inline', () => {
});
});

test('esbuild bundling is correctly done with custom runtime matching predefined runtime', () => {
Bundling.bundle({
entry,
projectRoot,
depsLockFilePath,
runtime: new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }),
architecture: Architecture.X86_64,
sourceMapMode: SourceMapMode.INLINE,
});

expect(Code.fromAsset).toHaveBeenCalledWith(path.dirname(depsLockFilePath), {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node14 --platform=node --outfile="/asset-output/index.js"',
'--sourcemap=inline --external:aws-sdk',
].join(' '),
],
}),
});
});

test('esbuild bundling source map enabled when only source map mode exists', () => {
Bundling.bundle({
entry,
Expand Down

0 comments on commit 043ac52

Please sign in to comment.