@vizejs/vite-plugin 0.425.1 → 0.426.0
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.
- package/README.md +36 -1
- package/dist/config-PP6EAmWc.mjs +39 -0
- package/dist/config-bridge-Dv6U7_RC.mjs +21 -0
- package/dist/editor-D3tfVb0Z.mjs +61 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -4212
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/internal/config-bridge.mjs +1 -20
- package/dist/internal/vite-plus-task.d.mts +1 -0
- package/dist/internal/vite-plus-task.mjs +10 -0
- package/dist/plugin-BSxbzkGl.mjs +4111 -0
- package/dist/plugin-CewswkDY.mjs +2 -0
- package/dist/runner-DvShtC55.mjs +202 -0
- package/dist/shared-config-dMxrrTkb.mjs +69 -0
- package/dist/{types-DliFOfUZ.d.mts → types-CtulgM97.d.mts} +1 -1
- package/dist/vite-plus.d.mts +65 -0
- package/dist/vite-plus.mjs +352 -0
- package/package.json +20 -6
package/README.md
CHANGED
|
@@ -22,7 +22,42 @@ Add `vize` as a direct dependency only if your project imports shared config hel
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
### Vite
|
|
25
|
+
### Vite+
|
|
26
|
+
|
|
27
|
+
Install the `vite-plus` version your project uses, then configure the whole toolchain:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// vite.config.ts
|
|
31
|
+
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
compiler: { sourceMap: true },
|
|
35
|
+
typecheck: { strict: true },
|
|
36
|
+
lint: { vize: { preset: "essential", typecheck: true } },
|
|
37
|
+
fmt: { vize: { singleQuote: true } },
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Run `vp run check`, `lint`, `fmt`, `build`, or `pack` without registering another
|
|
42
|
+
plugin or writing CLI scripts. Native lint runs alongside Oxlint; overlapping
|
|
43
|
+
rules and Vue formatting ownership are configured automatically.
|
|
44
|
+
|
|
45
|
+
Use `extends` for shared presets and `pack.vize` for native declarations,
|
|
46
|
+
declaration maps, and compiler maps. `vize.lint.typecheck` is also supported.
|
|
47
|
+
`withVue` and `withVize` are aliases with the same single-object API.
|
|
48
|
+
|
|
49
|
+
Vite+ remains a user-selected optional peer (0.2.3 or later); configuration types
|
|
50
|
+
come from that peer. Ordinary Vite users do not need to install it. Built-in
|
|
51
|
+
`vp check/lint/fmt` keep their Vite+ behavior; combined checks use `vp run`.
|
|
52
|
+
|
|
53
|
+
Run `vp run editor:setup` to recommend Vize alongside the Vite Plus extension
|
|
54
|
+
pack while preserving existing workspace settings and Oxc's non-Vue formatter.
|
|
55
|
+
|
|
56
|
+
See the [Vite+ guide](../../../docs/content/guide/vite-plus.md) and
|
|
57
|
+
[editor setup](../../../docs/content/guide/vite-plus-editor.md) for configuration,
|
|
58
|
+
task naming, native editor config, and tool ownership.
|
|
59
|
+
|
|
60
|
+
## Vite
|
|
26
61
|
|
|
27
62
|
```ts
|
|
28
63
|
// vite.config.ts
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region src/config.ts
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
const CONFIG_FILE_NAMES = [
|
|
5
|
+
"vize.config.pkl",
|
|
6
|
+
"vize.config.ts",
|
|
7
|
+
"vize.config.js",
|
|
8
|
+
"vize.config.mjs",
|
|
9
|
+
"vize.config.json"
|
|
10
|
+
];
|
|
11
|
+
let vizeConfigModulePromise = null;
|
|
12
|
+
function loadVizeConfigModule() {
|
|
13
|
+
vizeConfigModulePromise ??= import("vize/config");
|
|
14
|
+
return vizeConfigModulePromise;
|
|
15
|
+
}
|
|
16
|
+
function defineConfig(config) {
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
async function loadConfig(root, options) {
|
|
20
|
+
return (await loadVizeConfigModule()).loadConfig(root, options);
|
|
21
|
+
}
|
|
22
|
+
async function resolveConfigExport(exported, env) {
|
|
23
|
+
return (await loadVizeConfigModule()).resolveConfigExport(exported, env);
|
|
24
|
+
}
|
|
25
|
+
require.resolve("vize/schemas/vize.config.schema.json");
|
|
26
|
+
require.resolve("vize/pkl/vize.pkl");
|
|
27
|
+
[...CONFIG_FILE_NAMES];
|
|
28
|
+
const VIZE_CONFIG_FILE_ENV = "VIZE_CONFIG_FILE";
|
|
29
|
+
/**
|
|
30
|
+
* Shared config store for inter-plugin communication.
|
|
31
|
+
* Key = project root, Value = resolved VizeConfig.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Root identity cannot isolate parallel Vite client/SSR instances
|
|
34
|
+
* or servers. This export remains temporarily for compatibility; internal Vize
|
|
35
|
+
* integrations use an exact `ResolvedConfig`-scoped bridge instead.
|
|
36
|
+
*/
|
|
37
|
+
const vizeConfigStore = /* @__PURE__ */ new Map();
|
|
38
|
+
//#endregion
|
|
39
|
+
export { vizeConfigStore as a, resolveConfigExport as i, defineConfig as n, loadConfig as r, VIZE_CONFIG_FILE_ENV as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/internal/config-bridge.ts
|
|
2
|
+
const registrations = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
const missingRegistration = Object.freeze({ registered: false });
|
|
4
|
+
/** @internal */
|
|
5
|
+
function registerResolvedVizeConfig(resolvedConfig, config) {
|
|
6
|
+
registrations.set(resolvedConfig, Promise.resolve(config));
|
|
7
|
+
}
|
|
8
|
+
/** @internal */
|
|
9
|
+
function getResolvedVizeConfigRegistration(resolvedConfig) {
|
|
10
|
+
if (!registrations.has(resolvedConfig)) return missingRegistration;
|
|
11
|
+
return {
|
|
12
|
+
registered: true,
|
|
13
|
+
config: registrations.get(resolvedConfig)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
function unregisterResolvedVizeConfig(resolvedConfig) {
|
|
18
|
+
return registrations.delete(resolvedConfig);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { registerResolvedVizeConfig as n, unregisterResolvedVizeConfig as r, getResolvedVizeConfigRegistration as t };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { applyEdits, modify, parse } from "jsonc-parser";
|
|
5
|
+
//#region src/vite-plus/editor.ts
|
|
6
|
+
const recommendations = ["VoidZero.vite-plus-extension-pack", "ubugeeei.vize"];
|
|
7
|
+
const defaults = [
|
|
8
|
+
[["vize.enable"], true],
|
|
9
|
+
[["vize.lint.enable"], true],
|
|
10
|
+
[["vize.typecheck.enable"], true],
|
|
11
|
+
[["vize.editor.enable"], true],
|
|
12
|
+
[["vize.ecosystem.enable"], true],
|
|
13
|
+
[["vize.formatting.enable"], true],
|
|
14
|
+
[["[vue]", "editor.defaultFormatter"], "ubugeeei.vize"],
|
|
15
|
+
[["[vue]", "editor.formatOnSave"], true]
|
|
16
|
+
];
|
|
17
|
+
function recommendEditor(source, extensions) {
|
|
18
|
+
const errors = [];
|
|
19
|
+
const parsed = parse(source, errors, { allowTrailingComma: true });
|
|
20
|
+
if (errors.length || !parsed || Array.isArray(parsed) || typeof parsed !== "object") throw new Error("Editor setup requires a JSON/JSONC object; existing files were preserved.");
|
|
21
|
+
const formattingOptions = {
|
|
22
|
+
insertSpaces: true,
|
|
23
|
+
tabSize: 2
|
|
24
|
+
};
|
|
25
|
+
let result = source;
|
|
26
|
+
const set = (keys, value) => {
|
|
27
|
+
result = applyEdits(result, modify(result, keys, value, { formattingOptions }));
|
|
28
|
+
};
|
|
29
|
+
if (extensions) {
|
|
30
|
+
if (parsed.recommendations !== void 0 && (!Array.isArray(parsed.recommendations) || !parsed.recommendations.every((value) => typeof value === "string"))) throw new Error("extensions.json recommendations must be a string array.");
|
|
31
|
+
const merged = [...new Set([...parsed.recommendations ?? [], ...recommendations])];
|
|
32
|
+
if (JSON.stringify(merged) !== JSON.stringify(parsed.recommendations)) set(["recommendations"], merged);
|
|
33
|
+
} else for (const [keys, value] of defaults) if (keys.reduce((object, key) => object?.[key], parsed) === void 0) set(keys, value);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async function setupEditor(root = process.cwd()) {
|
|
37
|
+
const directory = path.join(root, ".vscode");
|
|
38
|
+
const planned = await Promise.all(["extensions.json", "settings.json"].map(async (name) => {
|
|
39
|
+
const file = path.join(directory, name);
|
|
40
|
+
return {
|
|
41
|
+
file,
|
|
42
|
+
source: recommendEditor(await readFile(file, "utf8").catch((error) => {
|
|
43
|
+
if (error.code !== "ENOENT") throw error;
|
|
44
|
+
return "{}\n";
|
|
45
|
+
}), name === "extensions.json")
|
|
46
|
+
};
|
|
47
|
+
}));
|
|
48
|
+
await mkdir(directory, { recursive: true });
|
|
49
|
+
for (const { file, source } of planned) {
|
|
50
|
+
const temporary = file + "." + randomUUID() + ".tmp";
|
|
51
|
+
try {
|
|
52
|
+
await writeFile(temporary, source, { flag: "wx" });
|
|
53
|
+
await rename(temporary, file);
|
|
54
|
+
} finally {
|
|
55
|
+
await rm(temporary, { force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log("Recommended Vize + Vite Plus extensions and Vue editor defaults. Existing settings were preserved.");
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { setupEditor };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as
|
|
1
|
+
import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as UserConfigExport, n as CompiledModule, o as VizeInspectorLintPlanRequest, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv, y as VizeConfig } from "./types-CtulgM97.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/virtual.d.ts
|