@rollipop/rolldown 0.0.0-beta.0 → 0.0.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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/README.md +1 -11
- package/package.json +2 -126
- package/LICENSE +0 -25
- package/bin/cli.mjs +0 -3
- package/dist/cli-setup.d.mts +0 -1
- package/dist/cli-setup.mjs +0 -17
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -1581
- package/dist/config.d.mts +0 -10
- package/dist/config.mjs +0 -14
- package/dist/experimental-index.d.mts +0 -239
- package/dist/experimental-index.mjs +0 -299
- package/dist/experimental-runtime-types.d.ts +0 -92
- package/dist/filter-index.d.mts +0 -4
- package/dist/filter-index.mjs +0 -369
- package/dist/get-log-filter.d.mts +0 -7
- package/dist/get-log-filter.mjs +0 -48
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -38
- package/dist/parallel-plugin-worker.d.mts +0 -1
- package/dist/parallel-plugin-worker.mjs +0 -32
- package/dist/parallel-plugin.d.mts +0 -14
- package/dist/parallel-plugin.mjs +0 -7
- package/dist/parse-ast-index.d.mts +0 -8
- package/dist/parse-ast-index.mjs +0 -4
- package/dist/plugins-index.d.mts +0 -31
- package/dist/plugins-index.mjs +0 -40
- package/dist/shared/binding-DmMMxMk0.mjs +0 -584
- package/dist/shared/binding-kAegJ1Bj.d.mts +0 -1775
- package/dist/shared/bindingify-input-options-D0BAGfk2.mjs +0 -1622
- package/dist/shared/constructors-F44lhsH3.d.mts +0 -30
- package/dist/shared/constructors-Rl_oLd2F.mjs +0 -67
- package/dist/shared/define-config-BF4P-Pum.mjs +0 -7
- package/dist/shared/define-config-DJ1-iIdx.d.mts +0 -2562
- package/dist/shared/load-config-BEpugZky.mjs +0 -114
- package/dist/shared/logging-DsnCZi19.d.mts +0 -42
- package/dist/shared/logs-cyjC0SDv.mjs +0 -183
- package/dist/shared/misc-DpjTMcQQ.mjs +0 -22
- package/dist/shared/normalize-string-or-regex-DbTZ9prS.mjs +0 -670
- package/dist/shared/parse-ast-index-BuuhACPk.mjs +0 -99
- package/dist/shared/prompt-5sWCM0jm.mjs +0 -847
- package/dist/shared/rolldown-build-viDZfkdI.mjs +0 -2292
- package/dist/shared/rolldown-il0-nWH9.mjs +0 -11
- package/dist/shared/watch-BSdMzY6q.mjs +0 -352
|
@@ -1,1622 +0,0 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-DmMMxMk0.mjs";
|
|
2
|
-
import { c as logPluginError, n as error, r as logCycleLoading, t as augmentCodeLocation } from "./logs-cyjC0SDv.mjs";
|
|
3
|
-
import { a as unreachable, o as unsupported, t as arraify } from "./misc-DpjTMcQQ.mjs";
|
|
4
|
-
import { E as LOG_LEVEL_WARN, S as normalizeLog, _ as PlainObjectLike, a as bindingifyManifestPlugin, c as collectChangedBundle, d as bindingifySourcemap, f as transformRenderedChunk, g as lazyProp, i as bindingifyCSSPostPlugin, l as transformToOutputBundle, m as bindingAssetSource, n as BuiltinPlugin, o as bindingifyViteHtmlPlugin, p as __decorate, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex, v as MinimalPluginContextImpl } from "./normalize-string-or-regex-DbTZ9prS.mjs";
|
|
5
|
-
import { t as parseAst } from "./parse-ast-index-BuuhACPk.mjs";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import * as filter from "@rollipop/rolldown-pluginutils";
|
|
8
|
-
import fsp from "node:fs/promises";
|
|
9
|
-
|
|
10
|
-
//#region src/utils/normalize-hook.ts
|
|
11
|
-
function normalizeHook(hook) {
|
|
12
|
-
if (typeof hook === "function" || typeof hook === "string") return {
|
|
13
|
-
handler: hook,
|
|
14
|
-
options: {},
|
|
15
|
-
meta: {}
|
|
16
|
-
};
|
|
17
|
-
if (typeof hook === "object" && hook !== null) {
|
|
18
|
-
const { handler, order, ...options } = hook;
|
|
19
|
-
return {
|
|
20
|
-
handler,
|
|
21
|
-
options,
|
|
22
|
-
meta: { order }
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
unreachable("Invalid hook type");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/utils/error.ts
|
|
30
|
-
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
31
|
-
function unwrapBindingResult(container) {
|
|
32
|
-
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
|
|
33
|
-
return container;
|
|
34
|
-
}
|
|
35
|
-
function normalizeBindingResult(container) {
|
|
36
|
-
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
|
|
37
|
-
return container;
|
|
38
|
-
}
|
|
39
|
-
function normalizeBindingError(e$1) {
|
|
40
|
-
return e$1.type === "JsError" ? e$1.field0 : Object.assign(/* @__PURE__ */ new Error(), {
|
|
41
|
-
code: e$1.field0.kind,
|
|
42
|
-
kind: e$1.field0.kind,
|
|
43
|
-
message: e$1.field0.message,
|
|
44
|
-
id: e$1.field0.id,
|
|
45
|
-
exporter: e$1.field0.exporter,
|
|
46
|
-
loc: e$1.field0.loc,
|
|
47
|
-
pos: e$1.field0.pos,
|
|
48
|
-
stack: void 0
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function aggregateBindingErrorsIntoJsError(rawErrors) {
|
|
52
|
-
const errors = rawErrors.map(normalizeBindingError);
|
|
53
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
54
|
-
for (let i = 0; i < errors.length; i++) {
|
|
55
|
-
summary += "\n";
|
|
56
|
-
if (i >= 5) {
|
|
57
|
-
summary += "...";
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
summary += getErrorMessage(errors[i]);
|
|
61
|
-
}
|
|
62
|
-
const wrapper = new Error(summary);
|
|
63
|
-
Object.defineProperty(wrapper, "errors", {
|
|
64
|
-
configurable: true,
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: () => errors,
|
|
67
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
68
|
-
configurable: true,
|
|
69
|
-
enumerable: true,
|
|
70
|
-
value
|
|
71
|
-
})
|
|
72
|
-
});
|
|
73
|
-
return wrapper;
|
|
74
|
-
}
|
|
75
|
-
function getErrorMessage(e$1) {
|
|
76
|
-
if (Object.hasOwn(e$1, "kind")) return e$1.message;
|
|
77
|
-
let s = "";
|
|
78
|
-
if (e$1.plugin) s += `[plugin ${e$1.plugin}]`;
|
|
79
|
-
const id = e$1.id ?? e$1.loc?.file;
|
|
80
|
-
if (id) {
|
|
81
|
-
s += " " + id;
|
|
82
|
-
if (e$1.loc) s += `:${e$1.loc.line}:${e$1.loc.column}`;
|
|
83
|
-
}
|
|
84
|
-
if (s) s += "\n";
|
|
85
|
-
const message = `${e$1.name ?? "Error"}: ${e$1.message}`;
|
|
86
|
-
s += message;
|
|
87
|
-
if (e$1.frame) s = joinNewLine(s, e$1.frame);
|
|
88
|
-
if (e$1.stack) s = joinNewLine(s, e$1.stack.replace(message, ""));
|
|
89
|
-
if (e$1.cause) {
|
|
90
|
-
s = joinNewLine(s, "Caused by:");
|
|
91
|
-
s = joinNewLine(s, getErrorMessage(e$1.cause).split("\n").map((line) => " " + line).join("\n"));
|
|
92
|
-
}
|
|
93
|
-
return s;
|
|
94
|
-
}
|
|
95
|
-
function joinNewLine(s1, s2) {
|
|
96
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/utils/transform-module-info.ts
|
|
101
|
-
function transformModuleInfo(info, option) {
|
|
102
|
-
return {
|
|
103
|
-
get ast() {
|
|
104
|
-
return unsupported("ModuleInfo#ast");
|
|
105
|
-
},
|
|
106
|
-
get code() {
|
|
107
|
-
return info.code;
|
|
108
|
-
},
|
|
109
|
-
id: info.id,
|
|
110
|
-
importers: info.importers,
|
|
111
|
-
dynamicImporters: info.dynamicImporters,
|
|
112
|
-
importedIds: info.importedIds,
|
|
113
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
114
|
-
exports: info.exports,
|
|
115
|
-
isEntry: info.isEntry,
|
|
116
|
-
...option
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/utils/transform-sourcemap.ts
|
|
122
|
-
function isEmptySourcemapFiled(array) {
|
|
123
|
-
if (!array) return true;
|
|
124
|
-
if (array.length === 0 || !array[0]) return true;
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
128
|
-
if (!rawMap) return;
|
|
129
|
-
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
130
|
-
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
131
|
-
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
132
|
-
return map;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.1/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
137
|
-
function e(e, t$2, n$1) {
|
|
138
|
-
let r = (n$2) => e(n$2, ...t$2);
|
|
139
|
-
return n$1 === void 0 ? r : Object.assign(r, {
|
|
140
|
-
lazy: n$1,
|
|
141
|
-
lazyArgs: t$2
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.1/node_modules/remeda/dist/purry-GjwKKIlp.js
|
|
147
|
-
function t$1(t$2, n$1, r) {
|
|
148
|
-
let i = t$2.length - n$1.length;
|
|
149
|
-
if (i === 0) return t$2(...n$1);
|
|
150
|
-
if (i === 1) return e(t$2, n$1, r);
|
|
151
|
-
throw Error(`Wrong number of arguments`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.1/node_modules/remeda/dist/partition.js
|
|
156
|
-
function t(...t) {
|
|
157
|
-
return t$1(n, t);
|
|
158
|
-
}
|
|
159
|
-
const n = (e$1, t) => {
|
|
160
|
-
let n = [[], []];
|
|
161
|
-
for (let [r, i] of e$1.entries()) t(i, r, e$1) ? n[0].push(i) : n[1].push(i);
|
|
162
|
-
return n;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/plugin/bindingify-hook-filter.ts
|
|
167
|
-
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
168
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [filter.include(generateAtomMatcher(stringKind, matcher))];
|
|
169
|
-
if (Array.isArray(matcher)) return matcher.map((m) => filter.include(generateAtomMatcher(stringKind, m)));
|
|
170
|
-
let ret = [];
|
|
171
|
-
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => filter.exclude(generateAtomMatcher(stringKind, m))));
|
|
172
|
-
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => filter.include(generateAtomMatcher(stringKind, m))));
|
|
173
|
-
return ret;
|
|
174
|
-
}
|
|
175
|
-
function generateAtomMatcher(kind, matcher) {
|
|
176
|
-
return kind === "code" ? filter.code(matcher) : filter.id(matcher);
|
|
177
|
-
}
|
|
178
|
-
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
179
|
-
if (!filterOption) return;
|
|
180
|
-
if (Array.isArray(filterOption)) return filterOption;
|
|
181
|
-
const { id, code, moduleType } = filterOption;
|
|
182
|
-
let ret = [];
|
|
183
|
-
let idIncludes = [];
|
|
184
|
-
let idExcludes = [];
|
|
185
|
-
let codeIncludes = [];
|
|
186
|
-
let codeExcludes = [];
|
|
187
|
-
if (id) [idIncludes, idExcludes] = t(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
|
|
188
|
-
if (code) [codeIncludes, codeExcludes] = t(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
|
|
189
|
-
ret.push(...idExcludes);
|
|
190
|
-
ret.push(...codeExcludes);
|
|
191
|
-
let andExprList = [];
|
|
192
|
-
if (moduleType) {
|
|
193
|
-
let moduleTypes = Array.isArray(moduleType) ? moduleType : moduleType.include ?? [];
|
|
194
|
-
andExprList.push(filter.or(...moduleTypes.map((m) => filter.moduleType(m))));
|
|
195
|
-
}
|
|
196
|
-
if (idIncludes.length) andExprList.push(filter.or(...idIncludes.map((item) => item.expr)));
|
|
197
|
-
if (codeIncludes.length) andExprList.push(filter.or(...codeIncludes.map((item) => item.expr)));
|
|
198
|
-
if (andExprList.length) ret.push(filter.include(filter.and(...andExprList)));
|
|
199
|
-
return ret;
|
|
200
|
-
}
|
|
201
|
-
function bindingifyGeneralHookFilter(stringKind, pattern) {
|
|
202
|
-
let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
|
|
203
|
-
let ret = [];
|
|
204
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
205
|
-
return ret.length > 0 ? { value: ret } : void 0;
|
|
206
|
-
}
|
|
207
|
-
function bindingifyFilterExpr(expr) {
|
|
208
|
-
let list = [];
|
|
209
|
-
bindingifyFilterExprImpl(expr, list);
|
|
210
|
-
return list;
|
|
211
|
-
}
|
|
212
|
-
function containsImporterId(expr) {
|
|
213
|
-
switch (expr.kind) {
|
|
214
|
-
case "and":
|
|
215
|
-
case "or": return expr.args.some(containsImporterId);
|
|
216
|
-
case "not":
|
|
217
|
-
case "include":
|
|
218
|
-
case "exclude": return containsImporterId(expr.expr);
|
|
219
|
-
case "importerId": return true;
|
|
220
|
-
default: return false;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function assertNoImporterId(filterExprs, hookName) {
|
|
224
|
-
if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
|
|
225
|
-
}
|
|
226
|
-
function bindingifyFilterExprImpl(expr, list) {
|
|
227
|
-
switch (expr.kind) {
|
|
228
|
-
case "and": {
|
|
229
|
-
let args = expr.args;
|
|
230
|
-
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
231
|
-
list.push({
|
|
232
|
-
kind: "And",
|
|
233
|
-
payload: args.length
|
|
234
|
-
});
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case "or": {
|
|
238
|
-
let args = expr.args;
|
|
239
|
-
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
240
|
-
list.push({
|
|
241
|
-
kind: "Or",
|
|
242
|
-
payload: args.length
|
|
243
|
-
});
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
case "not":
|
|
247
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
248
|
-
list.push({ kind: "Not" });
|
|
249
|
-
break;
|
|
250
|
-
case "id":
|
|
251
|
-
list.push({
|
|
252
|
-
kind: "Id",
|
|
253
|
-
payload: expr.pattern
|
|
254
|
-
});
|
|
255
|
-
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
256
|
-
break;
|
|
257
|
-
case "importerId":
|
|
258
|
-
list.push({
|
|
259
|
-
kind: "ImporterId",
|
|
260
|
-
payload: expr.pattern
|
|
261
|
-
});
|
|
262
|
-
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
263
|
-
break;
|
|
264
|
-
case "moduleType":
|
|
265
|
-
list.push({
|
|
266
|
-
kind: "ModuleType",
|
|
267
|
-
payload: expr.pattern
|
|
268
|
-
});
|
|
269
|
-
break;
|
|
270
|
-
case "code":
|
|
271
|
-
list.push({
|
|
272
|
-
kind: "Code",
|
|
273
|
-
payload: expr.pattern
|
|
274
|
-
});
|
|
275
|
-
break;
|
|
276
|
-
case "include":
|
|
277
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
278
|
-
list.push({ kind: "Include" });
|
|
279
|
-
break;
|
|
280
|
-
case "exclude":
|
|
281
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
282
|
-
list.push({ kind: "Exclude" });
|
|
283
|
-
break;
|
|
284
|
-
case "query":
|
|
285
|
-
list.push({
|
|
286
|
-
kind: "QueryKey",
|
|
287
|
-
payload: expr.key
|
|
288
|
-
});
|
|
289
|
-
list.push({
|
|
290
|
-
kind: "QueryValue",
|
|
291
|
-
payload: expr.pattern
|
|
292
|
-
});
|
|
293
|
-
break;
|
|
294
|
-
default: throw new Error(`Unknown filter expression: ${expr}`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function bindingifyResolveIdFilter(filterOption) {
|
|
298
|
-
if (!filterOption) return;
|
|
299
|
-
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
300
|
-
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
301
|
-
}
|
|
302
|
-
function bindingifyLoadFilter(filterOption) {
|
|
303
|
-
if (!filterOption) return;
|
|
304
|
-
if (Array.isArray(filterOption)) {
|
|
305
|
-
assertNoImporterId(filterOption, "load");
|
|
306
|
-
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
307
|
-
}
|
|
308
|
-
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
309
|
-
}
|
|
310
|
-
function bindingifyTransformFilter(filterOption) {
|
|
311
|
-
if (!filterOption) return;
|
|
312
|
-
let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
|
|
313
|
-
assertNoImporterId(filterExprs, "transform");
|
|
314
|
-
let ret = [];
|
|
315
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
316
|
-
return { value: ret.length > 0 ? ret : void 0 };
|
|
317
|
-
}
|
|
318
|
-
function bindingifyRenderChunkFilter(filterOption) {
|
|
319
|
-
if (!filterOption) return;
|
|
320
|
-
if (Array.isArray(filterOption)) {
|
|
321
|
-
assertNoImporterId(filterOption, "renderChunk");
|
|
322
|
-
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
323
|
-
}
|
|
324
|
-
return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
329
|
-
function bindingifyPluginHookMeta(options) {
|
|
330
|
-
return { order: bindingPluginOrder(options.order) };
|
|
331
|
-
}
|
|
332
|
-
function bindingPluginOrder(order) {
|
|
333
|
-
switch (order) {
|
|
334
|
-
case "post": return import_binding.BindingPluginOrder.Post;
|
|
335
|
-
case "pre": return import_binding.BindingPluginOrder.Pre;
|
|
336
|
-
case null:
|
|
337
|
-
case void 0: return;
|
|
338
|
-
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/plugin/fs.ts
|
|
344
|
-
const fsModule = {
|
|
345
|
-
appendFile: fsp.appendFile,
|
|
346
|
-
copyFile: fsp.copyFile,
|
|
347
|
-
mkdir: fsp.mkdir,
|
|
348
|
-
mkdtemp: fsp.mkdtemp,
|
|
349
|
-
readdir: fsp.readdir,
|
|
350
|
-
readFile: fsp.readFile,
|
|
351
|
-
realpath: fsp.realpath,
|
|
352
|
-
rename: fsp.rename,
|
|
353
|
-
rmdir: fsp.rmdir,
|
|
354
|
-
stat: fsp.stat,
|
|
355
|
-
lstat: fsp.lstat,
|
|
356
|
-
unlink: fsp.unlink,
|
|
357
|
-
writeFile: fsp.writeFile
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
//#endregion
|
|
361
|
-
//#region src/plugin/plugin-context.ts
|
|
362
|
-
var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
363
|
-
fs = fsModule;
|
|
364
|
-
getModuleInfo;
|
|
365
|
-
constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
|
|
366
|
-
super(onLog, logLevel, plugin.name, watchMode);
|
|
367
|
-
this.outputOptions = outputOptions;
|
|
368
|
-
this.context = context;
|
|
369
|
-
this.data = data;
|
|
370
|
-
this.onLog = onLog;
|
|
371
|
-
this.currentLoadingModule = currentLoadingModule;
|
|
372
|
-
this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
|
|
373
|
-
}
|
|
374
|
-
async load(options) {
|
|
375
|
-
const id = options.id;
|
|
376
|
-
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
377
|
-
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
378
|
-
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
379
|
-
const rawOptions = {
|
|
380
|
-
meta: options.meta || {},
|
|
381
|
-
moduleSideEffects: options.moduleSideEffects || null,
|
|
382
|
-
invalidate: false
|
|
383
|
-
};
|
|
384
|
-
this.data.updateModuleOption(id, rawOptions);
|
|
385
|
-
let loadPromise = this.data.loadModulePromiseMap.get(id);
|
|
386
|
-
if (!loadPromise) {
|
|
387
|
-
loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
|
|
388
|
-
this.data.loadModulePromiseMap.delete(id);
|
|
389
|
-
});
|
|
390
|
-
this.data.loadModulePromiseMap.set(id, loadPromise);
|
|
391
|
-
}
|
|
392
|
-
await loadPromise;
|
|
393
|
-
return this.data.getModuleInfo(id, this.context);
|
|
394
|
-
}
|
|
395
|
-
async resolve(source, importer, options) {
|
|
396
|
-
let receipt = void 0;
|
|
397
|
-
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
398
|
-
const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
|
|
399
|
-
if (key.startsWith("vite:")) (acc ??= {})[key] = value;
|
|
400
|
-
return acc;
|
|
401
|
-
}, void 0);
|
|
402
|
-
const res = await this.context.resolve(source, importer, {
|
|
403
|
-
custom: receipt,
|
|
404
|
-
isEntry: options?.isEntry,
|
|
405
|
-
skipSelf: options?.skipSelf,
|
|
406
|
-
vitePluginCustom
|
|
407
|
-
});
|
|
408
|
-
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
409
|
-
if (res == null) return null;
|
|
410
|
-
const info = this.data.getModuleOption(res.id) || {};
|
|
411
|
-
return {
|
|
412
|
-
...res,
|
|
413
|
-
external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
|
|
414
|
-
...info,
|
|
415
|
-
moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
|
|
416
|
-
packageJsonPath: res.packageJsonPath
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
emitFile = (file) => {
|
|
420
|
-
if (file.type === "prebuilt-chunk") return this.context.emitPrebuiltChunk({
|
|
421
|
-
fileName: file.fileName,
|
|
422
|
-
code: file.code,
|
|
423
|
-
exports: file.exports,
|
|
424
|
-
map: bindingifySourcemap(file.map),
|
|
425
|
-
sourcemapFileName: file.sourcemapFileName
|
|
426
|
-
});
|
|
427
|
-
if (file.type === "chunk") return this.context.emitChunk({
|
|
428
|
-
preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
|
|
429
|
-
...file
|
|
430
|
-
});
|
|
431
|
-
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
|
|
432
|
-
const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
|
|
433
|
-
return this.context.emitFile({
|
|
434
|
-
...file,
|
|
435
|
-
originalFileName: file.originalFileName || void 0,
|
|
436
|
-
source: bindingAssetSource(file.source)
|
|
437
|
-
}, filename, fnSanitizedFileName);
|
|
438
|
-
};
|
|
439
|
-
getAssetFileNames(file) {
|
|
440
|
-
if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
|
|
441
|
-
type: "asset",
|
|
442
|
-
name: file.name,
|
|
443
|
-
names: file.name ? [file.name] : [],
|
|
444
|
-
originalFileName: file.originalFileName,
|
|
445
|
-
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
446
|
-
source: file.source
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
getFileName(referenceId) {
|
|
450
|
-
return this.context.getFileName(referenceId);
|
|
451
|
-
}
|
|
452
|
-
getModuleIds() {
|
|
453
|
-
return this.data.getModuleIds(this.context);
|
|
454
|
-
}
|
|
455
|
-
addWatchFile(id) {
|
|
456
|
-
this.context.addWatchFile(id);
|
|
457
|
-
}
|
|
458
|
-
parse(input, options) {
|
|
459
|
-
return parseAst(input, options);
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/plugin/transform-plugin-context.ts
|
|
465
|
-
var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
466
|
-
constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
|
|
467
|
-
super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
|
|
468
|
-
this.inner = inner;
|
|
469
|
-
this.moduleId = moduleId;
|
|
470
|
-
this.moduleSource = moduleSource;
|
|
471
|
-
const getLogHandler = (handler) => (log, pos) => {
|
|
472
|
-
log = normalizeLog(log);
|
|
473
|
-
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
474
|
-
log.id = moduleId;
|
|
475
|
-
log.hook = "transform";
|
|
476
|
-
handler(log);
|
|
477
|
-
};
|
|
478
|
-
this.debug = getLogHandler(this.debug);
|
|
479
|
-
this.warn = getLogHandler(this.warn);
|
|
480
|
-
this.info = getLogHandler(this.info);
|
|
481
|
-
}
|
|
482
|
-
error(e$1, pos) {
|
|
483
|
-
if (typeof e$1 === "string") e$1 = { message: e$1 };
|
|
484
|
-
if (pos) augmentCodeLocation(e$1, pos, this.moduleSource, this.moduleId);
|
|
485
|
-
e$1.id = this.moduleId;
|
|
486
|
-
e$1.hook = "transform";
|
|
487
|
-
return error(logPluginError(normalizeLog(e$1), this.pluginName));
|
|
488
|
-
}
|
|
489
|
-
getCombinedSourcemap() {
|
|
490
|
-
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
491
|
-
}
|
|
492
|
-
addWatchFile(id) {
|
|
493
|
-
this.inner.addWatchFile(id);
|
|
494
|
-
}
|
|
495
|
-
sendMagicString(s) {
|
|
496
|
-
this.inner.sendMagicString(s);
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
//#endregion
|
|
501
|
-
//#region src/plugin/bindingify-build-hooks.ts
|
|
502
|
-
function bindingifyBuildStart(args) {
|
|
503
|
-
const hook = args.plugin.buildStart;
|
|
504
|
-
if (!hook) return {};
|
|
505
|
-
const { handler, meta } = normalizeHook(hook);
|
|
506
|
-
return {
|
|
507
|
-
plugin: async (ctx, opts) => {
|
|
508
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getInputOptions(opts));
|
|
509
|
-
},
|
|
510
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
function bindingifyBuildEnd(args) {
|
|
514
|
-
const hook = args.plugin.buildEnd;
|
|
515
|
-
if (!hook) return {};
|
|
516
|
-
const { handler, meta } = normalizeHook(hook);
|
|
517
|
-
return {
|
|
518
|
-
plugin: async (ctx, err) => {
|
|
519
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
|
|
520
|
-
},
|
|
521
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
function bindingifyResolveId(args) {
|
|
525
|
-
const hook = args.plugin.resolveId;
|
|
526
|
-
if (!hook) return {};
|
|
527
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
528
|
-
return {
|
|
529
|
-
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
530
|
-
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
531
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0, {
|
|
532
|
-
...extraOptions,
|
|
533
|
-
custom: contextResolveOptions?.custom
|
|
534
|
-
});
|
|
535
|
-
if (ret == null) return;
|
|
536
|
-
if (ret === false) return {
|
|
537
|
-
id: specifier,
|
|
538
|
-
external: true,
|
|
539
|
-
normalizeExternalId: true
|
|
540
|
-
};
|
|
541
|
-
if (typeof ret === "string") return {
|
|
542
|
-
id: ret,
|
|
543
|
-
normalizeExternalId: false
|
|
544
|
-
};
|
|
545
|
-
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
546
|
-
meta: ret.meta || {},
|
|
547
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
548
|
-
invalidate: false
|
|
549
|
-
});
|
|
550
|
-
return {
|
|
551
|
-
id: ret.id,
|
|
552
|
-
external: ret.external,
|
|
553
|
-
normalizeExternalId: false,
|
|
554
|
-
moduleSideEffects: exist.moduleSideEffects ?? void 0,
|
|
555
|
-
packageJsonPath: ret.packageJsonPath
|
|
556
|
-
};
|
|
557
|
-
},
|
|
558
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
559
|
-
filter: bindingifyResolveIdFilter(options.filter)
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
function bindingifyResolveDynamicImport(args) {
|
|
563
|
-
const hook = args.plugin.resolveDynamicImport;
|
|
564
|
-
if (!hook) return {};
|
|
565
|
-
const { handler, meta } = normalizeHook(hook);
|
|
566
|
-
return {
|
|
567
|
-
plugin: async (ctx, specifier, importer) => {
|
|
568
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
|
|
569
|
-
if (ret == null) return;
|
|
570
|
-
if (ret === false) return {
|
|
571
|
-
id: specifier,
|
|
572
|
-
external: true
|
|
573
|
-
};
|
|
574
|
-
if (typeof ret === "string") return { id: ret };
|
|
575
|
-
const result = {
|
|
576
|
-
id: ret.id,
|
|
577
|
-
external: ret.external,
|
|
578
|
-
packageJsonPath: ret.packageJsonPath
|
|
579
|
-
};
|
|
580
|
-
if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
|
|
581
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
582
|
-
meta: ret.meta || {},
|
|
583
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
584
|
-
invalidate: false
|
|
585
|
-
});
|
|
586
|
-
return result;
|
|
587
|
-
},
|
|
588
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
function bindingifyTransform(args) {
|
|
592
|
-
const hook = args.plugin.transform;
|
|
593
|
-
if (!hook) return {};
|
|
594
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
595
|
-
return {
|
|
596
|
-
plugin: async (ctx, code, id, meta$1) => {
|
|
597
|
-
let magicStringInstance, astInstance;
|
|
598
|
-
Object.defineProperties(meta$1, {
|
|
599
|
-
magicString: { get() {
|
|
600
|
-
if (magicStringInstance) return magicStringInstance;
|
|
601
|
-
magicStringInstance = new import_binding.BindingMagicString(code);
|
|
602
|
-
return magicStringInstance;
|
|
603
|
-
} },
|
|
604
|
-
ast: { get() {
|
|
605
|
-
if (astInstance) return astInstance;
|
|
606
|
-
let lang = "js";
|
|
607
|
-
switch (meta$1.moduleType) {
|
|
608
|
-
case "js":
|
|
609
|
-
case "jsx":
|
|
610
|
-
case "ts":
|
|
611
|
-
case "tsx":
|
|
612
|
-
lang = meta$1.moduleType;
|
|
613
|
-
break;
|
|
614
|
-
default: break;
|
|
615
|
-
}
|
|
616
|
-
astInstance = parseAst(code, {
|
|
617
|
-
astType: meta$1.moduleType.includes("ts") ? "ts" : "js",
|
|
618
|
-
lang
|
|
619
|
-
});
|
|
620
|
-
return astInstance;
|
|
621
|
-
} }
|
|
622
|
-
});
|
|
623
|
-
const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode);
|
|
624
|
-
const ret = await handler.call(transformCtx, code, id, meta$1);
|
|
625
|
-
if (ret == null) return;
|
|
626
|
-
if (typeof ret === "string") return { code: ret };
|
|
627
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
628
|
-
meta: ret.meta ?? {},
|
|
629
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
630
|
-
invalidate: false
|
|
631
|
-
});
|
|
632
|
-
let normalizedCode = void 0;
|
|
633
|
-
let map = ret.map;
|
|
634
|
-
if (typeof ret.code === "string") normalizedCode = ret.code;
|
|
635
|
-
else if (ret.code instanceof import_binding.BindingMagicString) {
|
|
636
|
-
let magicString = ret.code;
|
|
637
|
-
normalizedCode = magicString.toString();
|
|
638
|
-
let fallbackSourcemap = ctx.sendMagicString(magicString);
|
|
639
|
-
if (fallbackSourcemap != void 0) map = fallbackSourcemap;
|
|
640
|
-
}
|
|
641
|
-
return {
|
|
642
|
-
code: normalizedCode,
|
|
643
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, map)),
|
|
644
|
-
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
|
|
645
|
-
moduleType: ret.moduleType
|
|
646
|
-
};
|
|
647
|
-
},
|
|
648
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
649
|
-
filter: bindingifyTransformFilter(options.filter)
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
function bindingifyLoad(args) {
|
|
653
|
-
const hook = args.plugin.load;
|
|
654
|
-
if (!hook) return {};
|
|
655
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
656
|
-
return {
|
|
657
|
-
plugin: async (ctx, id) => {
|
|
658
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id), id);
|
|
659
|
-
if (ret == null) return;
|
|
660
|
-
if (typeof ret === "string") return { code: ret };
|
|
661
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
662
|
-
meta: ret.meta || {},
|
|
663
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
664
|
-
invalidate: false
|
|
665
|
-
});
|
|
666
|
-
let map = preProcessSourceMap(ret, id);
|
|
667
|
-
return {
|
|
668
|
-
code: ret.code,
|
|
669
|
-
map: bindingifySourcemap(map),
|
|
670
|
-
moduleType: ret.moduleType,
|
|
671
|
-
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
|
|
672
|
-
};
|
|
673
|
-
},
|
|
674
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
675
|
-
filter: bindingifyLoadFilter(options.filter)
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
function preProcessSourceMap(ret, id) {
|
|
679
|
-
if (!ret.map) return;
|
|
680
|
-
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
681
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
682
|
-
const directory = path.dirname(id) || ".";
|
|
683
|
-
const sourceRoot = map.sourceRoot || ".";
|
|
684
|
-
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
685
|
-
}
|
|
686
|
-
return map;
|
|
687
|
-
}
|
|
688
|
-
function bindingifyModuleParsed(args) {
|
|
689
|
-
const hook = args.plugin.moduleParsed;
|
|
690
|
-
if (!hook) return {};
|
|
691
|
-
const { handler, meta } = normalizeHook(hook);
|
|
692
|
-
return {
|
|
693
|
-
plugin: async (ctx, moduleInfo) => {
|
|
694
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
695
|
-
},
|
|
696
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region src/plugin/bindingify-output-hooks.ts
|
|
702
|
-
function bindingifyRenderStart(args) {
|
|
703
|
-
const hook = args.plugin.renderStart;
|
|
704
|
-
if (!hook) return {};
|
|
705
|
-
const { handler, meta } = normalizeHook(hook);
|
|
706
|
-
return {
|
|
707
|
-
plugin: async (ctx, opts) => {
|
|
708
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
|
|
709
|
-
},
|
|
710
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
function bindingifyRenderChunk(args) {
|
|
714
|
-
const hook = args.plugin.renderChunk;
|
|
715
|
-
if (!hook) return {};
|
|
716
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
717
|
-
return {
|
|
718
|
-
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
719
|
-
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
720
|
-
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getRenderChunkMeta());
|
|
721
|
-
if (ret == null) return;
|
|
722
|
-
if (typeof ret === "string") return { code: ret };
|
|
723
|
-
if (!ret.map) return { code: ret.code };
|
|
724
|
-
return {
|
|
725
|
-
code: ret.code,
|
|
726
|
-
map: bindingifySourcemap(ret.map)
|
|
727
|
-
};
|
|
728
|
-
},
|
|
729
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
730
|
-
filter: bindingifyRenderChunkFilter(options.filter)
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
function bindingifyAugmentChunkHash(args) {
|
|
734
|
-
const hook = args.plugin.augmentChunkHash;
|
|
735
|
-
if (!hook) return {};
|
|
736
|
-
const { handler, meta } = normalizeHook(hook);
|
|
737
|
-
return {
|
|
738
|
-
plugin: async (ctx, chunk) => {
|
|
739
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
740
|
-
},
|
|
741
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
function bindingifyRenderError(args) {
|
|
745
|
-
const hook = args.plugin.renderError;
|
|
746
|
-
if (!hook) return {};
|
|
747
|
-
const { handler, meta } = normalizeHook(hook);
|
|
748
|
-
return {
|
|
749
|
-
plugin: async (ctx, err) => {
|
|
750
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
|
|
751
|
-
},
|
|
752
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
function bindingifyGenerateBundle(args) {
|
|
756
|
-
const hook = args.plugin.generateBundle;
|
|
757
|
-
if (!hook) return {};
|
|
758
|
-
const { handler, meta } = normalizeHook(hook);
|
|
759
|
-
return {
|
|
760
|
-
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
761
|
-
const changed = {
|
|
762
|
-
updated: /* @__PURE__ */ new Set(),
|
|
763
|
-
deleted: /* @__PURE__ */ new Set()
|
|
764
|
-
};
|
|
765
|
-
const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
766
|
-
const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
|
|
767
|
-
await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
768
|
-
return collectChangedBundle(changed, output);
|
|
769
|
-
},
|
|
770
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
function bindingifyWriteBundle(args) {
|
|
774
|
-
const hook = args.plugin.writeBundle;
|
|
775
|
-
if (!hook) return {};
|
|
776
|
-
const { handler, meta } = normalizeHook(hook);
|
|
777
|
-
return {
|
|
778
|
-
plugin: async (ctx, bundle, opts) => {
|
|
779
|
-
const changed = {
|
|
780
|
-
updated: /* @__PURE__ */ new Set(),
|
|
781
|
-
deleted: /* @__PURE__ */ new Set()
|
|
782
|
-
};
|
|
783
|
-
const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
784
|
-
const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
|
|
785
|
-
await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
|
|
786
|
-
return collectChangedBundle(changed, output);
|
|
787
|
-
},
|
|
788
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
function bindingifyCloseBundle(args) {
|
|
792
|
-
const hook = args.plugin.closeBundle;
|
|
793
|
-
if (!hook) return {};
|
|
794
|
-
const { handler, meta } = normalizeHook(hook);
|
|
795
|
-
return {
|
|
796
|
-
plugin: async (ctx, err) => {
|
|
797
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
|
|
798
|
-
},
|
|
799
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function bindingifyBanner(args) {
|
|
803
|
-
const hook = args.plugin.banner;
|
|
804
|
-
if (!hook) return {};
|
|
805
|
-
const { handler, meta } = normalizeHook(hook);
|
|
806
|
-
return {
|
|
807
|
-
plugin: async (ctx, chunk) => {
|
|
808
|
-
if (typeof handler === "string") return handler;
|
|
809
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
810
|
-
},
|
|
811
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
function bindingifyFooter(args) {
|
|
815
|
-
const hook = args.plugin.footer;
|
|
816
|
-
if (!hook) return {};
|
|
817
|
-
const { handler, meta } = normalizeHook(hook);
|
|
818
|
-
return {
|
|
819
|
-
plugin: async (ctx, chunk) => {
|
|
820
|
-
if (typeof handler === "string") return handler;
|
|
821
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
822
|
-
},
|
|
823
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
function bindingifyIntro(args) {
|
|
827
|
-
const hook = args.plugin.intro;
|
|
828
|
-
if (!hook) return {};
|
|
829
|
-
const { handler, meta } = normalizeHook(hook);
|
|
830
|
-
return {
|
|
831
|
-
plugin: async (ctx, chunk) => {
|
|
832
|
-
if (typeof handler === "string") return handler;
|
|
833
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
834
|
-
},
|
|
835
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
function bindingifyOutro(args) {
|
|
839
|
-
const hook = args.plugin.outro;
|
|
840
|
-
if (!hook) return {};
|
|
841
|
-
const { handler, meta } = normalizeHook(hook);
|
|
842
|
-
return {
|
|
843
|
-
plugin: async (ctx, chunk) => {
|
|
844
|
-
if (typeof handler === "string") return handler;
|
|
845
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
846
|
-
},
|
|
847
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
//#endregion
|
|
852
|
-
//#region src/plugin/bindingify-watch-hooks.ts
|
|
853
|
-
function bindingifyWatchChange(args) {
|
|
854
|
-
const hook = args.plugin.watchChange;
|
|
855
|
-
if (!hook) return {};
|
|
856
|
-
const { handler, meta } = normalizeHook(hook);
|
|
857
|
-
return {
|
|
858
|
-
plugin: async (ctx, id, event) => {
|
|
859
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
|
|
860
|
-
},
|
|
861
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
function bindingifyCloseWatcher(args) {
|
|
865
|
-
const hook = args.plugin.closeWatcher;
|
|
866
|
-
if (!hook) return {};
|
|
867
|
-
const { handler, meta } = normalizeHook(hook);
|
|
868
|
-
return {
|
|
869
|
-
plugin: async (ctx) => {
|
|
870
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
871
|
-
},
|
|
872
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region src/plugin/generated/hook-usage.ts
|
|
878
|
-
let HookUsageKind = /* @__PURE__ */ function(HookUsageKind) {
|
|
879
|
-
HookUsageKind[HookUsageKind["buildStart"] = 1] = "buildStart";
|
|
880
|
-
HookUsageKind[HookUsageKind["resolveId"] = 2] = "resolveId";
|
|
881
|
-
HookUsageKind[HookUsageKind["resolveDynamicImport"] = 4] = "resolveDynamicImport";
|
|
882
|
-
HookUsageKind[HookUsageKind["load"] = 8] = "load";
|
|
883
|
-
HookUsageKind[HookUsageKind["transform"] = 16] = "transform";
|
|
884
|
-
HookUsageKind[HookUsageKind["moduleParsed"] = 32] = "moduleParsed";
|
|
885
|
-
HookUsageKind[HookUsageKind["buildEnd"] = 64] = "buildEnd";
|
|
886
|
-
HookUsageKind[HookUsageKind["renderStart"] = 128] = "renderStart";
|
|
887
|
-
HookUsageKind[HookUsageKind["renderError"] = 256] = "renderError";
|
|
888
|
-
HookUsageKind[HookUsageKind["renderChunk"] = 512] = "renderChunk";
|
|
889
|
-
HookUsageKind[HookUsageKind["augmentChunkHash"] = 1024] = "augmentChunkHash";
|
|
890
|
-
HookUsageKind[HookUsageKind["generateBundle"] = 2048] = "generateBundle";
|
|
891
|
-
HookUsageKind[HookUsageKind["writeBundle"] = 4096] = "writeBundle";
|
|
892
|
-
HookUsageKind[HookUsageKind["closeBundle"] = 8192] = "closeBundle";
|
|
893
|
-
HookUsageKind[HookUsageKind["watchChange"] = 16384] = "watchChange";
|
|
894
|
-
HookUsageKind[HookUsageKind["closeWatcher"] = 32768] = "closeWatcher";
|
|
895
|
-
HookUsageKind[HookUsageKind["transformAst"] = 65536] = "transformAst";
|
|
896
|
-
HookUsageKind[HookUsageKind["banner"] = 131072] = "banner";
|
|
897
|
-
HookUsageKind[HookUsageKind["footer"] = 262144] = "footer";
|
|
898
|
-
HookUsageKind[HookUsageKind["intro"] = 524288] = "intro";
|
|
899
|
-
HookUsageKind[HookUsageKind["outro"] = 1048576] = "outro";
|
|
900
|
-
return HookUsageKind;
|
|
901
|
-
}({});
|
|
902
|
-
var HookUsage = class {
|
|
903
|
-
bitflag = BigInt(0);
|
|
904
|
-
constructor() {}
|
|
905
|
-
union(kind) {
|
|
906
|
-
this.bitflag |= BigInt(kind);
|
|
907
|
-
}
|
|
908
|
-
inner() {
|
|
909
|
-
return Number(this.bitflag);
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
function extractHookUsage(plugin) {
|
|
913
|
-
let hookUsage = new HookUsage();
|
|
914
|
-
if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
|
|
915
|
-
if (plugin.resolveId) hookUsage.union(HookUsageKind.resolveId);
|
|
916
|
-
if (plugin.resolveDynamicImport) hookUsage.union(HookUsageKind.resolveDynamicImport);
|
|
917
|
-
if (plugin.load) hookUsage.union(HookUsageKind.load);
|
|
918
|
-
if (plugin.transform) hookUsage.union(HookUsageKind.transform);
|
|
919
|
-
if (plugin.moduleParsed) hookUsage.union(HookUsageKind.moduleParsed);
|
|
920
|
-
if (plugin.buildEnd) hookUsage.union(HookUsageKind.buildEnd);
|
|
921
|
-
if (plugin.renderStart) hookUsage.union(HookUsageKind.renderStart);
|
|
922
|
-
if (plugin.renderError) hookUsage.union(HookUsageKind.renderError);
|
|
923
|
-
if (plugin.renderChunk) hookUsage.union(HookUsageKind.renderChunk);
|
|
924
|
-
if (plugin.augmentChunkHash) hookUsage.union(HookUsageKind.augmentChunkHash);
|
|
925
|
-
if (plugin.generateBundle) hookUsage.union(HookUsageKind.generateBundle);
|
|
926
|
-
if (plugin.writeBundle) hookUsage.union(HookUsageKind.writeBundle);
|
|
927
|
-
if (plugin.closeBundle) hookUsage.union(HookUsageKind.closeBundle);
|
|
928
|
-
if (plugin.watchChange) hookUsage.union(HookUsageKind.watchChange);
|
|
929
|
-
if (plugin.closeWatcher) hookUsage.union(HookUsageKind.closeWatcher);
|
|
930
|
-
if (plugin.banner) hookUsage.union(HookUsageKind.banner);
|
|
931
|
-
if (plugin.footer) hookUsage.union(HookUsageKind.footer);
|
|
932
|
-
if (plugin.intro) hookUsage.union(HookUsageKind.intro);
|
|
933
|
-
if (plugin.outro) hookUsage.union(HookUsageKind.outro);
|
|
934
|
-
return hookUsage;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
//#endregion
|
|
938
|
-
//#region src/plugin/bindingify-plugin.ts
|
|
939
|
-
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
940
|
-
const args = {
|
|
941
|
-
plugin,
|
|
942
|
-
options,
|
|
943
|
-
outputOptions,
|
|
944
|
-
pluginContextData,
|
|
945
|
-
onLog,
|
|
946
|
-
logLevel,
|
|
947
|
-
watchMode,
|
|
948
|
-
normalizedOutputPlugins
|
|
949
|
-
};
|
|
950
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
951
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
952
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
953
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
954
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
955
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
956
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
957
|
-
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
|
|
958
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
959
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
960
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
961
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
962
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
963
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
964
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
965
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
966
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
967
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
968
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
969
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
970
|
-
let hookUsage = extractHookUsage(plugin).inner();
|
|
971
|
-
return wrapHandlers({
|
|
972
|
-
name: plugin.name,
|
|
973
|
-
buildStart,
|
|
974
|
-
buildStartMeta,
|
|
975
|
-
resolveId,
|
|
976
|
-
resolveIdMeta,
|
|
977
|
-
resolveIdFilter,
|
|
978
|
-
resolveDynamicImport,
|
|
979
|
-
resolveDynamicImportMeta,
|
|
980
|
-
buildEnd,
|
|
981
|
-
buildEndMeta,
|
|
982
|
-
transform,
|
|
983
|
-
transformMeta,
|
|
984
|
-
transformFilter,
|
|
985
|
-
moduleParsed,
|
|
986
|
-
moduleParsedMeta,
|
|
987
|
-
load,
|
|
988
|
-
loadMeta,
|
|
989
|
-
loadFilter,
|
|
990
|
-
renderChunk,
|
|
991
|
-
renderChunkMeta,
|
|
992
|
-
renderChunkFilter,
|
|
993
|
-
augmentChunkHash,
|
|
994
|
-
augmentChunkHashMeta,
|
|
995
|
-
renderStart,
|
|
996
|
-
renderStartMeta,
|
|
997
|
-
renderError,
|
|
998
|
-
renderErrorMeta,
|
|
999
|
-
generateBundle,
|
|
1000
|
-
generateBundleMeta,
|
|
1001
|
-
writeBundle,
|
|
1002
|
-
writeBundleMeta,
|
|
1003
|
-
closeBundle,
|
|
1004
|
-
closeBundleMeta,
|
|
1005
|
-
banner,
|
|
1006
|
-
bannerMeta,
|
|
1007
|
-
footer,
|
|
1008
|
-
footerMeta,
|
|
1009
|
-
intro,
|
|
1010
|
-
introMeta,
|
|
1011
|
-
outro,
|
|
1012
|
-
outroMeta,
|
|
1013
|
-
watchChange,
|
|
1014
|
-
watchChangeMeta,
|
|
1015
|
-
closeWatcher,
|
|
1016
|
-
closeWatcherMeta,
|
|
1017
|
-
hookUsage
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
function wrapHandlers(plugin) {
|
|
1021
|
-
for (const hookName of [
|
|
1022
|
-
"buildStart",
|
|
1023
|
-
"resolveId",
|
|
1024
|
-
"resolveDynamicImport",
|
|
1025
|
-
"buildEnd",
|
|
1026
|
-
"transform",
|
|
1027
|
-
"moduleParsed",
|
|
1028
|
-
"load",
|
|
1029
|
-
"renderChunk",
|
|
1030
|
-
"augmentChunkHash",
|
|
1031
|
-
"renderStart",
|
|
1032
|
-
"renderError",
|
|
1033
|
-
"generateBundle",
|
|
1034
|
-
"writeBundle",
|
|
1035
|
-
"closeBundle",
|
|
1036
|
-
"banner",
|
|
1037
|
-
"footer",
|
|
1038
|
-
"intro",
|
|
1039
|
-
"outro",
|
|
1040
|
-
"watchChange",
|
|
1041
|
-
"closeWatcher"
|
|
1042
|
-
]) {
|
|
1043
|
-
const handler = plugin[hookName];
|
|
1044
|
-
if (handler) plugin[hookName] = async (...args) => {
|
|
1045
|
-
try {
|
|
1046
|
-
return await handler(...args);
|
|
1047
|
-
} catch (e$1) {
|
|
1048
|
-
return error(logPluginError(e$1, plugin.name, {
|
|
1049
|
-
hook: hookName,
|
|
1050
|
-
id: hookName === "transform" ? args[2] : void 0
|
|
1051
|
-
}));
|
|
1052
|
-
}
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
return plugin;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region src/options/normalized-input-options.ts
|
|
1060
|
-
var NormalizedInputOptionsImpl = class extends PlainObjectLike {
|
|
1061
|
-
inner;
|
|
1062
|
-
constructor(inner, onLog) {
|
|
1063
|
-
super();
|
|
1064
|
-
this.onLog = onLog;
|
|
1065
|
-
this.inner = inner;
|
|
1066
|
-
}
|
|
1067
|
-
get shimMissingExports() {
|
|
1068
|
-
return this.inner.shimMissingExports;
|
|
1069
|
-
}
|
|
1070
|
-
get input() {
|
|
1071
|
-
return this.inner.input;
|
|
1072
|
-
}
|
|
1073
|
-
get cwd() {
|
|
1074
|
-
return this.inner.cwd;
|
|
1075
|
-
}
|
|
1076
|
-
get platform() {
|
|
1077
|
-
return this.inner.platform;
|
|
1078
|
-
}
|
|
1079
|
-
get context() {
|
|
1080
|
-
return this.inner.context;
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
|
|
1084
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
|
|
1085
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
|
|
1086
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
|
|
1087
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
|
|
1088
|
-
|
|
1089
|
-
//#endregion
|
|
1090
|
-
//#region src/options/normalized-output-options.ts
|
|
1091
|
-
var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
|
|
1092
|
-
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
1093
|
-
super();
|
|
1094
|
-
this.inner = inner;
|
|
1095
|
-
this.outputOptions = outputOptions;
|
|
1096
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
1097
|
-
}
|
|
1098
|
-
get dir() {
|
|
1099
|
-
return this.inner.dir ?? void 0;
|
|
1100
|
-
}
|
|
1101
|
-
get entryFileNames() {
|
|
1102
|
-
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
1103
|
-
}
|
|
1104
|
-
get chunkFileNames() {
|
|
1105
|
-
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
1106
|
-
}
|
|
1107
|
-
get assetFileNames() {
|
|
1108
|
-
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
1109
|
-
}
|
|
1110
|
-
get format() {
|
|
1111
|
-
return this.inner.format;
|
|
1112
|
-
}
|
|
1113
|
-
get exports() {
|
|
1114
|
-
return this.inner.exports;
|
|
1115
|
-
}
|
|
1116
|
-
get sourcemap() {
|
|
1117
|
-
return this.inner.sourcemap;
|
|
1118
|
-
}
|
|
1119
|
-
get sourcemapBaseUrl() {
|
|
1120
|
-
return this.inner.sourcemapBaseUrl ?? void 0;
|
|
1121
|
-
}
|
|
1122
|
-
get cssEntryFileNames() {
|
|
1123
|
-
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
1124
|
-
}
|
|
1125
|
-
get cssChunkFileNames() {
|
|
1126
|
-
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
1127
|
-
}
|
|
1128
|
-
get shimMissingExports() {
|
|
1129
|
-
return this.inner.shimMissingExports;
|
|
1130
|
-
}
|
|
1131
|
-
get name() {
|
|
1132
|
-
return this.inner.name ?? void 0;
|
|
1133
|
-
}
|
|
1134
|
-
get file() {
|
|
1135
|
-
return this.inner.file ?? void 0;
|
|
1136
|
-
}
|
|
1137
|
-
get inlineDynamicImports() {
|
|
1138
|
-
return this.inner.inlineDynamicImports;
|
|
1139
|
-
}
|
|
1140
|
-
get dynamicImportInCjs() {
|
|
1141
|
-
return this.inner.dynamicImportInCjs;
|
|
1142
|
-
}
|
|
1143
|
-
get externalLiveBindings() {
|
|
1144
|
-
return this.inner.externalLiveBindings;
|
|
1145
|
-
}
|
|
1146
|
-
get banner() {
|
|
1147
|
-
return normalizeAddon(this.outputOptions.banner);
|
|
1148
|
-
}
|
|
1149
|
-
get footer() {
|
|
1150
|
-
return normalizeAddon(this.outputOptions.footer);
|
|
1151
|
-
}
|
|
1152
|
-
get postBanner() {
|
|
1153
|
-
return normalizeAddon(this.outputOptions.postBanner);
|
|
1154
|
-
}
|
|
1155
|
-
get postFooter() {
|
|
1156
|
-
return normalizeAddon(this.outputOptions.postFooter);
|
|
1157
|
-
}
|
|
1158
|
-
get intro() {
|
|
1159
|
-
return normalizeAddon(this.outputOptions.intro);
|
|
1160
|
-
}
|
|
1161
|
-
get outro() {
|
|
1162
|
-
return normalizeAddon(this.outputOptions.outro);
|
|
1163
|
-
}
|
|
1164
|
-
get esModule() {
|
|
1165
|
-
return this.inner.esModule;
|
|
1166
|
-
}
|
|
1167
|
-
get extend() {
|
|
1168
|
-
return this.inner.extend;
|
|
1169
|
-
}
|
|
1170
|
-
get globals() {
|
|
1171
|
-
return this.inner.globals || this.outputOptions.globals;
|
|
1172
|
-
}
|
|
1173
|
-
get paths() {
|
|
1174
|
-
return this.outputOptions.paths;
|
|
1175
|
-
}
|
|
1176
|
-
get hashCharacters() {
|
|
1177
|
-
return this.inner.hashCharacters;
|
|
1178
|
-
}
|
|
1179
|
-
get sourcemapDebugIds() {
|
|
1180
|
-
return this.inner.sourcemapDebugIds;
|
|
1181
|
-
}
|
|
1182
|
-
get sourcemapIgnoreList() {
|
|
1183
|
-
return this.outputOptions.sourcemapIgnoreList;
|
|
1184
|
-
}
|
|
1185
|
-
get sourcemapPathTransform() {
|
|
1186
|
-
return this.outputOptions.sourcemapPathTransform;
|
|
1187
|
-
}
|
|
1188
|
-
get minify() {
|
|
1189
|
-
let ret = this.inner.minify;
|
|
1190
|
-
if (typeof ret === "object" && ret !== null) {
|
|
1191
|
-
delete ret["codegen"];
|
|
1192
|
-
delete ret["module"];
|
|
1193
|
-
delete ret["sourcemap"];
|
|
1194
|
-
}
|
|
1195
|
-
return ret;
|
|
1196
|
-
}
|
|
1197
|
-
get legalComments() {
|
|
1198
|
-
return this.inner.legalComments;
|
|
1199
|
-
}
|
|
1200
|
-
get polyfillRequire() {
|
|
1201
|
-
return this.inner.polyfillRequire;
|
|
1202
|
-
}
|
|
1203
|
-
get plugins() {
|
|
1204
|
-
return this.normalizedOutputPlugins;
|
|
1205
|
-
}
|
|
1206
|
-
get preserveModules() {
|
|
1207
|
-
return this.inner.preserveModules;
|
|
1208
|
-
}
|
|
1209
|
-
get preserveModulesRoot() {
|
|
1210
|
-
return this.inner.preserveModulesRoot;
|
|
1211
|
-
}
|
|
1212
|
-
get virtualDirname() {
|
|
1213
|
-
return this.inner.virtualDirname;
|
|
1214
|
-
}
|
|
1215
|
-
get topLevelVar() {
|
|
1216
|
-
return this.inner.topLevelVar ?? false;
|
|
1217
|
-
}
|
|
1218
|
-
get minifyInternalExports() {
|
|
1219
|
-
return this.inner.minifyInternalExports ?? false;
|
|
1220
|
-
}
|
|
1221
|
-
};
|
|
1222
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
|
|
1223
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
|
|
1224
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
|
|
1225
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
|
|
1226
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
|
|
1227
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
|
|
1228
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
|
|
1229
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
|
|
1230
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssEntryFileNames", null);
|
|
1231
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssChunkFileNames", null);
|
|
1232
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
|
|
1233
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
|
|
1234
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
|
|
1235
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
|
|
1236
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dynamicImportInCjs", null);
|
|
1237
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
|
|
1238
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
|
|
1239
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
|
|
1240
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postBanner", null);
|
|
1241
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postFooter", null);
|
|
1242
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
|
|
1243
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
|
|
1244
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
|
|
1245
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
|
|
1246
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
|
|
1247
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
|
|
1248
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
|
|
1249
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
|
|
1250
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
|
|
1251
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
|
|
1252
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
|
|
1253
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
|
|
1254
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
|
|
1255
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
|
|
1256
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
|
|
1257
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
|
|
1258
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
|
|
1259
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
|
|
1260
|
-
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
|
|
1261
|
-
function normalizeAddon(value) {
|
|
1262
|
-
if (typeof value === "function") return value;
|
|
1263
|
-
return () => value || "";
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
//#endregion
|
|
1267
|
-
//#region src/plugin/plugin-context-data.ts
|
|
1268
|
-
var PluginContextData = class {
|
|
1269
|
-
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
1270
|
-
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
1271
|
-
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
1272
|
-
renderedChunkMeta = null;
|
|
1273
|
-
normalizedInputOptions = null;
|
|
1274
|
-
normalizedOutputOptions = null;
|
|
1275
|
-
constructor(onLog, outputOptions, normalizedOutputPlugins) {
|
|
1276
|
-
this.onLog = onLog;
|
|
1277
|
-
this.outputOptions = outputOptions;
|
|
1278
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
1279
|
-
}
|
|
1280
|
-
updateModuleOption(id, option) {
|
|
1281
|
-
const existing = this.moduleOptionMap.get(id);
|
|
1282
|
-
if (existing) {
|
|
1283
|
-
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
1284
|
-
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
1285
|
-
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
1286
|
-
} else {
|
|
1287
|
-
this.moduleOptionMap.set(id, option);
|
|
1288
|
-
return option;
|
|
1289
|
-
}
|
|
1290
|
-
return existing;
|
|
1291
|
-
}
|
|
1292
|
-
getModuleOption(id) {
|
|
1293
|
-
const option = this.moduleOptionMap.get(id);
|
|
1294
|
-
if (!option) {
|
|
1295
|
-
const raw = {
|
|
1296
|
-
moduleSideEffects: null,
|
|
1297
|
-
meta: {}
|
|
1298
|
-
};
|
|
1299
|
-
this.moduleOptionMap.set(id, raw);
|
|
1300
|
-
return raw;
|
|
1301
|
-
}
|
|
1302
|
-
return option;
|
|
1303
|
-
}
|
|
1304
|
-
getModuleInfo(id, context) {
|
|
1305
|
-
const bindingInfo = context.getModuleInfo(id);
|
|
1306
|
-
if (bindingInfo) {
|
|
1307
|
-
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
1308
|
-
return this.proxyModuleInfo(id, info);
|
|
1309
|
-
}
|
|
1310
|
-
return null;
|
|
1311
|
-
}
|
|
1312
|
-
proxyModuleInfo(id, info) {
|
|
1313
|
-
let moduleSideEffects = info.moduleSideEffects;
|
|
1314
|
-
Object.defineProperty(info, "moduleSideEffects", {
|
|
1315
|
-
get() {
|
|
1316
|
-
return moduleSideEffects;
|
|
1317
|
-
},
|
|
1318
|
-
set: (v) => {
|
|
1319
|
-
this.updateModuleOption(id, {
|
|
1320
|
-
moduleSideEffects: v,
|
|
1321
|
-
meta: info.meta,
|
|
1322
|
-
invalidate: true
|
|
1323
|
-
});
|
|
1324
|
-
moduleSideEffects = v;
|
|
1325
|
-
}
|
|
1326
|
-
});
|
|
1327
|
-
return info;
|
|
1328
|
-
}
|
|
1329
|
-
getModuleIds(context) {
|
|
1330
|
-
return context.getModuleIds().values();
|
|
1331
|
-
}
|
|
1332
|
-
saveResolveOptions(options) {
|
|
1333
|
-
const index = this.resolveOptionsMap.size;
|
|
1334
|
-
this.resolveOptionsMap.set(index, options);
|
|
1335
|
-
return index;
|
|
1336
|
-
}
|
|
1337
|
-
getSavedResolveOptions(receipt) {
|
|
1338
|
-
return this.resolveOptionsMap.get(receipt);
|
|
1339
|
-
}
|
|
1340
|
-
removeSavedResolveOptions(receipt) {
|
|
1341
|
-
this.resolveOptionsMap.delete(receipt);
|
|
1342
|
-
}
|
|
1343
|
-
setRenderChunkMeta(meta) {
|
|
1344
|
-
this.renderedChunkMeta = meta;
|
|
1345
|
-
}
|
|
1346
|
-
getRenderChunkMeta() {
|
|
1347
|
-
return this.renderedChunkMeta;
|
|
1348
|
-
}
|
|
1349
|
-
getInputOptions(opts) {
|
|
1350
|
-
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
|
|
1351
|
-
return this.normalizedInputOptions;
|
|
1352
|
-
}
|
|
1353
|
-
getOutputOptions(opts) {
|
|
1354
|
-
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
1355
|
-
return this.normalizedOutputOptions;
|
|
1356
|
-
}
|
|
1357
|
-
clear() {
|
|
1358
|
-
this.renderedChunkMeta = null;
|
|
1359
|
-
this.loadModulePromiseMap.clear();
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
//#endregion
|
|
1364
|
-
//#region src/utils/normalize-transform-options.ts
|
|
1365
|
-
/**
|
|
1366
|
-
* Normalizes transform options by extracting `define`, `inject`, and `dropLabels` separately from OXC transform options.
|
|
1367
|
-
*
|
|
1368
|
-
* Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
|
|
1369
|
-
*/
|
|
1370
|
-
function normalizeTransformOptions(inputOptions) {
|
|
1371
|
-
const transform = inputOptions.transform;
|
|
1372
|
-
const define = transform?.define ? Object.entries(transform.define) : void 0;
|
|
1373
|
-
const inject = transform?.inject;
|
|
1374
|
-
const dropLabels = transform?.dropLabels;
|
|
1375
|
-
let oxcTransformOptions;
|
|
1376
|
-
if (transform) {
|
|
1377
|
-
const { define: _define, inject: _inject, dropLabels: _dropLabels, ...rest } = transform;
|
|
1378
|
-
if (Object.keys(rest).length > 0) {
|
|
1379
|
-
if (rest.jsx === false) rest.jsx = "disable";
|
|
1380
|
-
oxcTransformOptions = rest;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
return {
|
|
1384
|
-
define,
|
|
1385
|
-
inject,
|
|
1386
|
-
dropLabels,
|
|
1387
|
-
oxcTransformOptions
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
//#endregion
|
|
1392
|
-
//#region src/utils/bindingify-input-options.ts
|
|
1393
|
-
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
1394
|
-
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
|
|
1395
|
-
const plugins = rawPlugins.map((plugin) => {
|
|
1396
|
-
if ("_parallel" in plugin) return;
|
|
1397
|
-
if (plugin instanceof BuiltinPlugin) switch (plugin.name) {
|
|
1398
|
-
case "builtin:vite-css-post": return bindingifyCSSPostPlugin(plugin, pluginContextData);
|
|
1399
|
-
case "builtin:vite-html": return bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode, pluginContextData);
|
|
1400
|
-
case "builtin:vite-manifest": return bindingifyManifestPlugin(plugin, pluginContextData);
|
|
1401
|
-
default: return bindingifyBuiltInPlugin(plugin);
|
|
1402
|
-
}
|
|
1403
|
-
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
1404
|
-
});
|
|
1405
|
-
const normalizedTransform = normalizeTransformOptions(inputOptions);
|
|
1406
|
-
return {
|
|
1407
|
-
input: bindingifyInput(inputOptions.input),
|
|
1408
|
-
plugins,
|
|
1409
|
-
cwd: inputOptions.cwd ?? process.cwd(),
|
|
1410
|
-
external: bindingifyExternal(inputOptions.external),
|
|
1411
|
-
resolve: bindingifyResolve(inputOptions.resolve),
|
|
1412
|
-
platform: inputOptions.platform,
|
|
1413
|
-
shimMissingExports: inputOptions.shimMissingExports,
|
|
1414
|
-
logLevel: bindingifyLogLevel(logLevel),
|
|
1415
|
-
onLog: async (level, log) => onLog(level, log),
|
|
1416
|
-
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
1417
|
-
moduleTypes: inputOptions.moduleTypes,
|
|
1418
|
-
define: normalizedTransform.define,
|
|
1419
|
-
inject: bindingifyInject(normalizedTransform.inject),
|
|
1420
|
-
experimental: bindingifyExperimental(inputOptions.experimental),
|
|
1421
|
-
profilerNames: outputOptions.generatedCode?.profilerNames,
|
|
1422
|
-
transform: normalizedTransform.oxcTransformOptions,
|
|
1423
|
-
watch: bindingifyWatch(inputOptions.watch),
|
|
1424
|
-
dropLabels: normalizedTransform.dropLabels,
|
|
1425
|
-
keepNames: outputOptions.keepNames,
|
|
1426
|
-
checks: inputOptions.checks,
|
|
1427
|
-
deferSyncScanData: () => {
|
|
1428
|
-
let ret = [];
|
|
1429
|
-
pluginContextData.moduleOptionMap.forEach((value, key) => {
|
|
1430
|
-
if (value.invalidate) ret.push({
|
|
1431
|
-
id: key,
|
|
1432
|
-
sideEffects: value.moduleSideEffects ?? void 0
|
|
1433
|
-
});
|
|
1434
|
-
});
|
|
1435
|
-
return ret;
|
|
1436
|
-
},
|
|
1437
|
-
makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
|
|
1438
|
-
devtools: inputOptions.devtools,
|
|
1439
|
-
invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
|
|
1440
|
-
preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
|
|
1441
|
-
optimization: inputOptions.optimization,
|
|
1442
|
-
context: inputOptions.context,
|
|
1443
|
-
tsconfig: inputOptions.resolve?.tsconfigFilename ?? inputOptions.tsconfig
|
|
1444
|
-
};
|
|
1445
|
-
}
|
|
1446
|
-
function bindingifyDevMode(devMode) {
|
|
1447
|
-
if (devMode) {
|
|
1448
|
-
if (typeof devMode === "boolean") return devMode ? {} : void 0;
|
|
1449
|
-
return devMode;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
function bindingifyAttachDebugInfo(attachDebugInfo) {
|
|
1453
|
-
switch (attachDebugInfo) {
|
|
1454
|
-
case void 0: return;
|
|
1455
|
-
case "full": return import_binding.BindingAttachDebugInfo.Full;
|
|
1456
|
-
case "simple": return import_binding.BindingAttachDebugInfo.Simple;
|
|
1457
|
-
case "none": return import_binding.BindingAttachDebugInfo.None;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
function bindingifyExternal(external) {
|
|
1461
|
-
if (external) {
|
|
1462
|
-
if (typeof external === "function") return (id, importer, isResolved) => {
|
|
1463
|
-
if (id.startsWith("\0")) return false;
|
|
1464
|
-
return external(id, importer, isResolved) ?? false;
|
|
1465
|
-
};
|
|
1466
|
-
return arraify(external);
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
function bindingifyExperimental(experimental) {
|
|
1470
|
-
let chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ExecOrder;
|
|
1471
|
-
if (experimental?.chunkModulesOrder) switch (experimental.chunkModulesOrder) {
|
|
1472
|
-
case "exec-order":
|
|
1473
|
-
chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ExecOrder;
|
|
1474
|
-
break;
|
|
1475
|
-
case "module-id":
|
|
1476
|
-
chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ModuleId;
|
|
1477
|
-
break;
|
|
1478
|
-
default: throw new Error(`Unexpected chunkModulesOrder: ${experimental.chunkModulesOrder}`);
|
|
1479
|
-
}
|
|
1480
|
-
return {
|
|
1481
|
-
strictExecutionOrder: experimental?.strictExecutionOrder,
|
|
1482
|
-
viteMode: experimental?.viteMode,
|
|
1483
|
-
resolveNewUrlToAsset: experimental?.resolveNewUrlToAsset,
|
|
1484
|
-
devMode: bindingifyDevMode(experimental?.devMode),
|
|
1485
|
-
attachDebugInfo: bindingifyAttachDebugInfo(experimental?.attachDebugInfo),
|
|
1486
|
-
chunkModulesOrder,
|
|
1487
|
-
chunkImportMap: experimental?.chunkImportMap,
|
|
1488
|
-
onDemandWrapping: experimental?.onDemandWrapping,
|
|
1489
|
-
incrementalBuild: experimental?.incrementalBuild,
|
|
1490
|
-
nativeMagicString: experimental?.nativeMagicString,
|
|
1491
|
-
chunkOptimization: experimental?.chunkOptimization
|
|
1492
|
-
};
|
|
1493
|
-
}
|
|
1494
|
-
function bindingifyResolve(resolve) {
|
|
1495
|
-
const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
|
|
1496
|
-
if (resolve) {
|
|
1497
|
-
const { alias, extensionAlias, ...rest } = resolve;
|
|
1498
|
-
return {
|
|
1499
|
-
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
1500
|
-
find: name,
|
|
1501
|
-
replacements: replacement === false ? [void 0] : arraify(replacement)
|
|
1502
|
-
})) : void 0,
|
|
1503
|
-
extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
1504
|
-
target: name,
|
|
1505
|
-
replacements: value
|
|
1506
|
-
})) : void 0,
|
|
1507
|
-
yarnPnp,
|
|
1508
|
-
...rest
|
|
1509
|
-
};
|
|
1510
|
-
} else return { yarnPnp };
|
|
1511
|
-
}
|
|
1512
|
-
function bindingifyInject(inject) {
|
|
1513
|
-
if (inject) return Object.entries(inject).map(([alias, item]) => {
|
|
1514
|
-
if (Array.isArray(item)) {
|
|
1515
|
-
if (item[1] === "*") return {
|
|
1516
|
-
tagNamespace: true,
|
|
1517
|
-
alias,
|
|
1518
|
-
from: item[0]
|
|
1519
|
-
};
|
|
1520
|
-
return {
|
|
1521
|
-
tagNamed: true,
|
|
1522
|
-
alias,
|
|
1523
|
-
from: item[0],
|
|
1524
|
-
imported: item[1]
|
|
1525
|
-
};
|
|
1526
|
-
} else return {
|
|
1527
|
-
tagNamed: true,
|
|
1528
|
-
imported: "default",
|
|
1529
|
-
alias,
|
|
1530
|
-
from: item
|
|
1531
|
-
};
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
function bindingifyLogLevel(logLevel) {
|
|
1535
|
-
switch (logLevel) {
|
|
1536
|
-
case "silent": return import_binding.BindingLogLevel.Silent;
|
|
1537
|
-
case "debug": return import_binding.BindingLogLevel.Debug;
|
|
1538
|
-
case "warn": return import_binding.BindingLogLevel.Warn;
|
|
1539
|
-
case "info": return import_binding.BindingLogLevel.Info;
|
|
1540
|
-
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
function bindingifyInput(input) {
|
|
1544
|
-
if (input === void 0) return [];
|
|
1545
|
-
if (typeof input === "string") return [{ import: input }];
|
|
1546
|
-
if (Array.isArray(input)) return input.map((src) => ({ import: src }));
|
|
1547
|
-
return Object.entries(input).map(([name, import_path]) => {
|
|
1548
|
-
return {
|
|
1549
|
-
name,
|
|
1550
|
-
import: import_path
|
|
1551
|
-
};
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
function bindingifyWatch(watch) {
|
|
1555
|
-
if (watch) return {
|
|
1556
|
-
buildDelay: watch.buildDelay,
|
|
1557
|
-
skipWrite: watch.skipWrite,
|
|
1558
|
-
include: normalizedStringOrRegex(watch.include),
|
|
1559
|
-
exclude: normalizedStringOrRegex(watch.exclude),
|
|
1560
|
-
onInvalidate: (...args) => watch.onInvalidate?.(...args)
|
|
1561
|
-
};
|
|
1562
|
-
}
|
|
1563
|
-
function bindingifyTreeshakeOptions(config) {
|
|
1564
|
-
if (config === false) return;
|
|
1565
|
-
if (config === true || config === void 0) return { moduleSideEffects: true };
|
|
1566
|
-
let normalizedConfig = {
|
|
1567
|
-
moduleSideEffects: true,
|
|
1568
|
-
annotations: config.annotations,
|
|
1569
|
-
manualPureFunctions: config.manualPureFunctions,
|
|
1570
|
-
unknownGlobalSideEffects: config.unknownGlobalSideEffects,
|
|
1571
|
-
commonjs: config.commonjs
|
|
1572
|
-
};
|
|
1573
|
-
switch (config.propertyReadSideEffects) {
|
|
1574
|
-
case "always":
|
|
1575
|
-
normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.Always;
|
|
1576
|
-
break;
|
|
1577
|
-
case false:
|
|
1578
|
-
normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.False;
|
|
1579
|
-
break;
|
|
1580
|
-
default:
|
|
1581
|
-
}
|
|
1582
|
-
switch (config.propertyWriteSideEffects) {
|
|
1583
|
-
case "always":
|
|
1584
|
-
normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.Always;
|
|
1585
|
-
break;
|
|
1586
|
-
case false:
|
|
1587
|
-
normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.False;
|
|
1588
|
-
break;
|
|
1589
|
-
default:
|
|
1590
|
-
}
|
|
1591
|
-
if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
|
|
1592
|
-
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
1593
|
-
external: true,
|
|
1594
|
-
sideEffects: false
|
|
1595
|
-
}, {
|
|
1596
|
-
external: false,
|
|
1597
|
-
sideEffects: true
|
|
1598
|
-
}];
|
|
1599
|
-
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
1600
|
-
return normalizedConfig;
|
|
1601
|
-
}
|
|
1602
|
-
function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
|
|
1603
|
-
if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
|
|
1604
|
-
if (typeof makeAbsoluteExternalsRelative === "boolean") return {
|
|
1605
|
-
type: "Bool",
|
|
1606
|
-
field0: makeAbsoluteExternalsRelative
|
|
1607
|
-
};
|
|
1608
|
-
}
|
|
1609
|
-
function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
|
|
1610
|
-
if (preserveEntrySignatures == void 0) return;
|
|
1611
|
-
else if (typeof preserveEntrySignatures === "string") return {
|
|
1612
|
-
type: "String",
|
|
1613
|
-
field0: preserveEntrySignatures
|
|
1614
|
-
};
|
|
1615
|
-
else return {
|
|
1616
|
-
type: "Bool",
|
|
1617
|
-
field0: preserveEntrySignatures
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
//#endregion
|
|
1622
|
-
export { aggregateBindingErrorsIntoJsError as a, normalizeHook as c, transformModuleInfo as i, PluginContextData as n, normalizeBindingResult as o, bindingifyPlugin as r, unwrapBindingResult as s, bindingifyInputOptions as t };
|