Next.js: [i18n] missing SSG index pages from next dist with i18n

Created on 12 Nov 2020  路  4Comments  路  Source: vercel/next.js

Bug report

In a Next 10 app using i18n and target: serverless, Next does not seem to generate prerendered html _specifically_ for index routes.

Describe the bug

In a Next 9.x app (or Next 10 app not using i18n) using target: serverless, Next generates prerendered html for pages/index.js which can be found at .next/serverless/pages/index.html. Now, in Next 10 with i18n, Next puts its prerendered html in directories for each locale aka .next/serverless/pages/{locale}/page.html. However, it seems to omit index.js/index.html in this process.

Note: this may be similar to or a duplicate of https://github.com/vercel/next.js/issues/19095 and possibly resolved by https://github.com/vercel/next.js/pull/19116/files but not sure if that's (optional) catch-all specific

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Use getStaticProps in pages/index.js
  2. next.config.js should have i18n with locales and defaultLocale and target: serverless
  3. next build
  4. inspect .next/serverless/pages and see no prerendered index.html anywhere

Expected behavior

Use getStaticProps in pages/index.js with i18n and target:serverless and have Next generate prerendered html somewhere in .next/serverless/pages

System information

  • OS: macOS 10.15.4
  • Version of Next.js: 10.0.0
  • Version of Node.js: 14.12.0

Additional context

Add any other context about the problem here.

bug

All 4 comments

Could you try next@canary? This issue may already have been resolved.

@rokinsky
still an issue in canary
you can see in the tree under .next that there's no prerendered index.html

Screen Shot 2020-11-13 at 12 02 41 PM

馃 but is index.js becoming es.html and en.html..? i dont know why i didnt consider that before right now.. @rokinsky

edit: yeah, it is. that said, should it be? 馃

tangentially related:

a static SSG route i.e. pages/getStaticProps/static.js with i18n and target: serverless gets generated into .next as ->

.next/serverless/pages/getStaticProps/static.js
.next/serverless/pages/en/getStaticProps/static.html
.next/serverless/pages/es/getStaticProps/static.json

_but_

the prerender-manifest says the dataRoute for getStaticProps/static is /_next/data/{BUILD_ID}/getStaticProps/static.json. dynamic routes have the locale in their dataRoute i.e. /data/{BUILD_ID}/en/getStaticProps/withFallback/3.json. the internals behind i18n seem to be very confusing. why does the prerender-manifest only show static routes once (without the locales) whereas dynamic routes have the locale pre-included? this is causing static routes to have incorrect dataRoutes depending on their locale.

Was this page helpful?
0 / 5 - 0 ratings