I'd like to be able to specify different esbuild c...
# sst
r
I'd like to be able to specify different esbuild configuration per function. This is so we can apply a 3rd party esbuild plugin (Thundra) differently depending on the function. At present, the bundle.plugins property takes an import path. This means I need a different esbuild.js for each function. I'm wondering if there's a better way to pass an array of configured esbuild plugin objects to the bundle.plugin property
f
Hey @Ross Coundon, can you show me a quick example of what the
esbuild.js
looks like for a function, and which option would be different for each function?
r
So the esbuild.js looks like this:
Copy code
const { ThundraEsbuildPlugin } = require('@thundra/esbuild-plugin');

module.exports = [
  ThundraEsbuildPlugin({
    traceableConfigs: ['src.main.handler.api.*[traceLineByLine=true]'],
  }),
];
The array of strings assigned to traceableConfigs would be different per function
t
@Frank if we rework our build system with that fake function idea we can probably support defining plugins inline right
s
@Ross Coundon one approach from Thundra side is that you set the name of the config file in the Thundra esbuild plugin. And Thundra esbuild plugin read the configurations from the config file and there are multiple config files at the root of each project/module with the same name
So Thundra esbuikd plugin can use different configurations for each project/module as each of them has its own config file with specific configs.
But the question is that Thundra esbuild plugin is triggered individually for each project/module by SST?
r
@Frank is the esbuild plugin called once per stack?
f
I think it's per function. @thdxr can you confirm? AFK at the moment.
Can confirm that it is called once per function.
t
yeah it's once per function, we can maybe pass in an arg to the file we call so you can dynamically return results
the arg could contain info about the function
f
@thdxr yeah let’s explore the placeholder function trick after the dashboard sprint