mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
wip: track
This commit is contained in:
parent
c1b8b921f1
commit
cd946d1773
@ -39,6 +39,7 @@
|
|||||||
"klona": "^2.0.6",
|
"klona": "^2.0.6",
|
||||||
"mlly": "^1.7.3",
|
"mlly": "^1.7.3",
|
||||||
"ohash": "^1.1.4",
|
"ohash": "^1.1.4",
|
||||||
|
"on-change": "^5.0.1",
|
||||||
"pathe": "^1.1.2",
|
"pathe": "^1.1.2",
|
||||||
"pkg-types": "^1.3.0",
|
"pkg-types": "^1.3.0",
|
||||||
"scule": "^1.3.0",
|
"scule": "^1.3.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { existsSync, promises as fsp, lstatSync } from 'node:fs'
|
import { existsSync, promises as fsp, lstatSync } from 'node:fs'
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||||
import type { ModuleMeta, Nuxt, NuxtConfig, NuxtModule } from '@nuxt/schema'
|
import type { ModuleMeta, Nuxt, NuxtConfig, NuxtDebugModuleMutationRecord, NuxtModule } from '@nuxt/schema'
|
||||||
import { dirname, isAbsolute, join, resolve } from 'pathe'
|
import { dirname, isAbsolute, join, resolve } from 'pathe'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { createJiti } from 'jiti'
|
import { createJiti } from 'jiti'
|
||||||
@ -27,8 +27,44 @@ export async function installModule<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _nuxt = nuxt
|
||||||
|
if (nuxt.options.debug) {
|
||||||
|
const onChange = await import('on-change').then(r => r.default)
|
||||||
|
const moduleName = (await nuxtModule.getMeta?.())?.name || buildTimeModuleMeta?.name || resolvedModulePath
|
||||||
|
|
||||||
|
// Unwrap onChange proxy if already wrapped
|
||||||
|
nuxt = onChange.target(nuxt)
|
||||||
|
|
||||||
|
nuxt._debug ||= {}
|
||||||
|
nuxt._debug.moduleMutationRecords ||= []
|
||||||
|
|
||||||
|
_nuxt = onChange(
|
||||||
|
nuxt,
|
||||||
|
(keys, value, _, applyData) => {
|
||||||
|
// We only listen to changes in the `options` object
|
||||||
|
if (keys[0] !== 'options') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const record: NuxtDebugModuleMutationRecord = {
|
||||||
|
module: moduleName,
|
||||||
|
keys: keys.slice(1),
|
||||||
|
value,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
}
|
||||||
|
if (applyData?.name) {
|
||||||
|
record.method = applyData.name
|
||||||
|
}
|
||||||
|
nuxt._debug!.moduleMutationRecords!.push(record)
|
||||||
|
}, {
|
||||||
|
ignoreUnderscores: true,
|
||||||
|
ignoreSymbols: true,
|
||||||
|
pathAsArray: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Call module
|
// Call module
|
||||||
const res = await nuxtModule(inlineOptions || {}, nuxt) ?? {}
|
const res = await nuxtModule(inlineOptions || {}, _nuxt) ?? {}
|
||||||
if (res === false /* setup aborted */) {
|
if (res === false /* setup aborted */) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ export type { AppHeadMetaObject, MetaObject, MetaObjectRaw, HeadAugmentations }
|
|||||||
export type { ModuleDefinition, ModuleMeta, ModuleOptions, ModuleSetupInstallResult, ModuleSetupReturn, NuxtModule, ResolvedModuleOptions } from './types/module'
|
export type { ModuleDefinition, ModuleMeta, ModuleOptions, ModuleSetupInstallResult, ModuleSetupReturn, NuxtModule, ResolvedModuleOptions } from './types/module'
|
||||||
export type { Nuxt, NuxtApp, NuxtPlugin, NuxtPluginTemplate, NuxtTemplate, NuxtTypeTemplate, NuxtServerTemplate, ResolvedNuxtTemplate } from './types/nuxt'
|
export type { Nuxt, NuxtApp, NuxtPlugin, NuxtPluginTemplate, NuxtTemplate, NuxtTypeTemplate, NuxtServerTemplate, ResolvedNuxtTemplate } from './types/nuxt'
|
||||||
export type { RouterConfig, RouterConfigSerializable, RouterOptions } from './types/router'
|
export type { RouterConfig, RouterConfigSerializable, RouterOptions } from './types/router'
|
||||||
|
export type { NuxtDebugContext, NuxtDebugModuleMutationRecord } from './types/debug'
|
||||||
|
|
||||||
// Schema
|
// Schema
|
||||||
export { default as NuxtConfigSchema } from './config/index'
|
export { default as NuxtConfigSchema } from './config/index'
|
||||||
|
14
packages/schema/src/types/debug.ts
Normal file
14
packages/schema/src/types/debug.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export interface NuxtDebugContext {
|
||||||
|
/**
|
||||||
|
* Module mutation records to the `nuxt` instance.
|
||||||
|
*/
|
||||||
|
moduleMutationRecords?: NuxtDebugModuleMutationRecord[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NuxtDebugModuleMutationRecord {
|
||||||
|
module: string | undefined
|
||||||
|
keys: (string | symbol)[]
|
||||||
|
value: any
|
||||||
|
method?: string
|
||||||
|
timestamp: number
|
||||||
|
}
|
@ -3,6 +3,7 @@ import type { Ignore } from 'ignore'
|
|||||||
import type { NuxtHooks, NuxtLayout, NuxtMiddleware, NuxtPage } from './hooks'
|
import type { NuxtHooks, NuxtLayout, NuxtMiddleware, NuxtPage } from './hooks'
|
||||||
import type { Component } from './components'
|
import type { Component } from './components'
|
||||||
import type { NuxtOptions } from './config'
|
import type { NuxtOptions } from './config'
|
||||||
|
import type { NuxtDebugContext } from './debug'
|
||||||
|
|
||||||
export interface NuxtPlugin {
|
export interface NuxtPlugin {
|
||||||
/** @deprecated use mode */
|
/** @deprecated use mode */
|
||||||
@ -83,6 +84,7 @@ export interface Nuxt {
|
|||||||
_version: string
|
_version: string
|
||||||
_ignore?: Ignore
|
_ignore?: Ignore
|
||||||
_dependencies?: Set<string>
|
_dependencies?: Set<string>
|
||||||
|
_debug?: NuxtDebugContext
|
||||||
|
|
||||||
/** The resolved Nuxt configuration. */
|
/** The resolved Nuxt configuration. */
|
||||||
options: NuxtOptions
|
options: NuxtOptions
|
||||||
|
@ -230,6 +230,9 @@ importers:
|
|||||||
ohash:
|
ohash:
|
||||||
specifier: 1.1.4
|
specifier: 1.1.4
|
||||||
version: 1.1.4
|
version: 1.1.4
|
||||||
|
on-change:
|
||||||
|
specifier: ^5.0.1
|
||||||
|
version: 5.0.1
|
||||||
pathe:
|
pathe:
|
||||||
specifier: ^1.1.2
|
specifier: ^1.1.2
|
||||||
version: 1.1.2
|
version: 1.1.2
|
||||||
@ -1064,7 +1067,7 @@ importers:
|
|||||||
devDependencies:
|
devDependencies:
|
||||||
'@vue/devtools-api':
|
'@vue/devtools-api':
|
||||||
specifier: latest
|
specifier: latest
|
||||||
version: 7.6.8
|
version: 7.6.7
|
||||||
defu:
|
defu:
|
||||||
specifier: latest
|
specifier: latest
|
||||||
version: 6.1.4
|
version: 6.1.4
|
||||||
@ -1073,7 +1076,7 @@ importers:
|
|||||||
version: 1.5.4
|
version: 1.5.4
|
||||||
unplugin:
|
unplugin:
|
||||||
specifier: latest
|
specifier: latest
|
||||||
version: 2.1.2
|
version: 1.16.1
|
||||||
vue:
|
vue:
|
||||||
specifier: 3.5.13
|
specifier: 3.5.13
|
||||||
version: 3.5.13(typescript@5.7.2)
|
version: 3.5.13(typescript@5.7.2)
|
||||||
@ -3038,8 +3041,8 @@ packages:
|
|||||||
'@vue/devtools-api@6.6.4':
|
'@vue/devtools-api@6.6.4':
|
||||||
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
|
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
|
||||||
|
|
||||||
'@vue/devtools-api@7.6.8':
|
'@vue/devtools-api@7.6.7':
|
||||||
resolution: {integrity: sha512-ma6dY/sZR36zALVsV1W7eC57c6IJPXsy8SNgZn1PLVWU4z4dPn5TIBmnF4stmdJ4sQcixqKaQ8pwjbMPzEZwiA==}
|
resolution: {integrity: sha512-PV4I31WaV2rfA8RGauM+69uFEzWkqtP561RiLU2wK+Ce85u3zyKW3aoESlLCNzkc4y0JaJyskH6zAE3xWOP8+Q==}
|
||||||
|
|
||||||
'@vue/devtools-core@7.6.8':
|
'@vue/devtools-core@7.6.8':
|
||||||
resolution: {integrity: sha512-8X4roysTwzQ94o7IobjVcOd1aZF5iunikrMrHPI2uUdigZCi2kFTQc7ffYiFiTNaLElCpjOhCnM7bo7aK1yU7A==}
|
resolution: {integrity: sha512-8X4roysTwzQ94o7IobjVcOd1aZF5iunikrMrHPI2uUdigZCi2kFTQc7ffYiFiTNaLElCpjOhCnM7bo7aK1yU7A==}
|
||||||
@ -5817,6 +5820,10 @@ packages:
|
|||||||
ohash@1.1.4:
|
ohash@1.1.4:
|
||||||
resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==}
|
resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==}
|
||||||
|
|
||||||
|
on-change@5.0.1:
|
||||||
|
resolution: {integrity: sha512-n7THCP7RkyReRSLkJb8kUWoNsxUIBxTkIp3JKno+sEz6o/9AJ3w3P9fzQkITEkMwyTKJjZciF3v/pVoouxZZMg==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
on-finished@2.4.1:
|
on-finished@2.4.1:
|
||||||
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
|
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
@ -6590,6 +6597,7 @@ packages:
|
|||||||
rollup-plugin-visualizer@5.13.1:
|
rollup-plugin-visualizer@5.13.1:
|
||||||
resolution: {integrity: sha512-vMg8i6BprL8aFm9DKvL2c8AwS8324EgymYQo9o6E26wgVvwMhsJxS37aNL6ZsU7X9iAcMYwdME7gItLfG5fwJg==}
|
resolution: {integrity: sha512-vMg8i6BprL8aFm9DKvL2c8AwS8324EgymYQo9o6E26wgVvwMhsJxS37aNL6ZsU7X9iAcMYwdME7gItLfG5fwJg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
deprecated: Contains unintended breaking changes
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
rolldown: 1.x
|
rolldown: 1.x
|
||||||
@ -7278,6 +7286,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-5liCNPuJW8dqh3+DM6uNM2EI3MLLpCKp/KY+9pB5M2S2SR2qvvDHhKgBOaTWEbZTAws3CXfB0rKTIolWKL05VQ==}
|
resolution: {integrity: sha512-5liCNPuJW8dqh3+DM6uNM2EI3MLLpCKp/KY+9pB5M2S2SR2qvvDHhKgBOaTWEbZTAws3CXfB0rKTIolWKL05VQ==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
|
|
||||||
|
unplugin@1.16.1:
|
||||||
|
resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
|
||||||
unplugin@2.0.0-beta.1:
|
unplugin@2.0.0-beta.1:
|
||||||
resolution: {integrity: sha512-2qzQo5LN2DmUZXkWDHvGKLF5BP0WN+KthD6aPnPJ8plRBIjv4lh5O07eYcSxgO2znNw9s4MNhEO1sB+JDllDbQ==}
|
resolution: {integrity: sha512-2qzQo5LN2DmUZXkWDHvGKLF5BP0WN+KthD6aPnPJ8plRBIjv4lh5O07eYcSxgO2znNw9s4MNhEO1sB+JDllDbQ==}
|
||||||
engines: {node: '>=18.12.0'}
|
engines: {node: '>=18.12.0'}
|
||||||
@ -10006,7 +10018,7 @@ snapshots:
|
|||||||
chokidar: 3.6.0
|
chokidar: 3.6.0
|
||||||
magic-string: 0.30.17
|
magic-string: 0.30.17
|
||||||
tinyglobby: 0.2.10
|
tinyglobby: 0.2.10
|
||||||
unplugin: 1.16.0
|
unplugin: 1.16.1
|
||||||
webpack: 5.97.1(esbuild@0.24.2)
|
webpack: 5.97.1(esbuild@0.24.2)
|
||||||
webpack-sources: 3.2.3
|
webpack-sources: 3.2.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@ -10235,7 +10247,7 @@ snapshots:
|
|||||||
|
|
||||||
'@vue/devtools-api@6.6.4': {}
|
'@vue/devtools-api@6.6.4': {}
|
||||||
|
|
||||||
'@vue/devtools-api@7.6.8':
|
'@vue/devtools-api@7.6.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/devtools-kit': 7.6.8
|
'@vue/devtools-kit': 7.6.8
|
||||||
|
|
||||||
@ -13547,6 +13559,8 @@ snapshots:
|
|||||||
|
|
||||||
ohash@1.1.4: {}
|
ohash@1.1.4: {}
|
||||||
|
|
||||||
|
on-change@5.0.1: {}
|
||||||
|
|
||||||
on-finished@2.4.1:
|
on-finished@2.4.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
ee-first: 1.1.1
|
ee-first: 1.1.1
|
||||||
@ -15247,6 +15261,11 @@ snapshots:
|
|||||||
acorn: 8.14.0
|
acorn: 8.14.0
|
||||||
webpack-virtual-modules: 0.6.2
|
webpack-virtual-modules: 0.6.2
|
||||||
|
|
||||||
|
unplugin@1.16.1:
|
||||||
|
dependencies:
|
||||||
|
acorn: 8.14.0
|
||||||
|
webpack-virtual-modules: 0.6.2
|
||||||
|
|
||||||
unplugin@2.0.0-beta.1:
|
unplugin@2.0.0-beta.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
acorn: 8.14.0
|
acorn: 8.14.0
|
||||||
@ -15299,7 +15318,7 @@ snapshots:
|
|||||||
mlly: 1.7.3
|
mlly: 1.7.3
|
||||||
pathe: 1.1.2
|
pathe: 1.1.2
|
||||||
pkg-types: 1.3.0
|
pkg-types: 1.3.0
|
||||||
unplugin: 1.16.0
|
unplugin: 1.16.1
|
||||||
|
|
||||||
update-browserslist-db@1.1.0(browserslist@4.24.0):
|
update-browserslist-db@1.1.0(browserslist@4.24.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user