sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.07k stars 118 forks source link

`sst init` breaks fresh SvelteKit/TypeScript project #509

Closed debashisbiswas closed 2 weeks ago

debashisbiswas commented 3 weeks ago

Steps to reproduce:

import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
        // Consult https://kit.svelte.dev/docs/integrations#preprocessors
        // for more information about preprocessors
        preprocess: vitePreprocess(),

        kit: {
                // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
                // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
                // See https://kit.svelte.dev/docs/adapters for more information about adapters.
                adapter: adapter()
        }
};

export default config;
import adapter from "svelte-kit-sst";

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter(),
  },
};

export default config;
12:42:20 AM [vite] Pre-transform error: /home/almia/dev/sst-svelte/src/routes/Counter.svelte:10:18 Unexpected token
12:42:20 AM [vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "/src/routes/Counter.svelte"
|-

{
  name: 'ParseError',
  id: '/home/almia/dev/sst-svelte/src/routes/Counter.svelte',
  message: '/home/almia/dev/sst-svelte/src/routes/Counter.svelte:10:18 Unexpected token',
  frame: '  8 |    $: offset = modulo($displayed_count, 1);\n' +
    '  9 |  \n' +
    ' 10 |    function modulo(n: number, m: number) {\n' +
    '                          ^\n' +
    ' 11 |      // handle negative numbers\n' +
    ' 12 |      return ((n % m) + m) % m;',
  code: 'parse-error',
  stack: '',
  loc: {
    line: 10,
    column: 18,
    file: '/home/almia/dev/sst-svelte/src/routes/Counter.svelte'
  },
  plugin: 'vite-plugin-svelte',
...

This error is not observed in the SvelteKit with TypeScript example in the repo at examples/aws-svelte-kit because even though the project is configured with TypeScript, no TypeScript syntax is used.

thdxr commented 3 weeks ago

i think we need to consider not modifying the config and instead printing our instructions on how to add the adapter

thdxr commented 2 weeks ago

as of v0.0.408 we stopped modifying the config and instead print out instructions