Skip to content

Commit

Permalink
fix: stable integrations setup to have consistent plugins order (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 13, 2023
1 parent d9394b5 commit 310929b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/devtools/src/integrations/plugin-metrics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NuxtDevtoolsServerContext } from '../types'

export async function setup({ nuxt }: NuxtDevtoolsServerContext) {
export function setup({ nuxt }: NuxtDevtoolsServerContext) {
if (!nuxt.options.dev || nuxt.options.test)
return

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/integrations/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import semver from 'semver'
import type { NuxtDevtoolsServerContext } from '../types'
import { runtimeDir } from '../dirs'

export async function setup({ nuxt, options }: NuxtDevtoolsServerContext) {
export function setup({ nuxt, options }: NuxtDevtoolsServerContext) {
const helperPath = resolve(runtimeDir, 'function-metrics-helpers')

const includeFrom = options.timeline?.functions?.includeFrom || [
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/integrations/vite-inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Inspect from 'vite-plugin-inspect'
import { addCustomTab } from '@nuxt/devtools-kit'
import type { NuxtDevtoolsServerContext } from '../types'

export async function setup({ nuxt, rpc }: NuxtDevtoolsServerContext) {
export function setup({ nuxt, rpc }: NuxtDevtoolsServerContext) {
const plugin = Inspect()
addVitePlugin(plugin)

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/integrations/vue-inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Plugin } from 'vite'
import VueInspector from 'vite-plugin-vue-inspector'
import type { NuxtDevtoolsServerContext } from '../types'

export async function setup({ nuxt, options }: NuxtDevtoolsServerContext) {
export function setup({ nuxt, options }: NuxtDevtoolsServerContext) {
if (!nuxt.options.dev || nuxt.options.test)
return

Expand Down
19 changes: 10 additions & 9 deletions packages/devtools/src/module-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import { readLocalOptions } from './utils/local-options'

export async function enableModule(options: ModuleOptions, nuxt: Nuxt) {
// Disable in test mode
if (process.env.TEST || process.env.NODE_ENV === 'test')
if (process.env.TEST || process.env.NODE_ENV === 'test' || nuxt.options.test)
return

if (nuxt.options.builder !== '@nuxt/vite-builder') {
logger.warn('Nuxt DevTools only supports Vite mode, module is disabled.')
return
}

if (!nuxt.options.dev || nuxt.options.test) {
if (!nuxt.options.dev) {
if (nuxt.options.build.analyze)
await import('./integrations/analyze-build').then(({ setup }) => setup(nuxt, options))
return
Expand Down Expand Up @@ -178,14 +178,15 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
})
})

await import('./integrations/plugin-metrics').then(({ setup }) => setup(ctx))

if (options.viteInspect !== false)
await import('./integrations/vite-inspect').then(({ setup }) => setup(ctx))

if (options.componentInspector !== false)
await import('./integrations/vue-inspector').then(({ setup }) => setup(ctx))

const integrations = [
import('./integrations/plugin-metrics').then(({ setup }) => setup(ctx)),
options.viteInspect !== false
? import('./integrations/vite-inspect').then(({ setup }) => setup(ctx))
: null,
options.componentInspector !== false
? import('./integrations/vue-inspector').then(({ setup }) => setup(ctx))
: null,
options.vscode?.enabled
? import('./integrations/vscode').then(({ setup }) => setup(ctx))
: null,
Expand Down

0 comments on commit 310929b

Please sign in to comment.