hey guys! (<@U01JVDKASAC> <@U01J5Q8HV5Z> <@U01MV4U...
# help
j
hey guys! (@Frank @Jay @thdxr) 1 - I’m making a clear separation between my
dependencies
and my
devDependencies
, but on of my dev dependencies, even though it’s not a dependency of any of the dependencies, it’s going to the deployed lambda…is that expected? 2 - is there tree-shaking when deploying the lambdas?
t
Yes we use esbuild underneath to treeshake. There's actually nothing super special about
dependencies
vs
devDependencies
- only used by npm to skip installation in certain scenarios
What is the dependency you're seeing bundled?
j
the two dependencies are
tsoa
(dev dependency only - should only be used for the build process, similar to @types/*** stuff) and
@tsoa/runtime
(that actually needs to be deployed to the lambda)
by definition, devDependencies are only used during development (do not go into the build)
t
Yeah I meant tooling doesn't pay much attention to the difference between the two. So when you inspect the bundle you're seeing
tsoa
included?
j
yeah - I’m seeing
@tsoa/cli
, which is a dependency of
tsoa
but, conceptually speaking, shouldn’t the tooling follow the principle of not deploying
devDependencies
to the bundle?
t
It's up to the user to categorize it so it's not reliable to understand if something is actually referenced. Eg I can add something to devDependency but reference it at runtime and be confused why my bundle is broken in production. Also something can be included in
dependencies
but not actually needed for a certain function What I would try is running esbuild manually like this:
Copy code
./node_modules/.bin/esbuild --minify --metafile=meta.json --outfile=output.js --platform=node --bundle ./src/functions/router.ts
Then checking meta.json for
@tsoa/cli
and it can help you trace where it's from
j
sure - I can understand the possible confusion, but by definition, if you reference a devDependency in runtime, that should actually break - it’s a feature, not a bug 😄
t
Yeah this is an npm/node thing. I've always categorized my dependencies intentionally....but it actually does almost nothing so I question why I bother
Oh wow looks like esbuild 0.12.26 has a built in analysis tool
--analyze=verbose
j
@thdxr thanks man - I think the meta.json gave me some hints why it’s deploying it with the bundle
would be to large to describe here, but it deals with how typescript and tsoa all ties together
thanks!!
for some reason, when I call my lambda, instead of going to the correct handler, it’s calling the
tsoa spec generator
giving me this error:
Copy code
2021-10-11T08:56:17.709+13:00

Copy
2021-10-10T19:56:17.708Z	undefined	ERROR	Usage: index.js <command> [options]

Commands:
  index.js spec                Generate OpenAPI spec
  index.js swagger             Generate OpenAPI spec
  index.js routes              Generate routes
  index.js spec-and-routes     Generate OpenAPI spec and routes
  index.js swagger-and-routes  Generate OpenAPI spec and routes

Options:
  --version   Show version number                                      [boolean]
  --help, -h  Show help                                                [boolean]
2021-10-10T19:56:17.708Z undefined ERROR Usage: index.js <command> [options] Commands: index.js spec Generate OpenAPI spec index.js swagger Generate OpenAPI spec index.js routes Generate routes index.js spec-and-routes Generate OpenAPI spec and routes index.js swagger-and-routes Generate OpenAPI spec and routes Options: --version Show version number [boolean] --help, -h Show help [boolean]
so that’s why I was trying to take that out of my bundle…but now I see I can’t - but at the same time, it shouldn’t call the spec generator, but should call my handler
t
I actually have a tool that does something similar to TSOA but for JSONAPI and I realized I had a similar issue. Accidentally bundling all the codegen tooling not needed at runtime
j
@thdxr anyway to pass different params to esbuild when using sst?
oooh this is actually a bug in `tsoa`: https://github.com/lukeautry/tsoa/issues/1069