Skip to content

Commit

Permalink
feat: allow to set the plugin as parallel (#2297)
Browse files Browse the repository at this point in the history
* feat: allow to set the plugin as parallel

* chore: set parallelPlugin as optional

apply suggestion from code review

Co-authored-by: kazuya kawaguchi <[email protected]>

* docs: update doc

* fix: fix type

* docs: update doc

* test: update unit tests

---------

Co-authored-by: kazuya kawaguchi <[email protected]>
  • Loading branch information
huang-julien and kazupon authored Aug 13, 2023
1 parent 67ff1ea commit 93e89f8
Show file tree
Hide file tree
Showing 8 changed files with 454 additions and 420 deletions.
7 changes: 7 additions & 0 deletions docs/content/3.options/6.misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ The purpose of this option is to help identify any problems with @nuxtjs/i18n.
Don't enable this option for use in production. Performance will be decreased.

::

## `parallelPlugin`

- type: `boolean`
- default: `false`

Set the plugin as `parallel`. See [nuxt plugin loading strategy](https://nuxt.com/docs/guide/directory-structure/plugins#loading-strategy).
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const DEFAULT_OPTIONS = {
pages: {},
skipSettingLocaleOnNavigate: false,
types: 'composition',
debug: false
debug: false,
parallelPlugin: false
} as const

export const NUXT_I18N_TEMPLATE_OPTIONS_KEY = 'i18n.options.mjs' as const
Expand Down
4 changes: 3 additions & 1 deletion src/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function generateLoaderOptions(
misc: {
dev: boolean
ssg: boolean
} = { dev: true, ssg: false }
parallelPlugin: boolean
} = { dev: true, ssg: false, parallelPlugin: false }
) {
debug('generateLoaderOptions: lazy', lazy)
debug('generateLoaderOptions: localesRelativeBase', localesRelativeBase)
Expand Down Expand Up @@ -258,6 +259,7 @@ export function generateLoaderOptions(
*/
genCode += `export const NUXT_I18N_MODULE_ID = ${toCode(NUXT_I18N_MODULE_ID)}\n`
genCode += `export const isSSG = ${toCode(misc.ssg)}\n`
genCode += `export const parallelPlugin = ${toCode(misc.parallelPlugin)}\n`

debug('generate code', genCode)
return genCode
Expand Down
3 changes: 2 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ export default defineNuxtModule<NuxtI18nOptions>({
},
{
ssg: nuxt.options._generate,
dev: nuxt.options.dev
dev: nuxt.options.dev,
parallelPlugin: i18nOptions.parallelPlugin ?? false
}
)
}
Expand Down
Loading

0 comments on commit 93e89f8

Please sign in to comment.