@vizejs/vite-plugin 0.39.0 → 0.42.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 +42 -5
- package/dist/index.d.mts +9 -15
- package/dist/index.mjs +5 -72
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ High-performance native Vite plugin for Vue SFC compilation powered by [Vize](ht
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
# npm
|
|
17
|
-
npm install @vizejs/vite-plugin
|
|
17
|
+
npm install @vizejs/vite-plugin vize
|
|
18
18
|
|
|
19
19
|
# pnpm
|
|
20
|
-
pnpm add @vizejs/vite-plugin
|
|
20
|
+
pnpm add @vizejs/vite-plugin vize
|
|
21
21
|
|
|
22
22
|
# yarn
|
|
23
|
-
yarn add @vizejs/vite-plugin
|
|
23
|
+
yarn add @vizejs/vite-plugin vize
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Usage
|
|
@@ -41,6 +41,43 @@ export default defineConfig({
|
|
|
41
41
|
});
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
### Shared config
|
|
45
|
+
|
|
46
|
+
`vize.config.ts`
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { defineConfig } from "vize";
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
compiler: {
|
|
53
|
+
sourceMap: true,
|
|
54
|
+
},
|
|
55
|
+
vite: {
|
|
56
|
+
scanPatterns: ["src/**/*.vue"],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`vize.config.pkl`
|
|
62
|
+
|
|
63
|
+
```pkl
|
|
64
|
+
amends "node_modules/vize/pkl/vize.pkl"
|
|
65
|
+
|
|
66
|
+
compiler {
|
|
67
|
+
sourceMap = true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
vite {
|
|
71
|
+
scanPatterns = new Listing {
|
|
72
|
+
"src/**/*.vue"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`@vizejs/vite-plugin` loads the same `vize.config.ts`, `vize.config.js`, `vize.config.mjs`,
|
|
78
|
+
`vize.config.pkl`, and `vize.config.json` files as the `vize` npm CLI. Importing
|
|
79
|
+
`defineConfig` from `@vizejs/vite-plugin` still works, but `vize` is the shared entry point.
|
|
80
|
+
|
|
44
81
|
### Nuxt
|
|
45
82
|
|
|
46
83
|
For Nuxt 3, add the plugin to your `nuxt.config.ts`:
|
|
@@ -180,8 +217,8 @@ Vize's native compiler is significantly faster than the official Vue compiler:
|
|
|
180
217
|
|
|
181
218
|
| Benchmark (15,000 SFCs) | @vue/compiler-sfc | Vize | Speedup |
|
|
182
219
|
| ----------------------- | ----------------- | ----- | -------- |
|
|
183
|
-
| Single-threaded |
|
|
184
|
-
| Multi-threaded |
|
|
220
|
+
| Single-threaded | 10.43s | 6.06s | **1.7x** |
|
|
221
|
+
| Multi-threaded | 3.45s | 612ms | **5.6x** |
|
|
185
222
|
|
|
186
223
|
## Comparison with vite-plugin-vize
|
|
187
224
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineConfig, loadConfig } from "vize";
|
|
1
2
|
import { Plugin } from "vite";
|
|
2
3
|
|
|
3
4
|
//#region ../vize/src/types/compiler.d.ts
|
|
@@ -145,9 +146,9 @@ interface TypeCheckerConfig {
|
|
|
145
146
|
*/
|
|
146
147
|
tsconfig?: string;
|
|
147
148
|
/**
|
|
148
|
-
* Path to
|
|
149
|
+
* Path to the Corsa binary
|
|
149
150
|
*/
|
|
150
|
-
|
|
151
|
+
corsaPath?: string;
|
|
151
152
|
}
|
|
152
153
|
/**
|
|
153
154
|
* Formatter configuration
|
|
@@ -224,10 +225,10 @@ interface LspConfig {
|
|
|
224
225
|
*/
|
|
225
226
|
codeActions?: boolean;
|
|
226
227
|
/**
|
|
227
|
-
* Use
|
|
228
|
+
* Use Corsa for type checking in LSP
|
|
228
229
|
* @default false
|
|
229
230
|
*/
|
|
230
|
-
|
|
231
|
+
corsa?: boolean;
|
|
231
232
|
}
|
|
232
233
|
//#endregion
|
|
233
234
|
//#region ../vize/src/types/musea.d.ts
|
|
@@ -367,13 +368,11 @@ interface LoadConfigOptions {
|
|
|
367
368
|
}
|
|
368
369
|
//#endregion
|
|
369
370
|
//#region ../vize/src/types/core.d.ts
|
|
370
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
371
371
|
interface ConfigEnv {
|
|
372
372
|
mode: string;
|
|
373
373
|
command: "serve" | "build" | "check" | "lint" | "fmt";
|
|
374
374
|
isSsrBuild?: boolean;
|
|
375
375
|
}
|
|
376
|
-
type UserConfigExport = VizeConfig | ((env: ConfigEnv) => MaybePromise<VizeConfig>);
|
|
377
376
|
type RuleSeverity = "off" | "warn" | "error";
|
|
378
377
|
type RuleCategory = "correctness" | "suspicious" | "style" | "perf" | "a11y" | "security";
|
|
379
378
|
type LintPreset = "happy-path" | "opinionated" | "essential" | "nuxt";
|
|
@@ -381,6 +380,10 @@ type LintPreset = "happy-path" | "opinionated" | "essential" | "nuxt";
|
|
|
381
380
|
* Vize configuration options
|
|
382
381
|
*/
|
|
383
382
|
interface VizeConfig {
|
|
383
|
+
/**
|
|
384
|
+
* JSON Schema reference for editor autocompletion.
|
|
385
|
+
*/
|
|
386
|
+
$schema?: string;
|
|
384
387
|
/**
|
|
385
388
|
* Vue compiler options
|
|
386
389
|
*/
|
|
@@ -530,15 +533,6 @@ declare function rewriteStaticAssetUrls(code: string, aliasRules: DynamicImportA
|
|
|
530
533
|
declare function vize(options?: VizeOptions): Plugin[];
|
|
531
534
|
//#endregion
|
|
532
535
|
//#region src/config.d.ts
|
|
533
|
-
/**
|
|
534
|
-
* Define a Vize configuration with type checking.
|
|
535
|
-
* Accepts a plain object or a function that receives ConfigEnv.
|
|
536
|
-
*/
|
|
537
|
-
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
538
|
-
/**
|
|
539
|
-
* Load Vize configuration from file
|
|
540
|
-
*/
|
|
541
|
-
declare function loadConfig(root: string, options?: LoadConfigOptions): Promise<VizeConfig | null>;
|
|
542
536
|
/**
|
|
543
537
|
* Shared config store for inter-plugin communication.
|
|
544
538
|
* Key = project root, Value = resolved VizeConfig.
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { CONFIG_FILE_NAMES, defineConfig, loadConfig } from "vize";
|
|
5
6
|
import { glob } from "tinyglobby";
|
|
6
7
|
import * as native from "@vizejs/native";
|
|
7
8
|
import { pathToFileURL } from "node:url";
|
|
@@ -379,77 +380,7 @@ function createLogger(debug) {
|
|
|
379
380
|
error: (...args) => console.error("[vize]", ...args)
|
|
380
381
|
};
|
|
381
382
|
}
|
|
382
|
-
|
|
383
|
-
//#region src/config.ts
|
|
384
|
-
/**
|
|
385
|
-
* Vize configuration loading and management.
|
|
386
|
-
*
|
|
387
|
-
* Handles discovery, loading, and caching of vize.config.ts/js/json files,
|
|
388
|
-
* and provides the shared config store for inter-plugin communication.
|
|
389
|
-
*/
|
|
390
|
-
const CONFIG_FILES = [
|
|
391
|
-
"vize.config.ts",
|
|
392
|
-
"vize.config.js",
|
|
393
|
-
"vize.config.mjs",
|
|
394
|
-
"vize.config.json"
|
|
395
|
-
];
|
|
396
|
-
const DEFAULT_CONFIG_ENV = {
|
|
397
|
-
mode: "development",
|
|
398
|
-
command: "serve"
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* Define a Vize configuration with type checking.
|
|
402
|
-
* Accepts a plain object or a function that receives ConfigEnv.
|
|
403
|
-
*/
|
|
404
|
-
function defineConfig(config) {
|
|
405
|
-
return config;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Load Vize configuration from file
|
|
409
|
-
*/
|
|
410
|
-
async function loadConfig(root, options = {}) {
|
|
411
|
-
const { mode = "root", configFile, env } = options;
|
|
412
|
-
if (mode === "none") return null;
|
|
413
|
-
if (configFile) return loadConfigFile(path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile), env);
|
|
414
|
-
if (mode === "auto") {
|
|
415
|
-
let searchDir = root;
|
|
416
|
-
while (true) {
|
|
417
|
-
const found = findConfigInDir(searchDir);
|
|
418
|
-
if (found) return loadConfigFile(found, env);
|
|
419
|
-
const parentDir = path.dirname(searchDir);
|
|
420
|
-
if (parentDir === searchDir) break;
|
|
421
|
-
searchDir = parentDir;
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
}
|
|
425
|
-
const found = findConfigInDir(root);
|
|
426
|
-
return found ? loadConfigFile(found, env) : null;
|
|
427
|
-
}
|
|
428
|
-
function findConfigInDir(dir) {
|
|
429
|
-
for (const filename of CONFIG_FILES) {
|
|
430
|
-
const configPath = path.join(dir, filename);
|
|
431
|
-
if (fs.existsSync(configPath)) return configPath;
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
async function resolveConfigExport(exported, env) {
|
|
436
|
-
if (typeof exported === "function") return exported(env ?? DEFAULT_CONFIG_ENV);
|
|
437
|
-
return exported;
|
|
438
|
-
}
|
|
439
|
-
async function loadConfigFile(configPath, env) {
|
|
440
|
-
if (!fs.existsSync(configPath)) return null;
|
|
441
|
-
if (path.extname(configPath) === ".json") {
|
|
442
|
-
const content = fs.readFileSync(configPath, "utf-8");
|
|
443
|
-
return JSON.parse(content);
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
const module = await import(configPath);
|
|
447
|
-
return resolveConfigExport(module.default ?? module, env);
|
|
448
|
-
} catch (e) {
|
|
449
|
-
console.warn(`[vize] Failed to load config from ${configPath}:`, e);
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
383
|
+
[...CONFIG_FILE_NAMES];
|
|
453
384
|
/**
|
|
454
385
|
* Shared config store for inter-plugin communication.
|
|
455
386
|
* Key = project root, Value = resolved VizeConfig.
|
|
@@ -1226,7 +1157,7 @@ function vize(options = {}) {
|
|
|
1226
1157
|
isSsrBuild: !!resolvedConfig.build?.ssr
|
|
1227
1158
|
};
|
|
1228
1159
|
let fileConfig = null;
|
|
1229
|
-
if (options.configMode !== false) {
|
|
1160
|
+
if (options.configMode !== false) try {
|
|
1230
1161
|
fileConfig = await loadConfig(state.root, {
|
|
1231
1162
|
mode: options.configMode ?? "root",
|
|
1232
1163
|
configFile: options.configFile,
|
|
@@ -1236,6 +1167,8 @@ function vize(options = {}) {
|
|
|
1236
1167
|
state.logger.log("Loaded config from vize.config file");
|
|
1237
1168
|
vizeConfigStore.set(state.root, fileConfig);
|
|
1238
1169
|
}
|
|
1170
|
+
} catch (error) {
|
|
1171
|
+
state.logger.warn(`Failed to load vize config from ${options.configFile ?? state.root}:`, error);
|
|
1239
1172
|
}
|
|
1240
1173
|
const viteConfig = fileConfig?.vite ?? {};
|
|
1241
1174
|
const compilerConfig = fileConfig?.compiler ?? {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"tinyglobby": "^0.2.0",
|
|
37
|
-
"@vizejs/native": "0.
|
|
37
|
+
"@vizejs/native": "0.42.0",
|
|
38
|
+
"vize": "0.42.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/node": "^22.0.0",
|