Skip to content

Subpath exports

SpecifierWhat it provides
@mars-tech/vite-debug-pluginThe plugin factory (default export) and the public MT* types.
@mars-tech/vite-debug-plugin/helpersThe DEFAULT_* constants and the core MT* types.
@mars-tech/vite-debug-plugin/eslintAn ESLint flat config declaring the $debug global, and two helpers.
@mars-tech/vite-debug-plugin/testingTest-runner setup: installs a no-op $debug, and exports the stub and console installers.
@mars-tech/vite-debug-plugin/testing/logA setup module that installs the console logger with its defaults, for a config without the plugin.
@mars-tech/vite-debug-plugin/clientThe target of the triple-slash reference for the $debug global type.
ts
import mtDebug from "@mars-tech/vite-debug-plugin";
import {
  DEFAULT_COLORS,
  type MTLevel,
} from "@mars-tech/vite-debug-plugin/helpers";

The package manifest is also exported (@mars-tech/vite-debug-plugin/package.json), for tools that read a dependency's manifest through the exports map.

@mars-tech/vite-debug-plugin

Default export only: the plugin factory. The public MT* types are re-exported here too (import type { MTPluginOptions } from "@mars-tech/vite-debug-plugin"). It is callable from CommonJS: const mtDebug = require('@mars-tech/vite-debug-plugin') returns the function.

@mars-tech/vite-debug-plugin/helpers

The canonical home of the constants and core types:

  • constants: DEFAULT_COLORS, DEFAULT_PREFIX, DEFAULT_GLOBAL_NAME;
  • types: MTLevel, MTCallOptions, MTPluginOptions, MTDebug, MTDebugFn, MTColorMap, MTColorEntry, MTColorOverrides, MTSourceLocation, MTLogRecord, MTLogLine.

MTInstallStubOptions and MTInstallConsoleOptions ship on /testing, and MTGlobalAccess, MTEslintOptions and MTFlatConfig on /eslint. See Exported types for what each core type describes.

@mars-tech/vite-debug-plugin/eslint

The default export is an ESLint flat config declaring the $debug global. The module also exports two helpers that take the same options object ({ globalName?, access? }):

  • mtDebugFlatConfig(opts): a flat config for a custom globalName;
  • mtDebugGlobals(opts?): a globals map, for languageOptions.globals or a legacy .eslintrc (ESLint 9 and earlier).

See Tell ESLint about the global.

@mars-tech/vite-debug-plugin/testing

Test-runner setup: importing it installs a no-op $debug. It also exports installMtDebugStub(opts) and installMtDebugConsole(opts), the config-aware console logger that test: 'log' installs, for a hand-written setup file. See Testing and A logger in your own setup file.

@mars-tech/vite-debug-plugin/testing/log

A setup module that installs the real console logger with its defaults, for a config without the plugin (Jest, or a Vitest config that does not load it). List it first in setupFiles. To pass options such as prefix or redact, call installMtDebugConsole from /testing instead.

Under the plugin, test: 'log' registers a setup module generated from your configuration: do not list this one as well. Imported anyway, it leaves the configured logger in place. See Seeing $debug output in tests.

@mars-tech/vite-debug-plugin/client

The target of the triple-slash reference that declares the $debug global type. See Enable the $debug global type.

Exported types

TypeWhat it describes
MTLevelOne of the six levels: 'error', 'warning', 'info', 'debug', 'success', 'trace'.
MTCallOptionsThe per-call options: showStack, showSource, tag, prefix, inspect (and raw, its deprecated alias). See Call signature.
MTPluginOptionsThe options of mtDebug(). See Plugin options.
MTDebugThe global $debug: the callable and all 14 methods. Use it to declare a custom globalName.
MTDebugFnThe callable alone, as returned by $debug.ns().
MTColorMap / MTColorEntry / MTColorOverridesThe level colors: the full map, one level's { ansi, css, label }, and the partial overrides the colors option accepts.
MTSourceLocationWhere a call was made: { file, line, column }, the file relative to the Vite root, line and column counted from 1.
MTLogRecordOne call as the dev server prints it: level, message (rendered and redacted), and optional tag, source, stack and prefix.
MTLogLineOne line of the NDJSON log file: an MTLogRecord plus t (ISO write time), seq (order within the session) and origin ("browser" or "server").