Isn’t `sst start` supposed to update the functions...
# help
d
Isn’t
sst start
supposed to update the functions (
sst.Api
) live when saving? Right now I can see the console processing after save, but running the function again does not show the changes. Currently, we’re stopping and restarting sst cli in order to see changes. This can’t be whats supposed to happen?
t
yeah this sounds like a bug, your lambda code is inside the same folder as your stacks right?
Think the bug might be related to that let me check
d
ya… a co-worker had the same issue last week and I thought it was just on his machine but now I’m having the issue too….. same repo though, so you could be right about the stacks and functions together being the issue.
Should that organization style be avoided? To us it seemed only natural
t
Yeah it's definitely tempting to colocate everything but ultimately infra code is very different than application code even though they're in the same language. Leads to some tricky situations
I'll see if I can track this down though
d
ya feels like it should be allowed…. so long as your not cross-importing lambda and infra code. I just want the “folder” structure to be coupled with the constructs associated
@thdxr What IS the recommended way to organize lambda vs CDK code? Is it enough that they are in different root dirs or am I not supposed to even process with the same ts config?
ya seems like hot reload DOES work so long as I put lambdas in diff root folder… even while still using the same tsconfig. /lambdas/ContentfulApp /lib/constructs/ContentfulApp
t
I have a quick fix for your issue which I'll push out today
d
oh…. shit…. I’m just reorgin everything to fall in line 😛
t
Well, I still recommend that
d
kk
thats what I’ll do then…. but thanks for the fix
t
It's the same logic as having tests next to the files they're testing vs in a seperate directory. For example
Copy code
src/module.ts
src/module.test.ts
vs
Copy code
src/module.ts
test/module.test.ts
It can be nice to have everything colocated and there's good arguments for that. The arguments against it is the boundaries aren't as clearly defined and it's easy to intermix things that shouldn't be. And you can always use editor plugins to jump to the test from the module
If you haven't looked at this, this is close to what I use personally: https://github.com/serverless-stack/serverless-stack/tree/master/examples/typescript-monorepo
d
oh weird…. that uses diff tsconfig for lambdas (backend) and cdk
t
You can still share one if you want
d
See any issues sharing a
config.ts
of (static config values) file between CDK and Lambdas?