diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 201826ce8a..f732039356 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -106,6 +106,7 @@ "knitwork": "^1.2.0", "magic-string": "^0.30.17", "mlly": "^1.7.4", + "mocked-exports": "^0.1.0", "nanotar": "^0.2.0", "nitropack": "^2.11.5", "nypm": "^0.6.0", @@ -126,7 +127,6 @@ "ultrahtml": "^1.5.3", "uncrypto": "^0.1.3", "unctx": "^2.4.1", - "unenv": "^2.0.0-rc.12", "unimport": "^4.1.2", "unplugin": "^2.2.0", "unplugin-vue-router": "^0.12.0", diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 3462e6bdba..e74705cc82 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -14,6 +14,7 @@ import { isWindows } from 'std-env' import { ImpoundPlugin } from 'impound' import type { Nuxt, NuxtOptions } from 'nuxt/schema' import { resolveModulePath } from 'exsolve' + import { version as nuxtVersion } from '../../package.json' import { distDir } from '../dirs' import { toArray } from '../utils' @@ -63,7 +64,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { } } - const mockProxy = resolveModulePath('unenv/mock/proxy', { from: import.meta.url }) + const mockProxy = resolveModulePath('mocked-exports/proxy', { from: import.meta.url }) const nitroConfig: NitroConfig = defu(nuxt.options.nitro, { debug: nuxt.options.debug ? nuxt.options.debug.nitro : false, diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index 3def9d8c65..9e25ef4e40 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -872,6 +872,7 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise { options.modulesDir.push(resolve(options.workspaceDir, 'node_modules')) options.modulesDir.push(resolve(pkgDir, 'node_modules')) options.build.transpile.push( + 'mocked-exports', 'std-env', // we need to statically replace process.env when used in runtime code ) options.alias['vue-demi'] = resolve(options.appDir, 'compat/vue-demi') diff --git a/packages/vite/package.json b/packages/vite/package.json index c70f205e2c..e6aaa088e7 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -50,6 +50,7 @@ "magic-string": "^0.30.17", "mlly": "^1.7.4", "ohash": "^2.0.11", + "mocked-exports": "^0.1.0", "pathe": "^2.0.3", "perfect-debounce": "^1.0.0", "pkg-types": "^2.1.0", diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index 0e5818d87e..089f571269 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -12,6 +12,7 @@ import { defineEnv } from 'unenv' import { resolveModulePath } from 'exsolve' import { defineEventHandler, handleCors, setHeader } from 'h3' import type { ViteConfig } from '@nuxt/schema' + import type { ViteBuildContext } from './vite' import { DevStyleSSRPlugin } from './plugins/dev-ssr-css' import { RuntimePathsPlugin } from './plugins/paths' @@ -120,7 +121,7 @@ export async function buildClient (ctx: ViteBuildContext) { ...ctx.config.resolve?.alias, '#internal/nitro': join(ctx.nuxt.options.buildDir, 'nitro.client.mjs'), // work around vite optimizer bug - '#app-manifest': resolveModulePath('unenv/mock/empty', { from: import.meta.url }), + '#app-manifest': resolveModulePath('mocked-exports/empty', { from: import.meta.url }), }, dedupe: [ 'vue', diff --git a/packages/vite/src/vite.ts b/packages/vite/src/vite.ts index c913bcdd53..3df9f2ee39 100644 --- a/packages/vite/src/vite.ts +++ b/packages/vite/src/vite.ts @@ -10,6 +10,7 @@ import { withoutLeadingSlash } from 'ufo' import { filename } from 'pathe/utils' import { resolveModulePath } from 'exsolve' import { resolveTSConfig } from 'pkg-types' +import { resolveModulePath } from 'exsolve' import { buildClient } from './client' import { buildServer } from './server' @@ -55,9 +56,10 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => { const { $client, $server, ...viteConfig } = nuxt.options.vite + const mockEmpty = resolveModulePath('mocked-exports/empty', { from: import.meta.url }) + const isIgnored = createIsIgnored(nuxt) - const mockEmpty = resolveModulePath('unenv/mock/empty', { from: import.meta.url }) const ctx: ViteBuildContext = { nuxt, entry, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df1e2b517a..bbd8b7de84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -429,6 +429,9 @@ importers: mlly: specifier: ^1.7.4 version: 1.7.4 + mocked-exports: + specifier: ^0.1.0 + version: 0.1.0 nanotar: specifier: ^0.2.0 version: 0.2.0 @@ -489,9 +492,6 @@ importers: unctx: specifier: ^2.4.1 version: 2.4.1 - unenv: - specifier: ^2.0.0-rc.12 - version: 2.0.0-rc.12 unimport: specifier: 4.1.2 version: 4.1.2 @@ -927,6 +927,9 @@ importers: mlly: specifier: ^1.7.4 version: 1.7.4 + mocked-exports: + specifier: ^0.1.0 + version: 0.1.0 ohash: specifier: ^2.0.11 version: 2.0.11 @@ -5754,6 +5757,9 @@ packages: mlly@1.7.4: resolution: {integrity: sha512-qmdSIPC4bDJXgZTCR7XosJiNKySV7O215tsPtDN9iEO/7q/76b/ijtgRu/+epFXSJhijtTCCGp3DWS549P3xKw==} + mocked-exports@0.1.0: + resolution: {integrity: sha512-sD6J0bqR2L9OPz0Tmkb2iVFTft8u1VigiAb5vKC9wVk5Fmp70wkpnOYHIww4icXD5mn/kGW7q/kQN3VEOPL8QQ==} + mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} @@ -13209,6 +13215,8 @@ snapshots: pkg-types: 1.3.1 ufo: 1.5.4 + mocked-exports@0.1.0: {} + mri@1.2.0: {} mrmime@2.0.0: {}