-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sam): improved TypeScript support #3099
Conversation
.changes/next-release/Feature-46a93a97-f979-4c7a-9a8d-f241a30987b6.json
Outdated
Show resolved
Hide resolved
@@ -90,7 +96,7 @@ export async function makeInputTemplate( | |||
.withRuntime(config.lambda!.runtime!) | |||
.withCodeUri(pathutil.normalize(config.invokeTarget.projectRoot)) | |||
|
|||
if (config.lambda?.environmentVariables) { | |||
if (config.lambda?.environmentVariables && Object.entries(config.lambda?.environmentVariables).length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement.
/runintegrationtests .... |
// Adapted from: https://github.com/aws/aws-toolkit-jetbrains/blob/911c54252d6a4271ee6cacf0ea1023506c4b504a/jetbrains-ultimate/src/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsLambdaBuilder.kt#L60 | ||
const defaultTsconfig = { | ||
compilerOptions: { | ||
const tsConfigPath = path.join(config.codeRoot, tsConfigFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be really nice if we could write this to the build directory if possible. Maybe we can use extends instead of directly merging config files?
Problem
TypeScript debugger has a race condition that breaks debugging much of the time. Hard-coded tsconfig also is used which breaks anything more than a very basic typescript lambda.
Solution
Updated toolkit to generate tsconfig that attempts to match project tsconfig as close as possible, code is compiled into a ts build directory, sam deploys from there on an updated handler path (pointing to build dir). This eliminates the debugger race condition, and much more closely resembles a standard project build eliminating all of our errors. It also matches jetbrains approach here.
Code updated:
Tested with unit tests, and with several typescript projects including large and small lambdas. New code lines are covered with code coverage.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.