Closed j closed 1 year ago
I will switch from SAM to Serverless if this is not returned to the backlog
@whiteshadoww as you wish! Although Serverless is also a fine tool and if its features fit your needs better, you should consider it.
It has been quite a while since this issue was created and in the meantime the team added support for using makefiles in sam build
, allowing for various kinds of build customization:
Thanks for this suggestion! We will consider improving our build options to include the feature you mentioned.
Hello! Just so commenters are aware we have esbuild support in preview, which might solve some of the original commenter's reported issues. To find out more and leave feedback - https://github.com/aws/aws-sam-cli/issues/3700 Blog post here - https://aws.amazon.com/blogs/compute/building-typescript-projects-with-aws-sam-cli/
Our generic builder is Makefile
. There might be more things we can do here but in terms of the initial request we solved it through the Makefile builder.
Closing
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Putting a quick list of what was discussed in #samdev.
The builder implementation is great and
sam build
is exactly what we need. It seems to be missing the ability to go above and beyond typical build solutions. The builder (for node.js) as it stands expects the function code to build for the exact runtime. The issue is that most people use updated versions of node.js (or typescript) and deploy to older node.js runtimes that Lambda supports, as well as a majority of people need more advanced building. Popular tools like https://github.com/zeit/ncc, https://webpack.js.org/, gulp, browserify, babel, etc, etc, help build stuff that can compile down to AWS Lambda specific versions, perform minification, optimize images, etc, etc. It would be great if anyone who uses sam can also build using the tools they wish. We personally use serverless with functions that utilize webpack (react apps), and typescript (tsc -b).I'm proposing a more generic builder solution for anyone to implement their own build functionality that other Lambda deployment tools have.
Apex Up (https://up.docs.apex.sh/)
Up has an .upignore and up.json file. The up.json file can contain custom build commands:
Serverless
There are tons of build plugins for serverless (typescript, webpack, browserify, etc, etc)
Sam Proposal
It'd be awesome if we can take from what's been around for a while and that people are used to and implement it. Automated builds is awesome, but not flexible. If each lambda function could contain their own build directions, that'd make it more flexible.
template.yaml
OR sam.json & .samignore files contained in the function directory (not preferred)
Example of excluding everything and cherry picking what's needed.. you should be able to do the opposite of this too.
You can go even further and look at
scripts.build
inside of package.json and do this in the NPM builder, but I think keeping it simple would be best.I'm more in favor with keeping everything inside of template.yaml if possible.