@vizejs/vite-plugin 0.283.0 → 0.285.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/dist/index.mjs +77 -9
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -101,6 +101,83 @@ function toNativeCssAliasRule(rule) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
|
+
//#region src/utils/filter.ts
|
|
105
|
+
function createFilter(include, exclude) {
|
|
106
|
+
const includePatterns = include ? Array.isArray(include) ? include : [include] : [/\.vue$/];
|
|
107
|
+
const excludePatterns = exclude ? Array.isArray(exclude) ? exclude : [exclude] : [/node_modules/];
|
|
108
|
+
return (id) => {
|
|
109
|
+
const matchInclude = includePatterns.some((pattern) => matchesFilterPattern(pattern, id));
|
|
110
|
+
const matchExclude = excludePatterns.some((pattern) => matchesFilterPattern(pattern, id));
|
|
111
|
+
return matchInclude && !matchExclude;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const GLOB_META = /[*?]/;
|
|
115
|
+
function matchesFilterPattern(pattern, id) {
|
|
116
|
+
if (typeof pattern === "string") return matchesStringFilter(pattern, id);
|
|
117
|
+
pattern.lastIndex = 0;
|
|
118
|
+
const matched = pattern.test(id);
|
|
119
|
+
pattern.lastIndex = 0;
|
|
120
|
+
return matched;
|
|
121
|
+
}
|
|
122
|
+
function matchesStringFilter(pattern, id) {
|
|
123
|
+
const normalizedId = normalizeFilterPath(id);
|
|
124
|
+
const normalizedPattern = normalizeFilterPath(pattern);
|
|
125
|
+
if (!GLOB_META.test(normalizedPattern)) return normalizedId.includes(normalizedPattern);
|
|
126
|
+
return stringGlobToRegExp(normalizedPattern).test(normalizedId);
|
|
127
|
+
}
|
|
128
|
+
function normalizeFilterPath(value) {
|
|
129
|
+
return value.replace(/\\/g, "/");
|
|
130
|
+
}
|
|
131
|
+
function stringGlobToRegExp(pattern) {
|
|
132
|
+
const absolute = pattern.startsWith("/");
|
|
133
|
+
let body = absolute ? pattern : stripRelativePrefix(pattern);
|
|
134
|
+
let descendantSuffix = false;
|
|
135
|
+
if (body.endsWith("/**")) {
|
|
136
|
+
body = body.slice(0, -3);
|
|
137
|
+
descendantSuffix = true;
|
|
138
|
+
}
|
|
139
|
+
const prefix = absolute ? "^" : "(?:^|/)";
|
|
140
|
+
const suffix = descendantSuffix ? "(?:/.*)?$" : "$";
|
|
141
|
+
return new RegExp(`${prefix}${globBodyToRegExp(body)}${suffix}`);
|
|
142
|
+
}
|
|
143
|
+
function stripRelativePrefix(pattern) {
|
|
144
|
+
let rest = pattern;
|
|
145
|
+
while (rest.startsWith("../")) rest = rest.slice(3);
|
|
146
|
+
while (rest.startsWith("./")) rest = rest.slice(2);
|
|
147
|
+
return rest;
|
|
148
|
+
}
|
|
149
|
+
function globBodyToRegExp(pattern) {
|
|
150
|
+
let source = "";
|
|
151
|
+
for (let i = 0; i < pattern.length;) {
|
|
152
|
+
const char = pattern[i];
|
|
153
|
+
if (char === "*") {
|
|
154
|
+
if (pattern[i + 1] === "*") if (pattern[i + 2] === "/") {
|
|
155
|
+
source += "(?:.*\\/)?";
|
|
156
|
+
i += 3;
|
|
157
|
+
} else {
|
|
158
|
+
source += ".*";
|
|
159
|
+
i += 2;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
source += "[^/]*";
|
|
163
|
+
i += 1;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (char === "?") {
|
|
168
|
+
source += "[^/]";
|
|
169
|
+
i += 1;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
source += escapeRegExp(char);
|
|
173
|
+
i += 1;
|
|
174
|
+
}
|
|
175
|
+
return source;
|
|
176
|
+
}
|
|
177
|
+
function escapeRegExp(char) {
|
|
178
|
+
return "\\^$+?.()|[]{}".includes(char) ? `\\${char}` : char;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
104
181
|
//#region src/utils/index.ts
|
|
105
182
|
/** Known CSS preprocessor languages that must be delegated to Vite */
|
|
106
183
|
const PREPROCESSOR_LANGS = new Set([
|
|
@@ -169,15 +246,6 @@ function insertAfterStaticImports(output, imports) {
|
|
|
169
246
|
function generateScopeId(filename) {
|
|
170
247
|
return createHash("sha256").update(filename).digest("hex").slice(0, 8);
|
|
171
248
|
}
|
|
172
|
-
function createFilter(include, exclude) {
|
|
173
|
-
const includePatterns = include ? Array.isArray(include) ? include : [include] : [/\.vue$/];
|
|
174
|
-
const excludePatterns = exclude ? Array.isArray(exclude) ? exclude : [exclude] : [/node_modules/];
|
|
175
|
-
return (id) => {
|
|
176
|
-
const matchInclude = includePatterns.some((pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id));
|
|
177
|
-
const matchExclude = excludePatterns.some((pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id));
|
|
178
|
-
return matchInclude && !matchExclude;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
249
|
function generateOutput(compiled, options) {
|
|
182
250
|
const { isProduction, isDev, ssr, hmrUpdateType, extractCss, filePath } = options;
|
|
183
251
|
let output = compiled.code;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.285.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@vizejs/native": "0.
|
|
43
|
+
"@vizejs/native": "0.285.0",
|
|
44
44
|
"tinyglobby": "0.2.16",
|
|
45
|
-
"vize": "0.
|
|
45
|
+
"vize": "0.285.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "25.9.2",
|