docs: revert import.meta.* update until v3.7 release

This commit is contained in:
Daniel Roe 2023-08-17 08:06:15 +02:00
parent e04596ad2e
commit 98c17e5d46
6 changed files with 11 additions and 11 deletions

View File

@ -74,12 +74,12 @@ export const useLocale = () => useState<string>('locale', () => useDefaultLocale
export const useDefaultLocale = (fallback = 'en-US') => { export const useDefaultLocale = (fallback = 'en-US') => {
const locale = ref(fallback) const locale = ref(fallback)
if (import.meta.server) { if (process.server) {
const reqLocale = useRequestHeaders()['accept-language']?.split(',')[0] const reqLocale = useRequestHeaders()['accept-language']?.split(',')[0]
if (reqLocale) { if (reqLocale) {
locale.value = reqLocale locale.value = reqLocale
} }
} else if (import.meta.client) { } else if (process.client) {
const navLang = navigator.language const navLang = navigator.language
if (navLang) { if (navLang) {
locale.value = navLang locale.value = navLang

View File

@ -125,12 +125,12 @@ However, if you want to avoid this behaviour you can do so:
```js ```js
export default defineNuxtRouteMiddleware(to => { export default defineNuxtRouteMiddleware(to => {
// skip middleware on server // skip middleware on server
if (import.meta.server) return if (process.server) return
// skip middleware on client side entirely // skip middleware on client side entirely
if (import.meta.client) return if (process.client) return
// or only skip middleware on initial client load // or only skip middleware on initial client load
const nuxtApp = useNuxtApp() const nuxtApp = useNuxtApp()
if (import.meta.client && nuxtApp.isHydrating && nuxtApp.payload.serverRendered) return if (process.client && nuxtApp.isHydrating && nuxtApp.payload.serverRendered) return
}) })
``` ```

View File

@ -62,7 +62,7 @@ export default defineNuxtPlugin({
``` ```
::alert ::alert
If you are using an object-syntax plugin, the properties may be statically analyzed in future to produce a more optimized build. So you should not define them at runtime. For example, setting `enforce: import.meta.server ? 'pre' : 'post'` would defeat any future optimization Nuxt is able to do for your plugins. If you are using an object-syntax plugin, the properties may be statically analyzed in future to produce a more optimized build. So you should not define them at runtime. For example, setting `enforce: process.server ? 'pre' : 'post'` would defeat any future optimization Nuxt is able to do for your plugins.
:: ::
## Plugin Registration Order ## Plugin Registration Order

View File

@ -94,7 +94,7 @@ The entire runtime config is available on the server-side, but it is read-only t
<script setup lang="ts"> <script setup lang="ts">
const config = useRuntimeConfig() const config = useRuntimeConfig()
console.log('Runtime config:', config) console.log('Runtime config:', config)
if (import.meta.server) { if (process.server) {
console.log('API secret:', config.apiSecret) console.log('API secret:', config.apiSecret)
} }
</script> </script>

View File

@ -138,6 +138,6 @@ import { createMemoryHistory } from 'vue-router'
// https://router.vuejs.org/api/interfaces/routeroptions.html // https://router.vuejs.org/api/interfaces/routeroptions.html
export default <RouterConfig> { export default <RouterConfig> {
history: base => import.meta.client ? createMemoryHistory(base) : null /* default */ history: base => process.client ? createMemoryHistory(base) : null /* default */
} }
``` ```

View File

@ -45,7 +45,7 @@ export default defineNuxtPlugin((nuxtApp) => {
}) })
nuxtApp.hook('vue:error', (..._args) => { nuxtApp.hook('vue:error', (..._args) => {
console.log('vue:error') console.log('vue:error')
// if (import.meta.client) { // if (process.client) {
// console.log(..._args) // console.log(..._args)
// } // }
}) })
@ -105,7 +105,7 @@ When accessing the same `payload.data` from [ssrcontext](#ssrcontext), you can a
export const useColor = () => useState<string>('color', () => 'pink') export const useColor = () => useState<string>('color', () => 'pink')
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
if (import.meta.server) { if (process.server) {
const color = useColor() const color = useColor()
} }
}) })
@ -137,7 +137,7 @@ export default defineComponent({
setup (_props, { slots, emit }) { setup (_props, { slots, emit }) {
const nuxtApp = useNuxtApp() const nuxtApp = useNuxtApp()
onErrorCaptured((err) => { onErrorCaptured((err) => {
if (import.meta.client && !nuxtApp.isHydrating) { if (process.client && !nuxtApp.isHydrating) {
// ... // ...
} }
}) })