I’m running into a weird tsconfig issue (related t...
# help
s
I’m running into a weird tsconfig issue (related to what we just talked about w/ restructuring the project, @thdxr) in my
src/lambda
folder (which is a workspace/subpackage), I have this tsconfig:
Copy code
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "$core/*": ["../core/*"],
      "$libs/*": ["./libs/*"],
      "$types/*": ["./types/*"]
    },
  }
}
this works perfectly fine, so anywhere in lambda/* I can do
import { blah } from '$libs/whatever'
. at least, VS Code says it’s fine and it resolves.. but when I do `yarn build`:
Copy code
src/lambda/graphql/mutations/update-transcoding-status.ts:2:31 - error TS2307: Cannot find module '$libs/db' or its corresponding type declarations.

2 import { dataApi, knex } from '$libs/db';
how do I resolve this?
basically it seems like
yarn build
is ignoring the fact that
src/lambda
has its own tsconfig and is telling how to resolve path aliases
for now, I just added this to the root level tsconfig, though this isn’t ideal since paths have to be maintained in two places
Copy code
"$core/*": ["src/core/*"],
      "$libs/*": ["src/lambda/libs/*"],
      "$types/*": ["src/lambda/types/*"]
t
running yarn build in root?
s
yeppers
yarn build/start/deploy
etc
t
tsconfig is unaware of yarn workspaces, it has its own thing called
references
that maybe is the issue
any reason you're running yarn build in root?
s
isn’t that where it’s supposed to be? at root level is sst.json pointing to the entry file
infra/index.ts
that’s what the docs say to do
t
Ah, but the root tsconfig shouldn't include anything but
infra
s
ahhhhh
of course. the default tsconfig in new SST projects isn’t meant for monorepos. makes sense
omg man, it finally built 🙌
Copy code
Successfully compiled 3 stacks to .build/cdk.out:

  dev-microservices-core
  dev-microservices-api
  dev-microservices-media-processor
is it normal to have all thees
.build
folders? only
src/lambda
is ever used as a
srcPath
Copy code
./src/lambda/.build
./src/lambda/auth/.build
./src/lambda/graphql/.build
./src/lambda/media-processor/.build
./src/lambda/rest/.build
t
are those leftover from before maybe?
s
I don’t think so. I’m deploying now ,but afterwards I’ll remove those & do a
yarn build
and see if they show up
they might be from before
yyyep! just leftovers. now when I build, I just get
.build
and
src/lambda/.build