Never saw this SST error before… `Error: Cannot fi...
# help
d
Never saw this SST error before…
Error: Cannot find a "tsconfig.json" in the function's srcPath
t
Weird hm
d
one odd thing is that there seems to be TWO
.build
folders being created…
FYI, I made this change to
tsconfig.json
Copy code
{  
  "compilerOptions": {
    "typeRoots": ["./src/_types", "./node_modules/@types"],
  },
  "extends": "@tsconfig/node14",
  "include": ["stacks", "src"],
}
Want to see anything else @thdxr? I also removed the eslint config from the package.json in favor of
.eslintrc.js
Copy code
module.exports = {
  root: true,
  extends: [
    'serverless-stack',
    'eslint:recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier',
    'plugin:prettier/recommended'
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 2019,
    sourceType: 'module',
    tsconfigRootDir: __dirname,
    project: './tsconfig.json',
    files: '*.ts'
  },
  rules: {
    '@typescript-eslint/no-floating-promises': ['error'],
    '@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }]
  }
}
hmmmmm I wonder if that
tsconfigRootDir: __dirname,
is the issue? thought I had this working before though.
so narrowed down that the
sst.Api
code was doing it…. where as I also have two other
sst.Function
s that are working/building fine
t
I actually just rewrote all of this so I don't think this situation can happen anymore
d
just widdled down the above to this and it works.
Copy code
const api = new sst.Api(this, 'Api', {
      routes: {
        'GET /githubwebhook': 'src/githubwebhook.handler',
      },
    })
but this fails…
t
So the issue is "srcPath" is basically signifying what is your "project root"
Specifying
srcPath
sets that to your project root and all builds happen relative from there (which is why you get another .build) folder
I in the next version it's fixed so you don't get another build folder and also you don't necessarily need another tsconfig in your srcPath
but you probably should place one there
d
hmmm but why would these be any different….
Copy code
new sst.Api(this, 'Api', {
  routes: {
    'GET /githubwebhook': `src/githubwebhook.handler`
  }
}

new sst.Api(this, 'Api', {
  routes: {
    'GET /githubwebhook': {
      function: {
        srcPath: 'src/',
        handler: 'githubwebhook.handler',
      }
    }
  }
}
should I just be doing this?
Copy code
new sst.Api(this, 'Api', {
  routes: {
    'GET /githubwebhook': {
      function: {
        handler: 'src/githubwebhook.handler',
      }
    }
  }
}
ya that worked.
t
srcPath is what makes it different, it shouldn't be used if you just want a prefix on the handler path
we probably need a better name for it
projectRoot or something
d
kk…. my bad. sorry bout that
t
np I went through the exact same thing as you initially
d
just for your information I had the same issue... now that I fully read the documentation I understand the thing is that an example set me on a wrong path... for sure better naming would help