diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 5702c24e9c5b7..31d7aa839486f 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -98,9 +98,7 @@ export function createEntrypoints( loadedEnvFiles: Buffer.from(JSON.stringify(loadedEnvFiles)).toString( 'base64' ), - i18n: config.experimental.i18n - ? JSON.stringify(config.experimental.i18n) - : '', + i18n: config.i18n ? JSON.stringify(config.i18n) : '', } Object.keys(pages).forEach((page) => { diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 86c9db6323b41..909283becc48a 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -336,7 +336,7 @@ export default async function build( } }), dataRoutes: [], - i18n: config.experimental.i18n || undefined, + i18n: config.i18n || undefined, } await promises.mkdir(distDir, { recursive: true }) @@ -576,8 +576,8 @@ export default async function build( page, serverBundle, runtimeEnvConfig, - config.experimental.i18n?.locales, - config.experimental.i18n?.defaultLocale + config.i18n?.locales, + config.i18n?.defaultLocale ) if (workerResult.isHybridAmp) { @@ -739,7 +739,7 @@ export default async function build( // n.b. we cannot handle this above in combinedPages because the dynamic // page must be in the `pages` array, but not in the mapping. exportPathMap: (defaultMap: any) => { - const { i18n } = config.experimental + const { i18n } = config // Dynamically routed pages should be prerendered to be used as // a client-side skeleton (fallback) while data is being fetched. @@ -878,7 +878,7 @@ export default async function build( pagesManifest[page] = relativeDest } - const { i18n } = config.experimental + const { i18n } = config const isNotFound = ssgNotFoundPaths.includes(page) // for SSG files with i18n the non-prerendered variants are @@ -960,7 +960,7 @@ export default async function build( } if (isSsg) { - const { i18n } = config.experimental + const { i18n } = config // For a non-dynamic SSG page, we must copy its data file from export. if (!isDynamic) { diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 76c0e1225422f..5c049139d3458 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1004,12 +1004,8 @@ export default async function getBaseWebpackConfig( }), 'process.env.__NEXT_ROUTER_BASEPATH': JSON.stringify(config.basePath), 'process.env.__NEXT_HAS_REWRITES': JSON.stringify(hasRewrites), - 'process.env.__NEXT_I18N_SUPPORT': JSON.stringify( - !!config.experimental.i18n - ), - 'process.env.__NEXT_I18N_DOMAINS': JSON.stringify( - config.experimental.i18n.domains - ), + 'process.env.__NEXT_I18N_SUPPORT': JSON.stringify(!!config.i18n), + 'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n.domains), 'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId), ...(isServer ? { diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index 5c146431c3038..64120797c6577 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -283,7 +283,7 @@ export default async function exportApp( } } - const { i18n } = nextConfig.experimental + const { i18n } = nextConfig if (i18n && !options.buildExport) { throw new Error( diff --git a/packages/next/next-server/server/config.ts b/packages/next/next-server/server/config.ts index 55d384b460191..49c3c1b6b8995 100644 --- a/packages/next/next-server/server/config.ts +++ b/packages/next/next-server/server/config.ts @@ -45,6 +45,7 @@ const defaultConfig: { [key: string]: any } = { basePath: '', sassOptions: {}, trailingSlash: false, + i18n: false, experimental: { cpus: Math.max( 1, @@ -62,7 +63,6 @@ const defaultConfig: { [key: string]: any } = { optimizeFonts: false, optimizeImages: false, scrollRestoration: false, - i18n: false, }, future: { excludeDefaultMomentLocales: false, @@ -310,8 +310,8 @@ function assignDefaults(userConfig: { [key: string]: any }) { } } - if (result.experimental?.i18n) { - const { i18n } = result.experimental + if (result.i18n) { + const { i18n } = result const i18nType = typeof i18n if (i18nType !== 'object') { diff --git a/packages/next/next-server/server/next-server.ts b/packages/next/next-server/server/next-server.ts index 62e6853dc5bf9..2a116b19ad1ff 100644 --- a/packages/next/next-server/server/next-server.ts +++ b/packages/next/next-server/server/next-server.ts @@ -198,7 +198,7 @@ export default class Server { ? requireFontManifest(this.distDir, this._isLikeServerless) : null, optimizeImages: this.nextConfig.experimental.optimizeImages, - defaultLocale: this.nextConfig.experimental.i18n?.defaultLocale, + defaultLocale: this.nextConfig.i18n?.defaultLocale, } // Only the `publicRuntimeConfig` key is exposed to the client side @@ -298,8 +298,7 @@ export default class Server { parsedUrl.query = parseQs(parsedUrl.query) } - const { basePath } = this.nextConfig - const { i18n } = this.nextConfig.experimental + const { basePath, i18n } = this.nextConfig if (basePath && req.url?.startsWith(basePath)) { // store original URL to allow checking if basePath was @@ -577,7 +576,7 @@ export default class Server { // re-create page's pathname let pathname = `/${params.path.join('/')}` - const { i18n } = this.nextConfig.experimental + const { i18n } = this.nextConfig if (i18n) { const { host } = req?.headers || {} @@ -1213,7 +1212,7 @@ export default class Server { const locale = query.__nextLocale as string delete query.__nextLocale - const { i18n } = this.nextConfig.experimental + const { i18n } = this.nextConfig const locales = i18n.locales as string[] let previewData: string | false | object | undefined @@ -1243,7 +1242,7 @@ export default class Server { ) } - if (this.nextConfig.experimental.i18n) { + if (this.nextConfig.i18n) { return normalizeLocalePath(path, locales).pathname } return path diff --git a/packages/next/server/next-dev-server.ts b/packages/next/server/next-dev-server.ts index 17944484b967f..4ef111da02d47 100644 --- a/packages/next/server/next-dev-server.ts +++ b/packages/next/server/next-dev-server.ts @@ -534,7 +534,7 @@ export default class DevServer extends Server { const __getStaticPaths = async () => { const { publicRuntimeConfig, serverRuntimeConfig } = this.nextConfig - const { locales, defaultLocale } = this.nextConfig.experimental.i18n || {} + const { locales, defaultLocale } = this.nextConfig.i18n || {} const paths = await this.staticPathsWorker.loadStaticPaths( this.distDir, diff --git a/packages/next/telemetry/events/version.ts b/packages/next/telemetry/events/version.ts index 60a9ab67874fb..7370541f1dfb6 100644 --- a/packages/next/telemetry/events/version.ts +++ b/packages/next/telemetry/events/version.ts @@ -114,8 +114,7 @@ export function eventCliSession( const userConfiguration = getNextConfig(phase, dir) - const { images, experimental } = userConfiguration || {} - const { i18n } = experimental || {} + const { images, i18n } = userConfiguration || {} const payload: EventCliSessionStarted = { nextVersion: process.env.__NEXT_VERSION, diff --git a/test/integration/i18n-support/next.config.js b/test/integration/i18n-support/next.config.js index 3e1f4d2507dee..e6aec3f6e6bab 100644 --- a/test/integration/i18n-support/next.config.js +++ b/test/integration/i18n-support/next.config.js @@ -1,25 +1,23 @@ module.exports = { // target: 'experimental-serverless-trace', - experimental: { - i18n: { - locales: ['nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en-US', 'en'], - defaultLocale: 'en-US', - domains: [ - { - // used for testing, this should not be needed in most cases - // as production domains should always use https - http: true, - domain: 'example.be', - defaultLocale: 'nl-BE', - locales: ['nl', 'nl-NL', 'nl-BE'], - }, - { - http: true, - domain: 'example.fr', - defaultLocale: 'fr', - locales: ['fr-BE'], - }, - ], - }, + i18n: { + locales: ['nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en-US', 'en'], + defaultLocale: 'en-US', + domains: [ + { + // used for testing, this should not be needed in most cases + // as production domains should always use https + http: true, + domain: 'example.be', + defaultLocale: 'nl-BE', + locales: ['nl', 'nl-NL', 'nl-BE'], + }, + { + http: true, + domain: 'example.fr', + defaultLocale: 'fr', + locales: ['fr-BE'], + }, + ], }, } diff --git a/test/integration/telemetry/next.config.i18n-images b/test/integration/telemetry/next.config.i18n-images index 61d99bdee5e3f..2c68a13f49c1c 100644 --- a/test/integration/telemetry/next.config.i18n-images +++ b/test/integration/telemetry/next.config.i18n-images @@ -4,21 +4,19 @@ module.exports = phase => { sizes: [64, 128, 256, 512, 1024], domains: ['example.com'], }, - experimental: { - i18n: { - locales: ['en','nl','fr'], - defaultLocale: 'en', - domains: [ - { - domain: 'example.com', - defaultLocale: 'en' - }, - { - domain: 'example.fr', - defaultLocale: 'fr' - } - ] - } + i18n: { + locales: ['en','nl','fr'], + defaultLocale: 'en', + domains: [ + { + domain: 'example.com', + defaultLocale: 'en' + }, + { + domain: 'example.fr', + defaultLocale: 'fr' + } + ] } } }