@vizejs/vite-plugin 0.756.0 → 0.758.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as resolveConfigExport, r as loadConfig } from "./config-mRmJduOt.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { glob } from "tinyglobby";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -27,11 +27,28 @@ function resolveVitePlus() {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const catalogs = /* @__PURE__ */ new Map();
|
|
30
|
+
const CATALOG_CACHE_LIMIT = 8;
|
|
31
|
+
const CATALOG_PACKAGE = "{\"name\":\"vize-rule-catalog\",\"private\":true}";
|
|
32
|
+
let preparedCatalogRoot;
|
|
33
|
+
function cacheHome() {
|
|
34
|
+
const xdg = process.env.XDG_CACHE_HOME;
|
|
35
|
+
if (xdg && path.isAbsolute(xdg)) return xdg;
|
|
36
|
+
if (process.platform === "win32") {
|
|
37
|
+
const local = process.env.LOCALAPPDATA;
|
|
38
|
+
if (local && path.isAbsolute(local)) return local;
|
|
39
|
+
return path.join(os.homedir(), "AppData", "Local");
|
|
40
|
+
}
|
|
41
|
+
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Caches");
|
|
42
|
+
return path.join(os.homedir(), ".cache");
|
|
43
|
+
}
|
|
44
|
+
function catalogRoot() {
|
|
45
|
+
return path.join(cacheHome(), "vize", "vite-plus", "oxlint-rules-v1");
|
|
46
|
+
}
|
|
30
47
|
function catalogCacheFile(binary) {
|
|
31
48
|
try {
|
|
32
49
|
const stat = statSync(binary);
|
|
33
50
|
const key = createHash("sha256").update(binary).update("\0").update(String(stat.mtimeMs)).update("\0").update(String(stat.size)).digest("hex");
|
|
34
|
-
return path.join(
|
|
51
|
+
return path.join(catalogRoot(), `${key}.json`);
|
|
35
52
|
} catch {
|
|
36
53
|
return;
|
|
37
54
|
}
|
|
@@ -39,6 +56,8 @@ function catalogCacheFile(binary) {
|
|
|
39
56
|
function readCatalogCache(file) {
|
|
40
57
|
if (!file) return void 0;
|
|
41
58
|
try {
|
|
59
|
+
const metadata = lstatSync(file);
|
|
60
|
+
if (!metadata.isFile() || metadata.isSymbolicLink()) return void 0;
|
|
42
61
|
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
43
62
|
if (!Array.isArray(parsed) || parsed.some((rule) => typeof rule !== "string")) return void 0;
|
|
44
63
|
return new Set(parsed);
|
|
@@ -49,10 +68,105 @@ function readCatalogCache(file) {
|
|
|
49
68
|
function writeCatalogCache(file, rules) {
|
|
50
69
|
if (!file) return;
|
|
51
70
|
try {
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
const directory = path.dirname(file);
|
|
72
|
+
if (preparedCatalogRoot !== directory) {
|
|
73
|
+
ensurePrivateDirectory(directory);
|
|
74
|
+
recoverInterruptedWrites(directory);
|
|
75
|
+
preparedCatalogRoot = directory;
|
|
76
|
+
}
|
|
77
|
+
atomicWrite(file, JSON.stringify([...rules].sort()));
|
|
78
|
+
pruneCatalogCache(directory, file);
|
|
54
79
|
} catch {}
|
|
55
80
|
}
|
|
81
|
+
function ensurePrivateDirectory(directory) {
|
|
82
|
+
mkdirSync(directory, {
|
|
83
|
+
recursive: true,
|
|
84
|
+
mode: 448
|
|
85
|
+
});
|
|
86
|
+
const metadata = lstatSync(directory);
|
|
87
|
+
if (!metadata.isDirectory() || metadata.isSymbolicLink()) throw new Error(`Vite+ rule catalog cache is not a private directory: ${directory}`);
|
|
88
|
+
chmodSync(directory, 448);
|
|
89
|
+
}
|
|
90
|
+
function atomicWrite(file, source) {
|
|
91
|
+
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
92
|
+
try {
|
|
93
|
+
writeFileSync(temporary, source, {
|
|
94
|
+
flag: "wx",
|
|
95
|
+
mode: 384
|
|
96
|
+
});
|
|
97
|
+
try {
|
|
98
|
+
renameSync(temporary, file);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (readFileSync(file, "utf8") !== source) throw error;
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
rmSync(temporary, { force: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function processIsAlive(pid) {
|
|
107
|
+
try {
|
|
108
|
+
process.kill(pid, 0);
|
|
109
|
+
return true;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
return error instanceof Error && "code" in error && error.code === "EPERM";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function recoverInterruptedWrites(directory) {
|
|
115
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
116
|
+
if (!entry.isFile() || !entry.name.endsWith(".tmp")) continue;
|
|
117
|
+
const match = /\.([0-9]+)\.[^.]+\.tmp$/u.exec(entry.name);
|
|
118
|
+
if (match && !processIsAlive(Number(match[1]))) rmSync(path.join(directory, entry.name), { force: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function pruneCatalogCache(directory, current) {
|
|
122
|
+
const entries = readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isFile() && /^[a-f0-9]{64}\.json$/u.test(entry.name)).map((entry) => {
|
|
123
|
+
const file = path.join(directory, entry.name);
|
|
124
|
+
return {
|
|
125
|
+
file,
|
|
126
|
+
modified: lstatSync(file).mtimeMs
|
|
127
|
+
};
|
|
128
|
+
}).sort((left, right) => right.modified - left.modified);
|
|
129
|
+
const retained = new Set([current]);
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
if (retained.size >= CATALOG_CACHE_LIMIT) break;
|
|
132
|
+
retained.add(entry.file);
|
|
133
|
+
}
|
|
134
|
+
for (const entry of entries) if (!retained.has(entry.file)) rmSync(entry.file, { force: true });
|
|
135
|
+
}
|
|
136
|
+
function managedCatalogWorkspace() {
|
|
137
|
+
const directory = catalogRoot();
|
|
138
|
+
ensurePrivateDirectory(directory);
|
|
139
|
+
recoverInterruptedWrites(directory);
|
|
140
|
+
preparedCatalogRoot = directory;
|
|
141
|
+
const manifest = path.join(directory, "package.json");
|
|
142
|
+
try {
|
|
143
|
+
if (readFileSync(manifest, "utf8") === CATALOG_PACKAGE) return directory;
|
|
144
|
+
} catch {}
|
|
145
|
+
atomicWrite(manifest, CATALOG_PACKAGE);
|
|
146
|
+
return directory;
|
|
147
|
+
}
|
|
148
|
+
function temporaryCatalogWorkspace() {
|
|
149
|
+
const directory = mkdtempSync(path.join(os.tmpdir(), "vize-oxlint-rules-"));
|
|
150
|
+
try {
|
|
151
|
+
writeFileSync(path.join(directory, "package.json"), CATALOG_PACKAGE, {
|
|
152
|
+
flag: "wx",
|
|
153
|
+
mode: 384
|
|
154
|
+
});
|
|
155
|
+
} catch (error) {
|
|
156
|
+
rmSync(directory, {
|
|
157
|
+
recursive: true,
|
|
158
|
+
force: true
|
|
159
|
+
});
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
directory,
|
|
164
|
+
cleanup: () => rmSync(directory, {
|
|
165
|
+
recursive: true,
|
|
166
|
+
force: true
|
|
167
|
+
})
|
|
168
|
+
};
|
|
169
|
+
}
|
|
56
170
|
/** Only disable rules supported by the consumer's bundled Oxlint. */
|
|
57
171
|
function availableVueRules() {
|
|
58
172
|
const { binary } = resolveVitePlus();
|
|
@@ -64,9 +178,16 @@ function availableVueRules() {
|
|
|
64
178
|
catalogs.set(binary, stored);
|
|
65
179
|
return stored;
|
|
66
180
|
}
|
|
67
|
-
|
|
181
|
+
let directory;
|
|
182
|
+
let cleanup = () => {};
|
|
183
|
+
try {
|
|
184
|
+
directory = managedCatalogWorkspace();
|
|
185
|
+
} catch {
|
|
186
|
+
const temporary = temporaryCatalogWorkspace();
|
|
187
|
+
directory = temporary.directory;
|
|
188
|
+
cleanup = () => temporary.cleanup();
|
|
189
|
+
}
|
|
68
190
|
try {
|
|
69
|
-
writeFileSync(path.join(directory, "package.json"), "{\"name\":\"vize-rule-catalog\",\"private\":true}");
|
|
70
191
|
const result = spawnSync(process.execPath, [
|
|
71
192
|
binary,
|
|
72
193
|
"lint",
|
|
@@ -75,6 +196,7 @@ function availableVueRules() {
|
|
|
75
196
|
], {
|
|
76
197
|
cwd: directory,
|
|
77
198
|
encoding: "utf8",
|
|
199
|
+
env: process.env,
|
|
78
200
|
timeout: 6e4,
|
|
79
201
|
maxBuffer: 4 * 1024 * 1024
|
|
80
202
|
});
|
|
@@ -91,10 +213,7 @@ function availableVueRules() {
|
|
|
91
213
|
writeCatalogCache(cacheFile, available);
|
|
92
214
|
return available;
|
|
93
215
|
} finally {
|
|
94
|
-
|
|
95
|
-
recursive: true,
|
|
96
|
-
force: true
|
|
97
|
-
});
|
|
216
|
+
cleanup();
|
|
98
217
|
}
|
|
99
218
|
}
|
|
100
219
|
//#endregion
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as projectViteConfigSource, i as resolveConfigExport, l as vueConfigOptions, s as mergeVueConfigOptions } from "./config-mRmJduOt.mjs";
|
|
2
|
-
import { a as taskConfigKey, i as sourceConfigKey, r as availableVueRules, t as runNative } from "./runner-
|
|
2
|
+
import { a as taskConfigKey, i as sourceConfigKey, r as availableVueRules, t as runNative } from "./runner-CQQyqskC.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import os from "node:os";
|
|
@@ -106,37 +106,86 @@ const readOnlyTasks = new Set([
|
|
|
106
106
|
"check",
|
|
107
107
|
"typecheck"
|
|
108
108
|
]);
|
|
109
|
+
const lockfilesByPackageManager = {
|
|
110
|
+
bun: ["bun.lock", "bun.lockb"],
|
|
111
|
+
npm: ["npm-shrinkwrap.json", "package-lock.json"],
|
|
112
|
+
pnpm: ["pnpm-lock.yaml"],
|
|
113
|
+
yarn: ["yarn.lock"]
|
|
114
|
+
};
|
|
115
|
+
const allLockfiles = Object.values(lockfilesByPackageManager).flat();
|
|
109
116
|
function createTasks(existing = {}, names = {}, taskCache = false) {
|
|
110
117
|
if (names === false) return {};
|
|
111
118
|
const runner = fileURLToPath(import.meta.resolve("@vizejs/vite-plugin/internal/vite-plus-task"));
|
|
112
119
|
let scripts = {};
|
|
120
|
+
let packageManager;
|
|
113
121
|
try {
|
|
114
|
-
|
|
122
|
+
const manifest = readManifest(process.cwd());
|
|
123
|
+
scripts = manifest.scripts ?? {};
|
|
124
|
+
packageManager = manifest.packageManager;
|
|
115
125
|
} catch (error) {
|
|
116
126
|
if (error.code !== "ENOENT") throw error;
|
|
117
127
|
}
|
|
118
128
|
const result = {};
|
|
129
|
+
let lockfiles;
|
|
119
130
|
for (const task of tasks) {
|
|
120
131
|
if (names[task] === false) continue;
|
|
121
132
|
const name = names[task] ?? (task in scripts ? `vize:${task}` : task);
|
|
122
133
|
if (name in existing) continue;
|
|
123
134
|
if (name in scripts || name in result) throw new Error(`defineConfig task "${name}" already exists. Choose another name with options.tasks.`);
|
|
124
135
|
const command = `node ${quote(runner)} ${task}`;
|
|
125
|
-
result[name] = taskCache && readOnlyTasks.has(task) ? cachedTask(command) : {
|
|
136
|
+
result[name] = taskCache && readOnlyTasks.has(task) ? cachedTask(command, lockfiles ??= lockfileInputs(packageManager)) : {
|
|
126
137
|
command,
|
|
127
138
|
cache: false
|
|
128
139
|
};
|
|
129
140
|
}
|
|
130
141
|
return result;
|
|
131
142
|
}
|
|
132
|
-
function
|
|
143
|
+
function lockfileInputs(packageManager) {
|
|
144
|
+
const packageDirectory = process.cwd();
|
|
145
|
+
const local = allLockfiles.filter((file) => existsSync(path.join(packageDirectory, file)));
|
|
146
|
+
const workspaceDirectory = findWorkspaceDirectory(packageDirectory);
|
|
147
|
+
const workspace = workspaceDirectory === packageDirectory ? local : [];
|
|
148
|
+
const useWorkspace = workspaceDirectory !== packageDirectory && !local.length;
|
|
149
|
+
if (useWorkspace) workspace.push(...allLockfiles.filter((file) => existsSync(path.join(workspaceDirectory, file))));
|
|
150
|
+
const declared = (useWorkspace ? readManifest(workspaceDirectory).packageManager ?? packageManager : packageManager)?.split("@", 1)[0];
|
|
151
|
+
let selected;
|
|
152
|
+
if (declared && declared in lockfilesByPackageManager) selected = [...lockfilesByPackageManager[declared]];
|
|
153
|
+
else {
|
|
154
|
+
const present = useWorkspace ? workspace : local;
|
|
155
|
+
selected = present.length > 0 ? present : [...allLockfiles];
|
|
156
|
+
}
|
|
157
|
+
return useWorkspace ? selected.map((pattern) => ({
|
|
158
|
+
pattern,
|
|
159
|
+
base: "workspace"
|
|
160
|
+
})) : selected;
|
|
161
|
+
}
|
|
162
|
+
function findWorkspaceDirectory(packageDirectory) {
|
|
163
|
+
let directory = packageDirectory;
|
|
164
|
+
for (;;) {
|
|
165
|
+
if (existsSync(path.join(directory, "pnpm-workspace.yaml"))) return directory;
|
|
166
|
+
if (existsSync(path.join(directory, "package.json"))) try {
|
|
167
|
+
if (readManifest(directory).workspaces != null) return directory;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (directory === packageDirectory) throw error;
|
|
170
|
+
}
|
|
171
|
+
const parent = path.dirname(directory);
|
|
172
|
+
if (parent === directory) return packageDirectory;
|
|
173
|
+
directory = parent;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function readManifest(directory) {
|
|
177
|
+
return JSON.parse(readFileSync(path.join(directory, "package.json"), "utf8"));
|
|
178
|
+
}
|
|
179
|
+
function cachedTask(command, lockfiles) {
|
|
133
180
|
const require = createRequire(path.resolve("package.json"));
|
|
134
181
|
const { version } = JSON.parse(readFileSync(require.resolve("vite-plus/package.json"), "utf8"));
|
|
135
182
|
const cache = {
|
|
136
183
|
input: [
|
|
137
184
|
{ auto: true },
|
|
138
|
-
"
|
|
139
|
-
"
|
|
185
|
+
"!**/node_modules",
|
|
186
|
+
"!**/node_modules/**",
|
|
187
|
+
"!**/.vize/**",
|
|
188
|
+
...lockfiles
|
|
140
189
|
],
|
|
141
190
|
output: []
|
|
142
191
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.758.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@vizejs/native": "0.
|
|
58
|
-
"@vizejs/unplugin": "0.
|
|
57
|
+
"@vizejs/native": "0.758.0",
|
|
58
|
+
"@vizejs/unplugin": "0.758.0",
|
|
59
59
|
"jsonc-parser": "^3.3.1",
|
|
60
60
|
"oxc-parser": "0.157.0",
|
|
61
61
|
"picomatch": "4.0.7",
|
|
62
62
|
"tinyglobby": "0.2.17",
|
|
63
|
-
"vize": "0.
|
|
63
|
+
"vize": "0.758.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "25.9.2",
|