jlarmstrongiv / astro-i18n-aut

The i18n integration for Astro 🧑‍🚀
https://www.npmjs.com/package/astro-i18n-aut
MIT License
132 stars 12 forks source link

The translation pages take a very long time to build #39

Closed tiwka19 closed 8 months ago

tiwka19 commented 11 months ago

On dynamic pages ( such as blog ) I send graphql query to get data in different languages. It looks something like this

export async function getStaticPaths({ paginate }) {
  const directus = await getDirectusClient();
  const data = await directus.query(`
    query {  
      posts (
        filter: { 
          translations: {content: {_null: false}} 
          status: {_eq: "published"}} 
          sort: ["-date_created"]
        ){ 
        slug 
      } 
    }
  `);
  return paginate(data.posts, { pageSize: 12 });
}

And this is how long it takes to build. Why does the default language take several times less time to build than ru?

13:09:51 ▶ src/astro_tmp_pages_en/blog/[slug].astro 13:09:52 └─ /en/blog/how-to-use-cookies-bot.html (+4ms) 13:09:52 ▶ src/astro_tmp_pages_ru/blog/[slug].astro 13:09:56 └─ /ru/blog/how-to-use-cookies-bot.html (+2.55s)

jlarmstrongiv commented 11 months ago

Please only keep pages in your pages folder. If you add images, components, test files, etc. in the pages folder, then the build will be very slow.

For translations, astro-i18n-aut has to write files to disk due to an Astro core bug where injectRoute cannot be used with the same entryPoint Astro files. Unfortunately, any operation that has to write to the file system will always be slower.

tiwka19 commented 11 months ago

Please only keep pages in your pages folder. If you add images, components, test files, etc. in the pages folder, then the build will be very slow.

For translations, astro-i18n-aut has to write files to disk due to an Astro core bug where injectRoute cannot be used with the same entryPoint Astro files. Unfortunately, any operation that has to write to the file system will always be slower.

I only keep pages in the pages folder. It's just very strange that I request both en language and ru language from the server, but there is such a huge time difference

jlarmstrongiv commented 11 months ago

@tiwka19 it is strange that it would be slower after being deployed. It should only be slower during build

Would you send me two live website links to compare and which platform you are deploying on? Do you have a public GitHub repo by chance?

tiwka19 commented 11 months ago

@tiwka19 it is strange that it would be slower after being deployed. It should only be slower during build

Would you send me two live website links to compare and which platform you are deploying on? Do you have a public GitHub repo by chance?

I take the data from directus. My entire site is SSG. It's about the build time. I just don't understand why there is such a time difference if both languages are taken by API. Unfortunately, I cannot provide the source code. I can show code snippets of dynamic pages

tiwka19 commented 11 months ago

@tiwka19 it is strange that it would be slower after being deployed. It should only be slower during build

Would you send me two live website links to compare and which platform you are deploying on? Do you have a public GitHub repo by chance?

Duration~8 mins. 54 secs. That's how long it takes to build a website. And that's only in two languages. And in the future I will have about 6. 0_0

tiwka19 commented 11 months ago

en ru look at the difference

jlarmstrongiv commented 11 months ago

After chatting with @natemoo-re, we believe it’s a core Astro issue with injectRoute. I’m not sure where to go from here, so feel free to open an issue in Astro core

tiwka19 commented 11 months ago

After chatting with @natemoo-re, we believe it’s a core Astro issue with injectRoute. I’m not sure where to go from here, so feel free to open an issue in Astro core

So problem persists if use official i18 integration from astro?

jlarmstrongiv commented 11 months ago

@tiwka19 unfortunately, I do not know how the official integration works

jlarmstrongiv commented 11 months ago

@tiwka19 did you create an issue in the Astro core repository?