Open skorfmann opened 1 year ago
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!
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"]
A related use case is running cloud.Service
during sim
and accessing modules such as vite
, where the default esbuild bundling config fails.
external_node_modules = ["readable-stream"]
@skorfmann would it make sense to always build with this setting when bundling for aws lambda?
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.
This would help with using jsx in the Typescript SDK as well, e.g. something like this https://github.com/winglang/examples/pull/45
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!
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?
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(...)
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
Implementation Notes
No response
Component
Compiler
Community Notes