Hi, I'm blocked deploying my app to Seed. It's a l...
# seed
s
Hi, I'm blocked deploying my app to Seed. It's a lerna / ts / monorepo > it's not able to resolve an internal package consumed by other packages. Unsure on how to proceed. Any help debugging would be much appreciated.
Error msg is unclear it's
---------
- have a feeling I may be missing something on my side.
f
Hey @Sam Frampton,
@outflo/types
is another package in the workspace?
o
I ran into a similar issue where adding an internal package to the package.json next to sst.json meant that esbuild would think it’s a transpiled node_module and not transpile that package
I got around it by taking that dependency out of that package.json and creating a package for each set of handlers in a stack, which listed the internal package as a dependency
s
Hi @Frank yeah outflo/types is another package in the workspace > that is listed in each other package package.json file.
Hey @Omi Chowdhury - thanks for the tip I'll give it a try. So I'm 100% on same wave length you created a package.json for handle? Is it possible to share a small example of your setup/file structure as I can't quite envision it in my head 😅
@Frank @Omi Chowdhury - sample of my setup. Each package has it's own package.json. Each package has their own stack.
o
Sure:
Copy code
libs/
  cool-shared-utils/
    package.json <-- #1
    index.ts
sst/
  sst.json
  package.json <-- #2
  index.ts <-- sst's index.json
  stacks/
    auth.ts <-- uses to src: "code/auth-handlers/..."
    user.ts
  code/
    auth-handlers/
      login.ts
      logout.ts
      package.json <-- #3
    user-handlers/
      create.ts
      delete.ts
      package.json <-- #4
#3 and #4 have a dependency on #1, but not #2 (I need to have this in a snippet or something)
Usually handler files have very little in them, they just call out to a “command” somewhere in libs that does the real work. TBH the only reason we have this structure is because we need to support both SLS and sst in the same app simultaneously
Otherwise I’d just have sst.json at the top level, like in the typescript monorepo starter that Dax published
s
Hmm, so I followed that setup closely from memory. I have
sst.json
at the root level.
Copy code
sst.json
package.json // workspace dependencies 
yarn.lock
seed.yml
tsconfig.json
lerna.json
scripts/
  workspace/ => lerna cmds
  packages/ => package level
stacks/ 
  service1Stack.ts
  service2Stack.ts
  service3Stack.ts 
  ....
packages/ 
  service1/ 
    tsconfig
    package.json
    .eslintrc 
    src/ 
      core/
      routes/ => // file imported to stack routes 
      types/  
   service2/
   service3/ 
   ....
Fyi I was able to resolve this issue - I moved types into a separate folder and removed package.json / tsconfig and just created a module / path alias to other packages. If anyone comes across thread like so:
Copy code
"paths": {
      "@outflo/types": ["../../types"]
 }
I also needed to update jest config as jest won't read tsconfig paths
Copy code
moduleNameMapper: {
    '^@outflo/types$': '<rootDir>/../../types'
  },