Skip to content
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

Custom bundling (esbuild) config #3410

Open
skorfmann opened this issue Jul 13, 2023 · 9 comments
Open

Custom bundling (esbuild) config #3410

skorfmann opened this issue Jul 13, 2023 · 9 comments
Labels
✨ enhancement New feature or request 🎨 sdk SDK

Comments

@skorfmann
Copy link
Contributor

Feature Spec

Wing now supports customizing the esbuild config for bundling inflight functions. This enables bundling functions with custom requirements, such as WebAsssembly modules or using custom esbuild plugins.

Use Cases

  • enable usage of custom esbuild plugins
  • enable usage of custom loaders for WASM modules or similar formats

Implementation Notes

No response

Component

Compiler

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@github-actions
Copy link

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Sep 12, 2023
@staycoolcall911 staycoolcall911 added the needs-discussion Further discussion is needed prior to impl label Oct 4, 2023
@skorfmann
Copy link
Contributor Author

skorfmann commented Nov 15, 2023

Just ran into the error described here https://answers.netlify.com/t/lambda-functions-fastify-error-cannot-find-module-string-decoder/40219/12 in one of the examples.

The solution outlined there

external_node_modules = ["readable-stream"]

@skyrpex
Copy link
Contributor

skyrpex commented Nov 15, 2023

A related use case is running cloud.Service during sim and accessing modules such as vite, where the default esbuild bundling config fails.

@eladb
Copy link
Contributor

eladb commented Nov 17, 2023

external_node_modules = ["readable-stream"]

@skorfmann would it make sense to always build with this setting when bundling for aws lambda?

@skyrpex
Copy link
Contributor

skyrpex commented Nov 24, 2023

Dependencies such as the fsevents dependency should also never be bundled AFAIK, but I'm not sure if by always excluding it we may hide a potential bundle problem.

@skorfmann
Copy link
Contributor Author

This would help with using jsx in the Typescript SDK as well, e.g. something like this winglang/examples#45

Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label May 28, 2024
@eladb eladb changed the title Enable Custom esbuild config Custom bundling (esbuild) config Jun 24, 2024
@Chriscbr Chriscbr removed the needs-discussion Further discussion is needed prior to impl label Sep 6, 2024
@Chriscbr
Copy link
Contributor

Chriscbr commented Sep 6, 2024

See also the bundling options offered by CDK here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs.BundlingOptions.html

One design option could be to have some way to configure bundling on a per cloud.Function basis:

new cloud.Function(handler,
  env: {
    "KEY": "VALUE",
  },
  bundling: {
    external: ["fsevents"],
    minify: false,
  }
);

Another option is to have some way to configure bundling app-wide:

// inside the platform or in Wing, both can be supported
std.bundling.configure(
  external: @app.target == "aws" ? ["fsevents", "aws-sdk"] : ["fs-events"],
  minify: false,
);

When we expose an API for serializing an inflight into a string, bundling options would also be exposed for that naturally (this would be the lowest level).

@eladb thoughts?

@eladb
Copy link
Contributor

eladb commented Sep 9, 2024

Good idea - I think it might be sufficient as an initial step just support this at the app level.

Only thing, I'd try to avoid a global and expose it on via the @app:

@app.bundling.configure(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request 🎨 sdk SDK
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

5 participants