Open intptr-t opened 9 months ago
Does this have environment variable support? if that is the case you could possibly pass this option in by setting an env var in the build? Though I would need to check on how we handle env vars for this specifically.
@sriram-mv In terms of current(1.98.0), from what I have been able to ascertain, environment variables are not supported. Input from a template seems to be the current design.
https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/build/bundler.py#L86
But, I believe it is technically feasible to add new support for metadata output from environment variables. However, it would be very complicated with environment variables to support the case where function A automatically generates --enable-source-maps as before and function B does not.
Assumed sample of cases handled by environment variables
SAM_DISABLE_ENABLE_SOURCE_MAP__FuncA=false
SAM_DISABLE_ENABLE_SOURCE_MAP__FuncB=true
sam build template.yaml
Samples of templates only
Resources:
#
# FuncA automatically outputs --enable-source-maps.
# Example case: This is because cold starts, batch processing, etc., where the speed of the Node.js runtime is not affected.
#
FuncA:
Type: AWS::Serverless::Function
Properties:
CodeUri: assets/lambdas/funcA
Handler: app.handler
Runtime: nodejs18.x
Timeout: 900
Environment:
Variables:
EnvA: "VarA"
Metadata:
BuildMethod: esbuild
BuildProperties:
Format: cjs
Minify: false
Target: "es2022"
Sourcemap: true
#
# FuncB will output sourcemap files, but not --enable-source-maps.
# Example case: This is because it is a use case where a relatively fast response is desired.
#
FuncB:
Type: AWS::Serverless::Function
Properties:
CodeUri: assets/lambdas/funcB
Handler: app.handler
Runtime: nodejs18.x
Timeout: 1
Environment:
Variables:
EnvB: "VarB"
Metadata:
BuildMethod: esbuild
BuildProperties:
Format: cjs
Minify: false
Target: "es2022"
Sourcemap: true
DisableEnableSourcemap: true # This one
Describe your idea/feature/enhancement
When creating a TypeScript Lambda function, I would like to avoid forcing the "--enable-source-maps" output of the "Sourcemap: true" standard.
The purpose is to use source-map-support as a result of the following performance measurements. https://github.com/cspotcode/source-map-performance-demo
Proposal
Proposal1. make the output of "NODE_OPTIONS: '--enable-source-maps'" optional if "Sourcemap: true" is specified Proposal2. add a parameter to disable "NODE_OPTIONS: ' --enable-source-maps
Proposal1 example
This one will change the current behavior.
Proposal2 example
This does not change the current default behavior of outputting "NODE_OPTIONS: '--enable-source-maps'".
Additional Details
We get the following options
The --enable-source-maps slow issue seems to be resolved in Node 19 from the reference link above, but the current LTS is Node 18. I think it is a good idea to address this in SAM rather than wait for Node 20 to be supported in AWS Lambda We think it is a good idea to support SAM rather than waiting for Node 20 to be supported by AWS Lambda. Also important is the option to use third party libraries.