I just tried restructuring some of my folder struc...
# sst
t
I just tried restructuring some of my folder structure and am seeing this when trying to build even a simple lambda function
Copy code
Transpiling Lambda code...
 > error: Could not resolve "/home/thdxr/dev/projects/ironbay/nori/.js"
Some stuff from the debug log
Copy code
[2021-07-21T15:14:43.226] [DEBUG] default - Transpiling ./src/test.handler...
[2021-07-21T15:14:43.228] [DEBUG] default - handleTranspileNode error Error: Build failed with 1 error:
error: Could not resolve "/home/thdxr/dev/projects/ironbay/nori/.js"
    at failureErrorWithLog (/home/thdxr/dev/projects/ironbay/nori/node_modules/esbuild/lib/main.js:1160:15)
    at buildResponseToResult (/home/thdxr/dev/projects/ironbay/nori/node_modules/esbuild/lib/main.js:896:32)
I'm gonna keep seeing what I'm missing but was wondering if it's something obvious
f
Hey @thdxr, are you getting this on
sst start
?
t
yeah
Copy code
./node_modules/esbuild/bin/esbuild --platform=node --bundle ./src/test.ts
This works fine so maybe it's before esbuild is actually called
Or it's passing the wrong path to esbuild hm
f
hmm did u just upgrade by any chance?
t
yeah I did
0.35
f
hmmm.. where did the filename go
nori/.js
lol
t
lol yeah idk where this is coming from, let me downgrade to 0.34 and see
f
does
sst.json
sit in
/home/thdxr/dev/projects/ironbay/nori
?
t
yeah
same issue on 0.34 hm. I'm definitely missing something
p
#powerUser
t
time to add console.log statements into node_modules/@serverless-stack...
f
yeah
packages/cli/scripts/start.js
line 541
t
lol 🤦🏽‍♂️
I had my handler defined as
Copy code
handler: `./src/lambda.handler`,
the code that figures out the file name by splitting on
.
was freaking out accordingly
a
I had something similar where my debug stack deployment was failing due to difference of cdk bootstrap version between the already deployed debug stack and the one that I was trying to deploy.
does your debug stack get deployed successfully?
Oh! yes, you can’t use relative paths for the handler path, the time I faced this I almost burnt up three hours and was done for the day. 😂
f
t
I'll fix this
f
Hey @thdxr, I think someone else might just ran into the same issue. Let me know if haven’t gotten to this, I can take an crack at it.
t
Yeah I have a fix, for tests I'm seeing they're full tests of the entire cdk build. Is that what we should be doing for everything or is there somewhere for more specific tests of just individual functions
https://github.com/serverless-stack/serverless-stack/pull/596 lmk if / how I should do a test for this
f
Thanks @thdxr! I haven’t tried it yet, but if the handler were
path/to/lambda.main
,
path.basename(handler).split(".")
gives
["lambda", "main"]
, but we need
path/to/
to be able to find the file i think.
t
ah I see
I could use
path.dirname(handler)
in the path.join below - it would support setting
srcPath
to something then
handler
to something outside of it. Is that ok to allow?
f
But yeah, we don’t have unit tests currently. Feel free to add if helps. I think jest is setup to pick up all tests automatically.
Yup ur call 😆
t
Ended up adding similar tests to what's there so I could understand how everything works together. Think the PR is ready