rolldown 1.0.0-beta.1-commit.1d4a330 → 1.0.0-beta.1-commit.298dd8b
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/cjs/cli.cjs +32 -33
- package/dist/cjs/experimental-index.cjs +4 -2
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/parallel-plugin-worker.cjs +3 -2
- package/dist/cjs/parse-ast-index.cjs +59 -0
- package/dist/esm/cli.mjs +16 -17
- package/dist/esm/experimental-index.mjs +3 -2
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/parallel-plugin-worker.mjs +2 -1
- package/dist/esm/parse-ast-index.mjs +56 -0
- package/dist/shared/binding-D5MBYAdC.cjs +660 -0
- package/dist/shared/binding-DLjQWzkm.mjs +609 -0
- package/dist/shared/{consola_36c0034f-rAZL9aWp.mjs → consola_36c0034f-Cx52UqEq.mjs} +2 -2
- package/dist/shared/{consola_36c0034f-CnRr1OYk.cjs → consola_36c0034f-CynBWXXO.cjs} +2 -2
- package/dist/shared/{prompt-CvISMk2k.cjs → prompt-B58MxVuU.cjs} +2 -2
- package/dist/shared/{prompt-BN0wKILJ.mjs → prompt-DjjlOckE.mjs} +1 -1
- package/dist/shared/{src-B7GNdu2r.cjs → src-BYsFiN-a.cjs} +403 -960
- package/dist/shared/{src-BKtzXvhI.mjs → src-BiKHJ1rU.mjs} +374 -953
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/binding.d.ts +257 -5
- package/dist/types/builtin-plugin/constructors.d.ts +5 -1
- package/dist/types/experimental-index.d.ts +1 -1
- package/dist/types/log/logs.d.ts +1 -0
- package/dist/types/parse-ast-index.d.ts +4 -0
- package/dist/types/plugin/plugin-context.d.ts +8 -1
- package/dist/types/plugin/plugin-driver.d.ts +2 -2
- package/package.json +21 -15
|
@@ -1,600 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
const require_chunk = require('./chunk-qZFfknuJ.cjs');
|
|
2
|
-
const
|
|
3
|
-
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/utils/asset-source.ts
|
|
18
|
-
function transformAssetSource(bindingAssetSource$1) {
|
|
19
|
-
return bindingAssetSource$1.inner;
|
|
20
|
-
}
|
|
21
|
-
function bindingAssetSource(source) {
|
|
22
|
-
return { inner: source };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/types/sourcemap.ts
|
|
27
|
-
function bindingifySourcemap$1(map) {
|
|
28
|
-
if (map == null) return;
|
|
29
|
-
return { inner: typeof map === "string" ? map : {
|
|
30
|
-
file: map.file ?? undefined,
|
|
31
|
-
mappings: map.mappings,
|
|
32
|
-
sourceRoot: map.sourceRoot,
|
|
33
|
-
sources: map.sources?.map((s) => s ?? undefined),
|
|
34
|
-
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
35
|
-
names: map.names
|
|
36
|
-
} };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/utils/error.ts
|
|
41
|
-
function normalizeErrors(rawErrors) {
|
|
42
|
-
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
43
|
-
kind: e.kind,
|
|
44
|
-
message: e.message,
|
|
45
|
-
stack: undefined
|
|
46
|
-
}));
|
|
47
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
48
|
-
for (let i = 0; i < errors.length; i++) {
|
|
49
|
-
if (i >= 5) {
|
|
50
|
-
summary += "\n...";
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
summary += getErrorMessage(errors[i]) + "\n";
|
|
54
|
-
}
|
|
55
|
-
const wrapper = new Error(summary);
|
|
56
|
-
Object.defineProperty(wrapper, "errors", {
|
|
57
|
-
configurable: true,
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: () => errors,
|
|
60
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
61
|
-
configurable: true,
|
|
62
|
-
enumerable: true,
|
|
63
|
-
value
|
|
64
|
-
})
|
|
65
|
-
});
|
|
66
|
-
return wrapper;
|
|
67
|
-
}
|
|
68
|
-
function getErrorMessage(e) {
|
|
69
|
-
let s = "";
|
|
70
|
-
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
71
|
-
const id = e.id ?? e.loc?.file;
|
|
72
|
-
if (id) {
|
|
73
|
-
s += " " + id;
|
|
74
|
-
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
75
|
-
}
|
|
76
|
-
if (s) s += "\n";
|
|
77
|
-
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
78
|
-
s += message;
|
|
79
|
-
if (e.frame) s = joinNewLine(s, e.frame);
|
|
80
|
-
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
81
|
-
return s;
|
|
82
|
-
}
|
|
83
|
-
function joinNewLine(s1, s2) {
|
|
84
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/utils/transform-rendered-module.ts
|
|
89
|
-
function transformToRenderedModule(bindingRenderedModule) {
|
|
90
|
-
return {
|
|
91
|
-
get code() {
|
|
92
|
-
return bindingRenderedModule.code;
|
|
93
|
-
},
|
|
94
|
-
get renderedLength() {
|
|
95
|
-
return bindingRenderedModule.code?.length || 0;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/utils/transform-rendered-chunk.ts
|
|
102
|
-
function transformRenderedChunk(chunk) {
|
|
103
|
-
return {
|
|
104
|
-
get name() {
|
|
105
|
-
return chunk.name;
|
|
106
|
-
},
|
|
107
|
-
get isEntry() {
|
|
108
|
-
return chunk.isEntry;
|
|
109
|
-
},
|
|
110
|
-
get isDynamicEntry() {
|
|
111
|
-
return chunk.isDynamicEntry;
|
|
112
|
-
},
|
|
113
|
-
get facadeModuleId() {
|
|
114
|
-
return chunk.facadeModuleId;
|
|
115
|
-
},
|
|
116
|
-
get moduleIds() {
|
|
117
|
-
return chunk.moduleIds;
|
|
118
|
-
},
|
|
119
|
-
get exports() {
|
|
120
|
-
return chunk.exports;
|
|
121
|
-
},
|
|
122
|
-
get fileName() {
|
|
123
|
-
return chunk.fileName;
|
|
124
|
-
},
|
|
125
|
-
get imports() {
|
|
126
|
-
return chunk.imports;
|
|
127
|
-
},
|
|
128
|
-
get dynamicImports() {
|
|
129
|
-
return chunk.dynamicImports;
|
|
130
|
-
},
|
|
131
|
-
get modules() {
|
|
132
|
-
return transformChunkModules(chunk.modules);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function transformChunkModules(modules) {
|
|
137
|
-
const result = {};
|
|
138
|
-
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
139
|
-
let mod = modules.value[index];
|
|
140
|
-
result[id] = transformToRenderedModule(mod);
|
|
141
|
-
}
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
147
|
-
function transformToRollupSourceMap(map) {
|
|
148
|
-
const parsed = JSON.parse(map);
|
|
149
|
-
const obj = {
|
|
150
|
-
...parsed,
|
|
151
|
-
toString() {
|
|
152
|
-
return JSON.stringify(obj);
|
|
153
|
-
},
|
|
154
|
-
toUrl() {
|
|
155
|
-
return `data:application/json;charset=utf-8;base64,${node_buffer.Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
return obj;
|
|
159
|
-
}
|
|
160
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
161
|
-
const chunk = {
|
|
162
|
-
type: "chunk",
|
|
163
|
-
get code() {
|
|
164
|
-
return bindingChunk.code;
|
|
165
|
-
},
|
|
166
|
-
fileName: bindingChunk.fileName,
|
|
167
|
-
name: bindingChunk.name,
|
|
168
|
-
get modules() {
|
|
169
|
-
return transformChunkModules(bindingChunk.modules);
|
|
170
|
-
},
|
|
171
|
-
get imports() {
|
|
172
|
-
return bindingChunk.imports;
|
|
173
|
-
},
|
|
174
|
-
get dynamicImports() {
|
|
175
|
-
return bindingChunk.dynamicImports;
|
|
176
|
-
},
|
|
177
|
-
exports: bindingChunk.exports,
|
|
178
|
-
isEntry: bindingChunk.isEntry,
|
|
179
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
180
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
181
|
-
get moduleIds() {
|
|
182
|
-
return bindingChunk.moduleIds;
|
|
183
|
-
},
|
|
184
|
-
get map() {
|
|
185
|
-
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
186
|
-
},
|
|
187
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
188
|
-
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
189
|
-
};
|
|
190
|
-
const cache = {};
|
|
191
|
-
return new Proxy(chunk, {
|
|
192
|
-
get(target, p) {
|
|
193
|
-
if (p in cache) return cache[p];
|
|
194
|
-
return target[p];
|
|
195
|
-
},
|
|
196
|
-
set(target, p, newValue) {
|
|
197
|
-
cache[p] = newValue;
|
|
198
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
204
|
-
const asset = {
|
|
205
|
-
type: "asset",
|
|
206
|
-
fileName: bindingAsset.fileName,
|
|
207
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
208
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
209
|
-
get source() {
|
|
210
|
-
return transformAssetSource(bindingAsset.source);
|
|
211
|
-
},
|
|
212
|
-
name: bindingAsset.name ?? undefined,
|
|
213
|
-
names: bindingAsset.names
|
|
214
|
-
};
|
|
215
|
-
const cache = {};
|
|
216
|
-
return new Proxy(asset, {
|
|
217
|
-
get(target, p) {
|
|
218
|
-
if (p in cache) return cache[p];
|
|
219
|
-
return target[p];
|
|
220
|
-
},
|
|
221
|
-
set(target, p, newValue) {
|
|
222
|
-
cache[p] = newValue;
|
|
223
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
function transformToRollupOutput(output, changed) {
|
|
229
|
-
handleOutputErrors(output);
|
|
230
|
-
const { chunks, assets } = output;
|
|
231
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
232
|
-
}
|
|
233
|
-
function handleOutputErrors(output) {
|
|
234
|
-
const rawErrors = output.errors;
|
|
235
|
-
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
236
|
-
}
|
|
237
|
-
function transformToOutputBundle(output, changed) {
|
|
238
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
239
|
-
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
240
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
241
|
-
return true;
|
|
242
|
-
} });
|
|
243
|
-
}
|
|
244
|
-
function collectChangedBundle(changed, bundle) {
|
|
245
|
-
const assets = [];
|
|
246
|
-
const chunks = [];
|
|
247
|
-
for (const key in bundle) {
|
|
248
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
249
|
-
const item = bundle[key];
|
|
250
|
-
if (item.type === "asset") assets.push({
|
|
251
|
-
filename: item.fileName,
|
|
252
|
-
originalFileNames: item.originalFileNames,
|
|
253
|
-
source: bindingAssetSource(item.source),
|
|
254
|
-
names: item.names
|
|
255
|
-
});
|
|
256
|
-
else chunks.push({
|
|
257
|
-
code: item.code,
|
|
258
|
-
filename: item.fileName,
|
|
259
|
-
name: item.name,
|
|
260
|
-
isEntry: item.isEntry,
|
|
261
|
-
exports: item.exports,
|
|
262
|
-
modules: {},
|
|
263
|
-
imports: item.imports,
|
|
264
|
-
dynamicImports: item.dynamicImports,
|
|
265
|
-
facadeModuleId: item.facadeModuleId || undefined,
|
|
266
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
267
|
-
moduleIds: item.moduleIds,
|
|
268
|
-
map: bindingifySourcemap$1(item.map),
|
|
269
|
-
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
270
|
-
preliminaryFilename: item.preliminaryFileName
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
return {
|
|
274
|
-
assets,
|
|
275
|
-
chunks,
|
|
276
|
-
deleted: Array.from(changed.deleted)
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/binding.js
|
|
282
|
-
var require_binding = require_chunk.__commonJS({ "src/binding.js"(exports, module) {
|
|
283
|
-
const { createRequire } = require("node:module");
|
|
284
|
-
require = createRequire(__filename);
|
|
285
|
-
const { readFileSync } = require("node:fs");
|
|
286
|
-
let nativeBinding = null;
|
|
287
|
-
const loadErrors = [];
|
|
288
|
-
const isMusl = () => {
|
|
289
|
-
let musl = false;
|
|
290
|
-
if (process.platform === "linux") {
|
|
291
|
-
musl = isMuslFromFilesystem();
|
|
292
|
-
if (musl === null) musl = isMuslFromReport();
|
|
293
|
-
if (musl === null) musl = isMuslFromChildProcess();
|
|
294
|
-
}
|
|
295
|
-
return musl;
|
|
296
|
-
};
|
|
297
|
-
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
298
|
-
const isMuslFromFilesystem = () => {
|
|
299
|
-
try {
|
|
300
|
-
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
301
|
-
} catch {
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
const isMuslFromReport = () => {
|
|
306
|
-
const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
|
|
307
|
-
if (!report) return null;
|
|
308
|
-
if (report.header && report.header.glibcVersionRuntime) return false;
|
|
309
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
310
|
-
if (report.sharedObjects.some(isFileMusl)) return true;
|
|
311
|
-
}
|
|
312
|
-
return false;
|
|
313
|
-
};
|
|
314
|
-
const isMuslFromChildProcess = () => {
|
|
315
|
-
try {
|
|
316
|
-
return require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
317
|
-
} catch (e) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
function requireNative() {
|
|
322
|
-
if (process.platform === "android") if (process.arch === "arm64") {
|
|
323
|
-
try {
|
|
324
|
-
return require("./rolldown-binding.android-arm64.node");
|
|
325
|
-
} catch (e) {
|
|
326
|
-
loadErrors.push(e);
|
|
327
|
-
}
|
|
328
|
-
try {
|
|
329
|
-
return require("@rolldown/binding-android-arm64");
|
|
330
|
-
} catch (e) {
|
|
331
|
-
loadErrors.push(e);
|
|
332
|
-
}
|
|
333
|
-
} else if (process.arch === "arm") {
|
|
334
|
-
try {
|
|
335
|
-
return require("./rolldown-binding.android-arm-eabi.node");
|
|
336
|
-
} catch (e) {
|
|
337
|
-
loadErrors.push(e);
|
|
338
|
-
}
|
|
339
|
-
try {
|
|
340
|
-
return require("@rolldown/binding-android-arm-eabi");
|
|
341
|
-
} catch (e) {
|
|
342
|
-
loadErrors.push(e);
|
|
343
|
-
}
|
|
344
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
345
|
-
else if (process.platform === "win32") if (process.arch === "x64") {
|
|
346
|
-
try {
|
|
347
|
-
return require("./rolldown-binding.win32-x64-msvc.node");
|
|
348
|
-
} catch (e) {
|
|
349
|
-
loadErrors.push(e);
|
|
350
|
-
}
|
|
351
|
-
try {
|
|
352
|
-
return require("@rolldown/binding-win32-x64-msvc");
|
|
353
|
-
} catch (e) {
|
|
354
|
-
loadErrors.push(e);
|
|
355
|
-
}
|
|
356
|
-
} else if (process.arch === "ia32") {
|
|
357
|
-
try {
|
|
358
|
-
return require("./rolldown-binding.win32-ia32-msvc.node");
|
|
359
|
-
} catch (e) {
|
|
360
|
-
loadErrors.push(e);
|
|
361
|
-
}
|
|
362
|
-
try {
|
|
363
|
-
return require("@rolldown/binding-win32-ia32-msvc");
|
|
364
|
-
} catch (e) {
|
|
365
|
-
loadErrors.push(e);
|
|
366
|
-
}
|
|
367
|
-
} else if (process.arch === "arm64") {
|
|
368
|
-
try {
|
|
369
|
-
return require("./rolldown-binding.win32-arm64-msvc.node");
|
|
370
|
-
} catch (e) {
|
|
371
|
-
loadErrors.push(e);
|
|
372
|
-
}
|
|
373
|
-
try {
|
|
374
|
-
return require("@rolldown/binding-win32-arm64-msvc");
|
|
375
|
-
} catch (e) {
|
|
376
|
-
loadErrors.push(e);
|
|
377
|
-
}
|
|
378
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
379
|
-
else if (process.platform === "darwin") {
|
|
380
|
-
try {
|
|
381
|
-
return require("./rolldown-binding.darwin-universal.node");
|
|
382
|
-
} catch (e) {
|
|
383
|
-
loadErrors.push(e);
|
|
384
|
-
}
|
|
385
|
-
try {
|
|
386
|
-
return require("@rolldown/binding-darwin-universal");
|
|
387
|
-
} catch (e) {
|
|
388
|
-
loadErrors.push(e);
|
|
389
|
-
}
|
|
390
|
-
if (process.arch === "x64") {
|
|
391
|
-
try {
|
|
392
|
-
return require("./rolldown-binding.darwin-x64.node");
|
|
393
|
-
} catch (e) {
|
|
394
|
-
loadErrors.push(e);
|
|
395
|
-
}
|
|
396
|
-
try {
|
|
397
|
-
return require("@rolldown/binding-darwin-x64");
|
|
398
|
-
} catch (e) {
|
|
399
|
-
loadErrors.push(e);
|
|
400
|
-
}
|
|
401
|
-
} else if (process.arch === "arm64") {
|
|
402
|
-
try {
|
|
403
|
-
return require("./rolldown-binding.darwin-arm64.node");
|
|
404
|
-
} catch (e) {
|
|
405
|
-
loadErrors.push(e);
|
|
406
|
-
}
|
|
407
|
-
try {
|
|
408
|
-
return require("@rolldown/binding-darwin-arm64");
|
|
409
|
-
} catch (e) {
|
|
410
|
-
loadErrors.push(e);
|
|
411
|
-
}
|
|
412
|
-
} else loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
413
|
-
} else if (process.platform === "freebsd") if (process.arch === "x64") {
|
|
414
|
-
try {
|
|
415
|
-
return require("./rolldown-binding.freebsd-x64.node");
|
|
416
|
-
} catch (e) {
|
|
417
|
-
loadErrors.push(e);
|
|
418
|
-
}
|
|
419
|
-
try {
|
|
420
|
-
return require("@rolldown/binding-freebsd-x64");
|
|
421
|
-
} catch (e) {
|
|
422
|
-
loadErrors.push(e);
|
|
423
|
-
}
|
|
424
|
-
} else if (process.arch === "arm64") {
|
|
425
|
-
try {
|
|
426
|
-
return require("./rolldown-binding.freebsd-arm64.node");
|
|
427
|
-
} catch (e) {
|
|
428
|
-
loadErrors.push(e);
|
|
429
|
-
}
|
|
430
|
-
try {
|
|
431
|
-
return require("@rolldown/binding-freebsd-arm64");
|
|
432
|
-
} catch (e) {
|
|
433
|
-
loadErrors.push(e);
|
|
434
|
-
}
|
|
435
|
-
} else loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
436
|
-
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
|
|
437
|
-
try {
|
|
438
|
-
return require("./rolldown-binding.linux-x64-musl.node");
|
|
439
|
-
} catch (e) {
|
|
440
|
-
loadErrors.push(e);
|
|
441
|
-
}
|
|
442
|
-
try {
|
|
443
|
-
return require("@rolldown/binding-linux-x64-musl");
|
|
444
|
-
} catch (e) {
|
|
445
|
-
loadErrors.push(e);
|
|
446
|
-
}
|
|
447
|
-
} else {
|
|
448
|
-
try {
|
|
449
|
-
return require("./rolldown-binding.linux-x64-gnu.node");
|
|
450
|
-
} catch (e) {
|
|
451
|
-
loadErrors.push(e);
|
|
452
|
-
}
|
|
453
|
-
try {
|
|
454
|
-
return require("@rolldown/binding-linux-x64-gnu");
|
|
455
|
-
} catch (e) {
|
|
456
|
-
loadErrors.push(e);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
else if (process.arch === "arm64") if (isMusl()) {
|
|
460
|
-
try {
|
|
461
|
-
return require("./rolldown-binding.linux-arm64-musl.node");
|
|
462
|
-
} catch (e) {
|
|
463
|
-
loadErrors.push(e);
|
|
464
|
-
}
|
|
465
|
-
try {
|
|
466
|
-
return require("@rolldown/binding-linux-arm64-musl");
|
|
467
|
-
} catch (e) {
|
|
468
|
-
loadErrors.push(e);
|
|
469
|
-
}
|
|
470
|
-
} else {
|
|
471
|
-
try {
|
|
472
|
-
return require("./rolldown-binding.linux-arm64-gnu.node");
|
|
473
|
-
} catch (e) {
|
|
474
|
-
loadErrors.push(e);
|
|
475
|
-
}
|
|
476
|
-
try {
|
|
477
|
-
return require("@rolldown/binding-linux-arm64-gnu");
|
|
478
|
-
} catch (e) {
|
|
479
|
-
loadErrors.push(e);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
else if (process.arch === "arm") if (isMusl()) {
|
|
483
|
-
try {
|
|
484
|
-
return require("./rolldown-binding.linux-arm-musleabihf.node");
|
|
485
|
-
} catch (e) {
|
|
486
|
-
loadErrors.push(e);
|
|
487
|
-
}
|
|
488
|
-
try {
|
|
489
|
-
return require("@rolldown/binding-linux-arm-musleabihf");
|
|
490
|
-
} catch (e) {
|
|
491
|
-
loadErrors.push(e);
|
|
492
|
-
}
|
|
493
|
-
} else {
|
|
494
|
-
try {
|
|
495
|
-
return require("./rolldown-binding.linux-arm-gnueabihf.node");
|
|
496
|
-
} catch (e) {
|
|
497
|
-
loadErrors.push(e);
|
|
498
|
-
}
|
|
499
|
-
try {
|
|
500
|
-
return require("@rolldown/binding-linux-arm-gnueabihf");
|
|
501
|
-
} catch (e) {
|
|
502
|
-
loadErrors.push(e);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
else if (process.arch === "riscv64") if (isMusl()) {
|
|
506
|
-
try {
|
|
507
|
-
return require("./rolldown-binding.linux-riscv64-musl.node");
|
|
508
|
-
} catch (e) {
|
|
509
|
-
loadErrors.push(e);
|
|
510
|
-
}
|
|
511
|
-
try {
|
|
512
|
-
return require("@rolldown/binding-linux-riscv64-musl");
|
|
513
|
-
} catch (e) {
|
|
514
|
-
loadErrors.push(e);
|
|
515
|
-
}
|
|
516
|
-
} else {
|
|
517
|
-
try {
|
|
518
|
-
return require("./rolldown-binding.linux-riscv64-gnu.node");
|
|
519
|
-
} catch (e) {
|
|
520
|
-
loadErrors.push(e);
|
|
521
|
-
}
|
|
522
|
-
try {
|
|
523
|
-
return require("@rolldown/binding-linux-riscv64-gnu");
|
|
524
|
-
} catch (e) {
|
|
525
|
-
loadErrors.push(e);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
else if (process.arch === "ppc64") {
|
|
529
|
-
try {
|
|
530
|
-
return require("./rolldown-binding.linux-ppc64-gnu.node");
|
|
531
|
-
} catch (e) {
|
|
532
|
-
loadErrors.push(e);
|
|
533
|
-
}
|
|
534
|
-
try {
|
|
535
|
-
return require("@rolldown/binding-linux-ppc64-gnu");
|
|
536
|
-
} catch (e) {
|
|
537
|
-
loadErrors.push(e);
|
|
538
|
-
}
|
|
539
|
-
} else if (process.arch === "s390x") {
|
|
540
|
-
try {
|
|
541
|
-
return require("./rolldown-binding.linux-s390x-gnu.node");
|
|
542
|
-
} catch (e) {
|
|
543
|
-
loadErrors.push(e);
|
|
544
|
-
}
|
|
545
|
-
try {
|
|
546
|
-
return require("@rolldown/binding-linux-s390x-gnu");
|
|
547
|
-
} catch (e) {
|
|
548
|
-
loadErrors.push(e);
|
|
549
|
-
}
|
|
550
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
551
|
-
else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
552
|
-
}
|
|
553
|
-
nativeBinding = requireNative();
|
|
554
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
555
|
-
try {
|
|
556
|
-
nativeBinding = require("./rolldown-binding.wasi.cjs");
|
|
557
|
-
} catch (err) {
|
|
558
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
559
|
-
}
|
|
560
|
-
if (!nativeBinding) try {
|
|
561
|
-
nativeBinding = require("@rolldown/binding-wasm32-wasi");
|
|
562
|
-
} catch (err) {
|
|
563
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
if (!nativeBinding) {
|
|
567
|
-
if (loadErrors.length > 0) throw new Error("Failed to load native binding", { cause: loadErrors });
|
|
568
|
-
throw new Error(`Failed to load native binding`);
|
|
569
|
-
}
|
|
570
|
-
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
|
|
571
|
-
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
|
|
572
|
-
module.exports.BindingError = nativeBinding.BindingError;
|
|
573
|
-
module.exports.BindingLog = nativeBinding.BindingLog;
|
|
574
|
-
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
|
|
575
|
-
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
|
|
576
|
-
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
|
|
577
|
-
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
|
|
578
|
-
module.exports.BindingOutputs = nativeBinding.BindingOutputs;
|
|
579
|
-
module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
|
|
580
|
-
module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
|
|
581
|
-
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
|
|
582
|
-
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
|
|
583
|
-
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
|
|
584
|
-
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
585
|
-
module.exports.Bundler = nativeBinding.Bundler;
|
|
586
|
-
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
|
|
587
|
-
module.exports.RenderedChunk = nativeBinding.RenderedChunk;
|
|
588
|
-
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
589
|
-
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
590
|
-
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
591
|
-
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
592
|
-
module.exports.HelperMode = nativeBinding.HelperMode;
|
|
593
|
-
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
594
|
-
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
595
|
-
module.exports.Severity = nativeBinding.Severity;
|
|
596
|
-
module.exports.transform = nativeBinding.transform;
|
|
597
|
-
} });
|
|
3
|
+
const require_binding$1 = require('./binding-D5MBYAdC.cjs');
|
|
4
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
|
+
const node_buffer = require_chunk.__toESM(require("node:buffer"));
|
|
6
|
+
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
7
|
+
const node_os = require_chunk.__toESM(require("node:os"));
|
|
8
|
+
const valibot = require_chunk.__toESM(require("valibot"));
|
|
9
|
+
const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
|
|
10
|
+
|
|
11
|
+
//#region src/utils/define-config.ts
|
|
12
|
+
function defineConfig(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
598
15
|
|
|
599
16
|
//#endregion
|
|
600
17
|
//#region src/utils/misc.ts
|
|
@@ -631,180 +48,13 @@ const logLevelPriority = {
|
|
|
631
48
|
[LOG_LEVEL_SILENT]: 3
|
|
632
49
|
};
|
|
633
50
|
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region src/utils/code-frame.ts
|
|
636
|
-
function spaces(index) {
|
|
637
|
-
let result = "";
|
|
638
|
-
while (index--) result += " ";
|
|
639
|
-
return result;
|
|
640
|
-
}
|
|
641
|
-
function tabsToSpaces(value) {
|
|
642
|
-
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
643
|
-
}
|
|
644
|
-
const LINE_TRUNCATE_LENGTH = 120;
|
|
645
|
-
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
646
|
-
const ELLIPSIS = "...";
|
|
647
|
-
function getCodeFrame(source, line, column) {
|
|
648
|
-
let lines = source.split("\n");
|
|
649
|
-
if (line > lines.length) return "";
|
|
650
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
|
|
651
|
-
const frameStart = Math.max(0, line - 3);
|
|
652
|
-
let frameEnd = Math.min(line + 2, lines.length);
|
|
653
|
-
lines = lines.slice(frameStart, frameEnd);
|
|
654
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
655
|
-
lines.pop();
|
|
656
|
-
frameEnd -= 1;
|
|
657
|
-
}
|
|
658
|
-
const digits = String(frameEnd).length;
|
|
659
|
-
return lines.map((sourceLine, index) => {
|
|
660
|
-
const isErrorLine = frameStart + index + 1 === line;
|
|
661
|
-
let lineNumber = String(index + frameStart + 1);
|
|
662
|
-
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
663
|
-
let displayedLine = tabsToSpaces(sourceLine);
|
|
664
|
-
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
665
|
-
if (isErrorLine) {
|
|
666
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
667
|
-
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
668
|
-
}
|
|
669
|
-
return `${lineNumber}: ${displayedLine}`;
|
|
670
|
-
}).join("\n");
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region src/log/locate-character/index.js
|
|
675
|
-
/** @typedef {import('./types').Location} Location */
|
|
676
|
-
/**
|
|
677
|
-
* @param {import('./types').Range} range
|
|
678
|
-
* @param {number} index
|
|
679
|
-
*/
|
|
680
|
-
function rangeContains(range, index) {
|
|
681
|
-
return range.start <= index && index < range.end;
|
|
682
|
-
}
|
|
683
|
-
function getLocator(source, options = {}) {
|
|
684
|
-
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
685
|
-
let start = 0;
|
|
686
|
-
const ranges = source.split("\n").map((line, i$1) => {
|
|
687
|
-
const end = start + line.length + 1;
|
|
688
|
-
/** @type {import('./types').Range} */
|
|
689
|
-
const range = {
|
|
690
|
-
start,
|
|
691
|
-
end,
|
|
692
|
-
line: i$1
|
|
693
|
-
};
|
|
694
|
-
start = end;
|
|
695
|
-
return range;
|
|
696
|
-
});
|
|
697
|
-
let i = 0;
|
|
698
|
-
/**
|
|
699
|
-
* @param {string | number} search
|
|
700
|
-
* @param {number} [index]
|
|
701
|
-
* @returns {Location | undefined}
|
|
702
|
-
*/
|
|
703
|
-
function locator(search, index) {
|
|
704
|
-
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
705
|
-
if (search === -1) return undefined;
|
|
706
|
-
let range = ranges[i];
|
|
707
|
-
const d = search >= range.end ? 1 : -1;
|
|
708
|
-
while (range) {
|
|
709
|
-
if (rangeContains(range, search)) return {
|
|
710
|
-
line: offsetLine + range.line,
|
|
711
|
-
column: offsetColumn + search - range.start,
|
|
712
|
-
character: search
|
|
713
|
-
};
|
|
714
|
-
i += d;
|
|
715
|
-
range = ranges[i];
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
return locator;
|
|
719
|
-
}
|
|
720
|
-
function locate(source, search, options) {
|
|
721
|
-
return getLocator(source, options)(search, options && options.startIndex);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
//#endregion
|
|
725
|
-
//#region src/log/logs.ts
|
|
726
|
-
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", MINIFY_WARNING = "MINIFY_WARNING";
|
|
727
|
-
function logMinifyWarning() {
|
|
728
|
-
return {
|
|
729
|
-
code: MINIFY_WARNING,
|
|
730
|
-
message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
function logInvalidLogPosition(pluginName) {
|
|
734
|
-
return {
|
|
735
|
-
code: INVALID_LOG_POSITION,
|
|
736
|
-
message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
740
|
-
return {
|
|
741
|
-
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
742
|
-
message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
function logCycleLoading(pluginName, moduleId) {
|
|
746
|
-
return {
|
|
747
|
-
code: CYCLE_LOADING,
|
|
748
|
-
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
function logMultiplyNotifyOption() {
|
|
752
|
-
return {
|
|
753
|
-
code: MULTIPLY_NOTIFY_OPTION,
|
|
754
|
-
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
758
|
-
const code = error$1.code;
|
|
759
|
-
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
760
|
-
error$1.code = PLUGIN_ERROR;
|
|
761
|
-
error$1.plugin = plugin;
|
|
762
|
-
if (hook) error$1.hook = hook;
|
|
763
|
-
if (id) error$1.id = id;
|
|
764
|
-
return error$1;
|
|
765
|
-
}
|
|
766
|
-
function error(base) {
|
|
767
|
-
if (!(base instanceof Error)) {
|
|
768
|
-
base = Object.assign(new Error(base.message), base);
|
|
769
|
-
Object.defineProperty(base, "name", {
|
|
770
|
-
value: "RollupError",
|
|
771
|
-
writable: true
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
throw base;
|
|
775
|
-
}
|
|
776
|
-
function augmentCodeLocation(properties, pos, source, id) {
|
|
777
|
-
if (typeof pos === "object") {
|
|
778
|
-
const { line, column } = pos;
|
|
779
|
-
properties.loc = {
|
|
780
|
-
column,
|
|
781
|
-
file: id,
|
|
782
|
-
line
|
|
783
|
-
};
|
|
784
|
-
} else {
|
|
785
|
-
properties.pos = pos;
|
|
786
|
-
const location = locate(source, pos, { offsetLine: 1 });
|
|
787
|
-
if (!location) return;
|
|
788
|
-
const { line, column } = location;
|
|
789
|
-
properties.loc = {
|
|
790
|
-
column,
|
|
791
|
-
file: id,
|
|
792
|
-
line
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
if (properties.frame === undefined) {
|
|
796
|
-
const { line, column } = properties.loc;
|
|
797
|
-
properties.frame = getCodeFrame(source, line, column);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
51
|
//#endregion
|
|
802
52
|
//#region src/log/logHandler.ts
|
|
803
53
|
const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
804
54
|
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
805
55
|
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
806
56
|
return (log, pos) => {
|
|
807
|
-
if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
57
|
+
if (pos != null) logger(LOG_LEVEL_WARN, require_binding$1.logInvalidLogPosition(pluginName));
|
|
808
58
|
log = normalizeLog(log);
|
|
809
59
|
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
810
60
|
log.code = code;
|
|
@@ -850,7 +100,7 @@ function getLogger(plugins, onLog, logLevel) {
|
|
|
850
100
|
const handler = "handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
851
101
|
if (handler.call({
|
|
852
102
|
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
853
|
-
error: (log$1) => error(normalizeLog(log$1)),
|
|
103
|
+
error: (log$1) => require_binding$1.error(normalizeLog(log$1)),
|
|
854
104
|
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
855
105
|
meta: {
|
|
856
106
|
rollupVersion: "4.23.0",
|
|
@@ -872,7 +122,7 @@ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
|
872
122
|
if (onLog) {
|
|
873
123
|
const minimalPriority = logLevelPriority[logLevel];
|
|
874
124
|
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
875
|
-
if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
|
|
125
|
+
if (level$1 === LOG_LEVEL_ERROR) return require_binding$1.error(normalizeLog(handledLog));
|
|
876
126
|
if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
|
|
877
127
|
});
|
|
878
128
|
}
|
|
@@ -910,7 +160,7 @@ function relativeId(id) {
|
|
|
910
160
|
|
|
911
161
|
//#endregion
|
|
912
162
|
//#region src/builtin-plugin/utils.ts
|
|
913
|
-
var import_binding$6 = require_chunk.__toESM(require_binding());
|
|
163
|
+
var import_binding$6 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
914
164
|
function makeBuiltinPluginCallable(plugin) {
|
|
915
165
|
let callablePlugin = new import_binding$6.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
916
166
|
const wrappedPlugin = plugin;
|
|
@@ -970,6 +220,15 @@ function viteResolvePlugin(config) {
|
|
|
970
220
|
});
|
|
971
221
|
return makeBuiltinPluginCallable(builtinPlugin);
|
|
972
222
|
}
|
|
223
|
+
function moduleFederationPlugin(config) {
|
|
224
|
+
return new BuiltinPlugin("builtin:module-federation", {
|
|
225
|
+
...config,
|
|
226
|
+
remotes: config.remotes && Object.values(config.remotes).map((entry) => {
|
|
227
|
+
if (typeof entry === "string") return { entry };
|
|
228
|
+
return entry;
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
}
|
|
973
232
|
|
|
974
233
|
//#endregion
|
|
975
234
|
//#region src/utils/async-flatten.ts
|
|
@@ -1045,96 +304,360 @@ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins]))
|
|
|
1045
304
|
function checkOutputPluginOption(plugins, onLog) {
|
|
1046
305
|
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
1047
306
|
delete plugin[hook];
|
|
1048
|
-
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
|
|
307
|
+
onLog(LOG_LEVEL_WARN, require_binding$1.logInputHookInOutputPlugin(plugin.name, hook));
|
|
308
|
+
}
|
|
309
|
+
return plugins;
|
|
310
|
+
}
|
|
311
|
+
function normalizePlugins(plugins, anonymousPrefix) {
|
|
312
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
313
|
+
if ("_parallel" in plugin) continue;
|
|
314
|
+
if (plugin instanceof BuiltinPlugin) continue;
|
|
315
|
+
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
|
|
1049
316
|
}
|
|
1050
317
|
return plugins;
|
|
1051
318
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
319
|
+
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
320
|
+
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
321
|
+
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/plugin/plugin-driver.ts
|
|
324
|
+
var PluginDriver = class {
|
|
325
|
+
static async callOptionsHook(inputOptions) {
|
|
326
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
327
|
+
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
328
|
+
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
|
|
329
|
+
for (const plugin of plugins) {
|
|
330
|
+
const name = plugin.name || "unknown";
|
|
331
|
+
const options = plugin.options;
|
|
332
|
+
if (options) {
|
|
333
|
+
const { handler } = normalizeHook(options);
|
|
334
|
+
const result = await handler.call({
|
|
335
|
+
debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
|
|
336
|
+
error: (e) => require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), name, { hook: "onLog" })),
|
|
337
|
+
info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
|
|
338
|
+
meta: {
|
|
339
|
+
rollupVersion: "4.23.0",
|
|
340
|
+
rolldownVersion: VERSION,
|
|
341
|
+
watchMode: false
|
|
342
|
+
},
|
|
343
|
+
warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
|
|
344
|
+
pluginName: name
|
|
345
|
+
}, inputOptions);
|
|
346
|
+
if (result) inputOptions = result;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return inputOptions;
|
|
350
|
+
}
|
|
351
|
+
static callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
352
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
353
|
+
for (const plugin of sortedPlugins) {
|
|
354
|
+
const options = plugin.outputOptions;
|
|
355
|
+
if (options) {
|
|
356
|
+
const { handler } = normalizeHook(options);
|
|
357
|
+
const result = handler.call(null, outputOptions);
|
|
358
|
+
if (result) outputOptions = result;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return outputOptions;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
function getObjectPlugins(plugins) {
|
|
365
|
+
return plugins.filter((plugin) => {
|
|
366
|
+
if (!plugin) return undefined;
|
|
367
|
+
if ("_parallel" in plugin) return undefined;
|
|
368
|
+
if (plugin instanceof BuiltinPlugin) return undefined;
|
|
369
|
+
return plugin;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function getSortedPlugins(hookName, plugins) {
|
|
373
|
+
const pre = [];
|
|
374
|
+
const normal = [];
|
|
375
|
+
const post = [];
|
|
376
|
+
for (const plugin of plugins) {
|
|
377
|
+
const hook = plugin[hookName];
|
|
378
|
+
if (hook) {
|
|
379
|
+
if (typeof hook === "object") {
|
|
380
|
+
if (hook.order === "pre") {
|
|
381
|
+
pre.push(plugin);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (hook.order === "post") {
|
|
385
|
+
post.push(plugin);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
normal.push(plugin);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return [
|
|
393
|
+
...pre,
|
|
394
|
+
...normal,
|
|
395
|
+
...post
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/utils/asset-source.ts
|
|
401
|
+
function transformAssetSource(bindingAssetSource$1) {
|
|
402
|
+
return bindingAssetSource$1.inner;
|
|
403
|
+
}
|
|
404
|
+
function bindingAssetSource(source) {
|
|
405
|
+
return { inner: source };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/types/sourcemap.ts
|
|
410
|
+
function bindingifySourcemap$1(map) {
|
|
411
|
+
if (map == null) return;
|
|
412
|
+
return { inner: typeof map === "string" ? map : {
|
|
413
|
+
file: map.file ?? undefined,
|
|
414
|
+
mappings: map.mappings,
|
|
415
|
+
sourceRoot: map.sourceRoot,
|
|
416
|
+
sources: map.sources?.map((s) => s ?? undefined),
|
|
417
|
+
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
418
|
+
names: map.names
|
|
419
|
+
} };
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/utils/error.ts
|
|
424
|
+
function normalizeErrors(rawErrors) {
|
|
425
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
426
|
+
kind: e.kind,
|
|
427
|
+
message: e.message,
|
|
428
|
+
stack: undefined
|
|
429
|
+
}));
|
|
430
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
431
|
+
for (let i = 0; i < errors.length; i++) {
|
|
432
|
+
if (i >= 5) {
|
|
433
|
+
summary += "\n...";
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
summary += getErrorMessage(errors[i]) + "\n";
|
|
437
|
+
}
|
|
438
|
+
const wrapper = new Error(summary);
|
|
439
|
+
Object.defineProperty(wrapper, "errors", {
|
|
440
|
+
configurable: true,
|
|
441
|
+
enumerable: true,
|
|
442
|
+
get: () => errors,
|
|
443
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
444
|
+
configurable: true,
|
|
445
|
+
enumerable: true,
|
|
446
|
+
value
|
|
447
|
+
})
|
|
448
|
+
});
|
|
449
|
+
return wrapper;
|
|
450
|
+
}
|
|
451
|
+
function getErrorMessage(e) {
|
|
452
|
+
let s = "";
|
|
453
|
+
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
454
|
+
const id = e.id ?? e.loc?.file;
|
|
455
|
+
if (id) {
|
|
456
|
+
s += " " + id;
|
|
457
|
+
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
458
|
+
}
|
|
459
|
+
if (s) s += "\n";
|
|
460
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
461
|
+
s += message;
|
|
462
|
+
if (e.frame) s = joinNewLine(s, e.frame);
|
|
463
|
+
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
464
|
+
return s;
|
|
465
|
+
}
|
|
466
|
+
function joinNewLine(s1, s2) {
|
|
467
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/utils/transform-rendered-module.ts
|
|
472
|
+
function transformToRenderedModule(bindingRenderedModule) {
|
|
473
|
+
return {
|
|
474
|
+
get code() {
|
|
475
|
+
return bindingRenderedModule.code;
|
|
476
|
+
},
|
|
477
|
+
get renderedLength() {
|
|
478
|
+
return bindingRenderedModule.code?.length || 0;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/utils/transform-rendered-chunk.ts
|
|
485
|
+
function transformRenderedChunk(chunk) {
|
|
486
|
+
return {
|
|
487
|
+
get name() {
|
|
488
|
+
return chunk.name;
|
|
489
|
+
},
|
|
490
|
+
get isEntry() {
|
|
491
|
+
return chunk.isEntry;
|
|
492
|
+
},
|
|
493
|
+
get isDynamicEntry() {
|
|
494
|
+
return chunk.isDynamicEntry;
|
|
495
|
+
},
|
|
496
|
+
get facadeModuleId() {
|
|
497
|
+
return chunk.facadeModuleId;
|
|
498
|
+
},
|
|
499
|
+
get moduleIds() {
|
|
500
|
+
return chunk.moduleIds;
|
|
501
|
+
},
|
|
502
|
+
get exports() {
|
|
503
|
+
return chunk.exports;
|
|
504
|
+
},
|
|
505
|
+
get fileName() {
|
|
506
|
+
return chunk.fileName;
|
|
507
|
+
},
|
|
508
|
+
get imports() {
|
|
509
|
+
return chunk.imports;
|
|
510
|
+
},
|
|
511
|
+
get dynamicImports() {
|
|
512
|
+
return chunk.dynamicImports;
|
|
513
|
+
},
|
|
514
|
+
get modules() {
|
|
515
|
+
return transformChunkModules(chunk.modules);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function transformChunkModules(modules) {
|
|
520
|
+
const result = {};
|
|
521
|
+
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
522
|
+
let mod = modules.value[index];
|
|
523
|
+
result[id] = transformToRenderedModule(mod);
|
|
1057
524
|
}
|
|
1058
|
-
return
|
|
525
|
+
return result;
|
|
1059
526
|
}
|
|
1060
|
-
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
1061
|
-
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
1062
527
|
|
|
1063
528
|
//#endregion
|
|
1064
|
-
//#region src/
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
const { handler } = normalizeHook(options);
|
|
1075
|
-
const result = await handler.call({
|
|
1076
|
-
debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
|
|
1077
|
-
error: (e) => error(logPluginError(normalizeLog(e), name, { hook: "onLog" })),
|
|
1078
|
-
info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
|
|
1079
|
-
meta: {
|
|
1080
|
-
rollupVersion: "4.23.0",
|
|
1081
|
-
rolldownVersion: VERSION,
|
|
1082
|
-
watchMode: false
|
|
1083
|
-
},
|
|
1084
|
-
warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
|
|
1085
|
-
pluginName: name
|
|
1086
|
-
}, inputOptions);
|
|
1087
|
-
if (result) inputOptions = result;
|
|
1088
|
-
}
|
|
529
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
530
|
+
function transformToRollupSourceMap(map) {
|
|
531
|
+
const parsed = JSON.parse(map);
|
|
532
|
+
const obj = {
|
|
533
|
+
...parsed,
|
|
534
|
+
toString() {
|
|
535
|
+
return JSON.stringify(obj);
|
|
536
|
+
},
|
|
537
|
+
toUrl() {
|
|
538
|
+
return `data:application/json;charset=utf-8;base64,${node_buffer.Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
1089
539
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
540
|
+
};
|
|
541
|
+
return obj;
|
|
542
|
+
}
|
|
543
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
544
|
+
const chunk = {
|
|
545
|
+
type: "chunk",
|
|
546
|
+
get code() {
|
|
547
|
+
return bindingChunk.code;
|
|
548
|
+
},
|
|
549
|
+
fileName: bindingChunk.fileName,
|
|
550
|
+
name: bindingChunk.name,
|
|
551
|
+
get modules() {
|
|
552
|
+
return transformChunkModules(bindingChunk.modules);
|
|
553
|
+
},
|
|
554
|
+
get imports() {
|
|
555
|
+
return bindingChunk.imports;
|
|
556
|
+
},
|
|
557
|
+
get dynamicImports() {
|
|
558
|
+
return bindingChunk.dynamicImports;
|
|
559
|
+
},
|
|
560
|
+
exports: bindingChunk.exports,
|
|
561
|
+
isEntry: bindingChunk.isEntry,
|
|
562
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
563
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
564
|
+
get moduleIds() {
|
|
565
|
+
return bindingChunk.moduleIds;
|
|
566
|
+
},
|
|
567
|
+
get map() {
|
|
568
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
569
|
+
},
|
|
570
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
571
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
572
|
+
};
|
|
573
|
+
const cache = {};
|
|
574
|
+
return new Proxy(chunk, {
|
|
575
|
+
get(target, p) {
|
|
576
|
+
if (p in cache) return cache[p];
|
|
577
|
+
return target[p];
|
|
578
|
+
},
|
|
579
|
+
set(target, p, newValue) {
|
|
580
|
+
cache[p] = newValue;
|
|
581
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
582
|
+
return true;
|
|
1101
583
|
}
|
|
1102
|
-
return outputOptions;
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
function getObjectPlugins(plugins) {
|
|
1106
|
-
return plugins.filter((plugin) => {
|
|
1107
|
-
if (!plugin) return undefined;
|
|
1108
|
-
if ("_parallel" in plugin) return undefined;
|
|
1109
|
-
if (plugin instanceof BuiltinPlugin) return undefined;
|
|
1110
|
-
return plugin;
|
|
1111
584
|
});
|
|
1112
585
|
}
|
|
1113
|
-
function
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
586
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
587
|
+
const asset = {
|
|
588
|
+
type: "asset",
|
|
589
|
+
fileName: bindingAsset.fileName,
|
|
590
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
591
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
592
|
+
get source() {
|
|
593
|
+
return transformAssetSource(bindingAsset.source);
|
|
594
|
+
},
|
|
595
|
+
name: bindingAsset.name ?? undefined,
|
|
596
|
+
names: bindingAsset.names
|
|
597
|
+
};
|
|
598
|
+
const cache = {};
|
|
599
|
+
return new Proxy(asset, {
|
|
600
|
+
get(target, p) {
|
|
601
|
+
if (p in cache) return cache[p];
|
|
602
|
+
return target[p];
|
|
603
|
+
},
|
|
604
|
+
set(target, p, newValue) {
|
|
605
|
+
cache[p] = newValue;
|
|
606
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
607
|
+
return true;
|
|
1131
608
|
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
function transformToRollupOutput(output, changed) {
|
|
612
|
+
handleOutputErrors(output);
|
|
613
|
+
const { chunks, assets } = output;
|
|
614
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
615
|
+
}
|
|
616
|
+
function handleOutputErrors(output) {
|
|
617
|
+
const rawErrors = output.errors;
|
|
618
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
619
|
+
}
|
|
620
|
+
function transformToOutputBundle(output, changed) {
|
|
621
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
622
|
+
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
623
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
624
|
+
return true;
|
|
625
|
+
} });
|
|
626
|
+
}
|
|
627
|
+
function collectChangedBundle(changed, bundle) {
|
|
628
|
+
const assets = [];
|
|
629
|
+
const chunks = [];
|
|
630
|
+
for (const key in bundle) {
|
|
631
|
+
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
632
|
+
const item = bundle[key];
|
|
633
|
+
if (item.type === "asset") assets.push({
|
|
634
|
+
filename: item.fileName,
|
|
635
|
+
originalFileNames: item.originalFileNames,
|
|
636
|
+
source: bindingAssetSource(item.source),
|
|
637
|
+
names: item.names
|
|
638
|
+
});
|
|
639
|
+
else chunks.push({
|
|
640
|
+
code: item.code,
|
|
641
|
+
filename: item.fileName,
|
|
642
|
+
name: item.name,
|
|
643
|
+
isEntry: item.isEntry,
|
|
644
|
+
exports: item.exports,
|
|
645
|
+
modules: {},
|
|
646
|
+
imports: item.imports,
|
|
647
|
+
dynamicImports: item.dynamicImports,
|
|
648
|
+
facadeModuleId: item.facadeModuleId || undefined,
|
|
649
|
+
isDynamicEntry: item.isDynamicEntry,
|
|
650
|
+
moduleIds: item.moduleIds,
|
|
651
|
+
map: bindingifySourcemap$1(item.map),
|
|
652
|
+
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
653
|
+
preliminaryFilename: item.preliminaryFileName
|
|
654
|
+
});
|
|
1132
655
|
}
|
|
1133
|
-
return
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
656
|
+
return {
|
|
657
|
+
assets,
|
|
658
|
+
chunks,
|
|
659
|
+
deleted: Array.from(changed.deleted)
|
|
660
|
+
};
|
|
1138
661
|
}
|
|
1139
662
|
|
|
1140
663
|
//#endregion
|
|
@@ -1192,13 +715,13 @@ var MinimalPluginContext = class {
|
|
|
1192
715
|
};
|
|
1193
716
|
}
|
|
1194
717
|
error(e) {
|
|
1195
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
718
|
+
return require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), this.pluginName));
|
|
1196
719
|
}
|
|
1197
720
|
};
|
|
1198
721
|
|
|
1199
722
|
//#endregion
|
|
1200
723
|
//#region src/utils/transform-side-effects.ts
|
|
1201
|
-
var import_binding$5 = require_chunk.__toESM(require_binding());
|
|
724
|
+
var import_binding$5 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1202
725
|
function bindingifySideEffects(sideEffects) {
|
|
1203
726
|
switch (sideEffects) {
|
|
1204
727
|
case true: return import_binding$5.BindingHookSideEffects.True;
|
|
@@ -1222,7 +745,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1222
745
|
}
|
|
1223
746
|
async load(options) {
|
|
1224
747
|
const id = options.id;
|
|
1225
|
-
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
748
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, require_binding$1.logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
1226
749
|
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
1227
750
|
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
1228
751
|
const rawOptions = {
|
|
@@ -1264,7 +787,8 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1264
787
|
};
|
|
1265
788
|
}
|
|
1266
789
|
emitFile(file) {
|
|
1267
|
-
if (file.type
|
|
790
|
+
if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
|
|
791
|
+
if (file.type === "chunk") return this.context.emitChunk(file);
|
|
1268
792
|
return this.context.emitFile({
|
|
1269
793
|
...file,
|
|
1270
794
|
originalFileName: file.originalFileName || undefined,
|
|
@@ -1301,7 +825,7 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1301
825
|
this.moduleSource = moduleSource;
|
|
1302
826
|
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
1303
827
|
log = normalizeLog(log);
|
|
1304
|
-
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
828
|
+
if (pos) require_binding$1.augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
1305
829
|
log.id = moduleId;
|
|
1306
830
|
log.hook = "transform";
|
|
1307
831
|
handler(log);
|
|
@@ -1312,10 +836,10 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1312
836
|
}
|
|
1313
837
|
error(e, pos) {
|
|
1314
838
|
if (typeof e === "string") e = { message: e };
|
|
1315
|
-
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
839
|
+
if (pos) require_binding$1.augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1316
840
|
e.id = this.moduleId;
|
|
1317
841
|
e.hook = "transform";
|
|
1318
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
842
|
+
return require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), this.pluginName));
|
|
1319
843
|
}
|
|
1320
844
|
getCombinedSourcemap() {
|
|
1321
845
|
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
@@ -1324,7 +848,7 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1324
848
|
|
|
1325
849
|
//#endregion
|
|
1326
850
|
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1327
|
-
var import_binding$4 = require_chunk.__toESM(require_binding());
|
|
851
|
+
var import_binding$4 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1328
852
|
function bindingifyPluginHookMeta(options) {
|
|
1329
853
|
return { order: bindingPluginOrder(options.order) };
|
|
1330
854
|
}
|
|
@@ -1925,7 +1449,7 @@ function wrapHandlers(plugin) {
|
|
|
1925
1449
|
try {
|
|
1926
1450
|
return await handler(...args);
|
|
1927
1451
|
} catch (e) {
|
|
1928
|
-
return error(logPluginError(e, plugin.name, {
|
|
1452
|
+
return require_binding$1.error(require_binding$1.logPluginError(e, plugin.name, {
|
|
1929
1453
|
hook: hookName,
|
|
1930
1454
|
id: hookName === "transform" ? args[2] : undefined
|
|
1931
1455
|
}));
|
|
@@ -1995,7 +1519,7 @@ function normalizedStringOrRegex(pattern) {
|
|
|
1995
1519
|
|
|
1996
1520
|
//#endregion
|
|
1997
1521
|
//#region src/utils/bindingify-input-options.ts
|
|
1998
|
-
var import_binding$3 = require_chunk.__toESM(require_binding());
|
|
1522
|
+
var import_binding$3 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1999
1523
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog, logLevel) {
|
|
2000
1524
|
const pluginContextData = new PluginContextData();
|
|
2001
1525
|
const plugins = rawPlugins.map((plugin) => {
|
|
@@ -2566,7 +2090,7 @@ function composeJsPlugins(plugins) {
|
|
|
2566
2090
|
|
|
2567
2091
|
//#endregion
|
|
2568
2092
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
2569
|
-
var import_binding$2 = require_chunk.__toESM(require_binding());
|
|
2093
|
+
var import_binding$2 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
2570
2094
|
async function initializeParallelPlugins(plugins) {
|
|
2571
2095
|
const pluginInfos = [];
|
|
2572
2096
|
for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
|
|
@@ -2617,83 +2141,6 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
|
2617
2141
|
}
|
|
2618
2142
|
}
|
|
2619
2143
|
|
|
2620
|
-
//#endregion
|
|
2621
|
-
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
2622
|
-
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
2623
|
-
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
2624
|
-
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
2625
|
-
const isWindows = platform === "win32";
|
|
2626
|
-
const isDumbTerminal = env$1.TERM === "dumb";
|
|
2627
|
-
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
2628
|
-
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
2629
|
-
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
2630
|
-
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
2631
|
-
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
2632
|
-
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
2633
|
-
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
2634
|
-
const colors$1 = {
|
|
2635
|
-
reset: init(0, 0),
|
|
2636
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
2637
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
2638
|
-
italic: init(3, 23),
|
|
2639
|
-
underline: init(4, 24),
|
|
2640
|
-
inverse: init(7, 27),
|
|
2641
|
-
hidden: init(8, 28),
|
|
2642
|
-
strikethrough: init(9, 29),
|
|
2643
|
-
black: init(30, 39),
|
|
2644
|
-
red: init(31, 39),
|
|
2645
|
-
green: init(32, 39),
|
|
2646
|
-
yellow: init(33, 39),
|
|
2647
|
-
blue: init(34, 39),
|
|
2648
|
-
magenta: init(35, 39),
|
|
2649
|
-
cyan: init(36, 39),
|
|
2650
|
-
white: init(37, 39),
|
|
2651
|
-
gray: init(90, 39),
|
|
2652
|
-
bgBlack: init(40, 49),
|
|
2653
|
-
bgRed: init(41, 49),
|
|
2654
|
-
bgGreen: init(42, 49),
|
|
2655
|
-
bgYellow: init(43, 49),
|
|
2656
|
-
bgBlue: init(44, 49),
|
|
2657
|
-
bgMagenta: init(45, 49),
|
|
2658
|
-
bgCyan: init(46, 49),
|
|
2659
|
-
bgWhite: init(47, 49),
|
|
2660
|
-
blackBright: init(90, 39),
|
|
2661
|
-
redBright: init(91, 39),
|
|
2662
|
-
greenBright: init(92, 39),
|
|
2663
|
-
yellowBright: init(93, 39),
|
|
2664
|
-
blueBright: init(94, 39),
|
|
2665
|
-
magentaBright: init(95, 39),
|
|
2666
|
-
cyanBright: init(96, 39),
|
|
2667
|
-
whiteBright: init(97, 39),
|
|
2668
|
-
bgBlackBright: init(100, 49),
|
|
2669
|
-
bgRedBright: init(101, 49),
|
|
2670
|
-
bgGreenBright: init(102, 49),
|
|
2671
|
-
bgYellowBright: init(103, 49),
|
|
2672
|
-
bgBlueBright: init(104, 49),
|
|
2673
|
-
bgMagentaBright: init(105, 49),
|
|
2674
|
-
bgCyanBright: init(106, 49),
|
|
2675
|
-
bgWhiteBright: init(107, 49)
|
|
2676
|
-
};
|
|
2677
|
-
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
2678
|
-
...colors$2,
|
|
2679
|
-
[key]: String
|
|
2680
|
-
}), {});
|
|
2681
|
-
const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
2682
|
-
|
|
2683
|
-
//#endregion
|
|
2684
|
-
//#region src/cli/colors.ts
|
|
2685
|
-
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
|
|
2686
|
-
const colors = {
|
|
2687
|
-
bold,
|
|
2688
|
-
cyan,
|
|
2689
|
-
dim,
|
|
2690
|
-
gray,
|
|
2691
|
-
green,
|
|
2692
|
-
red,
|
|
2693
|
-
underline,
|
|
2694
|
-
yellow
|
|
2695
|
-
};
|
|
2696
|
-
|
|
2697
2144
|
//#endregion
|
|
2698
2145
|
//#region src/utils/validator.ts
|
|
2699
2146
|
const StringOrRegExpSchema = valibot.union([valibot.string(), valibot.instance(RegExp)]);
|
|
@@ -2783,10 +2230,10 @@ const InputOptionsSchema = valibot.strictObject({
|
|
|
2783
2230
|
valibot.literal("browser"),
|
|
2784
2231
|
valibot.literal("neutral"),
|
|
2785
2232
|
valibot.literal("node")
|
|
2786
|
-
])), valibot.description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
|
|
2233
|
+
])), valibot.description(`Platform for which the code should be generated (node, ${require_binding$1.colors.underline("browser")}, neutral)`)),
|
|
2787
2234
|
shimMissingExports: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Create shim variables for missing exports")),
|
|
2788
2235
|
treeshake: valibot.optional(TreeshakingOptionsSchema),
|
|
2789
|
-
logLevel: valibot.pipe(valibot.optional(LogLevelOptionSchema), valibot.description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
|
|
2236
|
+
logLevel: valibot.pipe(valibot.optional(LogLevelOptionSchema), valibot.description(`Log level (${require_binding$1.colors.dim("silent")}, ${require_binding$1.colors.underline(require_binding$1.colors.gray("info"))}, debug, ${require_binding$1.colors.yellow("warn")})`)),
|
|
2790
2237
|
onLog: valibot.optional(OnLogSchema),
|
|
2791
2238
|
onwarn: valibot.optional(OnwarnSchema),
|
|
2792
2239
|
moduleTypes: valibot.pipe(valibot.optional(ModuleTypesSchema), valibot.description("Module types for customized extensions")),
|
|
@@ -2868,18 +2315,18 @@ const OutputOptionsSchema = valibot.strictObject({
|
|
|
2868
2315
|
valibot.literal("named"),
|
|
2869
2316
|
valibot.literal("default"),
|
|
2870
2317
|
valibot.literal("none")
|
|
2871
|
-
])), valibot.description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
|
|
2318
|
+
])), valibot.description(`Specify a export mode (${require_binding$1.colors.underline("auto")}, named, default, none)`)),
|
|
2872
2319
|
hashCharacters: valibot.pipe(valibot.optional(valibot.union([
|
|
2873
2320
|
valibot.literal("base64"),
|
|
2874
2321
|
valibot.literal("base36"),
|
|
2875
2322
|
valibot.literal("hex")
|
|
2876
2323
|
])), valibot.description("Use the specified character set for file hashes")),
|
|
2877
|
-
format: valibot.pipe(valibot.optional(ModuleFormatSchema), valibot.description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
|
|
2324
|
+
format: valibot.pipe(valibot.optional(ModuleFormatSchema), valibot.description(`Output format of the generated bundle (supports ${require_binding$1.colors.underline("esm")}, cjs, and iife)`)),
|
|
2878
2325
|
sourcemap: valibot.pipe(valibot.optional(valibot.union([
|
|
2879
2326
|
valibot.boolean(),
|
|
2880
2327
|
valibot.literal("inline"),
|
|
2881
2328
|
valibot.literal("hidden")
|
|
2882
|
-
])), valibot.description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
2329
|
+
])), valibot.description(`Generate sourcemap (\`-s inline\` for inline, or ${require_binding$1.colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
2883
2330
|
sourcemapIgnoreList: valibot.optional(valibot.union([valibot.boolean(), valibot.custom(() => true)])),
|
|
2884
2331
|
sourcemapPathTransform: valibot.optional(valibot.custom(() => true)),
|
|
2885
2332
|
banner: valibot.optional(valibot.union([valibot.string(), AddonFunctionSchema])),
|
|
@@ -2903,7 +2350,7 @@ const OutputOptionsSchema = valibot.strictObject({
|
|
|
2903
2350
|
target: valibot.pipe(valibot.optional(valibot.enum(ESTarget)), valibot.description("The JavaScript target environment"))
|
|
2904
2351
|
});
|
|
2905
2352
|
const getAddonDescription = (placement, wrapper) => {
|
|
2906
|
-
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
2353
|
+
return `Code to insert the ${require_binding$1.colors.bold(placement)} of the bundled file (${require_binding$1.colors.bold(wrapper)} the wrapper function)`;
|
|
2907
2354
|
};
|
|
2908
2355
|
const OutputCliOverrideSchema = valibot.strictObject({
|
|
2909
2356
|
entryFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for emitted entry chunks")),
|
|
@@ -2953,15 +2400,13 @@ function getJsonSchema() {
|
|
|
2953
2400
|
//#endregion
|
|
2954
2401
|
//#region src/utils/create-bundler-option.ts
|
|
2955
2402
|
async function createBundlerOptions(inputOptions, outputOptions) {
|
|
2956
|
-
const pluginDriver = new PluginDriver();
|
|
2957
|
-
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2958
2403
|
if (inputOptions.treeshake !== undefined) validateTreeShakingOptions(inputOptions.treeshake);
|
|
2959
2404
|
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
2960
2405
|
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2961
2406
|
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2962
2407
|
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
2963
|
-
outputOptions =
|
|
2964
|
-
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
|
|
2408
|
+
outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
|
|
2409
|
+
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, require_binding$1.logMinifyWarning());
|
|
2965
2410
|
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
2966
2411
|
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
2967
2412
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
@@ -2986,7 +2431,7 @@ async function createBundlerOptions(inputOptions, outputOptions) {
|
|
|
2986
2431
|
|
|
2987
2432
|
//#endregion
|
|
2988
2433
|
//#region src/utils/create-bundler.ts
|
|
2989
|
-
var import_binding$1 = require_chunk.__toESM(require_binding());
|
|
2434
|
+
var import_binding$1 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
2990
2435
|
async function createBundler(inputOptions, outputOptions) {
|
|
2991
2436
|
const option = await createBundlerOptions(inputOptions, outputOptions);
|
|
2992
2437
|
try {
|
|
@@ -3039,7 +2484,8 @@ var RolldownBuild = class {
|
|
|
3039
2484
|
//#endregion
|
|
3040
2485
|
//#region src/api/rolldown/index.ts
|
|
3041
2486
|
const rolldown = async (input) => {
|
|
3042
|
-
|
|
2487
|
+
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
2488
|
+
return new RolldownBuild(inputOptions);
|
|
3043
2489
|
};
|
|
3044
2490
|
|
|
3045
2491
|
//#endregion
|
|
@@ -3108,7 +2554,7 @@ var WatcherEmitter = class {
|
|
|
3108
2554
|
|
|
3109
2555
|
//#endregion
|
|
3110
2556
|
//#region src/api/watch/watcher.ts
|
|
3111
|
-
var import_binding = require_chunk.__toESM(require_binding());
|
|
2557
|
+
var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
|
|
3112
2558
|
var Watcher = class {
|
|
3113
2559
|
closed;
|
|
3114
2560
|
inner;
|
|
@@ -3137,7 +2583,10 @@ var Watcher = class {
|
|
|
3137
2583
|
};
|
|
3138
2584
|
async function createWatcher(emitter, input) {
|
|
3139
2585
|
const options = arraify(input);
|
|
3140
|
-
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map((output) =>
|
|
2586
|
+
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
2587
|
+
const inputOptions = await PluginDriver.callOptionsHook(option);
|
|
2588
|
+
return createBundlerOptions(inputOptions, output);
|
|
2589
|
+
})).flat());
|
|
3141
2590
|
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
3142
2591
|
const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
3143
2592
|
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
@@ -3148,7 +2597,7 @@ function getValidNotifyOption(bundlerOptions) {
|
|
|
3148
2597
|
for (const option of bundlerOptions) if (option.inputOptions.watch) {
|
|
3149
2598
|
const notifyOption = option.inputOptions.watch.notify;
|
|
3150
2599
|
if (notifyOption) if (result) {
|
|
3151
|
-
option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
|
|
2600
|
+
option.onLog(LOG_LEVEL_WARN, require_binding$1.logMultiplyNotifyOption());
|
|
3152
2601
|
return result;
|
|
3153
2602
|
} else result = notifyOption;
|
|
3154
2603
|
}
|
|
@@ -3164,7 +2613,7 @@ const watch = (input) => {
|
|
|
3164
2613
|
|
|
3165
2614
|
//#endregion
|
|
3166
2615
|
//#region package.json
|
|
3167
|
-
var version = "1.0.0-beta.1-commit.
|
|
2616
|
+
var version = "1.0.0-beta.1-commit.298dd8b";
|
|
3168
2617
|
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
3169
2618
|
|
|
3170
2619
|
//#endregion
|
|
@@ -3230,12 +2679,6 @@ Object.defineProperty(exports, 'buildImportAnalysisPlugin', {
|
|
|
3230
2679
|
return buildImportAnalysisPlugin;
|
|
3231
2680
|
}
|
|
3232
2681
|
});
|
|
3233
|
-
Object.defineProperty(exports, 'colors', {
|
|
3234
|
-
enumerable: true,
|
|
3235
|
-
get: function () {
|
|
3236
|
-
return colors;
|
|
3237
|
-
}
|
|
3238
|
-
});
|
|
3239
2682
|
Object.defineProperty(exports, 'composeJsPlugins', {
|
|
3240
2683
|
enumerable: true,
|
|
3241
2684
|
get: function () {
|
|
@@ -3314,22 +2757,22 @@ Object.defineProperty(exports, 'manifestPlugin', {
|
|
|
3314
2757
|
return manifestPlugin;
|
|
3315
2758
|
}
|
|
3316
2759
|
});
|
|
3317
|
-
Object.defineProperty(exports, '
|
|
2760
|
+
Object.defineProperty(exports, 'moduleFederationPlugin', {
|
|
3318
2761
|
enumerable: true,
|
|
3319
2762
|
get: function () {
|
|
3320
|
-
return
|
|
2763
|
+
return moduleFederationPlugin;
|
|
3321
2764
|
}
|
|
3322
2765
|
});
|
|
3323
|
-
Object.defineProperty(exports, '
|
|
2766
|
+
Object.defineProperty(exports, 'modulePreloadPolyfillPlugin', {
|
|
3324
2767
|
enumerable: true,
|
|
3325
2768
|
get: function () {
|
|
3326
|
-
return
|
|
2769
|
+
return modulePreloadPolyfillPlugin;
|
|
3327
2770
|
}
|
|
3328
2771
|
});
|
|
3329
|
-
Object.defineProperty(exports, '
|
|
2772
|
+
Object.defineProperty(exports, 'normalizedStringOrRegex', {
|
|
3330
2773
|
enumerable: true,
|
|
3331
2774
|
get: function () {
|
|
3332
|
-
return
|
|
2775
|
+
return normalizedStringOrRegex;
|
|
3333
2776
|
}
|
|
3334
2777
|
});
|
|
3335
2778
|
Object.defineProperty(exports, 'rolldown', {
|