From 23935e544f9aae729ecf0ad589d9918738556573 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 12 Oct 2020 17:16:52 -0500 Subject: [PATCH 1/3] Add i18n items to routes manifest --- packages/next/build/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 1ddb4f3d3c98..e6542fe97d2a 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -306,6 +306,15 @@ export default async function build( dataRouteRegex: string namedDataRouteRegex?: string }> + i18n?: { + locales: string[] + defaultLocale: string[] + domains: Array<{ + domain: string + defaultLocale: string + locales: string[] + }> + } } = { version: 3, pages404: true, @@ -325,6 +334,7 @@ export default async function build( } }), dataRoutes: [], + i18n: config.experimental.i18n, } await promises.mkdir(distDir, { recursive: true }) From 7cf7661d8c2aaa96fc46b5033edfd296df8f5a84 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 14 Oct 2020 16:08:24 -0500 Subject: [PATCH 2/3] Add error --- packages/next/export/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index cc5f14a7a5ff..318ff6e920fd 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -285,6 +285,12 @@ export default async function exportApp( const { i18n } = nextConfig.experimental + if (i18n && !options.buildExport) { + throw new Error( + `i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment` + ) + } + // Start the rendering process const renderOpts = { dir, From d0d75d4589696345ad7f1998040368d13a2b8f5d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 14 Oct 2020 16:53:36 -0500 Subject: [PATCH 3/3] Add tests --- packages/next/build/index.ts | 2 +- .../i18n-support/test/index.test.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 96ae19b413b5..dd87c15fede9 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -334,7 +334,7 @@ export default async function build( } }), dataRoutes: [], - i18n: config.experimental.i18n, + i18n: config.experimental.i18n || undefined, } await promises.mkdir(distDir, { recursive: true }) diff --git a/test/integration/i18n-support/test/index.test.js b/test/integration/i18n-support/test/index.test.js index c34cdc488221..94e4eea25fa9 100644 --- a/test/integration/i18n-support/test/index.test.js +++ b/test/integration/i18n-support/test/index.test.js @@ -27,6 +27,31 @@ let appPort const locales = ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en'] function runTests(isDev) { + if (!isDev) { + it('should add i18n config to routes-manifest', async () => { + const routesManifest = await fs.readJSON( + join(appDir, '.next/routes-manifest.json') + ) + + expect(routesManifest.i18n).toEqual({ + locales: ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en'], + defaultLocale: 'en-US', + domains: [ + { + http: true, + domain: 'example.be', + defaultLocale: 'nl-BE', + }, + { + http: true, + domain: 'example.fr', + defaultLocale: 'fr', + }, + ], + }) + }) + } + it('should update asPath on the client correctly', async () => { for (const check of ['en', 'En']) { const browser = await webdriver(appPort, `/${check}`)