astro-i18next icon indicating copy to clipboard operation
astro-i18next copied to clipboard

Add Support & Testing for Cloudflare Workers SSR

Open L1lith opened this issue 2 years ago • 11 comments

L1lith avatar Nov 18 '22 18:11 L1lith

Hi @yassinedoghri , would this be possible for edge deploying? e.g Netlify/Vercel edge

fprl avatar Nov 28 '22 07:11 fprl

Hey @francoromanol, I'm hoping to figure it out at some point, I have set up an example with Netlify but it doesn't seem to be working.

image

Also, there's an issue on that matter (https://github.com/yassinedoghri/astro-i18next/issues/26)

I'm currently focused on getting features out during my spare time. If anyone has an idea on how to fix that, I'm all ears.

yassinedoghri avatar Nov 30 '22 10:11 yassinedoghri

Hey @yassinedoghri thanks for answering! I will try to check it out too. I also noticed I can't deploy to vercel/serverless since 1.0.0-beta.13:

14:40:25 [build] Rearranging server assets...
[@astrojs/vercel] The module "pnpapi" inside the file "/Users/me/me/Work/project/node_modules/esbuild/lib/main.js" couldn't be resolved. This may not be a problem, but it's worth checking.
 error   Failed to parse /Users/me/me/Work/project/node_modules/esbuild-darwin-arm64/bin/esbuild as script:
  Unexpected character '�' (1:0)

Do you know what could be happening?

fprl avatar Nov 30 '22 13:11 fprl

Do you know what could be happening?

Sorry, no clue with that error message.


So, you were able to deploy prior to v1.0.0-beta.13... 🤔 That means it's probably got something to do with the recent changes.

As a start, I'll setup examples for Vercel and Cloudflare (which will probably not work but it'll help debugging I guess).

yassinedoghri avatar Nov 30 '22 15:11 yassinedoghri

Yes, just tested it again. Okay, I will check everything again and ask in Vercel about this error.

fprl avatar Nov 30 '22 17:11 fprl

Hi Yassine,

I created a discussion at Vercel, I'm not really sure if v1.0.0-beta.13 changes introduce this TS problem, but it may be worth to check.

fprl avatar Dec 02 '22 09:12 fprl

Hey @yassinedoghri,

I forked the repo to contribute to this problem, but I never developed an Astro plugin — though reading the codebase is clear how it works —, how can I test the packages once I changed the code?

I see there is a build command which creates the dist directory, but if I import it from an astro.config file it yields an error

// examples/vercel/astro.config.mjs
import astroI18next from "../../dist/";

What am I doing wrong?

Thanks

fprl avatar Dec 02 '22 17:12 fprl

Hey @francoromanol,

No need to import the dist directory, I think the import looks for the package.json file where imports are specified. So I think you can just import the folder like so:

// examples/vercel/astro.config.mjs
import astroI18next from "../..";

Haven't tried it though. I usually define the local astro-i18next as a dependency with file:../... And I have yet to figure the best way to test these locally 😅

yassinedoghri avatar Dec 03 '22 13:12 yassinedoghri

Hi @yassinedoghri,

Thanks, I finally made it. I will take a look and let you know if I find something :)

fprl avatar Dec 03 '22 17:12 fprl

Hi again,

I track this the vercel error to commit ea939db76114ed0ffb5efec452d6fcfaefe8962c: feat: add option to show the default locale in the url (https://github.com/yassinedoghri/astro-i18next/pull/51)

I will try my best to find the change that created this issue.

Cheers!

fprl avatar Dec 04 '22 18:12 fprl

Okay, I found the line:

// src/index.ts
100        // initializing runtime astro-i18next config
101          serverImports += `import {initAstroI18next} from "astro-i18next";`;

I assume this is the - initialize astro-i18next config and to make it available at runtime mentioned in the PR.

I tested injecting the three scripts alone: imports, i18nextInit, astroi18nextInit and it only failed with serverImports when line 101 is defined.

106        injectScript("page-ssr", serverImports);

Any thoughts on this? Maybe it's the way of importing it?

fprl avatar Dec 04 '22 19:12 fprl