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

Function: nodejs.esbuild options are not getting applied #568

Open
leon opened this issue Jun 17, 2024 · 5 comments
Open

Function: nodejs.esbuild options are not getting applied #568

leon opened this issue Jun 17, 2024 · 5 comments
Assignees

Comments

@leon
Copy link
Contributor

leon commented Jun 17, 2024

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()],
    },
  },
})
@leon
Copy link
Contributor Author

leon commented Jun 17, 2024

A potential problem I see is that we are unmarshalling esbuild from json.
Does that mean that the plugin that is a javascript function won't get converted to go?
https://github.com/sst/ion/blob/dev/pkg/runtime/node.go#L70

How does esbuild handle the conversion from javascript to go?

@jayair
Copy link
Contributor

jayair commented Jun 25, 2024

@leon I was following your messages in Discord, did you make some progress on this?

@leon
Copy link
Contributor Author

leon commented Jun 25, 2024

No unfortunately not.
Tried a couple of things but got stuck.

It's a bit complicated because of the typescript / go marshaling.

Hope someone else can look at it soon 🤓

Copy link
Contributor

thdxr commented Jun 26, 2024

yeah this is quite tricky - we used to require you to pass in a path to a file that loaded the plugins, but don't really want to go back to that

we might not be able to support esbuild plugins

@leon
Copy link
Contributor Author

leon commented Jun 26, 2024

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? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants