From 0a94c3c8c917a29c8e58cded33aa6f3e073f3577 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 25 Mar 2024 14:08:41 +0000 Subject: [PATCH] fix: opt in to `import.meta.*` properties (#2622) --- packages/docs/ssr/index.md | 2 +- packages/nuxt/playground/app.vue | 2 +- packages/nuxt/src/runtime/plugin.vue2.ts | 2 +- packages/nuxt/src/runtime/plugin.vue3.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/docs/ssr/index.md b/packages/docs/ssr/index.md index 7cc389ff1d..d8ed2e567d 100644 --- a/packages/docs/ssr/index.md +++ b/packages/docs/ssr/index.md @@ -92,7 +92,7 @@ const pinia = createPinia() const app = createApp(App) app.use(pinia) -// `isClient` depends on the environment, e.g. on Nuxt it's `process.client` +// `isClient` depends on the environment, e.g. on Nuxt it's `import.meta.client` if (isClient) { pinia.state.value = JSON.parse(window.__pinia) } diff --git a/packages/nuxt/playground/app.vue b/packages/nuxt/playground/app.vue index 0d94c3c7bd..450e65a2d3 100644 --- a/packages/nuxt/playground/app.vue +++ b/packages/nuxt/playground/app.vue @@ -8,7 +8,7 @@ useSomeStoreStore() // await useAsyncData('counter', () => counter.asyncIncrement().then(() => true)) -if (process.server) { +if (import.meta.server) { counter.increment() } diff --git a/packages/nuxt/src/runtime/plugin.vue2.ts b/packages/nuxt/src/runtime/plugin.vue2.ts index 76c4a93907..188c3f99cd 100644 --- a/packages/nuxt/src/runtime/plugin.vue2.ts +++ b/packages/nuxt/src/runtime/plugin.vue2.ts @@ -16,7 +16,7 @@ export default (context: any, provide: any) => { Object.defineProperty(store, '$nuxt', { value: context }) }) - if (process.server) { + if (import.meta.server) { context.beforeNuxtRender((ctx: any) => { ctx.nuxtState.pinia = pinia.state.value }) diff --git a/packages/nuxt/src/runtime/plugin.vue3.ts b/packages/nuxt/src/runtime/plugin.vue3.ts index 70007f5faf..628abc65ad 100644 --- a/packages/nuxt/src/runtime/plugin.vue3.ts +++ b/packages/nuxt/src/runtime/plugin.vue3.ts @@ -9,7 +9,7 @@ const plugin: Plugin<{ pinia: Pinia }> = defineNuxtPlugin({ nuxtApp.vueApp.use(pinia) setActivePinia(pinia) - if (process.server) { + if (import.meta.server) { nuxtApp.payload.pinia = pinia.state.value } else if (nuxtApp.payload && nuxtApp.payload.pinia) { pinia.state.value = nuxtApp.payload.pinia