Skip to content

Commit

Permalink
refactor: remove aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored and kazupon committed Nov 23, 2023
1 parent 395e573 commit 8e3fab2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
15 changes: 0 additions & 15 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,6 @@ export default defineNuxtModule<NuxtI18nOptions>({
nuxt.options.alias['#i18n'] = resolve(distDir, 'runtime/composables.mjs')
nuxt.options.build.transpile.push('#i18n')

// TODO: We don't want to resolve the following as a template,
// but in the runtime dir we want to use as an ESM (e.g. internal and utils)

// for internal
addTemplate({
filename: 'i18n.internal.mjs',
src: resolve(distDir, 'runtime/internal.mjs')
})

// for utils
addTemplate({
filename: 'i18n.utils.mjs',
src: resolve(distDir, 'runtime/utils.mjs')
})

addTemplate({
filename: NUXT_I18N_TEMPLATE_OPTIONS_KEY,
src: resolve(distDir, 'runtime/templates/options.template.mjs'),
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/composables.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { findBrowserLocale, getComposer } from 'vue-i18n-routing'
import { useRoute, useRouter, useRequestHeaders, useCookie, useNuxtApp } from '#imports'
import { ref } from 'vue'
import { parseAcceptLanguage } from '#build/i18n.internal.mjs'
import { parseAcceptLanguage } from './internal'
import { nuxtI18nInternalOptions, nuxtI18nOptionsDefault, localeCodes as _localeCodes } from '#build/i18n.options.mjs'
import {
getComposer,
findBrowserLocale,
useRouteBaseName as _useRouteBaseName,
useLocalePath as _useLocalePath,
useLocaleRoute as _useLocaleRoute,
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import {
extendPrefixable,
extendSwitchLocalePathIntercepter,
_setLocale
} from '#build/i18n.utils.mjs'
} from '../utils'
import {
getBrowserLocale as _getBrowserLocale,
getLocaleCookie as _getLocaleCookie,
setLocaleCookie as _setLocaleCookie,
detectBrowserLanguage,
DefaultDetectBrowserLanguageFromResult
} from '#build/i18n.internal.mjs'
} from '../internal'

import type { Composer, Locale, I18nOptions } from 'vue-i18n'
import type { LocaleObject, ExtendProperyDescripters, VueI18nRoutingPluginOptions } from 'vue-i18n-routing'
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
getDomainFromLocale,
proxyNuxt,
DefaultDetectBrowserLanguageFromResult
} from '#build/i18n.internal.mjs'
} from './internal'
import { joinURL, isEqual } from 'ufo'

import type {
Expand All @@ -44,7 +44,7 @@ import type {
import type { NuxtApp } from '#app'
import type { I18n, I18nOptions, Locale, FallbackLocale, LocaleMessages, DefineLocaleMessage } from 'vue-i18n'
import type { NuxtI18nOptions, DetectBrowserLanguageOptions, RootRedirectOptions } from '#build/i18n.options.mjs'
import type { DetectLocaleContext } from '#build/i18n.internal.mjs'
import type { DetectLocaleContext } from './internal'
import type { DeepRequired } from 'ts-essentials'

export function _setLocale(i18n: I18n, locale: Locale) {
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
"#head": ["./node_modules/nuxt/dist/index.d.ts"],
"#i18n": ["./src/runtime/composables.ts"],
"#vue-router": ["./node_modules/vue-router"],
"#build/i18n.shared.mjs": ["./src/runtime/shared.ts"],
"#build/i18n.options.mjs": ["./src/options.d.ts"],
"#build/i18n.internal.mjs": ["./src/runtime/internal.ts"],
"#build/i18n.utils.mjs": ["./src/runtime/utils.ts"]
"#build/i18n.options.mjs": ["./src/options.d.ts"]
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
Expand Down

0 comments on commit 8e3fab2

Please sign in to comment.