This is likely a dumb question but here’s to becom...
# sst
c
This is likely a dumb question but here’s to becoming less dumb - I’ve noticed I can import various
aws-cdk
packages in a stack (e.g.
@aws-cdk/aws-events
) and have been able to successfully run and build the stack without having to install these packages first in the project. Is this ok, or should they be listed in the project’s package.json? And if so, is it ok for them to be devDependencies only?
t
I usually don't add it because I'm lazy. Sst implicitly depends on those packages so they get installed anyway
d
This is not specific to sst, more of a node thing, but... Any package that is listed as a dependency of installed packages (not dev or peer), will be available to you. I would recommend installing them directly in most cases so that things like intellisense work better, and you have direct control over the version.
And if so, is it ok for them to be devDependencies only?
I generally go devDependencies for all infrastructure related stuff, like sst and cdk and save the dependencies for things inside lambdas and such.
c
Perfect. Thank you guys
t
SST doesn't work with yarn2pnp or pnpm but this is one of the things that breaks under those systems. They do not allow importing dependencies of dependencies without them being listed in your package
c
@thdxr if you do install these directly, as Derek mentioned, will there be any version conflicts to what SST uses or expects under the hood?
t
You need to install the exact version that sst needs
Which is the main reason why I don't add them, annoying to deal with that
THere is a heper function in sst
sst add-cdk @aws-cdk/aws-events
which should add the right version
c
Gotcha, thanks
d
sst update
also works on installed packages in my experience
t
I added
sst update
because I found this particularly annoying haha
d
Thats the good kind of "lazy". 🙂
c
Derek, do you mean if you manually install them with the
sst add-cdk
helper first
sst update
keeps everything in sync afterward?
d
the first part is not a requirement, you can add it however you want
b
I tell my team to always explicitly include dependencies. If you import it, your package.json should depend on it - imho.
keeps projects much more portable