kopia lustrzana https://github.com/elk-zone/elk
fix: move to `mocked-exports` rather than implicit `unenv` dep (#3232)
rodzic
5623f87607
commit
1bf113a960
|
@ -1,4 +1,4 @@
|
|||
import proxy from 'unenv/runtime/mock/proxy'
|
||||
import proxy from 'mocked-exports/proxy'
|
||||
|
||||
export const Plugin = proxy
|
||||
export const PluginKey = proxy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import proxy from 'unenv/runtime/mock/proxy'
|
||||
import proxy from 'mocked-exports/proxy'
|
||||
|
||||
export const lt = proxy
|
||||
export const gt = proxy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import proxy from 'unenv/runtime/mock/proxy'
|
||||
import proxy from 'mocked-exports/proxy'
|
||||
|
||||
export const Extension = proxy
|
||||
export const useEditor = proxy
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { rm } from 'node:fs/promises'
|
||||
import { addImports, addImportsSources, addPlugin, createResolver, defineNuxtModule, useNuxt } from '@nuxt/kit'
|
||||
import { resolveModulePath } from 'exsolve'
|
||||
|
||||
const mockProxy = resolveModulePath('mocked-exports/proxy', { from: import.meta.url })
|
||||
|
||||
export default defineNuxtModule({
|
||||
meta: {
|
||||
|
@ -20,8 +23,8 @@ export default defineNuxtModule({
|
|||
|
||||
nuxt.options.alias = {
|
||||
...nuxt.options.alias,
|
||||
'unstorage/drivers/fs': 'unenv/runtime/mock/proxy',
|
||||
'unstorage/drivers/cloudflare-kv-http': 'unenv/runtime/mock/proxy',
|
||||
'unstorage/drivers/fs': mockProxy,
|
||||
'unstorage/drivers/cloudflare-kv-http': mockProxy,
|
||||
'#storage-config': resolve('./runtime/storage-config'),
|
||||
'node:events': 'unenv/runtime/node/events/index',
|
||||
'#build-info': resolve('./runtime/build-info'),
|
||||
|
|
|
@ -5,11 +5,8 @@ import {
|
|||
defineLazyEventHandler,
|
||||
toNodeListener,
|
||||
} from 'h3'
|
||||
import { fetchNodeRequestHandler } from 'node-mock-http'
|
||||
import { createFetch } from 'ofetch'
|
||||
import {
|
||||
createCall,
|
||||
createFetch as createLocalFetch,
|
||||
} from 'unenv/runtime/fetch/index'
|
||||
|
||||
const handlers = [
|
||||
{
|
||||
|
@ -52,12 +49,16 @@ export default defineNuxtPlugin(async () => {
|
|||
// @ts-expect-error TODO: fix
|
||||
h3App.use(config.app.baseURL, router)
|
||||
|
||||
const localCall = createCall(toNodeListener(h3App) as any)
|
||||
const localFetch = createLocalFetch(localCall, globalThis.fetch)
|
||||
const nodeHandler = toNodeListener(h3App)
|
||||
const localFetch: typeof fetch = async (input, init) => {
|
||||
if (!input.toString().startsWith('/')) {
|
||||
return globalThis.fetch(input.toString(), init)
|
||||
}
|
||||
return await fetchNodeRequestHandler(nodeHandler, input.toString(), init)
|
||||
}
|
||||
|
||||
// @ts-expect-error error types are subtly different here in a future nitro version
|
||||
globalThis.$fetch = createFetch({
|
||||
// @ts-expect-error slight differences in api
|
||||
fetch: localFetch,
|
||||
Headers,
|
||||
defaults: { baseURL: config.app.baseURL },
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { BuildInfo } from './types'
|
||||
import { createResolver, useNuxt } from '@nuxt/kit'
|
||||
import { resolveModulePath } from 'exsolve'
|
||||
import { isCI, isDevelopment, isWindows } from 'std-env'
|
||||
import { isPreview } from './config/env'
|
||||
import { currentLocales } from './config/i18n'
|
||||
|
@ -7,6 +8,8 @@ import { pwa } from './config/pwa'
|
|||
|
||||
const { resolve } = createResolver(import.meta.url)
|
||||
|
||||
const mockProxy = resolveModulePath('mocked-exports/proxy', { from: import.meta.url })
|
||||
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2024-09-11',
|
||||
typescript: {
|
||||
|
@ -186,7 +189,7 @@ export default defineNuxtConfig({
|
|||
},
|
||||
nitro: {
|
||||
alias: {
|
||||
'isomorphic-ws': 'unenv/runtime/mock/proxy',
|
||||
'isomorphic-ws': mockProxy,
|
||||
},
|
||||
esbuild: {
|
||||
options: {
|
||||
|
@ -230,7 +233,7 @@ export default defineNuxtConfig({
|
|||
for (const dep of ['eventemitter3', 'isomorphic-ws'])
|
||||
alias[dep] = resolve('./mocks/class')
|
||||
for (const dep of ['fuse.js'])
|
||||
alias[dep] = 'unenv/runtime/mock/proxy'
|
||||
alias[dep] = mockProxy
|
||||
const resolver = createResolver(import.meta.url)
|
||||
|
||||
config.plugins!.unshift({
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
"cheerio": "^1.0.0",
|
||||
"chroma-js": "^3.0.0",
|
||||
"emoji-mart": "^5.5.2",
|
||||
"exsolve": "^1.0.4",
|
||||
"file-saver": "^2.0.5",
|
||||
"floating-vue": "^5.2.2",
|
||||
"focus-trap": "^7.5.1",
|
||||
|
@ -85,7 +86,9 @@
|
|||
"js-yaml": "^4.1.0",
|
||||
"lru-cache": "^11.0.0",
|
||||
"masto": "^6.10.1",
|
||||
"mocked-exports": "^0.1.1",
|
||||
"node-emoji": "^2.1.3",
|
||||
"node-mock-http": "^1.0.0",
|
||||
"nuxt-security": "^2.0.0",
|
||||
"page-lifecycle": "^0.1.2",
|
||||
"pinia": "^2.2.6",
|
||||
|
|
|
@ -136,6 +136,9 @@ importers:
|
|||
emoji-mart:
|
||||
specifier: ^5.5.2
|
||||
version: 5.5.2
|
||||
exsolve:
|
||||
specifier: ^1.0.4
|
||||
version: 1.0.4
|
||||
file-saver:
|
||||
specifier: ^2.0.5
|
||||
version: 2.0.5
|
||||
|
@ -175,9 +178,15 @@ importers:
|
|||
masto:
|
||||
specifier: ^6.10.1
|
||||
version: 6.10.1
|
||||
mocked-exports:
|
||||
specifier: ^0.1.1
|
||||
version: 0.1.1
|
||||
node-emoji:
|
||||
specifier: ^2.1.3
|
||||
version: 2.1.3
|
||||
node-mock-http:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
nuxt-security:
|
||||
specifier: ^2.0.0
|
||||
version: 2.1.5(magicast@0.3.5)(rollup@2.79.1)(webpack-sources@3.2.3)
|
||||
|
@ -5498,6 +5507,9 @@ packages:
|
|||
resolution: {integrity: sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
exsolve@1.0.4:
|
||||
resolution: {integrity: sha512-xsZH6PXaER4XoV+NiT7JHp1bJodJVT+cxeSH1G0f0tlT0lJqYuHUP3bUx2HtfTDvOagMINYp8rsqusxud3RXhw==}
|
||||
|
||||
extend@3.0.2:
|
||||
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
|
||||
|
||||
|
@ -6833,6 +6845,9 @@ packages:
|
|||
mlly@1.7.4:
|
||||
resolution: {integrity: sha512-qmdSIPC4bDJXgZTCR7XosJiNKySV7O215tsPtDN9iEO/7q/76b/ijtgRu/+epFXSJhijtTCCGp3DWS549P3xKw==}
|
||||
|
||||
mocked-exports@0.1.1:
|
||||
resolution: {integrity: sha512-aF7yRQr/Q0O2/4pIXm6PZ5G+jAd7QS4Yu8m+WEeEHGnbo+7mE36CbLSDQiXYV8bVL3NfmdeqPJct0tUlnjVSnA==}
|
||||
|
||||
mri@1.2.0:
|
||||
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
|
||||
engines: {node: '>=4'}
|
||||
|
@ -16444,6 +16459,8 @@ snapshots:
|
|||
|
||||
expect-type@1.1.0: {}
|
||||
|
||||
exsolve@1.0.4: {}
|
||||
|
||||
extend@3.0.2: {}
|
||||
|
||||
externality@1.0.2:
|
||||
|
@ -18078,6 +18095,8 @@ snapshots:
|
|||
pkg-types: 1.3.1
|
||||
ufo: 1.5.4
|
||||
|
||||
mocked-exports@0.1.1: {}
|
||||
|
||||
mri@1.2.0: {}
|
||||
|
||||
mrmime@2.0.0: {}
|
||||
|
|
Ładowanie…
Reference in New Issue