mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 08:15:59 +00:00
fix(nuxt): use new mocked-exports
(#31295)
This commit is contained in:
parent
09beaa7424
commit
3e26b29b9f
@ -101,6 +101,7 @@
|
||||
"knitwork": "^1.2.0",
|
||||
"magic-string": "^0.30.17",
|
||||
"mlly": "^1.7.4",
|
||||
"mocked-exports": "^0.1.0",
|
||||
"nanotar": "^0.2.0",
|
||||
"nitro": "npm:nitro-nightly@3.0.0-beta-28969273.f7aa9de6",
|
||||
"nypm": "^0.6.0",
|
||||
@ -121,7 +122,6 @@
|
||||
"ultrahtml": "^1.5.3",
|
||||
"uncrypto": "^0.1.3",
|
||||
"unctx": "^2.4.1",
|
||||
"unenv": "^1.10.0",
|
||||
"unimport": "^4.1.2",
|
||||
"unplugin": "^2.2.0",
|
||||
"unplugin-vue-router": "^0.12.0",
|
||||
|
@ -13,6 +13,8 @@ import { dynamicEventHandler } from 'h3'
|
||||
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'
|
||||
@ -62,6 +64,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
rootDir: nuxt.options.rootDir,
|
||||
@ -198,11 +202,11 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||
...nuxt.options.vue.runtimeCompiler || nuxt.options.experimental.externalVue
|
||||
? {}
|
||||
: {
|
||||
'estree-walker': 'unenv/runtime/mock/proxy',
|
||||
'@babel/parser': 'unenv/runtime/mock/proxy',
|
||||
'@vue/compiler-core': 'unenv/runtime/mock/proxy',
|
||||
'@vue/compiler-dom': 'unenv/runtime/mock/proxy',
|
||||
'@vue/compiler-ssr': 'unenv/runtime/mock/proxy',
|
||||
'estree-walker': mockProxy,
|
||||
'@babel/parser': mockProxy,
|
||||
'@vue/compiler-core': mockProxy,
|
||||
'@vue/compiler-dom': mockProxy,
|
||||
'@vue/compiler-ssr': mockProxy,
|
||||
},
|
||||
'@vue/devtools-api': 'vue-devtools-stub',
|
||||
|
||||
@ -384,7 +388,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||
|
||||
// add stub alias to allow vite to resolve import
|
||||
if (!nuxt.options.experimental.appManifest) {
|
||||
nuxt.options.alias['#app-manifest'] = 'unenv/runtime/mock/proxy'
|
||||
nuxt.options.alias['#app-manifest'] = mockProxy
|
||||
}
|
||||
|
||||
// Add fallback server for `ssr: false`
|
||||
|
@ -873,6 +873,7 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
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')
|
||||
|
@ -60,7 +60,7 @@
|
||||
"std-env": "^3.8.1",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^1.5.4",
|
||||
"unenv": "^1.10.0",
|
||||
"unenv": "^2.0.0-rc.10",
|
||||
"unplugin": "^2.2.0",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue-bundle-renderer": "^2.1.1",
|
||||
|
@ -41,19 +41,21 @@
|
||||
"defu": "^6.1.4",
|
||||
"esbuild": "^0.25.0",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"exsolve": "^1.0.2",
|
||||
"get-port-please": "^3.1.2",
|
||||
"h3": "npm:h3-nightly@1.15.1-20250222-111608-d1c00fc",
|
||||
"jiti": "^2.4.2",
|
||||
"knitwork": "^1.2.0",
|
||||
"magic-string": "^0.30.17",
|
||||
"mlly": "^1.7.4",
|
||||
"mocked-exports": "^0.1.0",
|
||||
"pathe": "^2.0.3",
|
||||
"pkg-types": "^2.1.0",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup-plugin-visualizer": "^5.14.0",
|
||||
"std-env": "^3.8.1",
|
||||
"ufo": "^1.5.4",
|
||||
"unenv": "^1.10.0",
|
||||
"unenv": "^2.0.0-rc.10",
|
||||
"unplugin": "^2.2.0",
|
||||
"vite": "^6.2.1",
|
||||
"vite-node": "^3.0.8",
|
||||
|
@ -8,9 +8,11 @@ import { logger } from '@nuxt/kit'
|
||||
import { getPort } from 'get-port-please'
|
||||
import { joinURL, withoutLeadingSlash } from 'ufo'
|
||||
import { defu } from 'defu'
|
||||
import { env, nodeless } from 'unenv'
|
||||
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'
|
||||
@ -22,7 +24,10 @@ import { createViteLogger } from './utils/logger'
|
||||
export async function buildClient (ctx: ViteBuildContext) {
|
||||
const nodeCompat = ctx.nuxt.options.experimental.clientNodeCompat
|
||||
? {
|
||||
alias: env(nodeless).alias,
|
||||
alias: defineEnv({
|
||||
nodeCompat: true,
|
||||
resolve: true,
|
||||
}).env.alias,
|
||||
define: {
|
||||
global: 'globalThis',
|
||||
},
|
||||
@ -116,7 +121,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
...ctx.config.resolve?.alias,
|
||||
'nitro/runtime': join(ctx.nuxt.options.buildDir, 'nitro.client.mjs'),
|
||||
// work around vite optimizer bug
|
||||
'#app-manifest': 'unenv/runtime/mock/empty',
|
||||
'#app-manifest': resolveModulePath('mocked-exports/empty', { from: import.meta.url }),
|
||||
},
|
||||
dedupe: [
|
||||
'vue',
|
||||
|
@ -9,6 +9,7 @@ import { sanitizeFilePath } from 'mlly'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { filename } from 'pathe/utils'
|
||||
import { resolveTSConfig } from 'pkg-types'
|
||||
import { resolveModulePath } from 'exsolve'
|
||||
|
||||
import { buildClient } from './client'
|
||||
import { buildServer } from './server'
|
||||
@ -53,6 +54,8 @@ 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 ctx: ViteBuildContext = {
|
||||
nuxt,
|
||||
@ -64,9 +67,9 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
||||
alias: {
|
||||
...nuxt.options.alias,
|
||||
'#app': nuxt.options.appDir,
|
||||
'web-streams-polyfill/ponyfill/es2018': 'unenv/runtime/mock/empty',
|
||||
'web-streams-polyfill/ponyfill/es2018': mockEmpty,
|
||||
// Cannot destructure property 'AbortController' of ..
|
||||
'abort-controller': 'unenv/runtime/mock/empty',
|
||||
'abort-controller': mockEmpty,
|
||||
},
|
||||
},
|
||||
css: await resolveCSSOptions(nuxt),
|
||||
|
@ -60,7 +60,7 @@
|
||||
"std-env": "^3.8.1",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^1.5.4",
|
||||
"unenv": "^1.10.0",
|
||||
"unenv": "^2.0.0-rc.10",
|
||||
"unplugin": "^2.2.0",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue-bundle-renderer": "^2.1.1",
|
||||
|
@ -4,7 +4,7 @@ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { joinURL } from 'ufo'
|
||||
import ForkTSCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
|
||||
import { env, nodeless } from 'unenv'
|
||||
import { defineEnv } from 'unenv'
|
||||
|
||||
import type { WebpackConfigContext } from '../utils/config'
|
||||
import { applyPresets } from '../utils/config'
|
||||
@ -58,7 +58,10 @@ function clientNodeCompat (ctx: WebpackConfigContext) {
|
||||
|
||||
ctx.config.resolve ||= {}
|
||||
ctx.config.resolve.fallback = {
|
||||
...env(nodeless).alias,
|
||||
...defineEnv({
|
||||
nodeCompat: true,
|
||||
resolve: true,
|
||||
}).env.alias,
|
||||
...ctx.config.resolve.fallback,
|
||||
}
|
||||
|
||||
|
@ -423,6 +423,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
|
||||
@ -483,9 +486,6 @@ importers:
|
||||
unctx:
|
||||
specifier: ^2.4.1
|
||||
version: 2.4.1
|
||||
unenv:
|
||||
specifier: ^1.10.0
|
||||
version: 1.10.0
|
||||
unimport:
|
||||
specifier: 4.1.2
|
||||
version: 4.1.2
|
||||
@ -635,8 +635,8 @@ importers:
|
||||
specifier: 1.5.4
|
||||
version: 1.5.4
|
||||
unenv:
|
||||
specifier: ^1.10.0
|
||||
version: 1.10.0
|
||||
specifier: ^2.0.0-rc.10
|
||||
version: 2.0.0-rc.14
|
||||
unplugin:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
@ -891,6 +891,9 @@ importers:
|
||||
escape-string-regexp:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
exsolve:
|
||||
specifier: ^1.0.2
|
||||
version: 1.0.2
|
||||
get-port-please:
|
||||
specifier: ^3.1.2
|
||||
version: 3.1.2
|
||||
@ -909,6 +912,9 @@ importers:
|
||||
mlly:
|
||||
specifier: ^1.7.4
|
||||
version: 1.7.4
|
||||
mocked-exports:
|
||||
specifier: ^0.1.0
|
||||
version: 0.1.0
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -928,8 +934,8 @@ importers:
|
||||
specifier: 1.5.4
|
||||
version: 1.5.4
|
||||
unenv:
|
||||
specifier: ^1.10.0
|
||||
version: 1.10.0
|
||||
specifier: ^2.0.0-rc.10
|
||||
version: 2.0.0-rc.14
|
||||
unplugin:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
@ -1052,8 +1058,8 @@ importers:
|
||||
specifier: 1.5.4
|
||||
version: 1.5.4
|
||||
unenv:
|
||||
specifier: ^1.10.0
|
||||
version: 1.10.0
|
||||
specifier: ^2.0.0-rc.10
|
||||
version: 2.0.0-rc.14
|
||||
unplugin:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
@ -1886,10 +1892,6 @@ packages:
|
||||
resolution: {integrity: sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@eslint/js@9.21.0':
|
||||
resolution: {integrity: sha512-BqStZ3HX8Yz6LvsF5ByXYrtigrV5AXADWLAGc7PH/1SxOb7/FIYYMszZZWiUou/GB9P2lXWk2SV4d+Z8h0nknw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@eslint/js@9.22.0':
|
||||
resolution: {integrity: sha512-vLFajx9o8d1/oL2ZkpMYbkLv8nDB6yaIwFNt7nI4+I80U/z03SxmfOMsLbvWr3p7C+Wnoh//aOu2pQW8cS0HCQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
@ -2308,9 +2310,6 @@ packages:
|
||||
'@oxc-parser/wasm@0.56.5':
|
||||
resolution: {integrity: sha512-9vtn56ok7PHS0elihFP+Q+alveQuGR0vnF6OeZesxkKWLJr8mCk0kZJx5ZxLjibaPA/sxWTmOyn31UMM9jg9fg==}
|
||||
|
||||
'@oxc-project/types@0.56.3':
|
||||
resolution: {integrity: sha512-zYw7js4CgLSQZ9bfPJjqc5AMS3mM98ur18OA7smCUZe9gpv6agHBLsC5NsXerZLVS7L5r06i8olPvymiymhWyw==}
|
||||
|
||||
'@oxc-project/types@0.56.5':
|
||||
resolution: {integrity: sha512-skY3kOJwp22W4RkaadH1hZ3hqFHjkRrIIE0uQ4VUg+/Chvbl+2pF+B55IrIk2dgsKXS57YEUsJuN6I6s4rgFjA==}
|
||||
|
||||
@ -5830,6 +5829,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'}
|
||||
@ -7404,6 +7406,9 @@ packages:
|
||||
unenv@1.10.0:
|
||||
resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==}
|
||||
|
||||
unenv@2.0.0-rc.14:
|
||||
resolution: {integrity: sha512-od496pShMen7nOy5VmVJCnq8rptd45vh6Nx/r2iPbrba6pa6p+tS2ywuIHRZ/OBvSbQZB0kWvpO9XBNVFXHD3Q==}
|
||||
|
||||
unhead@2.0.0-rc.8:
|
||||
resolution: {integrity: sha512-v460EaVW4nQsXTULM2Fx5qmbmHpIs0kF72p3IwV5KXLk1uynFha0KbRraf8Vg+1EOJP91vLpNtXTLJtAzzF4zg==}
|
||||
|
||||
@ -8583,8 +8588,6 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@eslint/js@9.21.0': {}
|
||||
|
||||
'@eslint/js@9.22.0': {}
|
||||
|
||||
'@eslint/object-schema@2.1.6': {}
|
||||
@ -8901,7 +8904,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@antfu/install-pkg': 1.0.0
|
||||
'@clack/prompts': 0.10.0
|
||||
'@eslint/js': 9.21.0
|
||||
'@eslint/js': 9.22.0
|
||||
'@nuxt/eslint-plugin': 1.1.0(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2)
|
||||
'@stylistic/eslint-plugin': 4.0.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2)
|
||||
'@typescript-eslint/eslint-plugin': 8.24.1(@typescript-eslint/parser@8.24.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2)
|
||||
@ -9209,8 +9212,6 @@ snapshots:
|
||||
dependencies:
|
||||
'@oxc-project/types': 0.56.5
|
||||
|
||||
'@oxc-project/types@0.56.3': {}
|
||||
|
||||
'@oxc-project/types@0.56.5': {}
|
||||
|
||||
'@parcel/watcher-android-arm64@2.5.1':
|
||||
@ -13448,6 +13449,8 @@ snapshots:
|
||||
pkg-types: 1.3.1
|
||||
ufo: 1.5.4
|
||||
|
||||
mocked-exports@0.1.0: {}
|
||||
|
||||
mri@1.2.0: {}
|
||||
|
||||
mrmime@2.0.0: {}
|
||||
@ -13757,7 +13760,7 @@ snapshots:
|
||||
|
||||
oxc-parser@0.56.3:
|
||||
dependencies:
|
||||
'@oxc-project/types': 0.56.3
|
||||
'@oxc-project/types': 0.56.5
|
||||
optionalDependencies:
|
||||
'@oxc-parser/binding-darwin-arm64': 0.56.3
|
||||
'@oxc-parser/binding-darwin-x64': 0.56.3
|
||||
@ -15245,6 +15248,14 @@ snapshots:
|
||||
node-fetch-native: 1.6.6
|
||||
pathe: 1.1.2
|
||||
|
||||
unenv@2.0.0-rc.14:
|
||||
dependencies:
|
||||
defu: 6.1.4
|
||||
exsolve: 1.0.2
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
ufo: 1.5.4
|
||||
|
||||
unhead@2.0.0-rc.8:
|
||||
dependencies:
|
||||
hookable: 5.5.3
|
||||
|
Loading…
Reference in New Issue
Block a user