Skip to content

Commit

Permalink
feat: configurable bundle.optimizeTranslationDirective (nuxt-module…
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Dec 6, 2024
1 parent 7348f7e commit 1b4574f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/content/docs/4.api/0.options.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,13 @@ It can be useful if you have one code base (e.g. [Nuxt Layers](https://nuxt.com/
The value of this **option will not be merged with other Nuxt Layers**. This option should only be specified in the final project config.
::

### `optimizeTranslationDirective`

- type: `boolean`{lang="ts-type"}
- default: `true`{lang="ts"}

Whether to optimize `v-t` directive by transforming it's usage into a vue-i18n translation function, this needs to be enabled for projects using the `v-t` directive with SSR.

## experimental

Experimental configuration property is an object with the following properties:
Expand Down
4 changes: 2 additions & 2 deletions src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function extendBundler({ options: nuxtOptions }: I18nNuxtContext, n
compositionOnly: nuxtOptions.bundle.compositionOnly,
onlyLocales: nuxtOptions.bundle.onlyLocales,
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
optimizeTranslationDirective: true,
optimizeTranslationDirective: nuxtOptions.bundle.optimizeTranslationDirective,
strictMessage: nuxtOptions.compilation.strictMessage,
escapeHtml: nuxtOptions.compilation.escapeHtml,
include: localeIncludePaths
Expand Down Expand Up @@ -75,7 +75,7 @@ export async function extendBundler({ options: nuxtOptions }: I18nNuxtContext, n
fullInstall: nuxtOptions.bundle.fullInstall,
onlyLocales: nuxtOptions.bundle.onlyLocales,
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
optimizeTranslationDirective: true,
optimizeTranslationDirective: nuxtOptions.bundle.optimizeTranslationDirective,
strictMessage: nuxtOptions.compilation.strictMessage,
escapeHtml: nuxtOptions.compilation.escapeHtml,
defaultSFCLang: nuxtOptions.customBlocks.defaultSFCLang,
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const DEFAULT_OPTIONS = {
compositionOnly: true,
runtimeOnly: false,
fullInstall: true,
dropMessageCompiler: false
dropMessageCompiler: false,
optimizeTranslationDirective: true
},
compilation: {
jit: true,
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ export interface ExperimentalFeatures {
export interface BundleOptions
extends Pick<
PluginOptions,
'compositionOnly' | 'runtimeOnly' | 'fullInstall' | 'dropMessageCompiler' | 'onlyLocales'
| 'compositionOnly'
| 'runtimeOnly'
| 'fullInstall'
| 'dropMessageCompiler'
| 'onlyLocales'
| 'optimizeTranslationDirective'
> {}

export interface CustomBlocksOptions extends Pick<PluginOptions, 'defaultSFCLang' | 'globalSFCScope'> {}
Expand Down

0 comments on commit 1b4574f

Please sign in to comment.