@vitejs/devtools 0.0.0-alpha.3 → 0.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ import { a as createDevToolsContext, t as DevTools } from "./plugins-BbzqUdpu.js";
2
+ import { resolveConfig } from "vite";
3
+ import process from "node:process";
4
+
5
+ //#region src/node/standalone.ts
6
+ async function startStandaloneDevTools(options = {}) {
7
+ const { cwd = process.cwd(), command = "build", mode = "production" } = options;
8
+ const resolved = await resolveConfig({
9
+ configFile: options.config,
10
+ root: cwd,
11
+ plugins: [DevTools()]
12
+ }, command, mode);
13
+ dedupeVitePlugins(resolved.plugins, (plugin) => plugin.name?.startsWith("vite:devtools"));
14
+ return {
15
+ config: resolved,
16
+ context: await createDevToolsContext(resolved)
17
+ };
18
+ }
19
+ function dedupeVitePlugins(plugins, include) {
20
+ const toDelete = [];
21
+ const map = /* @__PURE__ */ new Map();
22
+ for (let i = 0; i < plugins.length; i++) {
23
+ const plugin = plugins[i];
24
+ if (!plugin || !include(plugin)) continue;
25
+ if (map.has(plugin.name)) toDelete.push(i);
26
+ else map.set(plugin.name, plugin);
27
+ }
28
+ toDelete.sort((a, b) => b - a);
29
+ for (const i of toDelete) plugins.splice(i, 1);
30
+ return plugins;
31
+ }
32
+
33
+ //#endregion
34
+ export { startStandaloneDevTools as t };