Skip to content

Commit 114e120

Browse files
authored
fix!: remove nuxtI18nOptions from generated options files (#3554)
1 parent 2fc2456 commit 114e120

4 files changed

Lines changed: 7 additions & 90 deletions

File tree

docs/content/docs/02.guide/90.migrating.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ This feature has been disabled and the option to enable it has been removed, see
4848
### Drop `experimental.generatedLocaleFilePathFormat`
4949
File paths (e.g. locale files, vue-i18n configs) configured for this module are now removed entirely making this option obsolete.
5050

51+
### Removed `nuxtI18nOptions` from generated options files.
52+
The generated options files in your projects are meant for internal use by this module at runtime and should never be used, more properties may be removed in the future.
53+
54+
The `nuxtI18nOptions` export has been removed from the generated options files (`#build/i18n.options.mjs` and `#internal/i18n/options.mjs`), since it is no longer used by the module and might expose vulnerable information in the final build.
55+
5156
## Upgrading from `nuxtjs/i18n` v8.x to v9.x
5257

5358
### Upgrade to Vue I18n v10

src/gen.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign, isString } from '@intlify/shared'
1+
import { isString } from '@intlify/shared'
22
import { genImport, genDynamicImport, genSafeVariableName, genString } from 'knitwork'
33
import { resolve, relative, join, basename } from 'pathe'
44
import { getLayerI18n } from './utils'
@@ -80,25 +80,12 @@ export function generateLoaderOptions(
8080
vueI18nConfigs.push({ specifier, importer, relative: relative(nuxt.options.buildDir, config.path) })
8181
}
8282

83-
const nuxtI18nOptions = assign({}, ctx.options, {
84-
locales: simplifyLocaleOptions(nuxt, ctx.options),
85-
i18nModules: (ctx.options.i18nModules ?? []).map(x => {
86-
delete x.langDir
87-
x.locales = (x.locales ?? []).map(locale => (isString(locale) ? locale : stripLocaleFiles(locale))) as
88-
| string[]
89-
| LocaleObject[]
90-
return x
91-
})
92-
})
93-
// @ts-expect-error is required
94-
delete nuxtI18nOptions.vueI18n
95-
9683
/**
9784
* Process locale file paths in `normalizedLocales`
9885
*/
9986
const normalizedLocales = ctx.normalizedLocales.map(x => stripLocaleFiles(x))
10087

101-
return { localeLoaders, nuxtI18nOptions, vueI18nConfigs, normalizedLocales }
88+
return { localeLoaders, vueI18nConfigs, normalizedLocales }
10289
}
10390

10491
/**

src/template.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ export const localeLoaders = ${genObjectFromRaw(localeLoaderEntries)}
155155
156156
export const vueI18nConfigs = ${genArrayFromRaw(opts.vueI18nConfigs.map(x => x.importer))}
157157
158-
export const nuxtI18nOptions = ${genObjectFromValues(opts.nuxtI18nOptions)}
159-
160158
export const normalizedLocales = ${genArrayFromRaw(opts.normalizedLocales.map(x => genObjectFromValues(x, ' ')))}
161159
162160
export const NUXT_I18N_MODULE_ID = ${genString(NUXT_I18N_MODULE_ID)}

test/__snapshots__/gen.test.ts.snap

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ exports[`basic 1`] = `
4545
"code": "fr",
4646
},
4747
],
48-
"nuxtI18nOptions": {
49-
"defaultLocale": "en",
50-
"i18nModules": [],
51-
"lazy": false,
52-
"locales": [],
53-
},
5448
"vueI18nConfigs": [
5549
{
5650
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -140,12 +134,6 @@ exports[`files with cache configuration 1`] = `
140134
"code": "es-AR",
141135
},
142136
],
143-
"nuxtI18nOptions": {
144-
"defaultLocale": "en",
145-
"i18nModules": [],
146-
"lazy": true,
147-
"locales": [],
148-
},
149137
"vueI18nConfigs": [
150138
{
151139
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -201,12 +189,6 @@ exports[`lazy 1`] = `
201189
"code": "fr",
202190
},
203191
],
204-
"nuxtI18nOptions": {
205-
"defaultLocale": "en",
206-
"i18nModules": [],
207-
"lazy": true,
208-
"locales": [],
209-
},
210192
"vueI18nConfigs": [
211193
{
212194
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -262,12 +244,6 @@ exports[`locale file in nested 1`] = `
262244
"code": "fr",
263245
},
264246
],
265-
"nuxtI18nOptions": {
266-
"defaultLocale": "en",
267-
"i18nModules": [],
268-
"lazy": true,
269-
"locales": [],
270-
},
271247
"vueI18nConfigs": [
272248
{
273249
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -357,12 +333,6 @@ exports[`multiple files 1`] = `
357333
"code": "es-AR",
358334
},
359335
],
360-
"nuxtI18nOptions": {
361-
"defaultLocale": "en",
362-
"i18nModules": [],
363-
"lazy": true,
364-
"locales": [],
365-
},
366336
"vueI18nConfigs": [
367337
{
368338
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -377,25 +347,6 @@ exports[`toCode: function (arrow) 1`] = `
377347
{
378348
"localeLoaders": {},
379349
"normalizedLocales": [],
380-
"nuxtI18nOptions": {
381-
"defaultLocale": "en",
382-
"i18nModules": [],
383-
"lazy": false,
384-
"locales": [
385-
{
386-
"code": "en",
387-
"testFunc": [Function],
388-
},
389-
{
390-
"code": "ja",
391-
"testFunc": [Function],
392-
},
393-
{
394-
"code": "fr",
395-
"testFunc": [Function],
396-
},
397-
],
398-
},
399350
"vueI18nConfigs": [
400351
{
401352
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -410,25 +361,6 @@ exports[`toCode: function (named) 1`] = `
410361
{
411362
"localeLoaders": {},
412363
"normalizedLocales": [],
413-
"nuxtI18nOptions": {
414-
"defaultLocale": "en",
415-
"i18nModules": [],
416-
"lazy": false,
417-
"locales": [
418-
{
419-
"code": "en",
420-
"testFunc": [Function],
421-
},
422-
{
423-
"code": "ja",
424-
"testFunc": [Function],
425-
},
426-
{
427-
"code": "fr",
428-
"testFunc": [Function],
429-
},
430-
],
431-
},
432364
"vueI18nConfigs": [
433365
{
434366
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",
@@ -484,11 +416,6 @@ exports[`vueI18n option 1`] = `
484416
"code": "fr",
485417
},
486418
],
487-
"nuxtI18nOptions": {
488-
"i18nModules": [],
489-
"lazy": false,
490-
"locales": [],
491-
},
492419
"vueI18nConfigs": [
493420
{
494421
"importer": "() => import("#nuxt-i18n/c3216fe6" /* webpackChunkName: "config_to_c3216fe6" */)",

0 commit comments

Comments
 (0)