Hi everyone. So, I have a monorepo project using ...
# help
e
Hi everyone. So, I have a monorepo project using Lerna and yarn workspaces with typescript. I want to use sst to develop the rest api and any other serverless requirements. I started simple, using
npx create-serverless-stack@latest my-sst-app --language typescript
. And treating this as one of the packages of the monorepo. The problem begins when I try to use other packages from my monorepo to develop something. I have two packages:
rest-api
this is the sst package
@temis/utils
this is another typescript package Inside
rest-api
I do a
yarn add @temis/utils
in order to use this package as a dependency, and develop some logic. So, I run
yarn build
inside
@temis/utils
and builds successfully. Then I run the same in
rest-api
and when its linting the code, this happens:
Copy code
.../dist/validator/index.js
   3:7    error    Unexpected dangling '_' in '__createBinding'                                                                                                                           no-underscore-dangle
   4:12   error    Unexpected dangling '_' in '__createBinding'                                                                                                                           no-underscore-dangle
   6:7    warning  Unexpected unnamed function                                                                                                                                            func-names
   7:31   error    Assignment to function parameter 'k2'
.........
There was a problem linting the source.
There was an error synthesizing your app.
Note that the sst package is trying to lint the compiled code from
@temis/utils
(using the dist folder: dist/validator/index.js). The tsconfig in
@temis/utils
is simple:
Copy code
{
  "compilerOptions": {
    "declarationMap": false,
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "outDir": "./dist",
    "rootDir": "./src"
  }
}
And the tsconfig in the sst package is the default one, I haven't touched it so far:
Copy code
{
  "compilerOptions": {
    "target": "ES2018",
    "module": "commonjs",
    "lib": [
      "es2018",
      "dom"
    ],
    "types": [
      "node"
    ],
    "declaration": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    "sourceMap": true,
    "baseUrl": ".",
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": [
    "lib",
    "src"
  ]
}
So, anyone has faced this problem before? Maybe its related to some typescript specific config that I don't know yet. I fairly new using typescript. Thank you in advance
f
Hey @Enrique Santeliz, that’s weird.. we use yarn workspaces as well.
j
Hmm I don't think this should be TS related. SST configures ESLint to run inside the directory it is called from. So it is strange that the
dist/
folder is getting picked up. Where are you running
yarn build
from? Is the
.../dist/validator/index.js
make sense? Is your
dist/
folder above the where the
rest-api
is?
e
Sorry, I added the "..." on purpose. Their level is this: packages/ utils/ services/ rest-api/ Both
packages
and
services
are the workspaces containing TS projects
Well, I read this https://serverless-stack.slack.com/archives/C01HQQVC8TH/p1613416397066500 . Updated the version to the latest, added
lint: false
and this fixed the issue đŸ™‚
j
Yeah it'll turn it off for now. But we should try and fix this. When you get a chance can you create a sample repo and we'll try and resolve it.
e
Sure, no problem