Skip to content

Commit

Permalink
fix(lambda-nodejs): cannot use .mts, .cts, and .cjs entry files (#25642)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
ersims committed Jun 5, 2023
1 parent 4240341 commit cbe9fe5
Show file tree
Hide file tree
Showing 26 changed files with 3,822 additions and 4 deletions.
@@ -0,0 +1,7 @@
/* eslint-disable no-console */
const crypto = require('crypto');

async function handler() {
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
}
module.exports = { handler }
@@ -0,0 +1,7 @@
/* eslint-disable no-console */
const crypto = require('crypto');

async function handler(): Promise<void> {
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
}
module.exports = { handler }
@@ -0,0 +1,6 @@
/* eslint-disable no-console */
import * as crypto from 'crypto';

export async function handler(): Promise<void> {
console.log(crypto.createHash('sha512').update('cdk').digest('hex'));
}
@@ -0,0 +1,32 @@
{
"version": "31.0.0",
"files": {
"ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3": {
"source": {
"path": "asset.ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"8a33a139431fff385be0d614ca0fa1d500235d787a28b7d7fc651257af8c722a": {
"source": {
"path": "LambdaModulesDefaultTestDeployAssert7E536B97.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "8a33a139431fff385be0d614ca0fa1d500235d787a28b7d7fc651257af8c722a.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}

0 comments on commit cbe9fe5

Please sign in to comment.