thgh / vercel-sapper

Vercel builder for Sapper with SSR enabled
MIT License
189 stars 25 forks source link

not support typescript in vercel function? #59

Closed Kilerd closed 3 years ago

Kilerd commented 3 years ago

I use typescript in my sapper project, and of cause I use some typescript syntax, like question mark syntax.

after deploying to vercel, the vercel-sapper function raise 502 because of the question mark syntax. the log is

2020-11-19T16:21:51.267Z    undefined   ERROR   Server is not listening /var/task/__sapper__/build/server/server.js:1828
        accountList = currentEntry?.accounts.map((account, index) => {
                                   ^
SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/var/task/launcher.js:20:14)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
RequestId: c967d75d-4677-47af-bcda-fbd4148466d1 Error: Runtime exited with error: exit status 1
Runtime.ExitError

it seems that typescript code is not translated to javascript, so the vercel-sapper function cannot recognize my typescript code ?

thgh commented 3 years ago

The typescript plugin in the rollup config should transform that syntax.

It seems to work when I do this:

npx vercel-sapper tstest
cd tstest
node scripts/setupTypeScript.js
# remove successkid import
# add `console.log(dev?.test)` to server.ts
vercel
Kilerd commented 3 years ago

my mistake, I just forgot to add lang="ts" in the svelte component. it works after adding the lang tag.