|
1 | 1 | import * as child_process from 'child_process';
|
2 | 2 | import * as os from 'os';
|
3 | 3 | import * as path from 'path';
|
4 |
| -import { Architecture, Code, Runtime } from '@aws-cdk/aws-lambda'; |
| 4 | +import { Architecture, Code, Runtime, RuntimeFamily } from '@aws-cdk/aws-lambda'; |
5 | 5 | import { AssetHashType, DockerImage } from '@aws-cdk/core';
|
6 | 6 | import { version as delayVersion } from 'delay/package.json';
|
7 | 7 | import { Bundling } from '../lib/bundling';
|
@@ -329,6 +329,30 @@ test('esbuild bundling source map inline', () => {
|
329 | 329 | });
|
330 | 330 | });
|
331 | 331 |
|
| 332 | +test('esbuild bundling is correctly done with custom runtime matching predefined runtime', () => { |
| 333 | + Bundling.bundle({ |
| 334 | + entry, |
| 335 | + projectRoot, |
| 336 | + depsLockFilePath, |
| 337 | + runtime: new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }), |
| 338 | + architecture: Architecture.X86_64, |
| 339 | + sourceMapMode: SourceMapMode.INLINE, |
| 340 | + }); |
| 341 | + |
| 342 | + expect(Code.fromAsset).toHaveBeenCalledWith(path.dirname(depsLockFilePath), { |
| 343 | + assetHashType: AssetHashType.OUTPUT, |
| 344 | + bundling: expect.objectContaining({ |
| 345 | + command: [ |
| 346 | + 'bash', '-c', |
| 347 | + [ |
| 348 | + 'esbuild --bundle "/asset-input/lib/handler.ts" --target=node14 --platform=node --outfile="/asset-output/index.js"', |
| 349 | + '--sourcemap=inline --external:aws-sdk', |
| 350 | + ].join(' '), |
| 351 | + ], |
| 352 | + }), |
| 353 | + }); |
| 354 | +}); |
| 355 | + |
332 | 356 | test('esbuild bundling source map enabled when only source map mode exists', () => {
|
333 | 357 | Bundling.bundle({
|
334 | 358 | entry,
|
|
0 commit comments