sst: Function: nodejs.esbuild options are not getting applied
When supplying a custom esbuild config to Function it’s not getting applied
const myFunction = new sst.aws.Function('MyFunction', {
handler: 'src/main.handler',
url: true,
nodejs: {
install: [
'@nestjs/platform-express',
'@nestjs/microservices*',
'@nestjs/websockets*',
'@fastify/static',
'@fastify/view',
],
esbuild: {
plugins: [tscPlugin()],
},
},
})
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 59 (30 by maintainers)
a few things to note:
sst@3.1.7successfully withesbuildPluginTscforemitDecoratorMetadata. is there other suggested way?pluginsas a viable option https://sst.dev/docs/component/aws/function/#nodejs-plugins@thdxr I know you wanted to look at the Sentry setup.
We want to migrate from serverless to SST but have the same problem with the Sentry esbuild plugin, which is a must to be able to continue.
We attempted to use this with the Sentry esbuild plugin but the
sst deploycommand just hangs.Our
plugins.mjs:Then in
sst.config.ts:Running
sst deploy --verbose --print-logs, we see log lines like:But then it seems to get stuck and there’s no more output.
After some debugging I found the problem. It is in the sst plaform code. The problematic file is
.sst/platform/functions/nodejs-runtime/plugin.mjsHere is the patched working file:The problem lies in a change in the request payload. I changed this
new RegExp(options.filter).test(msg.path)to thisnew RegExp(options.filter).test(msg.value.path)and now it works correctly.msg.pathdoes not exist in the payload. I tested this fix using the nodejs.plugins file option. My file looks like this:Hopefully this resolves the problem for all who need decorators metadata support. You may test it with other plugins. I expect this fix can be released in the next sst vesion.
Yeah good call on those other issues.
I’ll check with the team on the roadmap.
A solution we could do is add a config Boolean to function called experimentalDecorators which in turn adds an esbuild plugin that compiles using typescript.
Only a couple of lines of code is needed.
What do you think? 🤔
The above fix does not seem to work for me with for the Sentry ESBuild plugin. SST just hangs.
heavily impacted by this issue,
nodejs.pluginsdon’t seem to work,nodejs.esbuildoptions don’t work either. we’re stuck with<3.2.0Just out of the box, dev and deploy. I am using Nest’s standalone mode though.
I’ll publish the example later today.
experimental support in v3.2.2
the issue is in pulumi the node process spawns and exits after the deploy is done so for live dev mode we need to have it implemented separately
i just need to put more time into it and i think i can get it all working - esbuild is already doing this same thing under the hood they just don’t expose it for me to reuse
found some more issues - this is kind of a rabbit hole i’m not sure how stable we’ll be able to get this
Just found this issue and I must say it would be a bummer to not support plugins in some way. Just found that this plugin https://github.com/unplugin/unplugin-auto-import works directly with esbuild and I wanted to try it
just found this issue & bumping it, would love to find a solution here. i think the main one is for experimentalDecorators like @leon mentioned above because those are a very common use-case with frameworks like nestjs which i really wanna move into a sst dev environment. curious if there’s an appetite to special case that?
(Also small nit would be good to potentially hide the plugin option from the function if it’s not available. Spent a lot of time debugging my setup)