-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information
Showing
26 changed files
with
3,822 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...ws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ-handlers/cjs-handler.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
7 changes: 7 additions & 0 deletions
7
...ws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ-handlers/cts-handler.cts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
6 changes: 6 additions & 0 deletions
6
...ws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ-handlers/mts-handler.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
} |
32 changes: 32 additions & 0 deletions
32
...s/test/integ.modules.js.snapshot/LambdaModulesDefaultTestDeployAssert7E536B97.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": {} | ||
} |
Oops, something went wrong.