<@U01JVDKASAC> When building a construct, assuming...
# sst
d
@Frank When building a construct, assuming one that could be added to SST, is there a way to use
sst.Function
where you reference the assets using
path
like you guys do with
lambda.Function
? Just trying to envision portability of a custom construct.
t
This pattern actually breaks for the next gen pnp package managers
Cdk does it everywhere which is why it can't be used with pnpm or yarn2 with the pnp linker
f
Hey @Dan Van Brunt including an asset directory is not supported, but it often works if you set the handler in
sst.Function
in the same fashion. Are you concerned that the custom resource code might not be compatible with esbuild?
d
Likely just over thinking it. But if it ends up in a node modules folder as a module this relative links won't work. And can't see how to use path since the SST.Function ends in the handler name.
f
You probably don’t need to use
path
and
__dirname
. Just point
handler
to ie.
path/to/custom/resource/lambda.handler
should work?
d
Yes but does that still work as a npm?
f
Ah gotcha. I see what u mean now 🤔
d
Are you guys compiling your code before npm publish?
f
Yeah compiling ts to js
@Dan Van Brunt Sorry for the late follow up. Are you guys blocked by this?
d
@Frank Not at the moment no… just hardcoding the url and the constructs are just including in the same repo (not npm) but before launch we would like to manage them separately as npm’s
Currently blocked by this now @Frank, Just need to think of a way to create sst extending constructs in our own lib and figure out how to get them internally to reference assets via
handler
So far, all I can think of is to NOT use SST for our custom lib constructs and instead use cdk directly. Just be nice if there was a way to get this to work.
I think I’m going to just use cdk.Function to solve the issue. 😄
I’m not sure I fully grasp the issue either. Like, would it not work to simply include the assets folder into our lib? Oh… I guess the issue is that sst.Function.handler is relative of the sst.json ? hmmmm. Ya, wish there was a fix for this
f
Hey @Dan Van Brunt, I’m working on a RDS construct, and it has an
sst.Function
that has
srcPath
and
handler
pointing to an asset folder inside
node_modules/@serverless-stack/resources
instead of user’s project folder where sst.json sits.
^ it’s not clean, but works
d
Oh nice, I’ll def give that a try. Thanks!