Skip to content

Commit cbe9fe5

Browse files
authored
fix(lambda-nodejs): cannot use .mts, .cts, and .cjs entry files (#25642)
This adds support for using TypeScript Module (`.mts`), TypeScript CommonJS (`.cts`) and JavaScript CommonJS (`.cjs`) entry files, as well as adding these to the default entry file search. This is a must for projects mixing ESM and CommonJS (quite common as not everything can/should be fully ESM yet) or where explicit file extension is desired. I tried to follow the existing convention as best I could to keep it as simple as possible. I am not sure why the tests for the existing entry files are skipped as they seem to be working correctly, at least locally, so I enabled the new tests I added. Closes #21635. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4240341 commit cbe9fe5

File tree

26 files changed

+3822
-4
lines changed

26 files changed

+3822
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable no-console */
2+
const crypto = require('crypto');
3+
4+
async function handler() {
5+
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
6+
}
7+
module.exports = { handler }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable no-console */
2+
const crypto = require('crypto');
3+
4+
async function handler(): Promise<void> {
5+
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
6+
}
7+
module.exports = { handler }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable no-console */
2+
import * as crypto from 'crypto';
3+
4+
export async function handler(): Promise<void> {
5+
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "31.0.0",
3+
"files": {
4+
"ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3": {
5+
"source": {
6+
"path": "asset.ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.bundle",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"8a33a139431fff385be0d614ca0fa1d500235d787a28b7d7fc651257af8c722a": {
18+
"source": {
19+
"path": "LambdaModulesDefaultTestDeployAssert7E536B97.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "8a33a139431fff385be0d614ca0fa1d500235d787a28b7d7fc651257af8c722a.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}

0 commit comments

Comments
 (0)