@vizejs/vite-plugin 0.0.1-alpha.52 → 0.0.1-alpha.67

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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { LoadConfigOptions, VizeConfig, defineConfig, loadConfig } from "vizejs";
2
1
  import { Plugin } from "vite";
3
2
 
4
3
  //#region src/types.d.ts
@@ -75,8 +74,96 @@ interface CompiledModule {
75
74
  templateHash?: string;
76
75
  styleHash?: string;
77
76
  scriptHash?: string;
77
+ }
78
+ /**
79
+ * Vize configuration options
80
+ */
81
+ interface VizeConfig {
82
+ /**
83
+ * Vue compiler options
84
+ */
85
+ compiler?: {
86
+ /**
87
+ * Enable Vapor mode compilation
88
+ * @default false
89
+ */
90
+ vapor?: boolean;
91
+ /**
92
+ * Enable SSR mode
93
+ * @default false
94
+ */
95
+ ssr?: boolean;
96
+ /**
97
+ * Enable source map generation
98
+ * @default true in development, false in production
99
+ */
100
+ sourceMap?: boolean;
101
+ };
102
+ /**
103
+ * Vite plugin options
104
+ */
105
+ vite?: {
106
+ /**
107
+ * Files to include in compilation
108
+ * @default /\.vue$/
109
+ */
110
+ include?: string | RegExp | (string | RegExp)[];
111
+ /**
112
+ * Files to exclude from compilation
113
+ * @default /node_modules/
114
+ */
115
+ exclude?: string | RegExp | (string | RegExp)[];
116
+ /**
117
+ * Glob patterns to scan for .vue files during pre-compilation
118
+ * @default ['**\/*.vue']
119
+ */
120
+ scanPatterns?: string[];
121
+ /**
122
+ * Glob patterns to ignore during pre-compilation
123
+ * @default ['node_modules/**', 'dist/**', '.git/**']
124
+ */
125
+ ignorePatterns?: string[];
126
+ };
127
+ /**
128
+ * Linter options
129
+ */
130
+ linter?: {
131
+ /**
132
+ * Enable linting
133
+ */
134
+ enabled?: boolean;
135
+ /**
136
+ * Rules to enable/disable
137
+ */
138
+ rules?: Record<string, "off" | "warn" | "error">;
139
+ };
140
+ }
141
+ /**
142
+ * Options for loading vize.config file
143
+ */
144
+ interface LoadConfigOptions {
145
+ /**
146
+ * Config file search mode
147
+ * - 'root': Search only in the specified root directory
148
+ * - 'auto': Search from cwd upward until finding a config file
149
+ * - 'none': Don't load config file
150
+ * @default 'root'
151
+ */
152
+ mode?: "root" | "auto" | "none";
153
+ /**
154
+ * Custom config file path (overrides automatic search)
155
+ */
156
+ configFile?: string;
78
157
  } //#endregion
79
158
  //#region src/index.d.ts
159
+ /**
160
+ * Define a Vize configuration with type checking
161
+ */
162
+ declare function defineConfig(config: VizeConfig): VizeConfig;
163
+ /**
164
+ * Load Vize configuration from file
165
+ */
166
+ declare function loadConfig(root: string, options?: LoadConfigOptions): Promise<VizeConfig | null>;
80
167
  declare function vize(options?: VizeOptions): Plugin;
81
168
 
82
169
  //#endregion
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ import fs from "node:fs";
3
3
  import { glob } from "tinyglobby";
4
4
  import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
- import { defineConfig, loadConfig } from "vizejs";
7
6
 
8
7
  //#region src/hmr.ts
9
8
  /**
@@ -200,6 +199,58 @@ function compileBatch(files, cache, options) {
200
199
 
201
200
  //#endregion
202
201
  //#region src/index.ts
202
+ const CONFIG_FILES = [
203
+ "vize.config.ts",
204
+ "vize.config.js",
205
+ "vize.config.mjs",
206
+ "vize.config.cjs",
207
+ "vize.config.json"
208
+ ];
209
+ /**
210
+ * Define a Vize configuration with type checking
211
+ */
212
+ function defineConfig(config) {
213
+ return config;
214
+ }
215
+ /**
216
+ * Load Vize configuration from file
217
+ */
218
+ async function loadConfig(root, options = {}) {
219
+ const { mode = "root", configFile } = options;
220
+ if (mode === "none") return null;
221
+ const searchMode = mode === "auto" ? "nearest" : mode;
222
+ if (configFile) {
223
+ const configPath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);
224
+ return loadConfigFile(configPath);
225
+ }
226
+ let searchDir = root;
227
+ while (true) {
228
+ for (const filename of CONFIG_FILES) {
229
+ const configPath = path.join(searchDir, filename);
230
+ if (fs.existsSync(configPath)) return loadConfigFile(configPath);
231
+ }
232
+ if (searchMode === "root") break;
233
+ const parentDir = path.dirname(searchDir);
234
+ if (parentDir === searchDir) break;
235
+ searchDir = parentDir;
236
+ }
237
+ return null;
238
+ }
239
+ async function loadConfigFile(configPath) {
240
+ if (!fs.existsSync(configPath)) return null;
241
+ const ext = path.extname(configPath);
242
+ if (ext === ".json") {
243
+ const content = fs.readFileSync(configPath, "utf-8");
244
+ return JSON.parse(content);
245
+ }
246
+ try {
247
+ const module = await import(configPath);
248
+ return module.default ?? module;
249
+ } catch (e) {
250
+ console.warn(`[vize] Failed to load config from ${configPath}:`, e);
251
+ return null;
252
+ }
253
+ }
203
254
  const VIRTUAL_PREFIX = "\0vize:";
204
255
  const VIRTUAL_CSS_MODULE = "virtual:vize-styles";
205
256
  const RESOLVED_CSS_MODULE = "\0vize:all-styles.css";
@@ -285,8 +336,7 @@ function vize(options = {}) {
285
336
  extractCss = isProduction;
286
337
  let fileConfig = null;
287
338
  if (options.configMode !== false) {
288
- const { loadConfig: loadConfig$1 } = await import("vizejs");
289
- fileConfig = await loadConfig$1(root, {
339
+ fileConfig = await loadConfig(root, {
290
340
  mode: options.configMode ?? "root",
291
341
  configFile: options.configFile
292
342
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.0.1-alpha.52",
3
+ "version": "0.0.1-alpha.67",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "publishConfig": {
6
6
  "provenance": true,
@@ -44,8 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "tinyglobby": "^0.2.0",
47
- "@vizejs/native": "0.0.1-alpha.52",
48
- "vizejs": "0.0.1-alpha.52"
47
+ "@vizejs/native": "0.0.1-alpha.67"
49
48
  },
50
49
  "scripts": {
51
50
  "build": "tsdown",