yassinedoghri / astro-i18next

An astro integration of i18next + some utility components to help you translate your astro websites!
https://astro-i18next.yassinedoghri.com
MIT License
473 stars 33 forks source link

Error when evaluating SSR module #160

Open do-web opened 1 year ago

do-web commented 1 year ago

Describe the bug

It seams the bug is coming from astro-i18next/src/components/index.ts

8:57:26 PM [vite] Error when evaluating SSR module /node_modules/astro/astro.js:
|- SyntaxError: Invalid or unexpected token
    at new AsyncFunction (<anonymous>)
    at instantiateModule (/Private/astro/node_modules/vite/dist/node/chunks/dep-24daf00c.js:54348:28)

8:57:26 PM [vite] Error when evaluating SSR module /node_modules/astro-i18next/src/components/Trans.astro: failed to import "/node_modules/astro/astro.js"
|- SyntaxError: Invalid or unexpected token
    at new AsyncFunction (<anonymous>)
    at instantiateModule (/Private/astro/node_modules/vite/dist/node/chunks/dep-24daf00c.js:54348:28)

8:57:26 PM [vite] Error when evaluating SSR module /node_modules/astro-i18next/src/components/index.ts: failed to import "/node_modules/astro-i18next/src/components/Trans.astro"
|- SyntaxError: Invalid or unexpected token
    at new AsyncFunction (<anonymous>)
    at instantiateModule (/Private/astro/node_modules/vite/dist/node/chunks/dep-24daf00c.js:54348:28)

8:57:26 PM [vite] Error when evaluating SSR module /src/layouts/Layout.astro: failed to import "/node_modules/astro-i18next/src/components/index.ts"
|- SyntaxError: Invalid or unexpected token
    at new AsyncFunction (<anonymous>)
    at instantiateModule (/Private/astro/node_modules/vite/dist/node/chunks/dep-24daf00c.js:54348:28)

My config:

const config: AstroI18nextConfig = {
  defaultLocale: "en",
  locales: ["en", "de"],
  load: ["server", "client"],
  i18nextServer: {
    debug: false,
    backend: {
      loadPath: './public/locales/{lng}.json',
      addPath: '/locales/{lng}/{ns}.missing.json',
    },
    interpolation: {
      prefix: "{",
      suffix: "}",
    }
  },
  i18nextClient: {
    debug: false,
    backend: {
      loadPath: '/locales/{lng}.json',
      addPath: '/locales/{lng}/{ns}.missing.json',
    },
    interpolation: {
      prefix: "{",
      suffix: "}",
    }
  }
};
williamsjokvist commented 1 year ago

I got the same issue and downgrading Astro doesn't seem to help. I've tried building old commits which built successfully before as well, maybe a Vite update is causing this?

do-web commented 1 year ago

I dont know, actually i have not made any update. what exactly did you do to make it work again?

do-web commented 1 year ago

I downgraded to astro 2.2.2 so its not working with astro 2.3.0. Maybe @yassinedoghri can fix this?

williamsjokvist commented 1 year ago

Downgrading Astro to 2.1.3 made it work for me!