nitro-nightly 3.0.1-20260119-145349-d0c4950f → 3.0.1-20260120-020848-6786d069
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/_build/rolldown.mjs +13 -8
- package/dist/_build/vite.build.mjs +1 -1
- package/dist/_chunks/dev.mjs +5 -3
- package/dist/_chunks/nitro.mjs +24 -1183
- package/dist/_chunks/nitro2.mjs +248 -91
- package/dist/_chunks/nitro3.mjs +2696 -0
- package/dist/_chunks/nitro4.mjs +176 -0
- package/dist/_chunks/nitro5.mjs +733 -0
- package/dist/_chunks/nitro6.mjs +1458 -0
- package/dist/_chunks/nitro7.mjs +7561 -0
- package/dist/_chunks/nitro8.mjs +3524 -0
- package/dist/_chunks/nitro9.mjs +1729 -0
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +3 -0
- package/dist/_libs/_3.mjs +4 -0
- package/dist/_libs/_4.mjs +6 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +3 -0
- package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +8900 -0
- package/dist/_libs/{c12.mjs → c12+dotenv+rc9.mjs} +12 -105
- package/dist/_libs/{chokidar.mjs → chokidar+readdirp.mjs} +2 -9
- package/dist/_libs/confbox+exsolve+pkg-types.mjs +1249 -0
- package/dist/_libs/confbox.mjs +70 -2488
- package/dist/_libs/confbox2.mjs +786 -0
- package/dist/_libs/confbox3.mjs +404 -0
- package/dist/_libs/confbox4.mjs +3 -0
- package/dist/_libs/estree-walker+unimport.mjs +378 -0
- package/dist/_libs/fdir+picomatch+tinyglobby.mjs +2471 -0
- package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +2150 -0
- package/dist/_libs/giget+node-fetch-native.mjs +2692 -0
- package/dist/_libs/httpxy.mjs +1 -6
- package/dist/_libs/local-pkg+quansync+unimport.mjs +1526 -0
- package/dist/_libs/nypm+tinyexec.mjs +858 -0
- package/dist/_libs/pathe.mjs +164 -0
- package/dist/_libs/perfect-debounce.mjs +89 -0
- package/dist/_libs/{@rollup/plugin-inject.mjs → plugin-alias+plugin-inject.mjs} +65 -2
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/unimport.mjs +5 -1781
- package/dist/_libs/vite-plugin-fullstack.mjs +26 -0
- package/dist/_presets.mjs +8 -3
- package/dist/builder.mjs +8 -6
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +3 -2
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/types/index.d.mts +2410 -1174
- package/dist/vite.d.mts +13 -13
- package/dist/vite.mjs +640 -16
- package/package.json +9 -9
- package/dist/_build/common.mjs +0 -24931
- package/dist/_build/rollup.mjs +0 -201
- package/dist/_chunks/utils.mjs +0 -254
- package/dist/_common.mjs +0 -45
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +0 -652
- package/dist/_libs/@jridgewell/gen-mapping.mjs +0 -448
- package/dist/_libs/@jridgewell/remapping.mjs +0 -117
- package/dist/_libs/@rollup/plugin-alias.mjs +0 -64
- package/dist/_libs/@rollup/plugin-commonjs.mjs +0 -1300
- package/dist/_libs/@rollup/plugin-json.mjs +0 -36
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +0 -1972
- package/dist/_libs/escape-string-regexp.mjs +0 -8
- package/dist/_libs/estree-walker.mjs +0 -187
- package/dist/_libs/giget.mjs +0 -3550
- package/dist/_libs/klona.mjs +0 -38
- package/dist/_libs/rou3.mjs +0 -322
- package/dist/_libs/tsconfck.mjs +0 -832
- package/dist/_libs/ultrahtml.mjs +0 -138
- package/dist/cli/_chunks/task.mjs +0 -16
package/dist/_libs/unimport.mjs
CHANGED
|
@@ -1,1785 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { It as resolve$1, Mt as isAbsolute$2, N as getMagicString, Nt as join$1, X as Parser, Z as parse$1, at as require_picomatch, b as createUnimport, q as MagicString } from "../_build/common.mjs";
|
|
3
|
-
import { t as walk } from "./estree-walker.mjs";
|
|
4
|
-
import { t as remapping } from "./@jridgewell/remapping.mjs";
|
|
5
|
-
import { createRequire } from "node:module";
|
|
6
|
-
import fs, { promises } from "node:fs";
|
|
1
|
+
import "node:fs";
|
|
7
2
|
import "node:fs/promises";
|
|
8
|
-
import
|
|
3
|
+
import "node:url";
|
|
9
4
|
import "node:os";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
5
|
+
import "node:path";
|
|
6
|
+
import "node:process";
|
|
12
7
|
import "scule";
|
|
13
|
-
import { Buffer } from "node:buffer";
|
|
14
|
-
import * as querystring from "node:querystring";
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
var detect_acorn_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
-
createVirtualImportsAcronWalker: () => createVirtualImportsAcronWalker,
|
|
19
|
-
detectImportsAcorn: () => detectImportsAcorn,
|
|
20
|
-
traveseScopes: () => traveseScopes
|
|
21
|
-
});
|
|
22
|
-
async function detectImportsAcorn(code, ctx, options) {
|
|
23
|
-
const s = getMagicString(code);
|
|
24
|
-
const map = await ctx.getImportMap();
|
|
25
|
-
let matchedImports = [];
|
|
26
|
-
const enableAutoImport = options?.autoImport !== false;
|
|
27
|
-
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
|
|
28
|
-
if (enableAutoImport || enableTransformVirtualImports) {
|
|
29
|
-
const ast = parse$1(s.original, {
|
|
30
|
-
sourceType: "module",
|
|
31
|
-
ecmaVersion: "latest",
|
|
32
|
-
locations: true
|
|
33
|
-
});
|
|
34
|
-
const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
|
|
35
|
-
const scopes = traveseScopes(ast, enableTransformVirtualImports ? virtualImports.walk : {});
|
|
36
|
-
if (enableAutoImport) {
|
|
37
|
-
const identifiers = scopes.unmatched;
|
|
38
|
-
matchedImports.push(...Array.from(identifiers).map((name) => {
|
|
39
|
-
const item = map.get(name);
|
|
40
|
-
if (item && !item.disabled) return item;
|
|
41
|
-
return null;
|
|
42
|
-
}).filter(Boolean));
|
|
43
|
-
for (const addon of ctx.addons) matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
|
|
44
|
-
}
|
|
45
|
-
virtualImports.ranges.forEach(([start, end]) => {
|
|
46
|
-
s.remove(start, end);
|
|
47
|
-
});
|
|
48
|
-
matchedImports.push(...virtualImports.imports);
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
s,
|
|
52
|
-
strippedCode: code.toString(),
|
|
53
|
-
matchedImports,
|
|
54
|
-
isCJSContext: false,
|
|
55
|
-
firstOccurrence: 0
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function traveseScopes(ast, additionalWalk) {
|
|
59
|
-
const scopes = [];
|
|
60
|
-
let scopeCurrent = void 0;
|
|
61
|
-
const scopesStack = [];
|
|
62
|
-
function pushScope(node) {
|
|
63
|
-
scopeCurrent = {
|
|
64
|
-
node,
|
|
65
|
-
parent: scopeCurrent,
|
|
66
|
-
declarations: /* @__PURE__ */ new Set(),
|
|
67
|
-
references: /* @__PURE__ */ new Set()
|
|
68
|
-
};
|
|
69
|
-
scopes.push(scopeCurrent);
|
|
70
|
-
scopesStack.push(scopeCurrent);
|
|
71
|
-
}
|
|
72
|
-
function popScope(node) {
|
|
73
|
-
if (scopesStack.pop()?.node !== node) throw new Error("Scope mismatch");
|
|
74
|
-
scopeCurrent = scopesStack[scopesStack.length - 1];
|
|
75
|
-
}
|
|
76
|
-
pushScope(void 0);
|
|
77
|
-
walk(ast, {
|
|
78
|
-
enter(node, parent, prop, index) {
|
|
79
|
-
additionalWalk?.enter?.call(this, node, parent, prop, index);
|
|
80
|
-
switch (node.type) {
|
|
81
|
-
case "ImportSpecifier":
|
|
82
|
-
case "ImportDefaultSpecifier":
|
|
83
|
-
case "ImportNamespaceSpecifier":
|
|
84
|
-
scopeCurrent.declarations.add(node.local.name);
|
|
85
|
-
return;
|
|
86
|
-
case "FunctionDeclaration":
|
|
87
|
-
case "ClassDeclaration":
|
|
88
|
-
if (node.id) scopeCurrent.declarations.add(node.id.name);
|
|
89
|
-
return;
|
|
90
|
-
case "VariableDeclarator":
|
|
91
|
-
if (node.id.type === "Identifier") scopeCurrent.declarations.add(node.id.name);
|
|
92
|
-
else walk(node.id, { enter(node2) {
|
|
93
|
-
if (node2.type === "ObjectPattern") node2.properties.forEach((i) => {
|
|
94
|
-
if (i.type === "Property" && i.value.type === "Identifier") scopeCurrent.declarations.add(i.value.name);
|
|
95
|
-
else if (i.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
|
|
96
|
-
});
|
|
97
|
-
else if (node2.type === "ArrayPattern") node2.elements.forEach((i) => {
|
|
98
|
-
if (i?.type === "Identifier") scopeCurrent.declarations.add(i.name);
|
|
99
|
-
if (i?.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
|
|
100
|
-
});
|
|
101
|
-
} });
|
|
102
|
-
return;
|
|
103
|
-
case "BlockStatement":
|
|
104
|
-
switch (parent?.type) {
|
|
105
|
-
case "FunctionDeclaration":
|
|
106
|
-
case "ArrowFunctionExpression":
|
|
107
|
-
case "FunctionExpression": {
|
|
108
|
-
const parameterIdentifiers = parent.params.filter((p) => p.type === "Identifier");
|
|
109
|
-
for (const id of parameterIdentifiers) scopeCurrent.declarations.add(id.name);
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
pushScope(node);
|
|
114
|
-
return;
|
|
115
|
-
case "Identifier":
|
|
116
|
-
switch (parent?.type) {
|
|
117
|
-
case "CallExpression":
|
|
118
|
-
if (parent.callee === node || parent.arguments.includes(node)) scopeCurrent.references.add(node.name);
|
|
119
|
-
return;
|
|
120
|
-
case "MemberExpression":
|
|
121
|
-
if (parent.object === node) scopeCurrent.references.add(node.name);
|
|
122
|
-
return;
|
|
123
|
-
case "VariableDeclarator":
|
|
124
|
-
if (parent.init === node) scopeCurrent.references.add(node.name);
|
|
125
|
-
return;
|
|
126
|
-
case "SpreadElement":
|
|
127
|
-
if (parent.argument === node) scopeCurrent.references.add(node.name);
|
|
128
|
-
return;
|
|
129
|
-
case "ClassDeclaration":
|
|
130
|
-
if (parent.superClass === node) scopeCurrent.references.add(node.name);
|
|
131
|
-
return;
|
|
132
|
-
case "Property":
|
|
133
|
-
if (parent.value === node) scopeCurrent.references.add(node.name);
|
|
134
|
-
return;
|
|
135
|
-
case "TemplateLiteral":
|
|
136
|
-
if (parent.expressions.includes(node)) scopeCurrent.references.add(node.name);
|
|
137
|
-
return;
|
|
138
|
-
case "AssignmentExpression":
|
|
139
|
-
if (parent.right === node) scopeCurrent.references.add(node.name);
|
|
140
|
-
return;
|
|
141
|
-
case "IfStatement":
|
|
142
|
-
case "WhileStatement":
|
|
143
|
-
case "DoWhileStatement":
|
|
144
|
-
if (parent.test === node) scopeCurrent.references.add(node.name);
|
|
145
|
-
return;
|
|
146
|
-
case "SwitchStatement":
|
|
147
|
-
if (parent.discriminant === node) scopeCurrent.references.add(node.name);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (parent?.type.includes("Expression")) scopeCurrent.references.add(node.name);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
leave(node, parent, prop, index) {
|
|
154
|
-
additionalWalk?.leave?.call(this, node, parent, prop, index);
|
|
155
|
-
switch (node.type) {
|
|
156
|
-
case "BlockStatement": popScope(node);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
const unmatched = /* @__PURE__ */ new Set();
|
|
161
|
-
for (const scope of scopes) for (const name of scope.references) {
|
|
162
|
-
let defined = false;
|
|
163
|
-
let parent = scope;
|
|
164
|
-
while (parent) {
|
|
165
|
-
if (parent.declarations.has(name)) {
|
|
166
|
-
defined = true;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
parent = parent?.parent;
|
|
170
|
-
}
|
|
171
|
-
if (!defined) unmatched.add(name);
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
unmatched,
|
|
175
|
-
scopes
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
|
|
179
|
-
const imports = [];
|
|
180
|
-
const ranges = [];
|
|
181
|
-
return {
|
|
182
|
-
imports,
|
|
183
|
-
ranges,
|
|
184
|
-
walk: { enter(node) {
|
|
185
|
-
if (node.type === "ImportDeclaration") {
|
|
186
|
-
if (virtualImports.includes(node.source.value)) {
|
|
187
|
-
ranges.push([node.start, node.end]);
|
|
188
|
-
node.specifiers.forEach((i) => {
|
|
189
|
-
if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
|
|
190
|
-
const original = importMap.get(i.imported.name);
|
|
191
|
-
if (!original) throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
|
|
192
|
-
imports.push({
|
|
193
|
-
from: original.from,
|
|
194
|
-
name: original.name,
|
|
195
|
-
as: i.local.name
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
} }
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
|
|
207
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
208
|
-
function toArray$2(array) {
|
|
209
|
-
array = array || [];
|
|
210
|
-
if (Array.isArray(array)) return array;
|
|
211
|
-
return [array];
|
|
212
|
-
}
|
|
213
|
-
const BACKSLASH_REGEX = /\\/g;
|
|
214
|
-
function normalize$1(path$1) {
|
|
215
|
-
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
216
|
-
}
|
|
217
|
-
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
218
|
-
function isAbsolute$1(path$1) {
|
|
219
|
-
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
220
|
-
}
|
|
221
|
-
function getMatcherString$1(glob, cwd$1) {
|
|
222
|
-
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
|
223
|
-
return normalize$1(resolve(cwd$1, glob));
|
|
224
|
-
}
|
|
225
|
-
function patternToIdFilter(pattern) {
|
|
226
|
-
if (pattern instanceof RegExp) return (id) => {
|
|
227
|
-
const normalizedId = normalize$1(id);
|
|
228
|
-
const result = pattern.test(normalizedId);
|
|
229
|
-
pattern.lastIndex = 0;
|
|
230
|
-
return result;
|
|
231
|
-
};
|
|
232
|
-
const matcher = (0, import_picomatch.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
|
|
233
|
-
return (id) => {
|
|
234
|
-
return matcher(normalize$1(id));
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function patternToCodeFilter(pattern) {
|
|
238
|
-
if (pattern instanceof RegExp) return (code) => {
|
|
239
|
-
const result = pattern.test(code);
|
|
240
|
-
pattern.lastIndex = 0;
|
|
241
|
-
return result;
|
|
242
|
-
};
|
|
243
|
-
return (code) => code.includes(pattern);
|
|
244
|
-
}
|
|
245
|
-
function createFilter$1(exclude, include) {
|
|
246
|
-
if (!exclude && !include) return;
|
|
247
|
-
return (input) => {
|
|
248
|
-
if (exclude?.some((filter) => filter(input))) return false;
|
|
249
|
-
if (include?.some((filter) => filter(input))) return true;
|
|
250
|
-
return !(include && include.length > 0);
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function normalizeFilter(filter) {
|
|
254
|
-
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
255
|
-
if (Array.isArray(filter)) return { include: filter };
|
|
256
|
-
return {
|
|
257
|
-
exclude: filter.exclude ? toArray$2(filter.exclude) : void 0,
|
|
258
|
-
include: filter.include ? toArray$2(filter.include) : void 0
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
function createIdFilter(filter) {
|
|
262
|
-
if (!filter) return;
|
|
263
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
264
|
-
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
265
|
-
const includeFilter = include?.map(patternToIdFilter);
|
|
266
|
-
return createFilter$1(excludeFilter, includeFilter);
|
|
267
|
-
}
|
|
268
|
-
function createCodeFilter(filter) {
|
|
269
|
-
if (!filter) return;
|
|
270
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
271
|
-
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
272
|
-
const includeFilter = include?.map(patternToCodeFilter);
|
|
273
|
-
return createFilter$1(excludeFilter, includeFilter);
|
|
274
|
-
}
|
|
275
|
-
function createFilterForId(filter) {
|
|
276
|
-
const filterFunction = createIdFilter(filter);
|
|
277
|
-
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
278
|
-
}
|
|
279
|
-
function createFilterForTransform(idFilter, codeFilter) {
|
|
280
|
-
if (!idFilter && !codeFilter) return;
|
|
281
|
-
const idFilterFunction = createIdFilter(idFilter);
|
|
282
|
-
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
283
|
-
return (id, code) => {
|
|
284
|
-
let fallback = true;
|
|
285
|
-
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
286
|
-
if (!fallback) return false;
|
|
287
|
-
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
288
|
-
return fallback;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function normalizeObjectHook(name, hook) {
|
|
292
|
-
let handler;
|
|
293
|
-
let filter;
|
|
294
|
-
if (typeof hook === "function") handler = hook;
|
|
295
|
-
else {
|
|
296
|
-
handler = hook.handler;
|
|
297
|
-
const hookFilter = hook.filter;
|
|
298
|
-
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
299
|
-
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
300
|
-
}
|
|
301
|
-
return {
|
|
302
|
-
handler,
|
|
303
|
-
filter: filter || (() => true)
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
function parse(code, opts = {}) {
|
|
307
|
-
return Parser.parse(code, {
|
|
308
|
-
sourceType: "module",
|
|
309
|
-
ecmaVersion: "latest",
|
|
310
|
-
locations: true,
|
|
311
|
-
...opts
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
|
|
317
|
-
function transformUse(data, plugin, transformLoader) {
|
|
318
|
-
if (data.resource == null) return [];
|
|
319
|
-
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
|
320
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
|
321
|
-
const { filter } = normalizeObjectHook("load", plugin.transform);
|
|
322
|
-
if (!filter(id)) return [];
|
|
323
|
-
return [{
|
|
324
|
-
loader: transformLoader,
|
|
325
|
-
options: { plugin },
|
|
326
|
-
ident: plugin.name
|
|
327
|
-
}];
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
|
331
|
-
* the input path to the native os format. This is useful in cases where we want to normalize
|
|
332
|
-
* the `id` argument of a hook. Any absolute ids should be in the default format
|
|
333
|
-
* of the operating system. Any relative imports or node_module imports should remain
|
|
334
|
-
* untouched.
|
|
335
|
-
*
|
|
336
|
-
* @param path - Path to normalize.
|
|
337
|
-
* @returns a new normalized path.
|
|
338
|
-
*/
|
|
339
|
-
function normalizeAbsolutePath(path$1) {
|
|
340
|
-
if (isAbsolute(path$1)) return normalize(path$1);
|
|
341
|
-
else return path$1;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
|
|
346
|
-
function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
|
|
347
|
-
return {
|
|
348
|
-
getNativeBuildContext() {
|
|
349
|
-
return {
|
|
350
|
-
framework: "rspack",
|
|
351
|
-
compiler,
|
|
352
|
-
compilation,
|
|
353
|
-
loaderContext,
|
|
354
|
-
inputSourceMap
|
|
355
|
-
};
|
|
356
|
-
},
|
|
357
|
-
addWatchFile(file) {
|
|
358
|
-
const cwd$1 = process.cwd();
|
|
359
|
-
compilation.fileDependencies.add(resolve(cwd$1, file));
|
|
360
|
-
},
|
|
361
|
-
getWatchFiles() {
|
|
362
|
-
return Array.from(compilation.fileDependencies);
|
|
363
|
-
},
|
|
364
|
-
parse,
|
|
365
|
-
emitFile(emittedFile) {
|
|
366
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
367
|
-
if (emittedFile.source && outFileName) {
|
|
368
|
-
const { sources } = compilation.compiler.webpack;
|
|
369
|
-
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
function normalizeMessage$1(error) {
|
|
375
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
376
|
-
if (typeof error === "object") {
|
|
377
|
-
err.stack = error.stack;
|
|
378
|
-
err.cause = error.meta;
|
|
379
|
-
}
|
|
380
|
-
return err;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
//#endregion
|
|
384
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
|
|
385
|
-
function encodeVirtualModuleId(id, plugin) {
|
|
386
|
-
return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
|
387
|
-
}
|
|
388
|
-
function decodeVirtualModuleId(encoded, _plugin) {
|
|
389
|
-
return decodeURIComponent(basename(encoded));
|
|
390
|
-
}
|
|
391
|
-
function isVirtualModuleId(encoded, plugin) {
|
|
392
|
-
return dirname(encoded) === plugin.__virtualModulePrefix;
|
|
393
|
-
}
|
|
394
|
-
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
|
|
395
|
-
name = "FakeVirtualModulesPlugin";
|
|
396
|
-
static counters = /* @__PURE__ */ new Map();
|
|
397
|
-
static initCleanup = false;
|
|
398
|
-
constructor(plugin) {
|
|
399
|
-
this.plugin = plugin;
|
|
400
|
-
if (!FakeVirtualModulesPlugin$1.initCleanup) {
|
|
401
|
-
FakeVirtualModulesPlugin$1.initCleanup = true;
|
|
402
|
-
process.once("exit", () => {
|
|
403
|
-
FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
|
|
404
|
-
fs.rmSync(dir, {
|
|
405
|
-
recursive: true,
|
|
406
|
-
force: true
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
apply(compiler) {
|
|
413
|
-
const dir = this.plugin.__virtualModulePrefix;
|
|
414
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
415
|
-
const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
|
|
416
|
-
FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
|
|
417
|
-
compiler.hooks.shutdown.tap(this.name, () => {
|
|
418
|
-
const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
|
|
419
|
-
if (counter$1 === 0) {
|
|
420
|
-
FakeVirtualModulesPlugin$1.counters.delete(dir);
|
|
421
|
-
fs.rmSync(dir, {
|
|
422
|
-
recursive: true,
|
|
423
|
-
force: true
|
|
424
|
-
});
|
|
425
|
-
} else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
async writeModule(file) {
|
|
429
|
-
return fs.promises.writeFile(file, "");
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
|
|
435
|
-
function contextOptionsFromCompilation(compilation) {
|
|
436
|
-
return {
|
|
437
|
-
addWatchFile(file) {
|
|
438
|
-
(compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
|
|
439
|
-
},
|
|
440
|
-
getWatchFiles() {
|
|
441
|
-
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
const require$1 = createRequire(import.meta.url);
|
|
446
|
-
function getSource(fileSource) {
|
|
447
|
-
return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
|
|
448
|
-
}
|
|
449
|
-
function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
|
|
450
|
-
return {
|
|
451
|
-
parse,
|
|
452
|
-
addWatchFile(id) {
|
|
453
|
-
options.addWatchFile(resolve(process$1.cwd(), id));
|
|
454
|
-
},
|
|
455
|
-
emitFile(emittedFile) {
|
|
456
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
457
|
-
if (emittedFile.source && outFileName) {
|
|
458
|
-
if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
|
|
459
|
-
compilation.emitAsset(outFileName, getSource(emittedFile.source));
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
getWatchFiles() {
|
|
463
|
-
return options.getWatchFiles();
|
|
464
|
-
},
|
|
465
|
-
getNativeBuildContext() {
|
|
466
|
-
return {
|
|
467
|
-
framework: "webpack",
|
|
468
|
-
compiler,
|
|
469
|
-
compilation,
|
|
470
|
-
loaderContext,
|
|
471
|
-
inputSourceMap
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
function normalizeMessage(error) {
|
|
477
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
478
|
-
if (typeof error === "object") {
|
|
479
|
-
err.stack = error.stack;
|
|
480
|
-
err.cause = error.meta;
|
|
481
|
-
}
|
|
482
|
-
return err;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
|
|
487
|
-
var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
488
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
489
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
490
|
-
};
|
|
491
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
492
|
-
exports.VirtualStats = void 0;
|
|
493
|
-
const constants_1 = __importDefault(__require("constants"));
|
|
494
|
-
var VirtualStats = class {
|
|
495
|
-
constructor(config) {
|
|
496
|
-
for (const key in config) {
|
|
497
|
-
if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
|
|
498
|
-
this[key] = config[key];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
_checkModeProperty(property) {
|
|
502
|
-
return (this.mode & constants_1.default.S_IFMT) === property;
|
|
503
|
-
}
|
|
504
|
-
isDirectory() {
|
|
505
|
-
return this._checkModeProperty(constants_1.default.S_IFDIR);
|
|
506
|
-
}
|
|
507
|
-
isFile() {
|
|
508
|
-
return this._checkModeProperty(constants_1.default.S_IFREG);
|
|
509
|
-
}
|
|
510
|
-
isBlockDevice() {
|
|
511
|
-
return this._checkModeProperty(constants_1.default.S_IFBLK);
|
|
512
|
-
}
|
|
513
|
-
isCharacterDevice() {
|
|
514
|
-
return this._checkModeProperty(constants_1.default.S_IFCHR);
|
|
515
|
-
}
|
|
516
|
-
isSymbolicLink() {
|
|
517
|
-
return this._checkModeProperty(constants_1.default.S_IFLNK);
|
|
518
|
-
}
|
|
519
|
-
isFIFO() {
|
|
520
|
-
return this._checkModeProperty(constants_1.default.S_IFIFO);
|
|
521
|
-
}
|
|
522
|
-
isSocket() {
|
|
523
|
-
return this._checkModeProperty(constants_1.default.S_IFSOCK);
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
exports.VirtualStats = VirtualStats;
|
|
527
|
-
}));
|
|
528
|
-
|
|
529
|
-
//#endregion
|
|
530
|
-
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
|
|
531
|
-
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
532
|
-
const path_1 = (exports && exports.__importDefault || function(mod) {
|
|
533
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
534
|
-
})(__require("path"));
|
|
535
|
-
const virtual_stats_1 = require_virtual_stats();
|
|
536
|
-
let inode = 45e6;
|
|
537
|
-
const ALL = "all";
|
|
538
|
-
const STATIC = "static";
|
|
539
|
-
const DYNAMIC = "dynamic";
|
|
540
|
-
function checkActivation(instance) {
|
|
541
|
-
if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
|
|
542
|
-
}
|
|
543
|
-
function getModulePath(filePath, compiler) {
|
|
544
|
-
return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
|
|
545
|
-
}
|
|
546
|
-
function createWebpackData(result) {
|
|
547
|
-
return (backendOrStorage) => {
|
|
548
|
-
if (backendOrStorage._data) {
|
|
549
|
-
const curLevelIdx = backendOrStorage._currentLevel;
|
|
550
|
-
return {
|
|
551
|
-
result,
|
|
552
|
-
level: backendOrStorage._levels[curLevelIdx]
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
return [null, result];
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
function getData(storage, key) {
|
|
559
|
-
if (storage._data instanceof Map) return storage._data.get(key);
|
|
560
|
-
else if (storage._data) return storage.data[key];
|
|
561
|
-
else if (storage.data instanceof Map) return storage.data.get(key);
|
|
562
|
-
else return storage.data[key];
|
|
563
|
-
}
|
|
564
|
-
function setData(backendOrStorage, key, valueFactory) {
|
|
565
|
-
const value = valueFactory(backendOrStorage);
|
|
566
|
-
if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
|
|
567
|
-
else if (backendOrStorage._data) backendOrStorage.data[key] = value;
|
|
568
|
-
else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
|
|
569
|
-
else backendOrStorage.data[key] = value;
|
|
570
|
-
}
|
|
571
|
-
function getStatStorage(fileSystem) {
|
|
572
|
-
if (fileSystem._statStorage) return fileSystem._statStorage;
|
|
573
|
-
else if (fileSystem._statBackend) return fileSystem._statBackend;
|
|
574
|
-
else throw new Error("Couldn't find a stat storage");
|
|
575
|
-
}
|
|
576
|
-
function getFileStorage(fileSystem) {
|
|
577
|
-
if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
|
|
578
|
-
else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
|
|
579
|
-
else throw new Error("Couldn't find a readFileStorage");
|
|
580
|
-
}
|
|
581
|
-
function getReadDirBackend(fileSystem) {
|
|
582
|
-
if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
|
|
583
|
-
else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
|
|
584
|
-
else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
|
|
585
|
-
}
|
|
586
|
-
function getRealpathBackend(fileSystem) {
|
|
587
|
-
if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
|
|
588
|
-
}
|
|
589
|
-
var VirtualModulesPlugin = class {
|
|
590
|
-
constructor(modules) {
|
|
591
|
-
this._compiler = null;
|
|
592
|
-
this._watcher = null;
|
|
593
|
-
this._staticModules = modules || null;
|
|
594
|
-
}
|
|
595
|
-
getModuleList(filter = ALL) {
|
|
596
|
-
var _a, _b;
|
|
597
|
-
let modules = {};
|
|
598
|
-
const shouldGetStaticModules = filter === ALL || filter === STATIC;
|
|
599
|
-
const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
|
|
600
|
-
if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
|
|
601
|
-
if (shouldGetDynamicModules) {
|
|
602
|
-
const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
|
|
603
|
-
const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
|
|
604
|
-
const dynamicModules = {};
|
|
605
|
-
Object.keys(virtualFiles).forEach((key) => {
|
|
606
|
-
dynamicModules[key] = virtualFiles[key].contents;
|
|
607
|
-
});
|
|
608
|
-
modules = Object.assign(Object.assign({}, modules), dynamicModules);
|
|
609
|
-
}
|
|
610
|
-
return modules;
|
|
611
|
-
}
|
|
612
|
-
writeModule(filePath, contents) {
|
|
613
|
-
if (!this._compiler) throw new Error(`Plugin has not been initialized`);
|
|
614
|
-
checkActivation(this);
|
|
615
|
-
const len = contents ? contents.length : 0;
|
|
616
|
-
const time = Date.now();
|
|
617
|
-
const date = new Date(time);
|
|
618
|
-
const stats = new virtual_stats_1.VirtualStats({
|
|
619
|
-
dev: 8675309,
|
|
620
|
-
nlink: 0,
|
|
621
|
-
uid: 1e3,
|
|
622
|
-
gid: 1e3,
|
|
623
|
-
rdev: 0,
|
|
624
|
-
blksize: 4096,
|
|
625
|
-
ino: inode++,
|
|
626
|
-
mode: 33188,
|
|
627
|
-
size: len,
|
|
628
|
-
blocks: Math.floor(len / 4096),
|
|
629
|
-
atime: date,
|
|
630
|
-
mtime: date,
|
|
631
|
-
ctime: date,
|
|
632
|
-
birthtime: date
|
|
633
|
-
});
|
|
634
|
-
const modulePath = getModulePath(filePath, this._compiler);
|
|
635
|
-
if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
|
|
636
|
-
let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
|
|
637
|
-
while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
|
|
638
|
-
let finalInputFileSystem = this._compiler.inputFileSystem;
|
|
639
|
-
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
640
|
-
finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
|
|
641
|
-
if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
|
|
642
|
-
const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
|
|
643
|
-
for (let fileWatcher of fileWatchers) {
|
|
644
|
-
if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
|
|
645
|
-
if (fileWatcher.path === modulePath) {
|
|
646
|
-
if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
|
|
647
|
-
delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
|
|
648
|
-
fileWatcher.emit("change", time, null);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
apply(compiler) {
|
|
654
|
-
this._compiler = compiler;
|
|
655
|
-
const afterEnvironmentHook = () => {
|
|
656
|
-
let finalInputFileSystem = compiler.inputFileSystem;
|
|
657
|
-
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
658
|
-
if (!finalInputFileSystem._writeVirtualFile) {
|
|
659
|
-
const originalPurge = finalInputFileSystem.purge;
|
|
660
|
-
finalInputFileSystem.purge = () => {
|
|
661
|
-
originalPurge.apply(finalInputFileSystem, []);
|
|
662
|
-
if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
|
|
663
|
-
const data = finalInputFileSystem._virtualFiles[file];
|
|
664
|
-
finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
|
|
665
|
-
});
|
|
666
|
-
};
|
|
667
|
-
finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
|
|
668
|
-
const statStorage = getStatStorage(finalInputFileSystem);
|
|
669
|
-
const fileStorage = getFileStorage(finalInputFileSystem);
|
|
670
|
-
const readDirStorage = getReadDirBackend(finalInputFileSystem);
|
|
671
|
-
const realPathStorage = getRealpathBackend(finalInputFileSystem);
|
|
672
|
-
finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
|
|
673
|
-
finalInputFileSystem._virtualFiles[file] = {
|
|
674
|
-
stats,
|
|
675
|
-
contents
|
|
676
|
-
};
|
|
677
|
-
setData(statStorage, file, createWebpackData(stats));
|
|
678
|
-
setData(fileStorage, file, createWebpackData(contents));
|
|
679
|
-
const segments = file.split(/[\\/]/);
|
|
680
|
-
let count = segments.length - 1;
|
|
681
|
-
const minCount = segments[0] ? 1 : 0;
|
|
682
|
-
while (count > minCount) {
|
|
683
|
-
const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
|
|
684
|
-
try {
|
|
685
|
-
finalInputFileSystem.readdirSync(dir);
|
|
686
|
-
} catch (e) {
|
|
687
|
-
const time = Date.now();
|
|
688
|
-
const dirStats = new virtual_stats_1.VirtualStats({
|
|
689
|
-
dev: 8675309,
|
|
690
|
-
nlink: 0,
|
|
691
|
-
uid: 1e3,
|
|
692
|
-
gid: 1e3,
|
|
693
|
-
rdev: 0,
|
|
694
|
-
blksize: 4096,
|
|
695
|
-
ino: inode++,
|
|
696
|
-
mode: 16877,
|
|
697
|
-
size: stats.size,
|
|
698
|
-
blocks: Math.floor(stats.size / 4096),
|
|
699
|
-
atime: time,
|
|
700
|
-
mtime: time,
|
|
701
|
-
ctime: time,
|
|
702
|
-
birthtime: time
|
|
703
|
-
});
|
|
704
|
-
setData(readDirStorage, dir, createWebpackData([]));
|
|
705
|
-
if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
|
|
706
|
-
setData(statStorage, dir, createWebpackData(dirStats));
|
|
707
|
-
}
|
|
708
|
-
let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
|
|
709
|
-
dirData = dirData[1] || dirData.result;
|
|
710
|
-
const filename = segments[count];
|
|
711
|
-
if (dirData.indexOf(filename) < 0) {
|
|
712
|
-
const files = dirData.concat([filename]).sort();
|
|
713
|
-
setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
|
|
714
|
-
} else break;
|
|
715
|
-
count--;
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
const afterResolversHook = () => {
|
|
721
|
-
if (this._staticModules) {
|
|
722
|
-
for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
|
|
723
|
-
this._staticModules = null;
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
const version = typeof compiler.webpack === "undefined" ? 4 : 5;
|
|
727
|
-
const watchRunHook = (watcher, callback) => {
|
|
728
|
-
this._watcher = watcher.compiler || watcher;
|
|
729
|
-
const virtualFiles = compiler.inputFileSystem._virtualFiles;
|
|
730
|
-
const fts = compiler.fileTimestamps;
|
|
731
|
-
if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
|
|
732
|
-
const mtime = +virtualFiles[file].stats.mtime;
|
|
733
|
-
fts.set(file, version === 4 ? mtime : {
|
|
734
|
-
safeTime: mtime,
|
|
735
|
-
timestamp: mtime
|
|
736
|
-
});
|
|
737
|
-
});
|
|
738
|
-
callback();
|
|
739
|
-
};
|
|
740
|
-
if (compiler.hooks) {
|
|
741
|
-
compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
|
|
742
|
-
compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
|
|
743
|
-
compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
|
|
744
|
-
} else {
|
|
745
|
-
compiler.plugin("after-environment", afterEnvironmentHook);
|
|
746
|
-
compiler.plugin("after-resolvers", afterResolversHook);
|
|
747
|
-
compiler.plugin("watch-run", watchRunHook);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
module.exports = VirtualModulesPlugin;
|
|
752
|
-
}));
|
|
753
|
-
|
|
754
|
-
//#endregion
|
|
755
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
|
|
756
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
757
|
-
const ExtToLoader = {
|
|
758
|
-
".js": "js",
|
|
759
|
-
".mjs": "js",
|
|
760
|
-
".cjs": "js",
|
|
761
|
-
".jsx": "jsx",
|
|
762
|
-
".ts": "ts",
|
|
763
|
-
".cts": "ts",
|
|
764
|
-
".mts": "ts",
|
|
765
|
-
".tsx": "tsx",
|
|
766
|
-
".css": "css",
|
|
767
|
-
".less": "css",
|
|
768
|
-
".stylus": "css",
|
|
769
|
-
".scss": "css",
|
|
770
|
-
".sass": "css",
|
|
771
|
-
".json": "json",
|
|
772
|
-
".txt": "text"
|
|
773
|
-
};
|
|
774
|
-
function guessLoader(code, id) {
|
|
775
|
-
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
|
|
776
|
-
}
|
|
777
|
-
function unwrapLoader(loader, code, id) {
|
|
778
|
-
if (typeof loader === "function") return loader(code, id);
|
|
779
|
-
return loader;
|
|
780
|
-
}
|
|
781
|
-
function fixSourceMap(map) {
|
|
782
|
-
if (!Object.prototype.hasOwnProperty.call(map, "toString")) Object.defineProperty(map, "toString", {
|
|
783
|
-
enumerable: false,
|
|
784
|
-
value: function toString() {
|
|
785
|
-
return JSON.stringify(this);
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
if (!Object.prototype.hasOwnProperty.call(map, "toUrl")) Object.defineProperty(map, "toUrl", {
|
|
789
|
-
enumerable: false,
|
|
790
|
-
value: function toUrl() {
|
|
791
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(this.toString()).toString("base64")}`;
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
return map;
|
|
795
|
-
}
|
|
796
|
-
const nullSourceMap = {
|
|
797
|
-
names: [],
|
|
798
|
-
sources: [],
|
|
799
|
-
mappings: "",
|
|
800
|
-
version: 3
|
|
801
|
-
};
|
|
802
|
-
function combineSourcemaps(filename, sourcemapList) {
|
|
803
|
-
sourcemapList = sourcemapList.filter((m) => m.sources);
|
|
804
|
-
if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
|
|
805
|
-
let map;
|
|
806
|
-
let mapIndex = 1;
|
|
807
|
-
if (sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0) map = remapping(sourcemapList, () => null, true);
|
|
808
|
-
else map = remapping(sourcemapList[0], (sourcefile) => {
|
|
809
|
-
if (sourcefile === filename && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
|
|
810
|
-
else return { ...nullSourceMap };
|
|
811
|
-
}, true);
|
|
812
|
-
if (!map.file) delete map.file;
|
|
813
|
-
return map;
|
|
814
|
-
}
|
|
815
|
-
function createBuildContext$2(build) {
|
|
816
|
-
const watchFiles = [];
|
|
817
|
-
const { initialOptions } = build;
|
|
818
|
-
return {
|
|
819
|
-
parse,
|
|
820
|
-
addWatchFile() {
|
|
821
|
-
throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
|
|
822
|
-
},
|
|
823
|
-
emitFile(emittedFile) {
|
|
824
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
825
|
-
if (initialOptions.outdir && emittedFile.source && outFileName) {
|
|
826
|
-
const outPath = path.resolve(initialOptions.outdir, outFileName);
|
|
827
|
-
const outDir = path.dirname(outPath);
|
|
828
|
-
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
|
829
|
-
fs.writeFileSync(outPath, emittedFile.source);
|
|
830
|
-
}
|
|
831
|
-
},
|
|
832
|
-
getWatchFiles() {
|
|
833
|
-
return watchFiles;
|
|
834
|
-
},
|
|
835
|
-
getNativeBuildContext() {
|
|
836
|
-
return {
|
|
837
|
-
framework: "esbuild",
|
|
838
|
-
build
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
function createPluginContext(context) {
|
|
844
|
-
const errors = [];
|
|
845
|
-
const warnings = [];
|
|
846
|
-
const pluginContext = {
|
|
847
|
-
error(message) {
|
|
848
|
-
errors.push(normalizeMessage$2(message));
|
|
849
|
-
},
|
|
850
|
-
warn(message) {
|
|
851
|
-
warnings.push(normalizeMessage$2(message));
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
return {
|
|
855
|
-
errors,
|
|
856
|
-
warnings,
|
|
857
|
-
mixedContext: {
|
|
858
|
-
...context,
|
|
859
|
-
...pluginContext,
|
|
860
|
-
addWatchFile(id) {
|
|
861
|
-
context.getWatchFiles().push(id);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
function normalizeMessage$2(message) {
|
|
867
|
-
if (typeof message === "string") message = { message };
|
|
868
|
-
return {
|
|
869
|
-
id: message.id,
|
|
870
|
-
pluginName: message.plugin,
|
|
871
|
-
text: message.message,
|
|
872
|
-
location: message.loc ? {
|
|
873
|
-
file: message.loc.file,
|
|
874
|
-
line: message.loc.line,
|
|
875
|
-
column: message.loc.column
|
|
876
|
-
} : null,
|
|
877
|
-
detail: message.meta,
|
|
878
|
-
notes: []
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
function processCodeWithSourceMap(map, code) {
|
|
882
|
-
if (map) {
|
|
883
|
-
if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
|
|
884
|
-
map = fixSourceMap(map);
|
|
885
|
-
code += `\n//# sourceMappingURL=${map.toUrl()}`;
|
|
886
|
-
}
|
|
887
|
-
return code;
|
|
888
|
-
}
|
|
889
|
-
function getEsbuildPlugin(factory) {
|
|
890
|
-
return (userOptions) => {
|
|
891
|
-
const meta = { framework: "esbuild" };
|
|
892
|
-
const plugins = toArray$2(factory(userOptions, meta));
|
|
893
|
-
const setupPlugins = async (build) => {
|
|
894
|
-
const setup = buildSetup();
|
|
895
|
-
const loaders = [];
|
|
896
|
-
for (const plugin of plugins) {
|
|
897
|
-
const loader = {};
|
|
898
|
-
await setup(plugin)({
|
|
899
|
-
...build,
|
|
900
|
-
onLoad(_options, callback) {
|
|
901
|
-
loader.options = _options;
|
|
902
|
-
loader.onLoadCb = callback;
|
|
903
|
-
},
|
|
904
|
-
onTransform(_options, callback) {
|
|
905
|
-
loader.options ||= _options;
|
|
906
|
-
loader.onTransformCb = callback;
|
|
907
|
-
}
|
|
908
|
-
}, build);
|
|
909
|
-
if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
|
|
910
|
-
}
|
|
911
|
-
if (loaders.length) build.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
|
|
912
|
-
function checkFilter(options) {
|
|
913
|
-
return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
|
|
914
|
-
}
|
|
915
|
-
let result;
|
|
916
|
-
for (const { options, onLoadCb } of loaders) {
|
|
917
|
-
if (!checkFilter(options)) continue;
|
|
918
|
-
if (onLoadCb) result = await onLoadCb(args);
|
|
919
|
-
if (result?.contents) break;
|
|
920
|
-
}
|
|
921
|
-
let fsContentsCache;
|
|
922
|
-
for (const { options, onTransformCb } of loaders) {
|
|
923
|
-
if (!checkFilter(options)) continue;
|
|
924
|
-
if (onTransformCb) {
|
|
925
|
-
const _result = await onTransformCb({
|
|
926
|
-
...result,
|
|
927
|
-
...args,
|
|
928
|
-
async getContents() {
|
|
929
|
-
if (result?.contents) return result.contents;
|
|
930
|
-
if (fsContentsCache) return fsContentsCache;
|
|
931
|
-
return fsContentsCache = await fs.promises.readFile(args.path, "utf8");
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
if (_result?.contents) result = _result;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
if (result?.contents) return result;
|
|
938
|
-
});
|
|
939
|
-
};
|
|
940
|
-
return {
|
|
941
|
-
name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
|
|
942
|
-
setup: setupPlugins
|
|
943
|
-
};
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
function buildSetup() {
|
|
947
|
-
return (plugin) => {
|
|
948
|
-
return (build, rawBuild) => {
|
|
949
|
-
const context = createBuildContext$2(rawBuild);
|
|
950
|
-
const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
|
|
951
|
-
const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
|
|
952
|
-
const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
|
|
953
|
-
const loader = plugin.esbuild?.loader ?? guessLoader;
|
|
954
|
-
plugin.esbuild?.config?.call(context, initialOptions);
|
|
955
|
-
if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
|
|
956
|
-
if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
|
|
957
|
-
if (plugin.buildEnd) await plugin.buildEnd.call(context);
|
|
958
|
-
if (plugin.writeBundle) await plugin.writeBundle();
|
|
959
|
-
});
|
|
960
|
-
if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
|
|
961
|
-
const id = args.path;
|
|
962
|
-
if (initialOptions.external?.includes(id)) return;
|
|
963
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
964
|
-
if (!filter(id)) return;
|
|
965
|
-
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
966
|
-
const isEntry = args.kind === "entry-point";
|
|
967
|
-
const result = await handler.call(mixedContext, id, isEntry ? void 0 : args.importer, { isEntry });
|
|
968
|
-
if (typeof result === "string") return {
|
|
969
|
-
path: result,
|
|
970
|
-
namespace: plugin.name,
|
|
971
|
-
errors,
|
|
972
|
-
warnings,
|
|
973
|
-
watchFiles: mixedContext.getWatchFiles()
|
|
974
|
-
};
|
|
975
|
-
else if (typeof result === "object" && result !== null) return {
|
|
976
|
-
path: result.id,
|
|
977
|
-
external: result.external,
|
|
978
|
-
namespace: plugin.name,
|
|
979
|
-
errors,
|
|
980
|
-
warnings,
|
|
981
|
-
watchFiles: mixedContext.getWatchFiles()
|
|
982
|
-
};
|
|
983
|
-
});
|
|
984
|
-
if (plugin.load) onLoad({ filter: onLoadFilter }, async (args) => {
|
|
985
|
-
const { handler, filter } = normalizeObjectHook("load", plugin.load);
|
|
986
|
-
const id = args.path + (args.suffix || "");
|
|
987
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
988
|
-
if (!filter(id)) return;
|
|
989
|
-
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
990
|
-
let code;
|
|
991
|
-
let map;
|
|
992
|
-
const result = await handler.call(mixedContext, id);
|
|
993
|
-
if (typeof result === "string") code = result;
|
|
994
|
-
else if (typeof result === "object" && result !== null) {
|
|
995
|
-
code = result.code;
|
|
996
|
-
map = result.map;
|
|
997
|
-
}
|
|
998
|
-
if (code === void 0) return null;
|
|
999
|
-
if (map) code = processCodeWithSourceMap(map, code);
|
|
1000
|
-
const resolveDir = path.dirname(args.path);
|
|
1001
|
-
return {
|
|
1002
|
-
contents: code,
|
|
1003
|
-
errors,
|
|
1004
|
-
warnings,
|
|
1005
|
-
watchFiles: mixedContext.getWatchFiles(),
|
|
1006
|
-
loader: unwrapLoader(loader, code, args.path),
|
|
1007
|
-
resolveDir
|
|
1008
|
-
};
|
|
1009
|
-
});
|
|
1010
|
-
if (plugin.transform) onTransform({ filter: onLoadFilter }, async (args) => {
|
|
1011
|
-
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
|
1012
|
-
const id = args.path + (args.suffix || "");
|
|
1013
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
1014
|
-
let code = await args.getContents();
|
|
1015
|
-
if (!filter(id, code)) return;
|
|
1016
|
-
const { mixedContext, errors, warnings } = createPluginContext(context);
|
|
1017
|
-
const resolveDir = path.dirname(args.path);
|
|
1018
|
-
let map;
|
|
1019
|
-
const result = await handler.call(mixedContext, code, id);
|
|
1020
|
-
if (typeof result === "string") code = result;
|
|
1021
|
-
else if (typeof result === "object" && result !== null) {
|
|
1022
|
-
code = result.code;
|
|
1023
|
-
if (map && result.map) map = combineSourcemaps(args.path, [result.map === "string" ? JSON.parse(result.map) : result.map, map]);
|
|
1024
|
-
else if (typeof result.map === "string") map = JSON.parse(result.map);
|
|
1025
|
-
else map = result.map;
|
|
1026
|
-
}
|
|
1027
|
-
if (code) {
|
|
1028
|
-
if (map) code = processCodeWithSourceMap(map, code);
|
|
1029
|
-
return {
|
|
1030
|
-
contents: code,
|
|
1031
|
-
errors,
|
|
1032
|
-
warnings,
|
|
1033
|
-
watchFiles: mixedContext.getWatchFiles(),
|
|
1034
|
-
loader: unwrapLoader(loader, code, args.path),
|
|
1035
|
-
resolveDir
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
});
|
|
1039
|
-
if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
|
|
1040
|
-
};
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
function createFarmContext(context, currentResolveId) {
|
|
1044
|
-
return {
|
|
1045
|
-
parse,
|
|
1046
|
-
addWatchFile(id) {
|
|
1047
|
-
context.addWatchFile(id, currentResolveId || id);
|
|
1048
|
-
},
|
|
1049
|
-
emitFile(emittedFile) {
|
|
1050
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
1051
|
-
if (emittedFile.source && outFileName) context.emitFile({
|
|
1052
|
-
resolvedPath: outFileName,
|
|
1053
|
-
name: outFileName,
|
|
1054
|
-
content: [...Buffer.from(emittedFile.source)],
|
|
1055
|
-
resourceType: extname(outFileName)
|
|
1056
|
-
});
|
|
1057
|
-
},
|
|
1058
|
-
getWatchFiles() {
|
|
1059
|
-
return context.getWatchFiles();
|
|
1060
|
-
},
|
|
1061
|
-
getNativeBuildContext() {
|
|
1062
|
-
return {
|
|
1063
|
-
framework: "farm",
|
|
1064
|
-
context
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
function unpluginContext(context) {
|
|
1070
|
-
return {
|
|
1071
|
-
error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
|
|
1072
|
-
warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
|
|
1073
|
-
};
|
|
1074
|
-
}
|
|
1075
|
-
function convertEnforceToPriority(value) {
|
|
1076
|
-
const defaultPriority = 100;
|
|
1077
|
-
const enforceToPriority = {
|
|
1078
|
-
pre: 102,
|
|
1079
|
-
post: 98
|
|
1080
|
-
};
|
|
1081
|
-
return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
|
|
1082
|
-
}
|
|
1083
|
-
function convertWatchEventChange(value) {
|
|
1084
|
-
return {
|
|
1085
|
-
Added: "create",
|
|
1086
|
-
Updated: "update",
|
|
1087
|
-
Removed: "delete"
|
|
1088
|
-
}[value];
|
|
1089
|
-
}
|
|
1090
|
-
function isString(variable) {
|
|
1091
|
-
return typeof variable === "string";
|
|
1092
|
-
}
|
|
1093
|
-
function isObject(variable) {
|
|
1094
|
-
return typeof variable === "object" && variable !== null;
|
|
1095
|
-
}
|
|
1096
|
-
function customParseQueryString(url) {
|
|
1097
|
-
if (!url) return [];
|
|
1098
|
-
const queryString = url.split("?")[1];
|
|
1099
|
-
const parsedParams = querystring.parse(queryString);
|
|
1100
|
-
const paramsArray = [];
|
|
1101
|
-
for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
|
|
1102
|
-
return paramsArray;
|
|
1103
|
-
}
|
|
1104
|
-
function encodeStr(str) {
|
|
1105
|
-
const len = str.length;
|
|
1106
|
-
if (len === 0) return str;
|
|
1107
|
-
const firstNullIndex = str.indexOf("\0");
|
|
1108
|
-
if (firstNullIndex === -1) return str;
|
|
1109
|
-
const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
|
|
1110
|
-
let pos = 0;
|
|
1111
|
-
for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
|
|
1112
|
-
for (let i = firstNullIndex; i < len; i++) {
|
|
1113
|
-
const char = str[i];
|
|
1114
|
-
if (char === "\0") {
|
|
1115
|
-
result[pos++] = "\\";
|
|
1116
|
-
result[pos++] = "0";
|
|
1117
|
-
} else result[pos++] = char;
|
|
1118
|
-
}
|
|
1119
|
-
return path.posix.normalize(result.join(""));
|
|
1120
|
-
}
|
|
1121
|
-
function decodeStr(str) {
|
|
1122
|
-
const len = str.length;
|
|
1123
|
-
if (len === 0) return str;
|
|
1124
|
-
const firstIndex = str.indexOf("\\0");
|
|
1125
|
-
if (firstIndex === -1) return str;
|
|
1126
|
-
const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
|
|
1127
|
-
let pos = 0;
|
|
1128
|
-
for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
|
|
1129
|
-
let i = firstIndex;
|
|
1130
|
-
while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
1131
|
-
result[pos++] = "\0";
|
|
1132
|
-
i += 2;
|
|
1133
|
-
} else result[pos++] = str[i++];
|
|
1134
|
-
return path.posix.normalize(result.join(""));
|
|
1135
|
-
}
|
|
1136
|
-
function getContentValue(content) {
|
|
1137
|
-
if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
|
|
1138
|
-
return encodeStr(typeof content === "string" ? content : content.code || "");
|
|
1139
|
-
}
|
|
1140
|
-
function countNulls(str, startIndex) {
|
|
1141
|
-
let count = 0;
|
|
1142
|
-
const len = str.length;
|
|
1143
|
-
for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
|
|
1144
|
-
return count;
|
|
1145
|
-
}
|
|
1146
|
-
function countBackslashZeros(str, startIndex) {
|
|
1147
|
-
let count = 0;
|
|
1148
|
-
const len = str.length;
|
|
1149
|
-
for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
1150
|
-
count++;
|
|
1151
|
-
i++;
|
|
1152
|
-
}
|
|
1153
|
-
return count;
|
|
1154
|
-
}
|
|
1155
|
-
function removeQuery(pathe) {
|
|
1156
|
-
const queryIndex = pathe.indexOf("?");
|
|
1157
|
-
if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
|
|
1158
|
-
return path.posix.normalize(pathe);
|
|
1159
|
-
}
|
|
1160
|
-
function isStartsWithSlash(str) {
|
|
1161
|
-
return str?.startsWith("/");
|
|
1162
|
-
}
|
|
1163
|
-
function appendQuery(id, query) {
|
|
1164
|
-
if (!query.length) return id;
|
|
1165
|
-
return `${id}?${stringifyQuery(query)}`;
|
|
1166
|
-
}
|
|
1167
|
-
function stringifyQuery(query) {
|
|
1168
|
-
if (!query.length) return "";
|
|
1169
|
-
let queryStr = "";
|
|
1170
|
-
for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
|
|
1171
|
-
return `${queryStr.slice(0, -1)}`;
|
|
1172
|
-
}
|
|
1173
|
-
const CSS_LANGS_RES = [
|
|
1174
|
-
[/\.(less)(?:$|\?)/, "less"],
|
|
1175
|
-
[/\.(scss|sass)(?:$|\?)/, "sass"],
|
|
1176
|
-
[/\.(styl|stylus)(?:$|\?)/, "stylus"],
|
|
1177
|
-
[/\.(css)(?:$|\?)/, "css"]
|
|
1178
|
-
];
|
|
1179
|
-
const JS_LANGS_RES = [
|
|
1180
|
-
[/\.(js|mjs|cjs)(?:$|\?)/, "js"],
|
|
1181
|
-
[/\.(jsx)(?:$|\?)/, "jsx"],
|
|
1182
|
-
[/\.(ts|cts|mts)(?:$|\?)/, "ts"],
|
|
1183
|
-
[/\.(tsx)(?:$|\?)/, "tsx"]
|
|
1184
|
-
];
|
|
1185
|
-
function getCssModuleType(id) {
|
|
1186
|
-
for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
|
|
1187
|
-
return null;
|
|
1188
|
-
}
|
|
1189
|
-
function getJsModuleType(id) {
|
|
1190
|
-
for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
|
|
1191
|
-
return null;
|
|
1192
|
-
}
|
|
1193
|
-
function formatLoadModuleType(id) {
|
|
1194
|
-
const cssModuleType = getCssModuleType(id);
|
|
1195
|
-
if (cssModuleType) return cssModuleType;
|
|
1196
|
-
const jsModuleType = getJsModuleType(id);
|
|
1197
|
-
if (jsModuleType) return jsModuleType;
|
|
1198
|
-
return "js";
|
|
1199
|
-
}
|
|
1200
|
-
function formatTransformModuleType(id) {
|
|
1201
|
-
return formatLoadModuleType(id);
|
|
1202
|
-
}
|
|
1203
|
-
function getFarmPlugin(factory) {
|
|
1204
|
-
return ((userOptions) => {
|
|
1205
|
-
const plugins = toArray$2(factory(userOptions, { framework: "farm" })).map((rawPlugin) => {
|
|
1206
|
-
const plugin = toFarmPlugin(rawPlugin, userOptions);
|
|
1207
|
-
if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
|
|
1208
|
-
return plugin;
|
|
1209
|
-
});
|
|
1210
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
function toFarmPlugin(plugin, options) {
|
|
1214
|
-
const farmPlugin = {
|
|
1215
|
-
name: plugin.name,
|
|
1216
|
-
priority: convertEnforceToPriority(plugin.enforce)
|
|
1217
|
-
};
|
|
1218
|
-
if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
|
|
1219
|
-
const value = plugin.farm[key];
|
|
1220
|
-
if (value) Reflect.set(farmPlugin, key, value);
|
|
1221
|
-
});
|
|
1222
|
-
if (plugin.buildStart) {
|
|
1223
|
-
const _buildStart = plugin.buildStart;
|
|
1224
|
-
farmPlugin.buildStart = { async executor(_, context) {
|
|
1225
|
-
await _buildStart.call(createFarmContext(context));
|
|
1226
|
-
} };
|
|
1227
|
-
}
|
|
1228
|
-
if (plugin.resolveId) {
|
|
1229
|
-
const _resolveId = plugin.resolveId;
|
|
1230
|
-
let filters = [];
|
|
1231
|
-
if (options) filters = options?.filters ?? [];
|
|
1232
|
-
farmPlugin.resolve = {
|
|
1233
|
-
filters: {
|
|
1234
|
-
sources: filters.length ? filters : [".*"],
|
|
1235
|
-
importers: [".*"]
|
|
1236
|
-
},
|
|
1237
|
-
async executor(params, context) {
|
|
1238
|
-
const resolvedIdPath = path.resolve(params.importer ?? "");
|
|
1239
|
-
const id = decodeStr(params.source);
|
|
1240
|
-
const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
|
|
1241
|
-
if (!filter(id)) return null;
|
|
1242
|
-
let isEntry = false;
|
|
1243
|
-
if (isObject(params.kind) && "entry" in params.kind) isEntry = params.kind.entry === "index";
|
|
1244
|
-
const farmContext = createFarmContext(context, resolvedIdPath);
|
|
1245
|
-
const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, resolvedIdPath ?? null, { isEntry });
|
|
1246
|
-
if (isString(resolveIdResult)) return {
|
|
1247
|
-
resolvedPath: removeQuery(encodeStr(resolveIdResult)),
|
|
1248
|
-
query: customParseQueryString(resolveIdResult),
|
|
1249
|
-
sideEffects: true,
|
|
1250
|
-
external: false,
|
|
1251
|
-
meta: {}
|
|
1252
|
-
};
|
|
1253
|
-
if (isObject(resolveIdResult)) return {
|
|
1254
|
-
resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
|
|
1255
|
-
query: customParseQueryString(resolveIdResult?.id),
|
|
1256
|
-
sideEffects: false,
|
|
1257
|
-
external: Boolean(resolveIdResult?.external),
|
|
1258
|
-
meta: {}
|
|
1259
|
-
};
|
|
1260
|
-
if (!isStartsWithSlash(params.source)) return null;
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
if (plugin.load) {
|
|
1265
|
-
const _load = plugin.load;
|
|
1266
|
-
farmPlugin.load = {
|
|
1267
|
-
filters: { resolvedPaths: [".*"] },
|
|
1268
|
-
async executor(params, context) {
|
|
1269
|
-
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
1270
|
-
const loader = formatTransformModuleType(id);
|
|
1271
|
-
if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
|
|
1272
|
-
const { handler, filter } = normalizeObjectHook("load", _load);
|
|
1273
|
-
if (!filter(id)) return null;
|
|
1274
|
-
const farmContext = createFarmContext(context, id);
|
|
1275
|
-
return {
|
|
1276
|
-
content: getContentValue(await handler.call(Object.assign(unpluginContext(context), farmContext), id)),
|
|
1277
|
-
moduleType: loader
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
if (plugin.transform) {
|
|
1283
|
-
const _transform = plugin.transform;
|
|
1284
|
-
farmPlugin.transform = {
|
|
1285
|
-
filters: {
|
|
1286
|
-
resolvedPaths: [".*"],
|
|
1287
|
-
moduleTypes: [".*"]
|
|
1288
|
-
},
|
|
1289
|
-
async executor(params, context) {
|
|
1290
|
-
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
1291
|
-
const loader = formatTransformModuleType(id);
|
|
1292
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
|
|
1293
|
-
const { handler, filter } = normalizeObjectHook("transform", _transform);
|
|
1294
|
-
if (!filter(id, params.content)) return null;
|
|
1295
|
-
const farmContext = createFarmContext(context, id);
|
|
1296
|
-
const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
|
|
1297
|
-
if (resource && typeof resource !== "string") return {
|
|
1298
|
-
content: getContentValue(resource),
|
|
1299
|
-
moduleType: loader,
|
|
1300
|
-
sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
if (plugin.watchChange) {
|
|
1306
|
-
const _watchChange = plugin.watchChange;
|
|
1307
|
-
farmPlugin.updateModules = { async executor(param, context) {
|
|
1308
|
-
const updatePathContent = param.paths[0];
|
|
1309
|
-
const ModifiedPath = updatePathContent[0];
|
|
1310
|
-
const eventChange = convertWatchEventChange(updatePathContent[1]);
|
|
1311
|
-
await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
|
|
1312
|
-
} };
|
|
1313
|
-
}
|
|
1314
|
-
if (plugin.buildEnd) {
|
|
1315
|
-
const _buildEnd = plugin.buildEnd;
|
|
1316
|
-
farmPlugin.buildEnd = { async executor(_, context) {
|
|
1317
|
-
await _buildEnd.call(createFarmContext(context));
|
|
1318
|
-
} };
|
|
1319
|
-
}
|
|
1320
|
-
if (plugin.writeBundle) {
|
|
1321
|
-
const _writeBundle = plugin.writeBundle;
|
|
1322
|
-
farmPlugin.finish = { async executor() {
|
|
1323
|
-
await _writeBundle();
|
|
1324
|
-
} };
|
|
1325
|
-
}
|
|
1326
|
-
return farmPlugin;
|
|
1327
|
-
}
|
|
1328
|
-
function getRollupPlugin(factory) {
|
|
1329
|
-
return ((userOptions) => {
|
|
1330
|
-
const plugins = toArray$2(factory(userOptions, { framework: "rollup" })).map((plugin) => toRollupPlugin(plugin, "rollup"));
|
|
1331
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
function toRollupPlugin(plugin, key) {
|
|
1335
|
-
const nativeFilter = key === "rolldown";
|
|
1336
|
-
if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
|
|
1337
|
-
const resolveIdHook = plugin.resolveId;
|
|
1338
|
-
const { handler, filter } = normalizeObjectHook("load", resolveIdHook);
|
|
1339
|
-
replaceHookHandler("resolveId", resolveIdHook, function(...args) {
|
|
1340
|
-
const [id] = args;
|
|
1341
|
-
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
1342
|
-
return handler.apply(this, args);
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
|
|
1346
|
-
const loadHook = plugin.load;
|
|
1347
|
-
const { handler, filter } = normalizeObjectHook("load", loadHook);
|
|
1348
|
-
replaceHookHandler("load", loadHook, function(...args) {
|
|
1349
|
-
const [id] = args;
|
|
1350
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
1351
|
-
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
1352
|
-
return handler.apply(this, args);
|
|
1353
|
-
});
|
|
1354
|
-
}
|
|
1355
|
-
if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
|
|
1356
|
-
const transformHook = plugin.transform;
|
|
1357
|
-
const { handler, filter } = normalizeObjectHook("transform", transformHook);
|
|
1358
|
-
replaceHookHandler("transform", transformHook, function(...args) {
|
|
1359
|
-
const [code, id] = args;
|
|
1360
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
1361
|
-
if (!supportNativeFilter(this, key) && !filter(id, code)) return;
|
|
1362
|
-
return handler.apply(this, args);
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
if (plugin[key]) Object.assign(plugin, plugin[key]);
|
|
1366
|
-
return plugin;
|
|
1367
|
-
function replaceHookHandler(name, hook, handler) {
|
|
1368
|
-
if (typeof hook === "function") plugin[name] = handler;
|
|
1369
|
-
else hook.handler = handler;
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
function supportNativeFilter(context, framework) {
|
|
1373
|
-
if (framework === "unloader") return false;
|
|
1374
|
-
if (framework === "vite") return !!context?.meta?.viteVersion;
|
|
1375
|
-
if (framework === "rolldown") return true;
|
|
1376
|
-
const rollupVersion = context?.meta?.rollupVersion;
|
|
1377
|
-
if (!rollupVersion) return false;
|
|
1378
|
-
const [major, minor] = rollupVersion.split(".");
|
|
1379
|
-
return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
|
|
1380
|
-
}
|
|
1381
|
-
function getRolldownPlugin(factory) {
|
|
1382
|
-
return ((userOptions) => {
|
|
1383
|
-
const plugins = toArray$2(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
|
|
1384
|
-
return toRollupPlugin(rawPlugin, "rolldown");
|
|
1385
|
-
});
|
|
1386
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
1387
|
-
});
|
|
1388
|
-
}
|
|
1389
|
-
const getFilename = () => fileURLToPath(import.meta.url);
|
|
1390
|
-
const getDirname = () => path.dirname(getFilename());
|
|
1391
|
-
const __dirname = /* @__PURE__ */ getDirname();
|
|
1392
|
-
const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
|
|
1393
|
-
const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
|
|
1394
|
-
function getRspackPlugin(factory) {
|
|
1395
|
-
return (userOptions) => {
|
|
1396
|
-
return { apply(compiler) {
|
|
1397
|
-
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
|
|
1398
|
-
const meta = {
|
|
1399
|
-
framework: "rspack",
|
|
1400
|
-
rspack: { compiler }
|
|
1401
|
-
};
|
|
1402
|
-
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
1403
|
-
for (const rawPlugin of rawPlugins) {
|
|
1404
|
-
const plugin = Object.assign(rawPlugin, {
|
|
1405
|
-
__unpluginMeta: meta,
|
|
1406
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
1407
|
-
});
|
|
1408
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
1409
|
-
if (plugin.resolveId) {
|
|
1410
|
-
const createPlugin = (plugin$1) => {
|
|
1411
|
-
if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
|
|
1412
|
-
return new FakeVirtualModulesPlugin(plugin$1);
|
|
1413
|
-
};
|
|
1414
|
-
const vfs = createPlugin(plugin);
|
|
1415
|
-
vfs.apply(compiler);
|
|
1416
|
-
const vfsModules = /* @__PURE__ */ new Map();
|
|
1417
|
-
plugin.__vfsModules = vfsModules;
|
|
1418
|
-
plugin.__vfs = vfs;
|
|
1419
|
-
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
|
|
1420
|
-
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
|
|
1421
|
-
const id = normalizeAbsolutePath(resolveData.request);
|
|
1422
|
-
const requestContext = resolveData.contextInfo;
|
|
1423
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
1424
|
-
const isEntry = requestContext.issuer === "";
|
|
1425
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
1426
|
-
const context = createBuildContext$1(compiler, compilation);
|
|
1427
|
-
let error;
|
|
1428
|
-
const pluginContext = {
|
|
1429
|
-
error(msg) {
|
|
1430
|
-
if (error == null) error = normalizeMessage$1(msg);
|
|
1431
|
-
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
|
|
1432
|
-
},
|
|
1433
|
-
warn(msg) {
|
|
1434
|
-
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
1438
|
-
if (!filter(id)) return;
|
|
1439
|
-
const resolveIdResult = await handler.call({
|
|
1440
|
-
...context,
|
|
1441
|
-
...pluginContext
|
|
1442
|
-
}, id, importer, { isEntry });
|
|
1443
|
-
if (error != null) throw error;
|
|
1444
|
-
if (resolveIdResult == null) return;
|
|
1445
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
1446
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
1447
|
-
let isVirtual = true;
|
|
1448
|
-
try {
|
|
1449
|
-
(compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
|
|
1450
|
-
isVirtual = false;
|
|
1451
|
-
} catch {
|
|
1452
|
-
isVirtual = !isVirtualModuleId(resolved, plugin);
|
|
1453
|
-
}
|
|
1454
|
-
if (isVirtual) {
|
|
1455
|
-
const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
|
|
1456
|
-
if (!vfsModules.has(resolved)) {
|
|
1457
|
-
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
|
|
1458
|
-
vfsModules.set(resolved, fsPromise);
|
|
1459
|
-
await fsPromise;
|
|
1460
|
-
} else await vfsModules.get(resolved);
|
|
1461
|
-
resolved = encodedVirtualPath;
|
|
1462
|
-
}
|
|
1463
|
-
resolveData.request = resolved;
|
|
1464
|
-
});
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
1468
|
-
enforce: plugin.enforce,
|
|
1469
|
-
include(id) {
|
|
1470
|
-
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
|
1471
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
1472
|
-
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
1473
|
-
if (!filter(id)) return false;
|
|
1474
|
-
return !externalModules.has(id);
|
|
1475
|
-
},
|
|
1476
|
-
use: [{
|
|
1477
|
-
loader: LOAD_LOADER$1,
|
|
1478
|
-
options: { plugin }
|
|
1479
|
-
}],
|
|
1480
|
-
type: "javascript/auto"
|
|
1481
|
-
});
|
|
1482
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
1483
|
-
enforce: plugin.enforce,
|
|
1484
|
-
use(data) {
|
|
1485
|
-
return transformUse(data, plugin, TRANSFORM_LOADER$1);
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
if (plugin.rspack) plugin.rspack(compiler);
|
|
1489
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
1490
|
-
const context = createBuildContext$1(compiler, compilation);
|
|
1491
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
1492
|
-
const promises$1 = [];
|
|
1493
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
1494
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
1495
|
-
await Promise.all(promises$1);
|
|
1496
|
-
}
|
|
1497
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
1498
|
-
});
|
|
1499
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
1500
|
-
await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
|
|
1501
|
-
});
|
|
1502
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
1503
|
-
await plugin.writeBundle();
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
} };
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
function getUnloaderPlugin(factory) {
|
|
1510
|
-
return ((userOptions) => {
|
|
1511
|
-
const plugins = toArray$2(factory(userOptions, { framework: "unloader" })).map((rawPlugin) => {
|
|
1512
|
-
return toRollupPlugin(rawPlugin, "unloader");
|
|
1513
|
-
});
|
|
1514
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
function getVitePlugin(factory) {
|
|
1518
|
-
return ((userOptions) => {
|
|
1519
|
-
const plugins = toArray$2(factory(userOptions, { framework: "vite" })).map((rawPlugin) => {
|
|
1520
|
-
return toRollupPlugin(rawPlugin, "vite");
|
|
1521
|
-
});
|
|
1522
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
|
|
1526
|
-
const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
|
|
1527
|
-
function getWebpackPlugin(factory) {
|
|
1528
|
-
return (userOptions) => {
|
|
1529
|
-
return { apply(compiler) {
|
|
1530
|
-
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
|
|
1531
|
-
const meta = {
|
|
1532
|
-
framework: "webpack",
|
|
1533
|
-
webpack: { compiler }
|
|
1534
|
-
};
|
|
1535
|
-
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
1536
|
-
for (const rawPlugin of rawPlugins) {
|
|
1537
|
-
const plugin = Object.assign(rawPlugin, {
|
|
1538
|
-
__unpluginMeta: meta,
|
|
1539
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
1540
|
-
});
|
|
1541
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
1542
|
-
if (plugin.resolveId) {
|
|
1543
|
-
let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
|
|
1544
|
-
if (!vfs) {
|
|
1545
|
-
vfs = new import_lib.default();
|
|
1546
|
-
compiler.options.plugins.push(vfs);
|
|
1547
|
-
}
|
|
1548
|
-
const vfsModules = /* @__PURE__ */ new Set();
|
|
1549
|
-
plugin.__vfsModules = vfsModules;
|
|
1550
|
-
plugin.__vfs = vfs;
|
|
1551
|
-
const resolverPlugin = { apply(resolver) {
|
|
1552
|
-
const target = resolver.ensureHook("resolve");
|
|
1553
|
-
resolver.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
|
|
1554
|
-
if (!request.request) return callback();
|
|
1555
|
-
if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
|
|
1556
|
-
const id = normalizeAbsolutePath(request.request);
|
|
1557
|
-
const requestContext = request.context;
|
|
1558
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
1559
|
-
const isEntry = requestContext.issuer === "";
|
|
1560
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
1561
|
-
const fileDependencies = /* @__PURE__ */ new Set();
|
|
1562
|
-
const context = createBuildContext({
|
|
1563
|
-
addWatchFile(file) {
|
|
1564
|
-
fileDependencies.add(file);
|
|
1565
|
-
resolveContext.fileDependencies?.add(file);
|
|
1566
|
-
},
|
|
1567
|
-
getWatchFiles() {
|
|
1568
|
-
return Array.from(fileDependencies);
|
|
1569
|
-
}
|
|
1570
|
-
}, compiler);
|
|
1571
|
-
let error;
|
|
1572
|
-
const pluginContext = {
|
|
1573
|
-
error(msg) {
|
|
1574
|
-
if (error == null) error = normalizeMessage(msg);
|
|
1575
|
-
else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
|
|
1576
|
-
},
|
|
1577
|
-
warn(msg) {
|
|
1578
|
-
console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
|
|
1579
|
-
}
|
|
1580
|
-
};
|
|
1581
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
1582
|
-
if (!filter(id)) return callback();
|
|
1583
|
-
const resolveIdResult = await handler.call({
|
|
1584
|
-
...context,
|
|
1585
|
-
...pluginContext
|
|
1586
|
-
}, id, importer, { isEntry });
|
|
1587
|
-
if (error != null) return callback(error);
|
|
1588
|
-
if (resolveIdResult == null) return callback();
|
|
1589
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
1590
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
1591
|
-
if (!fs.existsSync(resolved)) {
|
|
1592
|
-
resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
|
|
1593
|
-
if (!vfsModules.has(resolved)) {
|
|
1594
|
-
plugin.__vfs.writeModule(resolved, "");
|
|
1595
|
-
vfsModules.add(resolved);
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
const newRequest = {
|
|
1599
|
-
...request,
|
|
1600
|
-
request: resolved
|
|
1601
|
-
};
|
|
1602
|
-
resolver.doResolve(target, newRequest, null, resolveContext, callback);
|
|
1603
|
-
});
|
|
1604
|
-
} };
|
|
1605
|
-
compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
|
|
1606
|
-
compiler.options.resolve.plugins.push(resolverPlugin);
|
|
1607
|
-
}
|
|
1608
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
1609
|
-
include(id) {
|
|
1610
|
-
return shouldLoad(id, plugin, externalModules);
|
|
1611
|
-
},
|
|
1612
|
-
enforce: plugin.enforce,
|
|
1613
|
-
use: [{
|
|
1614
|
-
loader: LOAD_LOADER,
|
|
1615
|
-
options: { plugin }
|
|
1616
|
-
}],
|
|
1617
|
-
type: "javascript/auto"
|
|
1618
|
-
});
|
|
1619
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
1620
|
-
enforce: plugin.enforce,
|
|
1621
|
-
use(data) {
|
|
1622
|
-
return transformUse(data, plugin, TRANSFORM_LOADER);
|
|
1623
|
-
}
|
|
1624
|
-
});
|
|
1625
|
-
if (plugin.webpack) plugin.webpack(compiler);
|
|
1626
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
1627
|
-
const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
|
|
1628
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
1629
|
-
const promises$1 = [];
|
|
1630
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
1631
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
1632
|
-
await Promise.all(promises$1);
|
|
1633
|
-
}
|
|
1634
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
1635
|
-
});
|
|
1636
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
1637
|
-
await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
|
|
1638
|
-
});
|
|
1639
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
1640
|
-
await plugin.writeBundle();
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
} };
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
function shouldLoad(id, plugin, externalModules) {
|
|
1647
|
-
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
|
1648
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
1649
|
-
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
1650
|
-
if (!filter(id)) return false;
|
|
1651
|
-
return !externalModules.has(id);
|
|
1652
|
-
}
|
|
1653
|
-
function createUnplugin(factory) {
|
|
1654
|
-
return {
|
|
1655
|
-
get esbuild() {
|
|
1656
|
-
return getEsbuildPlugin(factory);
|
|
1657
|
-
},
|
|
1658
|
-
get rollup() {
|
|
1659
|
-
return getRollupPlugin(factory);
|
|
1660
|
-
},
|
|
1661
|
-
get vite() {
|
|
1662
|
-
return getVitePlugin(factory);
|
|
1663
|
-
},
|
|
1664
|
-
get rolldown() {
|
|
1665
|
-
return getRolldownPlugin(factory);
|
|
1666
|
-
},
|
|
1667
|
-
get webpack() {
|
|
1668
|
-
return getWebpackPlugin(factory);
|
|
1669
|
-
},
|
|
1670
|
-
get rspack() {
|
|
1671
|
-
return getRspackPlugin(factory);
|
|
1672
|
-
},
|
|
1673
|
-
get farm() {
|
|
1674
|
-
return getFarmPlugin(factory);
|
|
1675
|
-
},
|
|
1676
|
-
get unloader() {
|
|
1677
|
-
return getUnloaderPlugin(factory);
|
|
1678
|
-
},
|
|
1679
|
-
get raw() {
|
|
1680
|
-
return factory;
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
//#endregion
|
|
1686
|
-
//#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
|
|
1687
|
-
/**
|
|
1688
|
-
* Converts path separators to forward slash.
|
|
1689
|
-
*/
|
|
1690
|
-
function normalizePath(filename) {
|
|
1691
|
-
return filename.replaceAll("\\", "/");
|
|
1692
|
-
}
|
|
1693
|
-
const isArray = Array.isArray;
|
|
1694
|
-
function toArray$1(thing) {
|
|
1695
|
-
if (isArray(thing)) return thing;
|
|
1696
|
-
if (thing == null) return [];
|
|
1697
|
-
return [thing];
|
|
1698
|
-
}
|
|
1699
|
-
const escapeMark = "[_#EsCaPe#_]";
|
|
1700
|
-
function getMatcherString(id, resolutionBase) {
|
|
1701
|
-
if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
|
|
1702
|
-
return join$1(normalizePath(resolve$1(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* Constructs a filter function which can be used to determine whether or not
|
|
1706
|
-
* certain modules should be operated upon.
|
|
1707
|
-
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
|
1708
|
-
* @param exclude ID must not match any of the `exclude` patterns.
|
|
1709
|
-
* @param options Additional options.
|
|
1710
|
-
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
|
1711
|
-
* If a `string` is specified, then the value will be used as the base directory.
|
|
1712
|
-
* Relative paths will be resolved against `process.cwd()` first.
|
|
1713
|
-
* If `false`, then the patterns will not be resolved against any directory.
|
|
1714
|
-
* This can be useful if you want to create a filter for virtual module names.
|
|
1715
|
-
*/
|
|
1716
|
-
function createFilter(include, exclude, options) {
|
|
1717
|
-
const resolutionBase = options && options.resolve;
|
|
1718
|
-
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
|
|
1719
|
-
return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
|
|
1720
|
-
} };
|
|
1721
|
-
const includeMatchers = toArray$1(include).map(getMatcher);
|
|
1722
|
-
const excludeMatchers = toArray$1(exclude).map(getMatcher);
|
|
1723
|
-
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
|
|
1724
|
-
return function result(id) {
|
|
1725
|
-
if (typeof id !== "string") return false;
|
|
1726
|
-
if (id.includes("\0")) return false;
|
|
1727
|
-
const pathId = normalizePath(id);
|
|
1728
|
-
for (const matcher of excludeMatchers) {
|
|
1729
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
1730
|
-
if (matcher.test(pathId)) return false;
|
|
1731
|
-
}
|
|
1732
|
-
for (const matcher of includeMatchers) {
|
|
1733
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
1734
|
-
if (matcher.test(pathId)) return true;
|
|
1735
|
-
}
|
|
1736
|
-
return !includeMatchers.length;
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
//#endregion
|
|
1741
|
-
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
|
|
1742
|
-
var unplugin_exports = /* @__PURE__ */ __exportAll({
|
|
1743
|
-
default: () => unplugin,
|
|
1744
|
-
defaultExcludes: () => defaultExcludes,
|
|
1745
|
-
defaultIncludes: () => defaultIncludes
|
|
1746
|
-
});
|
|
1747
|
-
const defaultIncludes = [
|
|
1748
|
-
/\.[jt]sx?$/,
|
|
1749
|
-
/\.vue$/,
|
|
1750
|
-
/\.vue\?vue/,
|
|
1751
|
-
/\.svelte$/
|
|
1752
|
-
];
|
|
1753
|
-
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
|
|
1754
|
-
function toArray(x) {
|
|
1755
|
-
return x == null ? [] : Array.isArray(x) ? x : [x];
|
|
1756
|
-
}
|
|
1757
|
-
const unplugin = createUnplugin((options = {}) => {
|
|
1758
|
-
const ctx = createUnimport(options);
|
|
1759
|
-
const filter = createFilter(toArray(options.include || []).length ? options.include : defaultIncludes, options.exclude || defaultExcludes);
|
|
1760
|
-
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
|
|
1761
|
-
const { autoImport = true } = options;
|
|
1762
|
-
return {
|
|
1763
|
-
name: "unimport",
|
|
1764
|
-
enforce: "post",
|
|
1765
|
-
transformInclude(id) {
|
|
1766
|
-
return filter(id);
|
|
1767
|
-
},
|
|
1768
|
-
async transform(code, id) {
|
|
1769
|
-
const s = new MagicString(code);
|
|
1770
|
-
await ctx.injectImports(s, id, { autoImport });
|
|
1771
|
-
if (!s.hasChanged()) return;
|
|
1772
|
-
return {
|
|
1773
|
-
code: s.toString(),
|
|
1774
|
-
map: s.generateMap()
|
|
1775
|
-
};
|
|
1776
|
-
},
|
|
1777
|
-
async buildStart() {
|
|
1778
|
-
await ctx.init();
|
|
1779
|
-
if (dts) return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
|
|
1780
|
-
}
|
|
1781
|
-
};
|
|
1782
|
-
});
|
|
1783
|
-
|
|
1784
|
-
//#endregion
|
|
1785
|
-
export { createVirtualImportsAcronWalker as a, traveseScopes as c, unplugin_exports as i, defaultIncludes as n, detectImportsAcorn as o, unplugin as r, detect_acorn_exports as s, defaultExcludes as t };
|
|
9
|
+
export { };
|