Skip to content

Commit b581a4b

Browse files
authored
fix: opt in to import.meta.* properties (#526)
1 parent 9e24605 commit b581a4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/runtime/router.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ export default defineNuxtPlugin({
3838

3939
const history =
4040
routerOptions.history?.(routerBase) ??
41-
(process.client
41+
(import.meta.client
4242
? routerOptions.hashMode
4343
? createWebHashHistory(routerBase)
4444
: createWebHistory(routerBase)
4545
: createMemoryHistory(routerBase))
4646

4747
const routes = routerOptions.routes?.(_routes) ?? _routes
4848

49-
const initialURL = process.server
49+
const initialURL = import.meta.server
5050
? nuxtApp.ssrContext!.url
5151
: createCurrentLocation(routerBase, window.location)
5252
const router = createRouter({
@@ -129,7 +129,7 @@ export default defineNuxtPlugin({
129129
: entry
130130

131131
if (!middleware) {
132-
if (process.dev) {
132+
if (import.meta.dev) {
133133
throw new Error(
134134
`Unknown route middleware: '${entry}'. Valid middleware: ${Object.keys(
135135
namedMiddleware
@@ -142,7 +142,7 @@ export default defineNuxtPlugin({
142142
}
143143

144144
const result = await callWithNuxt(nuxtApp, middleware, [to, from])
145-
if (process.server || (!nuxtApp.payload.serverRendered && nuxtApp.isHydrating)) {
145+
if (import.meta.server || (!nuxtApp.payload.serverRendered && nuxtApp.isHydrating)) {
146146
if (result === false || result instanceof Error) {
147147
const error =
148148
result ||
@@ -163,7 +163,7 @@ export default defineNuxtPlugin({
163163
router.afterEach(async to => {
164164
delete nuxtApp._processingMiddleware
165165

166-
if (process.client && !nuxtApp.isHydrating && error.value) {
166+
if (import.meta.client && !nuxtApp.isHydrating && error.value) {
167167
// Clear any existing errors
168168
await callWithNuxt(nuxtApp, clearError)
169169
}
@@ -175,7 +175,7 @@ export default defineNuxtPlugin({
175175
statusMessage: `Page not found: ${to.fullPath}`,
176176
}),
177177
])
178-
} else if (process.server) {
178+
} else if (import.meta.server) {
179179
const currentURL = to.fullPath || '/'
180180
if (!isEqual(currentURL, initialURL, { trailingSlash: true })) {
181181
const event = await callWithNuxt(nuxtApp, useRequestEvent)
@@ -189,7 +189,7 @@ export default defineNuxtPlugin({
189189
})
190190

191191
try {
192-
if (process.client) {
192+
if (import.meta.client) {
193193
await router.replace({
194194
...router.resolve(initialURL),
195195
name: undefined, // #4920, #4982

0 commit comments

Comments
 (0)