I'm working with the guys at Thundra to get the tr...
# sst
r
I'm working with the guys at Thundra to get the travel time debugging (TTD) option working (tracing now works with just the inclusion of a layer! @Adrián Mouly) The way TTD works is you give it an env var that represents the path of the handler so that it can slurp up the code. We're struggling, we think, because of the output structure from esbuild. They are considering an esbuild plugin to set this up (they already have one for webpack) Therefore, for debugging purposes I'm trying to build unbundled but I'm getting the error
Copy code
Error: Bundle cannot be disabled for the "AuthorizerFunction" function since the "srcPath" is set to the project root. Read more here — <https://github.com/serverless-stack/serverless-stack/issues/78>
Looking at the github issue I'm confused as to how to workaround this. Shifting my
src
down a level doesn't make any difference. Does the code need to live in an entirely different folder structure for this to work?
@Frank - don't suppose you have any ideas on making this work?
f
Hey @Ross Coundon, just to clarify are you trying to disable
bundle
so that the functions do not get built by esbuild?
r
Hi - yes, that's right. It's a part of my evaluation of Thundra. They're working on an esbuild plugin to support the travel time debug feature but I'd like to evaluate that feature sooner than that'll be ready and we thought removing bundling would allow me to do that
f
Got it. When
bundle
is set to
false
, the function gets built by esbuild with all the dependencies set as external modules. So esbuild is not following and building the imports, and the built file is zipped up with the entire
srcPath
(including the
nodeModules
). https://docs.serverless-stack.com/constructs/Function#bundle
Not sure if I explained it well. But in essence, even with
bundle: false
, the code still goes through
esbuild
. Will that work for Thundra?
r
@Serkan Özal what do you think?
s
That should for Thundra TTD as longs as all the srcPath and dependencies are bundled into a single js file. Because we are hooking into module compile cycle.
Additionally, we are already working on a esbuild plugin based solution and verified that our idea works. It should be available in a few days.
f
Hey @Serkan Özal, thanks for the update. Keep us posted on the progress, we will add it to our docs and have an example published https://github.com/serverless-stack/serverless-stack/issues/1003
@Ross Coundon if you want to give
bundle: false
a try before the esbuild plugin is ready, you can give it a quick try by creating a test function inside (ie.
/test-function/lambda.js
), and define the function like this:
Copy code
new Function(this, "MyTESTLambda", {
  bundle: false,
  srcPath: "test-function/",
  handler: "lambda.main",
});
Currently when
bundle
is disabled,
srcPath
cannot be project root (default is the root) due to how SST current zips up the directory. We have an open issue to support it https://github.com/serverless-stack/serverless-stack/issues/78.
But give the above setup a try first, and see if
bundle: false
works.