Comments (7)
After looking into this I've decided to go a different direction and use Webpack to handle the sam build
process. I've now released a Webpack plugin to help others https://github.com/buggy/aws-sam-webpack-plugin
Once Webpack completes the build your can use sam package
/ sam deploy
/ sam local invoke
/ etc as usual. It also outputs the VS Code debugging configuration for your Lambda :)
from aws-lambda-builders.
I like this.
I ve been using this SAM scaffold (i've adapted it to my sollutions).
What I like about it, is that it builds multiple functions wich are in separate folders.
from aws-lambda-builders.
Awesome! Makes sense.
Actually I just realized we didn't write down these instructions. Let me do it for you tomorrow. It's quite simple actually.
from aws-lambda-builders.
@buggy Good idea! This has come up several times before in the Typescript context.
The command you mentioned involves detecting the specific typescript file as well. Is there a more generic command/solution that works even if the project doesn't use Typescript? Alternatively we can create one Typescript builder & one generic webpack builder.
We should also think about if and how the built artifacts can be used to debug. If we have to produce additional artifacts like say sourcemaps for debugging, we should also support that (may be as a v2 if its hard).
Would you be able to send a PR? We can help you take this forward.
from aws-lambda-builders.
The command you mentioned involves detecting the specific typescript file as well. Is there a more generic command/solution that works even if the project doesn't use Typescript? Alternatively we can create one Typescript builder & one generic webpack builder.
@sanathkr The proposal is generic. I've used app.ts
in my example but you would replace that with the name of the handler function from the template.yaml
. If someone was using Babel instead of TypeScript and their handler was called src/handler.js
then the command would become:
npx webpack-cli src/handler.js -o ../.aws-ts/build/HelloWorldFunction/app.js --config ./webpack.config.js
Developers would control the build process using the webpack.config.js
allowing them to select the loaders they want to use (i.e. TypeScript, Babel, etc). I think we can provide one template with support for both TypeScript and Babel along with documentation for removing each if they only want one.
We should also think about if and how the built artifacts can be used to debug. If we have to produce additional artifacts like say sourcemaps for debugging, we should also support that (may be as a v2 if its hard).
The standard approach is to build sourcemaps and use https://www.npmjs.com/package/source-map-support. It's something I would want to support immediately. The developer just needs to include it at the top of their handler.
Would you be able to send a PR? We can help you take this forward.
Are there instructions somewhere for how to do local development for aws-lamba-builders and aws-sam-cli? Specifically, how to get aws-sam-cli to use my local instance of aws-lamba-builders?
from aws-lambda-builders.
@sanathkr I was looking at this over the weekend and I don't think a dedicated builder is required but I need to figure out why adding a prepack script to the package.json fails when "npm pack" is executed during "sam build" but works if you use "npm pack".
If I can sort that out then the we just need a new template to get webpack working.
from aws-lambda-builders.
@buggy I just submitted a PR on how to do local testing through SAM CLI in #119. For this issue, it may require changes to SAM CLI too for testing the full workflow (if there is a new files we need to detect or a new workflow).
from aws-lambda-builders.
Related Issues (20)
- SAM build failed in sam cli using python 3.9. HOT 3
- How to make `sam` hold my SSH keys so `sam build` can download dependencies from my private repository? HOT 4
- [Announcement] Deprecating AWS Lambda Builders on python3.6 HOT 1
- Feature request: Add support for ES Modules with esbuild. HOT 4
- Feature request: Support packaging resource files with workflow HOT 7
- Add support for SourcesContent option in esbuild builds HOT 2
- Bug: UnsupportedPackageError when tests run under setuptools 66+ HOT 1
- [Announcement] .NET Core 3.1 Runtime Deprecation
- Using pip 23.1 produces invalid deployment file when package references other local packages HOT 1
- Feature request: Allow ignoring dependencies when building with python pip HOT 2
- Bug: sam build throws error with python packages installed with git+https url HOT 3
- Bug: No message from the Maven's stderr in the sam output logs HOT 1
- Feature request: Include/Exclude Interface for AWS Lambda Builders HOT 3
- Bug: SAM is failing to build python package neo4j HOT 5
- German Umlaut in Maven stdout causes SAM build to fail HOT 4
- NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use `--omit=dev` instead HOT 3
- Can not install custom python dependency from custom git url HOT 3
- Bug: Using AWS::Serverless::LayerVersion with BuildMethod: makefile and python runtime fails to build HOT 2
- [Announcement] Upcoming Runtime Deprecations
- Bug: dnf command does not work on version of public.ecr.aws/lambda/python:3.11-x86_64 publish around 2023.12.05 16:00 UTC HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-builders.