Git Product home page Git Product logo

Comments (7)

buggy avatar buggy commented on June 14, 2024 6

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.

Jeremias-Tecnom avatar Jeremias-Tecnom commented on June 14, 2024 2

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.

sanathkr avatar sanathkr commented on June 14, 2024 1

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.

sanathkr avatar sanathkr commented on June 14, 2024

@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.

buggy avatar buggy commented on June 14, 2024

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.

buggy avatar buggy commented on June 14, 2024

@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.

jfuss avatar jfuss commented on June 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.