opral / monorepo

lix (change control system) && inlang (globalization ecosystem for software built on lix)
https://opral.com
Apache License 2.0
1.23k stars 109 forks source link

Deploying to Vercel - did not recognize object of type "TSSatisfiesExpression" #843

Closed mschmdb closed 1 year ago

mschmdb commented 1 year ago

Problem

Inlang on sveltekit, works on localhost. When I commit my changes and push, the test-deployment on vercel exits with:

[11:13:15.922] Error: did not recognize object of type "TSSatisfiesExpression" 
[11:13:15.922]     at Object.tt (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:6:16430
[11:13:15.922]     at jd (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1117)
[11:13:15.922]     at jd (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1197)
[11:13:15.922]     at Rd (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1251)
[11:13:15.922]     at Rd (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
[11:13:15.922]     at Rd (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
[11:13:15.922]     at file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1715
[11:13:15.922]     at Array.forEach (<anonymous>)
[11:13:15.922]     at Ud (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1681)
[11:13:15.922]     at eo (file:///vercel/path0/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:78:1380)
[11:13:15.945] Error: Command "npm run build" exited with 1
[11:13:16.187] BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

Expected behavior

Build would succeed

Steps to reproduce

  1. Install
  2. Restart server
  3. commit

Additional information (screenshots?)

Packages: ├── @accuser/svelte-plausible-analytics@0.2.0 ├── @carbon/charts-svelte@1.6.14 ├── @carbon/charts@1.6.4 ├── @carbon/themes@11.18.0 ├── @floating-ui/dom@1.2.8 ├── @fortawesome/free-solid-svg-icons@6.4.0 ├── @inlang/sdk-js@0.6.1 ├── @playwright/test@1.34.3 ├── @skeletonlabs/skeleton@1.6.2 ├── @supabase/auth-helpers-sveltekit@0.8.7 ├── @supabase/supabase-js@2.23.0 ├── @sveltejs/adapter-auto@1.0.0-next.91 ├── @sveltejs/adapter-vercel@2.4.3 ├── @sveltejs/kit@1.19.0 ├── @tailwindcss/forms@0.5.3 ├── autoprefixer@10.4.14 ├── carbon-components@10.58.3 ├── d3@7.8.4 ├── dotenv@16.0.3 ├── postcss-load-config@4.0.1 ├── postcss-preset-env@7.8.3 ├── postcss-simple-vars@7.0.1 ├── postcss@8.4.23 ├── prettier-plugin-svelte@2.10.0 ├── prettier@2.8.8 ├── svelte-check@3.3.2 ├── svelte-fa@3.0.4 ├── svelte-local-storage-store@0.4.0 ├── svelte-multiselect@8.6.2 ├── svelte-preprocess@5.0.3 ├── svelte-seo@1.5.3 ├── svelte@3.59.1 ├── tailwindcss@3.3.2 ├── tslib@2.5.2 ├── typescript@5.0.4 ├── vite@4.3.8 └── vitest@0.29.8

ivanhofer commented 1 year ago

@mschmdb can you please build your application locally and share a screenshot of the code that throws the error? What node version are you using locally and what on vercel?

mschmdb commented 1 year ago

EDIT: Ah, ok I see. I have some Type Errors on /account/+page.server.ts. Will first try to solve them. @ivanhofer sure. node local: node v20.2.0 (npm v9.6.6) node vercel: 18.x

image
mschmdb commented 1 year ago

Ok @ivanhofer type errors from the mentioned page are removed. This is the error I now get when calling the route /account on localhost:

Internal server error: did not recognize object of type "TSSatisfiesExpression"
  Plugin: vite-plugin-inlang-sdk-js-sveltekit
  File: /Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/src/routes/account/+page.server.ts
      at Object.tt (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:6:16430)
      at jd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1117)
      at jd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1197)
      at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1251)
      at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
      at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
      at file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1715
      at Array.forEach (<anonymous>)
      at Ud (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1681)
      at eo (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:78:1380) (x3)
Error: did not recognize object of type "TSSatisfiesExpression"
    at Object.tt (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:6:16430)
    at jd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1117)
    at jd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1197)
    at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1251)
    at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
    at Rd (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1390)
    at file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1715
    at Array.forEach (<anonymous>)
    at Ud (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:74:1681)
    at eo (file:///Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/node_modules/@inlang/sdk-js/dist/adapter-sveltekit/index.js:78:1380) {
  plugin: 'vite-plugin-inlang-sdk-js-sveltekit',
  id: '/Users/matthiasschmidbauer/Sites/sv-sb-patscen-auth-2023-04/src/routes/account/+page.server.ts',
  pluginCode: "import { fail, redirect } from '@sveltejs/kit';\n" +
    "import type { Actions, PageServerLoad } from './$types';\n" +
    "import { supabaseClient } from '$lib/supabase';\n" +
    "import { deleteUser } from '$lib/supabaseAdmin';\n" +
    '\n' +
    '\n' +
    'export const load = (async ({ locals: { supabase, getSession } }) => {\n' +
    '    const session = await getSession();\n' +
    '\n' +
    '    if (!session) {\n' +
    "        throw redirect(303, '/');\n" +
    '    }\n' +
    '\n' +
    '    const { data: profile } = await supabaseClient\n' +
    "        .from('profiles')\n" +
    "        .select('firstname, lastname, email, company, newsletter')\n" +
    "        .eq('id', session.user.id)\n" +
    '        .limit(1)\n' +
    '        .single()\n' +
    '        \n' +
    '    console.log(session.user.id)\n' +
    '    console.log(JSON.stringify(profile))\n' +
    '    return { session, profile };\n' +
    '}) satisfies PageServerLoad;\n' +
    '\n' +
    'export const actions = {\n' +
    '    update: async ({ request, locals: { sb, getSession } }) => {\n' +
    '        const formData = await request.formData();\n' +
    "        const firstname = formData.get('firstname') as string;\n" +
    "        const lastname = formData.get('lastname') as string;\n" +
    "        const email = formData.get('email') as string;\n" +
    "        const company = formData.get('company') as string;\n" +
    "        const newsletter = formData.get('newsletter') === 'on' ? true : false;\n" +
    '        console.log("firstnamefrom form", firstname)\n' +
    '        console.log("newletterfrom form", newsletter)\n' +
    '        const session = await getSession();\n' +
    '\n' +
    "        const { error } = await sb.from('profiles').upsert({\n" +
    '            id: session?.user.id,\n' +
    '            firstname: firstname,\n' +
    '            lastname,\n' +
    '            newsletter,\n' +
    '            company,\n' +
    '\n' +
    '            updated_at: new Date()\n' +
    '        });\n' +
    '        console.log("error", error)\n' +
    '        if (error) {\n' +
    '            return fail(500, {\n' +
    '                firstname,\n' +
    '                lastname,\n' +
    '                email,\n' +
    '                company,\n' +
    '                newsletter\n' +
    '\n' +
    '            });\n' +
    '        }\n' +
    '        console.log("firstname", firstname)\n' +
    '        return {\n' +
    '            firstname,\n' +
    '            lastname,\n' +
    '            email,\n' +
    '            company,\n' +
    '            newsletter,\n' +
    '            success: true\n' +
    '        };\n' +
    '    },\n' +
    '    signout: async ({ locals: { sb, getSession } }) => {\n' +
    '        const session = await getSession();\n' +
    '        if (session) {\n' +
    '            console.log("signout")\n' +
    '            await sb.auth.signOut();\n' +
    "            throw redirect(303, '/');\n" +
    "            // goto ('/');\n" +
    '        }\n' +
    '    },\n' +
    '    deleteAccount: async ({ locals: { sb, getSession } }) => {\n' +
    '        const session = await getSession();\n' +
    '        if (!session) {\n' +
    "            throw redirect(303, '/');\n" +
    '        }\n' +
    '    \n' +
    "        // Delete user's profile from the database\n" +
    "        await sb.from('profiles').delete().eq('id', session.user.id);\n" +
    '    \n' +
    "        // Delete user's account using the deleteUser function\n" +
    '        try {\n' +
    '          await deleteUser(session.user.id);\n' +
    '        } catch (error) {\n' +
    "        //   return fail(500, 'Failed to delete user account');\n" +
    '        }\n' +
    '    \n' +
    '        // Sign the user out\n' +
    '        await sb.auth.signOut();\n' +
    "        throw redirect(303, '/');\n" +
    '    }\n' +
    '\n' +
    '   \n' +
    '} satisfies Actions;\n' +
    '\n'
}
ivanhofer commented 1 year ago

@mschmdb is the repo open source? Can you share a link to it?

mschmdb commented 1 year ago

@ivanhofer unfortunately not. Compliance stuff...

ivanhofer commented 1 year ago

Can you create a small repository where I can reproduce the issue?

mschmdb commented 1 year ago

@ivanhofer not needed anymore. problem was with satisfies in the code. Just deleted it, now the route is running & vercel deployment. Sorry for wasting your time, but thx for all your contribution & work.

ivanhofer commented 1 year ago

Could you please share the code snippet you have used previously? Someone will probalby run into the same issue in the future if we don't address it.

mschmdb commented 1 year ago

sure.

Previously used:

export const actions = {
//your action
} satisfies Actions;

Now correctly using:

export const actions = {
//your action
};
moonvader commented 1 year ago

have the same problem on local environment

Internal server error: did not recognize object of type "TSSatisfiesExpression"
  Plugin: vite-plugin-inlang-sdk-js-sveltekit
ivanhofer commented 1 year ago

@moonvader if you can, just remove satisfies in your code until we fix the issue. SvelteKit is able to offer full typesafety for it's built-in feature-set: https://svelte.dev/blog/zero-config-type-safety

moonvader commented 1 year ago

Could you please advise me where this satisfies is located?

ivanhofer commented 1 year ago

Could you please advise me where this satisfies is located?

I don't know your code base. CTRL + F and search for satisfies

moonvader commented 1 year ago

@ivanhofer thank you, I got some progress but translation still not working. I started separate issue with all the details and steps taken.

jannesblobel commented 1 year ago

Unfortunately, Ivan has passed away, and we are trying to find a solution. I will close this issue as not planned for now when we have a solution.