@vizejs/vite-plugin 0.471.0 → 0.475.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 +46 -63
- package/dist/config-DE1fZbgD.mjs +234 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/internal/vite-plus-task.mjs +1 -1
- package/dist/{plugin-CsZ0RKny.mjs → plugin-DtrTTtew.mjs} +96 -2
- package/dist/plugin-VGQR_WGT.mjs +2 -0
- package/dist/{runner-Y2Iuaafy.mjs → runner-B_lRJlux.mjs} +4 -4
- package/dist/{types-B3cTltTi.d.mts → types-kbMQcMYf.d.mts} +9 -13
- package/dist/vite-plus.d.mts +25 -12
- package/dist/vite-plus.mjs +41 -94
- package/dist/vue-version-BUu5UzZ5.mjs +75 -0
- package/dist/vue-version-DGtIj1Bv.mjs +2 -0
- package/package.json +4 -4
- package/dist/config-DNse8RdN.mjs +0 -260
- package/dist/plugin-Cmv6xcTJ.mjs +0 -2
- package/dist/shared-config-DZHugBg2.mjs +0 -179
|
@@ -23,10 +23,6 @@ interface VizeConfig {
|
|
|
23
23
|
* Glob patterns this config excludes
|
|
24
24
|
*/
|
|
25
25
|
ignores?: string[];
|
|
26
|
-
/**
|
|
27
|
-
* Base config files or presets to compose
|
|
28
|
-
*/
|
|
29
|
-
extends?: string | string[];
|
|
30
26
|
/**
|
|
31
27
|
* Vue dialect profile for standalone HTML documents; when absent the dialect is detected structurally per document
|
|
32
28
|
*/
|
|
@@ -178,9 +174,9 @@ interface LinterConfig {
|
|
|
178
174
|
*/
|
|
179
175
|
enabled?: boolean;
|
|
180
176
|
/**
|
|
181
|
-
* Built-in lint preset
|
|
177
|
+
* Built-in lint preset (happy-path is the recommended canonical name; native aliases are accepted)
|
|
182
178
|
*/
|
|
183
|
-
preset?: "happy-path" | "opinionated" | "essential" | "incremental" | "ecosystem" | "nuxt";
|
|
179
|
+
preset?: "general-recommended" | "general_recommended" | "generalRecommended" | "happy-path" | "happy_path" | "happy" | "default" | "recommended" | "opinionated" | "strict" | "all" | "essential" | "incremental" | "ecosystem" | "nuxt";
|
|
184
180
|
/**
|
|
185
181
|
* Enable native type-aware lint rules from the active lint configuration
|
|
186
182
|
*/
|
|
@@ -525,6 +521,10 @@ interface LanguageServerConfig {
|
|
|
525
521
|
* Enable Vue ecosystem lint and editor helpers
|
|
526
522
|
*/
|
|
527
523
|
ecosystem?: boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Enable workspace-wide cross-file diagnostic groups (disabled by default)
|
|
526
|
+
*/
|
|
527
|
+
crossFile?: boolean;
|
|
528
528
|
/**
|
|
529
529
|
* Enable Vue 2.7 / Nuxt 2 editor and type-checking compatibility
|
|
530
530
|
*/
|
|
@@ -764,10 +764,6 @@ interface VizeConfigEntry {
|
|
|
764
764
|
* Glob patterns this entry excludes
|
|
765
765
|
*/
|
|
766
766
|
ignores?: string[];
|
|
767
|
-
/**
|
|
768
|
-
* Base config files or presets to compose
|
|
769
|
-
*/
|
|
770
|
-
extends?: string | string[];
|
|
771
767
|
/**
|
|
772
768
|
* Vue dialect profile for standalone HTML documents; when absent the dialect is detected structurally per document
|
|
773
769
|
*/
|
|
@@ -803,8 +799,8 @@ type VueConfig = {
|
|
|
803
799
|
version?: VueVersion;
|
|
804
800
|
};
|
|
805
801
|
/** Native Vue settings shared by Vite, Vite+, the CLI projection and the editor. */
|
|
806
|
-
type VueOptionKeys = "compiler" | "typeChecker" | "linter" | "formatter" | "languageServer" | "globalTypes" | "files" | "ignores" | "basePath" | "lib";
|
|
807
|
-
/**
|
|
802
|
+
type VueOptionKeys = "name" | "compiler" | "experimentals" | "dialect" | "vite" | "musea" | "typeChecker" | "linter" | "formatter" | "languageServer" | "globalTypes" | "files" | "ignores" | "basePath" | "lib";
|
|
803
|
+
/** Native scopes retain the same authored options inside the Vue namespace. */
|
|
808
804
|
type VueOptionsEntry = Pick<VizeConfigEntry, "basePath" | "files" | "ignores" | "linter">;
|
|
809
805
|
/** Section option values reuse the native types rather than a second schema. */
|
|
810
806
|
type VueOptions = Pick<VizeConfig, VueOptionKeys> & {
|
|
@@ -1303,4 +1299,4 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
1303
1299
|
debug?: boolean;
|
|
1304
1300
|
}
|
|
1305
1301
|
//#endregion
|
|
1306
|
-
export {
|
|
1302
|
+
export { FormatterConfig as _, VizeInspectorLintPlanProvider as a, VizeConfig as b, VizeCompatibilityOptions as c, LoadConfigOptions as d, ResolvedVizeConfig as f, CompilerConfig as g, VueOptionsEntry as h, VizeVueFeatures as i, VizeVueVersion as l, VueOptions as m, CompiledModule as n, VizeInspectorLintPlanRequest as o, UserConfigExport as p, MacroArtifact as r, VizeInspectorOptions as s, VizeOptions as t, ConfigEnv as u, LinterConfig as v, TypeCheckerConfig as y };
|
package/dist/vite-plus.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-kbMQcMYf.mjs";
|
|
2
2
|
import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
|
|
3
3
|
|
|
4
4
|
//#region src/vite-plus/types.d.ts
|
|
@@ -26,7 +26,8 @@ interface VizePackOptions {
|
|
|
26
26
|
tsconfig?: string;
|
|
27
27
|
}
|
|
28
28
|
type WithPack<T> = T extends (infer Item)[] ? WithPack<Item>[] : T & {
|
|
29
|
-
|
|
29
|
+
vue?: VizePackOptions | false;
|
|
30
|
+
vize?: never;
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
32
33
|
* Vite and Vite+ both accept a named plugin (including nested async options),
|
|
@@ -39,24 +40,20 @@ type CompatiblePluginOption = {
|
|
|
39
40
|
type WithCompatiblePlugins<T> = Omit<T, "plugins"> & {
|
|
40
41
|
plugins?: CompatiblePluginOption[];
|
|
41
42
|
};
|
|
42
|
-
type VizeSharedConfig = UserConfig$1 & {
|
|
43
|
-
/** Alias of lint.vize; lint.vize takes precedence when both are provided. */lint?: VizeLintOptions | boolean;
|
|
44
|
-
};
|
|
45
43
|
interface VueIntegrationConfig {
|
|
46
44
|
/** Shared native Vue policy. */
|
|
47
45
|
vue?: VueOptions;
|
|
48
|
-
extends?: VueConfig | VueConfig[];
|
|
49
46
|
compiler?: VizeCompilerOptions | false;
|
|
50
47
|
typecheck?: TypeCheckerConfig | boolean;
|
|
51
48
|
lint?: UserConfig["lint"] & {
|
|
52
|
-
|
|
49
|
+
vue?: VizeLintOptions | boolean;
|
|
50
|
+
vize?: never;
|
|
53
51
|
};
|
|
54
52
|
fmt?: UserConfig["fmt"] & {
|
|
55
|
-
|
|
53
|
+
vue?: FormatterConfig | boolean;
|
|
54
|
+
vize?: never;
|
|
56
55
|
};
|
|
57
56
|
pack?: WithPack<NonNullable<UserConfig["pack"]>>;
|
|
58
|
-
/** Shared native settings, including scopes, globals and editor settings. */
|
|
59
|
-
vize?: VizeSharedConfig | UserConfigExport;
|
|
60
57
|
}
|
|
61
58
|
type WithVize<T> = T extends ((...args: infer Args) => infer Result) ? (...args: Args) => WithVize<Result> : T extends Promise<infer Result> ? Promise<WithVize<Result>> : Omit<WithCompatiblePlugins<T>, "lint" | "fmt" | "pack"> & VueIntegrationConfig;
|
|
62
59
|
type VueConfig = WithVize<VitePlusConfig>;
|
|
@@ -73,10 +70,26 @@ interface VizePlusOptions {
|
|
|
73
70
|
/** Rename or disable generated tasks. Existing run.tasks take precedence. */
|
|
74
71
|
tasks?: false | Partial<Record<VizeTask, string | false>>;
|
|
75
72
|
}
|
|
76
|
-
|
|
73
|
+
interface VizeTaskConfig {
|
|
74
|
+
config?: UserConfigExport;
|
|
75
|
+
options: VizePlusOptions;
|
|
76
|
+
lintTypecheck?: boolean;
|
|
77
|
+
lintLocale?: VizeLintOptions["locale"];
|
|
78
|
+
lintHelpLevel?: VizeLintOptions["helpLevel"];
|
|
79
|
+
fmtIgnorePatterns?: string[];
|
|
80
|
+
}
|
|
81
|
+
interface VizePlusConfigFactory {
|
|
82
|
+
(env: ConfigEnv): Promise<ConfigWithVizeTasks>;
|
|
83
|
+
/** Configure native Vue tooling without changing the existing Vite+ export. */
|
|
84
|
+
withVue(vue: VueOptions): VizePlusConfigFactory;
|
|
85
|
+
}
|
|
86
|
+
declare const taskConfigKey: unique symbol;
|
|
87
|
+
type ConfigWithVizeTasks = UserConfig & {
|
|
88
|
+
[taskConfigKey]?: VizeTaskConfig;
|
|
89
|
+
};
|
|
77
90
|
//#endregion
|
|
78
91
|
//#region src/vite-plus.d.ts
|
|
79
|
-
/**
|
|
92
|
+
/** Add the native Vue toolchain to an ordinary Vite+ export. */
|
|
80
93
|
declare function defineConfig(config?: VueConfig, integration?: VizePlusOptions): VizePlusConfigFactory;
|
|
81
94
|
/** Add Vue settings to an existing Vite+ export without another Vite+ injection. */
|
|
82
95
|
declare function withVue(vue: VueOptions, vpConfig?: VitePlusConfig, integration?: VizePlusOptions): VizePlusConfigFactory;
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import {
|
|
3
|
-
import { a as sourceConfigKey, i as resolveVitePlus, o as taskConfigKey, r as availableVueRules, t as runNative } from "./runner-Y2Iuaafy.mjs";
|
|
1
|
+
import { c as projectViteConfigSource, i as resolveConfigExport, l as vueConfigOptions, s as mergeVueConfigOptions } from "./config-DE1fZbgD.mjs";
|
|
2
|
+
import { a as taskConfigKey, i as sourceConfigKey, r as availableVueRules, t as runNative } from "./runner-B_lRJlux.mjs";
|
|
4
3
|
import { randomUUID } from "node:crypto";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import { readFileSync } from "node:fs";
|
|
@@ -123,48 +122,25 @@ function quote(value) {
|
|
|
123
122
|
}
|
|
124
123
|
//#endregion
|
|
125
124
|
//#region src/vite-plus/config.ts
|
|
126
|
-
async function resolveConfig(config, env
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const merged = mergeConfig(base, selected);
|
|
137
|
-
const vue = mergeVueConfigOptions(base.vue, selected.vue);
|
|
138
|
-
return vue === void 0 ? merged : {
|
|
139
|
-
...merged,
|
|
140
|
-
vue
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
for (const base of Array.isArray(bases) ? bases : bases ? [bases] : []) result = compose(result, await resolveConfig(base, env, parents));
|
|
144
|
-
return compose(result, own);
|
|
145
|
-
} finally {
|
|
146
|
-
parents.delete(config);
|
|
147
|
-
}
|
|
125
|
+
async function resolveConfig(config, env) {
|
|
126
|
+
if (config !== null && (typeof config === "function" || typeof config === "object") && sourceConfigKey in config) return resolveConfig(config[sourceConfigKey], env);
|
|
127
|
+
const source = await (typeof config === "function" ? config(env) : config);
|
|
128
|
+
if ("extends" in source) throw new Error("Custom config extends is no longer supported; use defineConfig(vpConfig).withVue(vueConfig)");
|
|
129
|
+
assertVueConfigSpelling(source);
|
|
130
|
+
return source;
|
|
131
|
+
}
|
|
132
|
+
function assertVueConfigSpelling(source) {
|
|
133
|
+
const legacy = "vize" in source ? "vize" : source.lint && "vize" in source.lint ? "lint.vize" : source.fmt && "vize" in source.fmt ? "fmt.vize" : void 0;
|
|
134
|
+
if (legacy) throw new Error(`${legacy}: configuration is no longer supported; move Vue settings to vue: in vite.config.*`);
|
|
148
135
|
}
|
|
149
136
|
function normalizeConfig(source, integration) {
|
|
150
|
-
|
|
137
|
+
assertVueConfigSpelling(source);
|
|
138
|
+
const { compiler: compilerOption, typecheck, lint, fmt, vue: _vue, ...rest } = source;
|
|
151
139
|
const vue = vueConfigOptions(source);
|
|
152
140
|
const configDirectory = process.cwd();
|
|
153
|
-
const {
|
|
154
|
-
const {
|
|
155
|
-
const
|
|
156
|
-
...oxfmt.sortImports === void 0 ? {} : { sortImports: oxfmt.sortImports },
|
|
157
|
-
...typeof nativeFmt === "object" ? nativeFmt : {}
|
|
158
|
-
};
|
|
159
|
-
const alias = vize && typeof vize === "object" && !Array.isArray(vize) ? vize.lint : void 0;
|
|
160
|
-
const lintConfig = typeof alias === "object" && typeof nativeLint === "object" ? {
|
|
161
|
-
...alias,
|
|
162
|
-
...nativeLint,
|
|
163
|
-
rules: {
|
|
164
|
-
...alias.rules,
|
|
165
|
-
...nativeLint.rules
|
|
166
|
-
}
|
|
167
|
-
} : nativeLint === void 0 ? alias : nativeLint;
|
|
141
|
+
const { vue: nativeLint, ...oxlint } = lint ?? {};
|
|
142
|
+
const { vue: nativeFmt, ...oxfmt } = fmt ?? {};
|
|
143
|
+
const lintConfig = nativeLint;
|
|
168
144
|
const compiler = vueCompiler(compilerOption ?? integration.plugin ?? {}, vue);
|
|
169
145
|
const options = {
|
|
170
146
|
...integration,
|
|
@@ -172,26 +148,9 @@ function normalizeConfig(source, integration) {
|
|
|
172
148
|
lint: vue?.linter?.enabled !== void 0 ? vue.linter.enabled : lintConfig === void 0 ? integration.lint : lintConfig !== false,
|
|
173
149
|
fmt: vue?.formatter !== void 0 ? true : nativeFmt === void 0 ? integration.fmt : nativeFmt !== false
|
|
174
150
|
};
|
|
175
|
-
const
|
|
176
|
-
let base = vize;
|
|
177
|
-
if (vize && typeof vize === "object" && !Array.isArray(vize)) {
|
|
178
|
-
const { lint: _alias, ...shared } = vize;
|
|
179
|
-
base = shared;
|
|
180
|
-
}
|
|
181
|
-
const inherited = base === void 0 ? await loadConfig(process.cwd(), {
|
|
182
|
-
env,
|
|
183
|
-
viteConfig: false
|
|
184
|
-
}) : await resolveConfigExport(base, env);
|
|
185
|
-
const overrides = await resolveConfigExport({
|
|
186
|
-
...compiler === false ? {} : { compiler: nativeCompiler(compiler) },
|
|
187
|
-
...typeof typecheck === "object" ? { typeChecker: typecheck } : {},
|
|
188
|
-
...typeof lintConfig === "object" ? { linter: withoutTaskLintOptions(lintConfig) } : {},
|
|
189
|
-
...Object.keys(formatter).length ? { formatter } : {}
|
|
190
|
-
}, env);
|
|
191
|
-
return mergeSharedConfig(mergeSharedConfig(env.command === "check" && (base !== void 0 || inherited === null) ? await resolveConfigExport({ typeChecker: { jsxTypecheck: true } }, env) : null, inherited), overrides) ?? {};
|
|
192
|
-
};
|
|
151
|
+
const config = async (env) => await projectViteConfigSource(source, env, configDirectory);
|
|
193
152
|
const metadata = {
|
|
194
|
-
config
|
|
153
|
+
config,
|
|
195
154
|
options,
|
|
196
155
|
lintTypecheck: typeof lintConfig === "object" && lintConfig.typecheck === true,
|
|
197
156
|
lintLocale: typeof lintConfig === "object" ? lintConfig.locale : void 0,
|
|
@@ -209,35 +168,12 @@ function normalizeConfig(source, integration) {
|
|
|
209
168
|
compiler
|
|
210
169
|
};
|
|
211
170
|
}
|
|
212
|
-
function withoutTaskLintOptions(config) {
|
|
213
|
-
const { typecheck: _typecheck, locale: _locale, helpLevel: _helpLevel, ...native } = config;
|
|
214
|
-
return native;
|
|
215
|
-
}
|
|
216
|
-
function nativeCompiler(options) {
|
|
217
|
-
const { compatibility, ...compiler } = options;
|
|
218
|
-
const version = options.vueVersion ?? compatibility?.vueVersion;
|
|
219
|
-
const versions = {
|
|
220
|
-
.1: "0.10",
|
|
221
|
-
.11: "0.11",
|
|
222
|
-
1: "1",
|
|
223
|
-
2: "2",
|
|
224
|
-
"2.7": "2.7",
|
|
225
|
-
3: "3",
|
|
226
|
-
legacy: "2"
|
|
227
|
-
};
|
|
228
|
-
return {
|
|
229
|
-
...compiler,
|
|
230
|
-
compatibility: {
|
|
231
|
-
...compatibility,
|
|
232
|
-
vueVersion: version === void 0 ? void 0 : versions[version]
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
171
|
/** Keep plugin-only fields while native canonical leaves choose their own values. */
|
|
237
172
|
function vueCompiler(legacy, vue) {
|
|
238
173
|
if (vue?.compiler === void 0 && vue?.version === void 0) return legacy;
|
|
239
174
|
if (legacy === false && vue.compiler === void 0) return false;
|
|
240
175
|
const { compatibility, ...native } = vue.compiler ?? {};
|
|
176
|
+
const { vueVersion: _nativeVersion, ...nativeCompatibility } = compatibility ?? {};
|
|
241
177
|
const version = vue.version ?? compatibility?.vueVersion;
|
|
242
178
|
const versions = {
|
|
243
179
|
"0.10": .1,
|
|
@@ -253,7 +189,7 @@ function vueCompiler(legacy, vue) {
|
|
|
253
189
|
...native,
|
|
254
190
|
compatibility: {
|
|
255
191
|
...previous.compatibility,
|
|
256
|
-
...
|
|
192
|
+
...nativeCompatibility,
|
|
257
193
|
...version === void 0 ? {} : { vueVersion: versions[version] }
|
|
258
194
|
},
|
|
259
195
|
...version === void 0 ? {} : { vueVersion: versions[version] }
|
|
@@ -317,7 +253,8 @@ async function emitDeclarations(options, metadata) {
|
|
|
317
253
|
async function configurePack(input, compiler, metadata) {
|
|
318
254
|
if (input === void 0) return void 0;
|
|
319
255
|
if (Array.isArray(input)) return Promise.all(input.map(async (entry) => await configurePack(entry, compiler, metadata)));
|
|
320
|
-
|
|
256
|
+
if ("vize" in input) throw new Error("The pack.vize config option was removed. Use pack.vue instead.");
|
|
257
|
+
const { vue: native, ...pack } = input;
|
|
321
258
|
if (native === false) return pack;
|
|
322
259
|
const sourcemap = native?.sourcemap ?? pack.sourcemap;
|
|
323
260
|
const plugins = Array.isArray(pack.plugins) ? [...pack.plugins] : pack.plugins ? [pack.plugins] : [];
|
|
@@ -360,15 +297,16 @@ async function configurePack(input, compiler, metadata) {
|
|
|
360
297
|
}
|
|
361
298
|
//#endregion
|
|
362
299
|
//#region src/vite-plus.ts
|
|
363
|
-
/**
|
|
300
|
+
/** Add the native Vue toolchain to an ordinary Vite+ export. */
|
|
364
301
|
function defineConfig(config = {}, integration = {}) {
|
|
365
302
|
return Object.assign(async (env) => {
|
|
366
303
|
const source = await resolveConfig(config, env);
|
|
367
304
|
const { vp, metadata, compiler } = normalizeConfig(source, integration);
|
|
368
305
|
const { options } = metadata;
|
|
369
|
-
const
|
|
306
|
+
const legacy = compiler !== false && (await import("./vue-version-DGtIj1Bv.mjs")).isLegacyVueCompatibilityMode(compiler);
|
|
307
|
+
const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
|
|
370
308
|
if (compiler !== false) {
|
|
371
|
-
const { vize } = await import("./plugin-
|
|
309
|
+
const { vize } = await import("./plugin-VGQR_WGT.mjs");
|
|
372
310
|
plugins.push(vize({
|
|
373
311
|
...compiler,
|
|
374
312
|
configMode: false,
|
|
@@ -386,9 +324,21 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
386
324
|
...vp.run?.tasks
|
|
387
325
|
}
|
|
388
326
|
},
|
|
327
|
+
[sourceConfigKey]: source,
|
|
389
328
|
[taskConfigKey]: metadata
|
|
390
329
|
};
|
|
391
|
-
}, {
|
|
330
|
+
}, {
|
|
331
|
+
[sourceConfigKey]: config,
|
|
332
|
+
withVue(vue) {
|
|
333
|
+
return defineConfig(async (env) => {
|
|
334
|
+
const source = await resolveConfig(config, env);
|
|
335
|
+
return {
|
|
336
|
+
...source,
|
|
337
|
+
vue: mergeVueConfigOptions(source.vue, vue)
|
|
338
|
+
};
|
|
339
|
+
}, integration);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
392
342
|
}
|
|
393
343
|
async function withoutVueCompiler(plugins) {
|
|
394
344
|
const result = [];
|
|
@@ -401,10 +351,7 @@ async function withoutVueCompiler(plugins) {
|
|
|
401
351
|
}
|
|
402
352
|
/** Add Vue settings to an existing Vite+ export without another Vite+ injection. */
|
|
403
353
|
function withVue(vue, vpConfig = {}, integration = {}) {
|
|
404
|
-
return defineConfig(
|
|
405
|
-
extends: vpConfig,
|
|
406
|
-
vue
|
|
407
|
-
}, integration);
|
|
354
|
+
return defineConfig(vpConfig, integration).withVue(vue);
|
|
408
355
|
}
|
|
409
356
|
//#endregion
|
|
410
357
|
export { defineConfig, defineConfig as withVize, withVue };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { applyViteDefineReplacements, rewriteViteDynamicTemplateImports, rewriteViteImportMetaGlobBase, rewriteViteStaticAssetUrls, shouldApplyViteDefineInVirtualModule } from "@vizejs/native";
|
|
2
|
+
//#region src/transform.ts
|
|
3
|
+
/**
|
|
4
|
+
* Code transformation utilities for Vize.
|
|
5
|
+
*
|
|
6
|
+
* Handles static asset URL rewriting, Vite define replacements, and
|
|
7
|
+
* provides the debug logger.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Rewrite static asset URLs in compiled template output.
|
|
11
|
+
*
|
|
12
|
+
* Transforms property values like `src: "@/assets/logo.svg"` into import
|
|
13
|
+
* statements hoisted to the top of the module, so Vite's module resolution
|
|
14
|
+
* pipeline handles alias expansion and asset hashing in both dev and build.
|
|
15
|
+
*/
|
|
16
|
+
function rewriteStaticAssetUrls(code, aliasRules) {
|
|
17
|
+
if (aliasRules.length === 0 || !code.includes("src")) return code;
|
|
18
|
+
return rewriteViteStaticAssetUrls(code, aliasRules);
|
|
19
|
+
}
|
|
20
|
+
function rewriteDynamicTemplateImports(code, aliasRules) {
|
|
21
|
+
if (!code.includes("import(") || !code.includes("`")) return code;
|
|
22
|
+
return rewriteViteDynamicTemplateImports(code, aliasRules);
|
|
23
|
+
}
|
|
24
|
+
function rewriteImportMetaGlobBase(code, importer, root) {
|
|
25
|
+
if (!code.includes("import.meta.glob")) return code;
|
|
26
|
+
return rewriteViteImportMetaGlobBase(code, importer, root);
|
|
27
|
+
}
|
|
28
|
+
function shouldApplyDefineInVirtualModule(key) {
|
|
29
|
+
return shouldApplyViteDefineInVirtualModule(key);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Apply Vite define replacements to code.
|
|
33
|
+
* Replaces keys like `import.meta.vfFeatures.photoSection` with their values.
|
|
34
|
+
* Uses word-boundary-aware matching to avoid replacing inside strings or partial matches.
|
|
35
|
+
*/
|
|
36
|
+
function applyDefineReplacements(code, defines) {
|
|
37
|
+
return applyViteDefineReplacements(code, Object.entries(defines).map(([key, value]) => ({
|
|
38
|
+
key,
|
|
39
|
+
value
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
function createLogger(debug) {
|
|
43
|
+
return {
|
|
44
|
+
log: (...args) => debug && console.log("[vize]", ...args),
|
|
45
|
+
info: (...args) => console.log("[vize]", ...args),
|
|
46
|
+
warn: (...args) => console.warn("[vize]", ...args),
|
|
47
|
+
error: (...args) => console.error("[vize]", ...args)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/plugin/vue-version.ts
|
|
52
|
+
function isLegacyVueVersion(version) {
|
|
53
|
+
return version === "legacy" || version === .1 || version === .11 || version === 1 || version === 2 || version === "2.7";
|
|
54
|
+
}
|
|
55
|
+
function isLegacyVueCompatibilityMode(options) {
|
|
56
|
+
const vueVersion = options.vueVersion ?? options.compatibility?.vueVersion;
|
|
57
|
+
return (options.compatibility?.hostCompiler ?? isLegacyVueVersion(vueVersion)) && isLegacyVueVersion(vueVersion);
|
|
58
|
+
}
|
|
59
|
+
function hasHostVueSfcCompilerPlugin(plugins) {
|
|
60
|
+
return plugins.some((plugin) => {
|
|
61
|
+
const name = plugin.name;
|
|
62
|
+
return name === "vite:vue" || name === "vite:vue2" || name.includes("plugin-vue") || name.includes("vue2");
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function createLegacyVueCompatibilityPlugin(options) {
|
|
66
|
+
return {
|
|
67
|
+
name: "vite-plugin-vize:legacy-vue-compat",
|
|
68
|
+
configResolved(resolvedConfig) {
|
|
69
|
+
if (!hasHostVueSfcCompilerPlugin(resolvedConfig.plugins)) throw new Error("vite-plugin-vize: legacy Vue host-compiler mode requires a host Vue SFC compiler plugin. Add @vitejs/plugin-vue2 (or your framework's Vue 2 Vite SFC plugin), or set compatibility.hostCompiler=false if this project can use Vize's compiler pipeline.");
|
|
70
|
+
createLogger(options.debug ?? false).log(`Legacy Vue compatibility mode is active for ${resolvedConfig.root}; Vize will not compile .vue files.`);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { applyDefineReplacements as a, rewriteImportMetaGlobBase as c, isLegacyVueVersion as i, rewriteStaticAssetUrls as l, hasHostVueSfcCompilerPlugin as n, createLogger as o, isLegacyVueCompatibilityMode as r, rewriteDynamicTemplateImports as s, createLegacyVueCompatibilityPlugin as t, shouldApplyDefineInVirtualModule as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.475.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vizejs/native": "0.
|
|
55
|
-
"@vizejs/unplugin": "0.
|
|
54
|
+
"@vizejs/native": "0.475.0",
|
|
55
|
+
"@vizejs/unplugin": "0.475.0",
|
|
56
56
|
"jsonc-parser": "^3.3.1",
|
|
57
57
|
"oxc-parser": "0.144.0",
|
|
58
58
|
"picomatch": "4.0.5",
|
|
59
59
|
"tinyglobby": "0.2.17",
|
|
60
|
-
"vize": "0.
|
|
60
|
+
"vize": "0.475.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|