https://serverless-stack.com/ logo
#help
Title
# help
d

Dan Coates

11/18/2021, 10:15 PM
Hi folks, I've noticed that when using
sst start
with an api with multiple routes defined that the code will only rebuild if I change the handler file referenced in the route config, not if I change a file imported by the handler. ie. if I have config like this:
Copy code
const api = new sst.Api(this, 'Api', {
    routes: {
        'GET /route1': `route1.handler`,
        'GET /route2': `route2.handler`,
        'GET /route3': `route3.handler`,
        'GET /route4': `route4.handler`,
    }
});
and all of those handlers import a
config.ts
file or something, saving
config.ts
won't cause any of them to rebuild. Is this a known issue?
d

Dan Greaves

11/18/2021, 10:32 PM
I have experienced this too, need to save the actual handler file before it will refresh. Haven’t gotten around to opening an issue for it though.
f

Frank

11/18/2021, 11:11 PM
Oh hmm… @Dan Coates can you show me how you are importing
config.ts
?
d

Dan Coates

11/18/2021, 11:40 PM
They are just standard
import config from './config'
style imports, nothing fancy or dynamic. That said, I actually can't replicate this right at the moment though it was happening consistently yesterday. I'll keep an eye on it and let you know if I get a clearer idea of when/why it is happening...
f

Frank

11/19/2021, 9:21 PM
Sounds good! I think it might know what the issue is. Was
config.ts
a newly added file?
Just opened an issue about this, see if this describe what u saw https://github.com/serverless-stack/serverless-stack/issues/1069
d

Dan Greaves

11/20/2021, 8:29 AM
@Frank I just tested in my project and that’s exactly what’s happening. If you add a new file while
sst start
is running, it doesn’t get watched. Also explains why @Dan Coates’s project suddenly didn’t have the issue (because he would have restarted
sst start
)!
d

Dan Coates

11/21/2021, 9:48 PM
Thanks @Frank for creating the issue. It is quite possible that my problem was the same as @Dan Greaves, it was pretty early stages for the project so was creating and moving around files a lot.
f

Frank

11/22/2021, 2:33 AM
Got it! Thanks for confirming guys!