rolldown 1.0.0-beta.1-commit.67a0051 → 1.0.0-beta.1-commit.2fe52d4
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 +24 -25
- package/dist/cjs/experimental-index.cjs +3 -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 +24 -25
- package/dist/esm/experimental-index.mjs +2 -1
- 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-BMSG-hw7.mjs +530 -0
- package/dist/shared/binding-Cw1COxB5.cjs +575 -0
- package/dist/shared/{consola_36c0034f-BBnpcLZ5.cjs → consola_36c0034f-7VQAd79i.cjs} +7 -7
- package/dist/shared/{consola_36c0034f-BwyQ494_.mjs → consola_36c0034f-DJFB73x3.mjs} +7 -7
- package/dist/shared/{prompt-CqEsx-3v.mjs → prompt-CwUxfcCh.mjs} +7 -7
- package/dist/shared/{prompt-BKuli-WV.cjs → prompt-sP1wES-1.cjs} +7 -7
- package/dist/shared/{src-ed8l008o.cjs → src-Dck9jWki.cjs} +405 -890
- package/dist/shared/{src-BvPrj1a4.mjs → src-genj5En-.mjs} +379 -886
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/binding.d.ts +254 -0
- 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 -0
- package/dist/types/plugin/plugin-driver.d.ts +2 -2
- package/package.json +20 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Buffer as Buffer$1 } from "node:buffer";
|
|
1
|
+
import { __toESM, augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, require_binding } from "./binding-BMSG-hw7.mjs";
|
|
3
2
|
import path from "node:path";
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
4
|
import { Worker } from "node:worker_threads";
|
|
5
5
|
import { availableParallelism } from "node:os";
|
|
6
6
|
import * as v from "valibot";
|
|
@@ -8,619 +8,10 @@ import { env } from "node:process";
|
|
|
8
8
|
import * as tty from "tty";
|
|
9
9
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
10
10
|
|
|
11
|
-
//#region
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
-
var __commonJS = (cb, mod) => function() {
|
|
19
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
23
|
-
key = keys[i];
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
25
|
-
get: ((k) => from[k]).bind(null, key),
|
|
26
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return to;
|
|
30
|
-
};
|
|
31
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
32
|
-
value: mod,
|
|
33
|
-
enumerable: true
|
|
34
|
-
}) : target, mod));
|
|
35
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/utils/define-config.ts
|
|
39
|
-
function defineConfig(config) {
|
|
40
|
-
return config;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/utils/asset-source.ts
|
|
45
|
-
function transformAssetSource(bindingAssetSource$1) {
|
|
46
|
-
return bindingAssetSource$1.inner;
|
|
47
|
-
}
|
|
48
|
-
function bindingAssetSource(source) {
|
|
49
|
-
return { inner: source };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/types/sourcemap.ts
|
|
54
|
-
function bindingifySourcemap$1(map) {
|
|
55
|
-
if (map == null) return;
|
|
56
|
-
return { inner: typeof map === "string" ? map : {
|
|
57
|
-
file: map.file ?? undefined,
|
|
58
|
-
mappings: map.mappings,
|
|
59
|
-
sourceRoot: map.sourceRoot,
|
|
60
|
-
sources: map.sources?.map((s) => s ?? undefined),
|
|
61
|
-
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
62
|
-
names: map.names
|
|
63
|
-
} };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/utils/error.ts
|
|
68
|
-
function normalizeErrors(rawErrors) {
|
|
69
|
-
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
70
|
-
kind: e.kind,
|
|
71
|
-
message: e.message,
|
|
72
|
-
stack: undefined
|
|
73
|
-
}));
|
|
74
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
75
|
-
for (let i = 0; i < errors.length; i++) {
|
|
76
|
-
if (i >= 5) {
|
|
77
|
-
summary += "\n...";
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
summary += getErrorMessage(errors[i]) + "\n";
|
|
81
|
-
}
|
|
82
|
-
const wrapper = new Error(summary);
|
|
83
|
-
Object.defineProperty(wrapper, "errors", {
|
|
84
|
-
configurable: true,
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: () => errors,
|
|
87
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
88
|
-
configurable: true,
|
|
89
|
-
enumerable: true,
|
|
90
|
-
value
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
return wrapper;
|
|
94
|
-
}
|
|
95
|
-
function getErrorMessage(e) {
|
|
96
|
-
let s = "";
|
|
97
|
-
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
98
|
-
const id = e.id ?? e.loc?.file;
|
|
99
|
-
if (id) {
|
|
100
|
-
s += " " + id;
|
|
101
|
-
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
102
|
-
}
|
|
103
|
-
if (s) s += "\n";
|
|
104
|
-
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
105
|
-
s += message;
|
|
106
|
-
if (e.frame) s = joinNewLine(s, e.frame);
|
|
107
|
-
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
108
|
-
return s;
|
|
109
|
-
}
|
|
110
|
-
function joinNewLine(s1, s2) {
|
|
111
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/utils/transform-rendered-module.ts
|
|
116
|
-
function transformToRenderedModule(bindingRenderedModule) {
|
|
117
|
-
return {
|
|
118
|
-
get code() {
|
|
119
|
-
return bindingRenderedModule.code;
|
|
120
|
-
},
|
|
121
|
-
get renderedLength() {
|
|
122
|
-
return bindingRenderedModule.code?.length || 0;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/utils/transform-rendered-chunk.ts
|
|
129
|
-
function transformRenderedChunk(chunk) {
|
|
130
|
-
return {
|
|
131
|
-
get name() {
|
|
132
|
-
return chunk.name;
|
|
133
|
-
},
|
|
134
|
-
get isEntry() {
|
|
135
|
-
return chunk.isEntry;
|
|
136
|
-
},
|
|
137
|
-
get isDynamicEntry() {
|
|
138
|
-
return chunk.isDynamicEntry;
|
|
139
|
-
},
|
|
140
|
-
get facadeModuleId() {
|
|
141
|
-
return chunk.facadeModuleId;
|
|
142
|
-
},
|
|
143
|
-
get moduleIds() {
|
|
144
|
-
return chunk.moduleIds;
|
|
145
|
-
},
|
|
146
|
-
get exports() {
|
|
147
|
-
return chunk.exports;
|
|
148
|
-
},
|
|
149
|
-
get fileName() {
|
|
150
|
-
return chunk.fileName;
|
|
151
|
-
},
|
|
152
|
-
get imports() {
|
|
153
|
-
return chunk.imports;
|
|
154
|
-
},
|
|
155
|
-
get dynamicImports() {
|
|
156
|
-
return chunk.dynamicImports;
|
|
157
|
-
},
|
|
158
|
-
get modules() {
|
|
159
|
-
return transformChunkModules(chunk.modules);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function transformChunkModules(modules) {
|
|
164
|
-
const result = {};
|
|
165
|
-
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
166
|
-
let mod = modules.value[index];
|
|
167
|
-
result[id] = transformToRenderedModule(mod);
|
|
168
|
-
}
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
174
|
-
function transformToRollupSourceMap(map) {
|
|
175
|
-
const parsed = JSON.parse(map);
|
|
176
|
-
const obj = {
|
|
177
|
-
...parsed,
|
|
178
|
-
toString() {
|
|
179
|
-
return JSON.stringify(obj);
|
|
180
|
-
},
|
|
181
|
-
toUrl() {
|
|
182
|
-
return `data:application/json;charset=utf-8;base64,${Buffer$1.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
return obj;
|
|
186
|
-
}
|
|
187
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
188
|
-
const chunk = {
|
|
189
|
-
type: "chunk",
|
|
190
|
-
get code() {
|
|
191
|
-
return bindingChunk.code;
|
|
192
|
-
},
|
|
193
|
-
fileName: bindingChunk.fileName,
|
|
194
|
-
name: bindingChunk.name,
|
|
195
|
-
get modules() {
|
|
196
|
-
return transformChunkModules(bindingChunk.modules);
|
|
197
|
-
},
|
|
198
|
-
get imports() {
|
|
199
|
-
return bindingChunk.imports;
|
|
200
|
-
},
|
|
201
|
-
get dynamicImports() {
|
|
202
|
-
return bindingChunk.dynamicImports;
|
|
203
|
-
},
|
|
204
|
-
exports: bindingChunk.exports,
|
|
205
|
-
isEntry: bindingChunk.isEntry,
|
|
206
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
207
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
208
|
-
get moduleIds() {
|
|
209
|
-
return bindingChunk.moduleIds;
|
|
210
|
-
},
|
|
211
|
-
get map() {
|
|
212
|
-
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
213
|
-
},
|
|
214
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
215
|
-
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
216
|
-
};
|
|
217
|
-
const cache = {};
|
|
218
|
-
return new Proxy(chunk, {
|
|
219
|
-
get(target, p) {
|
|
220
|
-
if (p in cache) return cache[p];
|
|
221
|
-
return target[p];
|
|
222
|
-
},
|
|
223
|
-
set(target, p, newValue) {
|
|
224
|
-
cache[p] = newValue;
|
|
225
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
231
|
-
const asset = {
|
|
232
|
-
type: "asset",
|
|
233
|
-
fileName: bindingAsset.fileName,
|
|
234
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
235
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
236
|
-
get source() {
|
|
237
|
-
return transformAssetSource(bindingAsset.source);
|
|
238
|
-
},
|
|
239
|
-
name: bindingAsset.name ?? undefined,
|
|
240
|
-
names: bindingAsset.names
|
|
241
|
-
};
|
|
242
|
-
const cache = {};
|
|
243
|
-
return new Proxy(asset, {
|
|
244
|
-
get(target, p) {
|
|
245
|
-
if (p in cache) return cache[p];
|
|
246
|
-
return target[p];
|
|
247
|
-
},
|
|
248
|
-
set(target, p, newValue) {
|
|
249
|
-
cache[p] = newValue;
|
|
250
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
function transformToRollupOutput(output, changed) {
|
|
256
|
-
handleOutputErrors(output);
|
|
257
|
-
const { chunks, assets } = output;
|
|
258
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
259
|
-
}
|
|
260
|
-
function handleOutputErrors(output) {
|
|
261
|
-
const rawErrors = output.errors;
|
|
262
|
-
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
263
|
-
}
|
|
264
|
-
function transformToOutputBundle(output, changed) {
|
|
265
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
266
|
-
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
267
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
268
|
-
return true;
|
|
269
|
-
} });
|
|
270
|
-
}
|
|
271
|
-
function collectChangedBundle(changed, bundle) {
|
|
272
|
-
const assets = [];
|
|
273
|
-
const chunks = [];
|
|
274
|
-
for (const key in bundle) {
|
|
275
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
276
|
-
const item = bundle[key];
|
|
277
|
-
if (item.type === "asset") assets.push({
|
|
278
|
-
filename: item.fileName,
|
|
279
|
-
originalFileNames: item.originalFileNames,
|
|
280
|
-
source: bindingAssetSource(item.source),
|
|
281
|
-
names: item.names
|
|
282
|
-
});
|
|
283
|
-
else chunks.push({
|
|
284
|
-
code: item.code,
|
|
285
|
-
filename: item.fileName,
|
|
286
|
-
name: item.name,
|
|
287
|
-
isEntry: item.isEntry,
|
|
288
|
-
exports: item.exports,
|
|
289
|
-
modules: {},
|
|
290
|
-
imports: item.imports,
|
|
291
|
-
dynamicImports: item.dynamicImports,
|
|
292
|
-
facadeModuleId: item.facadeModuleId || undefined,
|
|
293
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
294
|
-
moduleIds: item.moduleIds,
|
|
295
|
-
map: bindingifySourcemap$1(item.map),
|
|
296
|
-
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
297
|
-
preliminaryFilename: item.preliminaryFileName
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
return {
|
|
301
|
-
assets,
|
|
302
|
-
chunks,
|
|
303
|
-
deleted: Array.from(changed.deleted)
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/binding.js
|
|
309
|
-
var require_binding = __commonJS({ "src/binding.js"(exports, module) {
|
|
310
|
-
const { createRequire: createRequire$1 } = __require("node:module");
|
|
311
|
-
const { readFileSync } = __require("node:fs");
|
|
312
|
-
let nativeBinding = null;
|
|
313
|
-
const loadErrors = [];
|
|
314
|
-
const isMusl = () => {
|
|
315
|
-
let musl = false;
|
|
316
|
-
if (process.platform === "linux") {
|
|
317
|
-
musl = isMuslFromFilesystem();
|
|
318
|
-
if (musl === null) musl = isMuslFromReport();
|
|
319
|
-
if (musl === null) musl = isMuslFromChildProcess();
|
|
320
|
-
}
|
|
321
|
-
return musl;
|
|
322
|
-
};
|
|
323
|
-
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
324
|
-
const isMuslFromFilesystem = () => {
|
|
325
|
-
try {
|
|
326
|
-
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
327
|
-
} catch {
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
const isMuslFromReport = () => {
|
|
332
|
-
const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
|
|
333
|
-
if (!report) return null;
|
|
334
|
-
if (report.header && report.header.glibcVersionRuntime) return false;
|
|
335
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
336
|
-
if (report.sharedObjects.some(isFileMusl)) return true;
|
|
337
|
-
}
|
|
338
|
-
return false;
|
|
339
|
-
};
|
|
340
|
-
const isMuslFromChildProcess = () => {
|
|
341
|
-
try {
|
|
342
|
-
return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
343
|
-
} catch (e) {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
function requireNative() {
|
|
348
|
-
if (process.platform === "android") if (process.arch === "arm64") {
|
|
349
|
-
try {
|
|
350
|
-
return __require("./rolldown-binding.android-arm64.node");
|
|
351
|
-
} catch (e) {
|
|
352
|
-
loadErrors.push(e);
|
|
353
|
-
}
|
|
354
|
-
try {
|
|
355
|
-
return __require("@rolldown/binding-android-arm64");
|
|
356
|
-
} catch (e) {
|
|
357
|
-
loadErrors.push(e);
|
|
358
|
-
}
|
|
359
|
-
} else if (process.arch === "arm") {
|
|
360
|
-
try {
|
|
361
|
-
return __require("./rolldown-binding.android-arm-eabi.node");
|
|
362
|
-
} catch (e) {
|
|
363
|
-
loadErrors.push(e);
|
|
364
|
-
}
|
|
365
|
-
try {
|
|
366
|
-
return __require("@rolldown/binding-android-arm-eabi");
|
|
367
|
-
} catch (e) {
|
|
368
|
-
loadErrors.push(e);
|
|
369
|
-
}
|
|
370
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
371
|
-
else if (process.platform === "win32") if (process.arch === "x64") {
|
|
372
|
-
try {
|
|
373
|
-
return __require("./rolldown-binding.win32-x64-msvc.node");
|
|
374
|
-
} catch (e) {
|
|
375
|
-
loadErrors.push(e);
|
|
376
|
-
}
|
|
377
|
-
try {
|
|
378
|
-
return __require("@rolldown/binding-win32-x64-msvc");
|
|
379
|
-
} catch (e) {
|
|
380
|
-
loadErrors.push(e);
|
|
381
|
-
}
|
|
382
|
-
} else if (process.arch === "ia32") {
|
|
383
|
-
try {
|
|
384
|
-
return __require("./rolldown-binding.win32-ia32-msvc.node");
|
|
385
|
-
} catch (e) {
|
|
386
|
-
loadErrors.push(e);
|
|
387
|
-
}
|
|
388
|
-
try {
|
|
389
|
-
return __require("@rolldown/binding-win32-ia32-msvc");
|
|
390
|
-
} catch (e) {
|
|
391
|
-
loadErrors.push(e);
|
|
392
|
-
}
|
|
393
|
-
} else if (process.arch === "arm64") {
|
|
394
|
-
try {
|
|
395
|
-
return __require("./rolldown-binding.win32-arm64-msvc.node");
|
|
396
|
-
} catch (e) {
|
|
397
|
-
loadErrors.push(e);
|
|
398
|
-
}
|
|
399
|
-
try {
|
|
400
|
-
return __require("@rolldown/binding-win32-arm64-msvc");
|
|
401
|
-
} catch (e) {
|
|
402
|
-
loadErrors.push(e);
|
|
403
|
-
}
|
|
404
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
405
|
-
else if (process.platform === "darwin") {
|
|
406
|
-
try {
|
|
407
|
-
return __require("./rolldown-binding.darwin-universal.node");
|
|
408
|
-
} catch (e) {
|
|
409
|
-
loadErrors.push(e);
|
|
410
|
-
}
|
|
411
|
-
try {
|
|
412
|
-
return __require("@rolldown/binding-darwin-universal");
|
|
413
|
-
} catch (e) {
|
|
414
|
-
loadErrors.push(e);
|
|
415
|
-
}
|
|
416
|
-
if (process.arch === "x64") {
|
|
417
|
-
try {
|
|
418
|
-
return __require("./rolldown-binding.darwin-x64.node");
|
|
419
|
-
} catch (e) {
|
|
420
|
-
loadErrors.push(e);
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
return __require("@rolldown/binding-darwin-x64");
|
|
424
|
-
} catch (e) {
|
|
425
|
-
loadErrors.push(e);
|
|
426
|
-
}
|
|
427
|
-
} else if (process.arch === "arm64") {
|
|
428
|
-
try {
|
|
429
|
-
return __require("./rolldown-binding.darwin-arm64.node");
|
|
430
|
-
} catch (e) {
|
|
431
|
-
loadErrors.push(e);
|
|
432
|
-
}
|
|
433
|
-
try {
|
|
434
|
-
return __require("@rolldown/binding-darwin-arm64");
|
|
435
|
-
} catch (e) {
|
|
436
|
-
loadErrors.push(e);
|
|
437
|
-
}
|
|
438
|
-
} else loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
439
|
-
} else if (process.platform === "freebsd") if (process.arch === "x64") {
|
|
440
|
-
try {
|
|
441
|
-
return __require("./rolldown-binding.freebsd-x64.node");
|
|
442
|
-
} catch (e) {
|
|
443
|
-
loadErrors.push(e);
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
return __require("@rolldown/binding-freebsd-x64");
|
|
447
|
-
} catch (e) {
|
|
448
|
-
loadErrors.push(e);
|
|
449
|
-
}
|
|
450
|
-
} else if (process.arch === "arm64") {
|
|
451
|
-
try {
|
|
452
|
-
return __require("./rolldown-binding.freebsd-arm64.node");
|
|
453
|
-
} catch (e) {
|
|
454
|
-
loadErrors.push(e);
|
|
455
|
-
}
|
|
456
|
-
try {
|
|
457
|
-
return __require("@rolldown/binding-freebsd-arm64");
|
|
458
|
-
} catch (e) {
|
|
459
|
-
loadErrors.push(e);
|
|
460
|
-
}
|
|
461
|
-
} else loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
462
|
-
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
|
|
463
|
-
try {
|
|
464
|
-
return __require("./rolldown-binding.linux-x64-musl.node");
|
|
465
|
-
} catch (e) {
|
|
466
|
-
loadErrors.push(e);
|
|
467
|
-
}
|
|
468
|
-
try {
|
|
469
|
-
return __require("@rolldown/binding-linux-x64-musl");
|
|
470
|
-
} catch (e) {
|
|
471
|
-
loadErrors.push(e);
|
|
472
|
-
}
|
|
473
|
-
} else {
|
|
474
|
-
try {
|
|
475
|
-
return __require("./rolldown-binding.linux-x64-gnu.node");
|
|
476
|
-
} catch (e) {
|
|
477
|
-
loadErrors.push(e);
|
|
478
|
-
}
|
|
479
|
-
try {
|
|
480
|
-
return __require("@rolldown/binding-linux-x64-gnu");
|
|
481
|
-
} catch (e) {
|
|
482
|
-
loadErrors.push(e);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
else if (process.arch === "arm64") if (isMusl()) {
|
|
486
|
-
try {
|
|
487
|
-
return __require("./rolldown-binding.linux-arm64-musl.node");
|
|
488
|
-
} catch (e) {
|
|
489
|
-
loadErrors.push(e);
|
|
490
|
-
}
|
|
491
|
-
try {
|
|
492
|
-
return __require("@rolldown/binding-linux-arm64-musl");
|
|
493
|
-
} catch (e) {
|
|
494
|
-
loadErrors.push(e);
|
|
495
|
-
}
|
|
496
|
-
} else {
|
|
497
|
-
try {
|
|
498
|
-
return __require("./rolldown-binding.linux-arm64-gnu.node");
|
|
499
|
-
} catch (e) {
|
|
500
|
-
loadErrors.push(e);
|
|
501
|
-
}
|
|
502
|
-
try {
|
|
503
|
-
return __require("@rolldown/binding-linux-arm64-gnu");
|
|
504
|
-
} catch (e) {
|
|
505
|
-
loadErrors.push(e);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
else if (process.arch === "arm") if (isMusl()) {
|
|
509
|
-
try {
|
|
510
|
-
return __require("./rolldown-binding.linux-arm-musleabihf.node");
|
|
511
|
-
} catch (e) {
|
|
512
|
-
loadErrors.push(e);
|
|
513
|
-
}
|
|
514
|
-
try {
|
|
515
|
-
return __require("@rolldown/binding-linux-arm-musleabihf");
|
|
516
|
-
} catch (e) {
|
|
517
|
-
loadErrors.push(e);
|
|
518
|
-
}
|
|
519
|
-
} else {
|
|
520
|
-
try {
|
|
521
|
-
return __require("./rolldown-binding.linux-arm-gnueabihf.node");
|
|
522
|
-
} catch (e) {
|
|
523
|
-
loadErrors.push(e);
|
|
524
|
-
}
|
|
525
|
-
try {
|
|
526
|
-
return __require("@rolldown/binding-linux-arm-gnueabihf");
|
|
527
|
-
} catch (e) {
|
|
528
|
-
loadErrors.push(e);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
else if (process.arch === "riscv64") if (isMusl()) {
|
|
532
|
-
try {
|
|
533
|
-
return __require("./rolldown-binding.linux-riscv64-musl.node");
|
|
534
|
-
} catch (e) {
|
|
535
|
-
loadErrors.push(e);
|
|
536
|
-
}
|
|
537
|
-
try {
|
|
538
|
-
return __require("@rolldown/binding-linux-riscv64-musl");
|
|
539
|
-
} catch (e) {
|
|
540
|
-
loadErrors.push(e);
|
|
541
|
-
}
|
|
542
|
-
} else {
|
|
543
|
-
try {
|
|
544
|
-
return __require("./rolldown-binding.linux-riscv64-gnu.node");
|
|
545
|
-
} catch (e) {
|
|
546
|
-
loadErrors.push(e);
|
|
547
|
-
}
|
|
548
|
-
try {
|
|
549
|
-
return __require("@rolldown/binding-linux-riscv64-gnu");
|
|
550
|
-
} catch (e) {
|
|
551
|
-
loadErrors.push(e);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
else if (process.arch === "ppc64") {
|
|
555
|
-
try {
|
|
556
|
-
return __require("./rolldown-binding.linux-ppc64-gnu.node");
|
|
557
|
-
} catch (e) {
|
|
558
|
-
loadErrors.push(e);
|
|
559
|
-
}
|
|
560
|
-
try {
|
|
561
|
-
return __require("@rolldown/binding-linux-ppc64-gnu");
|
|
562
|
-
} catch (e) {
|
|
563
|
-
loadErrors.push(e);
|
|
564
|
-
}
|
|
565
|
-
} else if (process.arch === "s390x") {
|
|
566
|
-
try {
|
|
567
|
-
return __require("./rolldown-binding.linux-s390x-gnu.node");
|
|
568
|
-
} catch (e) {
|
|
569
|
-
loadErrors.push(e);
|
|
570
|
-
}
|
|
571
|
-
try {
|
|
572
|
-
return __require("@rolldown/binding-linux-s390x-gnu");
|
|
573
|
-
} catch (e) {
|
|
574
|
-
loadErrors.push(e);
|
|
575
|
-
}
|
|
576
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
577
|
-
else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
578
|
-
}
|
|
579
|
-
nativeBinding = requireNative();
|
|
580
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
581
|
-
try {
|
|
582
|
-
nativeBinding = __require("./rolldown-binding.wasi.cjs");
|
|
583
|
-
} catch (err) {
|
|
584
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
585
|
-
}
|
|
586
|
-
if (!nativeBinding) try {
|
|
587
|
-
nativeBinding = __require("@rolldown/binding-wasm32-wasi");
|
|
588
|
-
} catch (err) {
|
|
589
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (!nativeBinding) {
|
|
593
|
-
if (loadErrors.length > 0) throw new Error("Failed to load native binding", { cause: loadErrors });
|
|
594
|
-
throw new Error(`Failed to load native binding`);
|
|
595
|
-
}
|
|
596
|
-
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
|
|
597
|
-
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
|
|
598
|
-
module.exports.BindingError = nativeBinding.BindingError;
|
|
599
|
-
module.exports.BindingLog = nativeBinding.BindingLog;
|
|
600
|
-
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
|
|
601
|
-
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
|
|
602
|
-
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
|
|
603
|
-
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
|
|
604
|
-
module.exports.BindingOutputs = nativeBinding.BindingOutputs;
|
|
605
|
-
module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
|
|
606
|
-
module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
|
|
607
|
-
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
|
|
608
|
-
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
|
|
609
|
-
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
|
|
610
|
-
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
611
|
-
module.exports.Bundler = nativeBinding.Bundler;
|
|
612
|
-
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
|
|
613
|
-
module.exports.RenderedChunk = nativeBinding.RenderedChunk;
|
|
614
|
-
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
615
|
-
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
616
|
-
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
617
|
-
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
618
|
-
module.exports.HelperMode = nativeBinding.HelperMode;
|
|
619
|
-
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
620
|
-
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
621
|
-
module.exports.Severity = nativeBinding.Severity;
|
|
622
|
-
module.exports.transform = nativeBinding.transform;
|
|
623
|
-
} });
|
|
11
|
+
//#region src/utils/define-config.ts
|
|
12
|
+
function defineConfig(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
624
15
|
|
|
625
16
|
//#endregion
|
|
626
17
|
//#region src/utils/misc.ts
|
|
@@ -657,173 +48,6 @@ const logLevelPriority = {
|
|
|
657
48
|
[LOG_LEVEL_SILENT]: 3
|
|
658
49
|
};
|
|
659
50
|
|
|
660
|
-
//#endregion
|
|
661
|
-
//#region src/utils/code-frame.ts
|
|
662
|
-
function spaces(index) {
|
|
663
|
-
let result = "";
|
|
664
|
-
while (index--) result += " ";
|
|
665
|
-
return result;
|
|
666
|
-
}
|
|
667
|
-
function tabsToSpaces(value) {
|
|
668
|
-
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
669
|
-
}
|
|
670
|
-
const LINE_TRUNCATE_LENGTH = 120;
|
|
671
|
-
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
672
|
-
const ELLIPSIS = "...";
|
|
673
|
-
function getCodeFrame(source, line, column) {
|
|
674
|
-
let lines = source.split("\n");
|
|
675
|
-
if (line > lines.length) return "";
|
|
676
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
|
|
677
|
-
const frameStart = Math.max(0, line - 3);
|
|
678
|
-
let frameEnd = Math.min(line + 2, lines.length);
|
|
679
|
-
lines = lines.slice(frameStart, frameEnd);
|
|
680
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
681
|
-
lines.pop();
|
|
682
|
-
frameEnd -= 1;
|
|
683
|
-
}
|
|
684
|
-
const digits = String(frameEnd).length;
|
|
685
|
-
return lines.map((sourceLine, index) => {
|
|
686
|
-
const isErrorLine = frameStart + index + 1 === line;
|
|
687
|
-
let lineNumber = String(index + frameStart + 1);
|
|
688
|
-
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
689
|
-
let displayedLine = tabsToSpaces(sourceLine);
|
|
690
|
-
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
691
|
-
if (isErrorLine) {
|
|
692
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
693
|
-
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
694
|
-
}
|
|
695
|
-
return `${lineNumber}: ${displayedLine}`;
|
|
696
|
-
}).join("\n");
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
//#endregion
|
|
700
|
-
//#region src/log/locate-character/index.js
|
|
701
|
-
/** @typedef {import('./types').Location} Location */
|
|
702
|
-
/**
|
|
703
|
-
* @param {import('./types').Range} range
|
|
704
|
-
* @param {number} index
|
|
705
|
-
*/
|
|
706
|
-
function rangeContains(range, index) {
|
|
707
|
-
return range.start <= index && index < range.end;
|
|
708
|
-
}
|
|
709
|
-
function getLocator(source, options = {}) {
|
|
710
|
-
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
711
|
-
let start = 0;
|
|
712
|
-
const ranges = source.split("\n").map((line, i$1) => {
|
|
713
|
-
const end = start + line.length + 1;
|
|
714
|
-
/** @type {import('./types').Range} */
|
|
715
|
-
const range = {
|
|
716
|
-
start,
|
|
717
|
-
end,
|
|
718
|
-
line: i$1
|
|
719
|
-
};
|
|
720
|
-
start = end;
|
|
721
|
-
return range;
|
|
722
|
-
});
|
|
723
|
-
let i = 0;
|
|
724
|
-
/**
|
|
725
|
-
* @param {string | number} search
|
|
726
|
-
* @param {number} [index]
|
|
727
|
-
* @returns {Location | undefined}
|
|
728
|
-
*/
|
|
729
|
-
function locator(search, index) {
|
|
730
|
-
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
731
|
-
if (search === -1) return undefined;
|
|
732
|
-
let range = ranges[i];
|
|
733
|
-
const d = search >= range.end ? 1 : -1;
|
|
734
|
-
while (range) {
|
|
735
|
-
if (rangeContains(range, search)) return {
|
|
736
|
-
line: offsetLine + range.line,
|
|
737
|
-
column: offsetColumn + search - range.start,
|
|
738
|
-
character: search
|
|
739
|
-
};
|
|
740
|
-
i += d;
|
|
741
|
-
range = ranges[i];
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return locator;
|
|
745
|
-
}
|
|
746
|
-
function locate(source, search, options) {
|
|
747
|
-
return getLocator(source, options)(search, options && options.startIndex);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region src/log/logs.ts
|
|
752
|
-
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";
|
|
753
|
-
function logMinifyWarning() {
|
|
754
|
-
return {
|
|
755
|
-
code: MINIFY_WARNING,
|
|
756
|
-
message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
function logInvalidLogPosition(pluginName) {
|
|
760
|
-
return {
|
|
761
|
-
code: INVALID_LOG_POSITION,
|
|
762
|
-
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.`
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
766
|
-
return {
|
|
767
|
-
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
768
|
-
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.`
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
function logCycleLoading(pluginName, moduleId) {
|
|
772
|
-
return {
|
|
773
|
-
code: CYCLE_LOADING,
|
|
774
|
-
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
function logMultiplyNotifyOption() {
|
|
778
|
-
return {
|
|
779
|
-
code: MULTIPLY_NOTIFY_OPTION,
|
|
780
|
-
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
784
|
-
const code = error$1.code;
|
|
785
|
-
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
786
|
-
error$1.code = PLUGIN_ERROR;
|
|
787
|
-
error$1.plugin = plugin;
|
|
788
|
-
if (hook) error$1.hook = hook;
|
|
789
|
-
if (id) error$1.id = id;
|
|
790
|
-
return error$1;
|
|
791
|
-
}
|
|
792
|
-
function error(base) {
|
|
793
|
-
if (!(base instanceof Error)) {
|
|
794
|
-
base = Object.assign(new Error(base.message), base);
|
|
795
|
-
Object.defineProperty(base, "name", {
|
|
796
|
-
value: "RollupError",
|
|
797
|
-
writable: true
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
throw base;
|
|
801
|
-
}
|
|
802
|
-
function augmentCodeLocation(properties, pos, source, id) {
|
|
803
|
-
if (typeof pos === "object") {
|
|
804
|
-
const { line, column } = pos;
|
|
805
|
-
properties.loc = {
|
|
806
|
-
column,
|
|
807
|
-
file: id,
|
|
808
|
-
line
|
|
809
|
-
};
|
|
810
|
-
} else {
|
|
811
|
-
properties.pos = pos;
|
|
812
|
-
const location = locate(source, pos, { offsetLine: 1 });
|
|
813
|
-
if (!location) return;
|
|
814
|
-
const { line, column } = location;
|
|
815
|
-
properties.loc = {
|
|
816
|
-
column,
|
|
817
|
-
file: id,
|
|
818
|
-
line
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
if (properties.frame === undefined) {
|
|
822
|
-
const { line, column } = properties.loc;
|
|
823
|
-
properties.frame = getCodeFrame(source, line, column);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
|
|
827
51
|
//#endregion
|
|
828
52
|
//#region src/log/logHandler.ts
|
|
829
53
|
const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
@@ -906,7 +130,7 @@ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
|
906
130
|
};
|
|
907
131
|
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
908
132
|
if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
909
|
-
else printLog(level, log);
|
|
133
|
+
else printLog(level, log);
|
|
910
134
|
} : printLog;
|
|
911
135
|
const addLogToString = (log) => {
|
|
912
136
|
Object.defineProperty(log, "toString", {
|
|
@@ -1000,7 +224,7 @@ function viteResolvePlugin(config) {
|
|
|
1000
224
|
//#endregion
|
|
1001
225
|
//#region src/utils/async-flatten.ts
|
|
1002
226
|
async function asyncFlatten(array) {
|
|
1003
|
-
do
|
|
227
|
+
do
|
|
1004
228
|
array = (await Promise.all(array)).flat(Infinity);
|
|
1005
229
|
while (array.some((v$1) => v$1?.then));
|
|
1006
230
|
return array;
|
|
@@ -1066,101 +290,365 @@ const DEFINED_HOOK_NAMES = {
|
|
|
1066
290
|
};
|
|
1067
291
|
|
|
1068
292
|
//#endregion
|
|
1069
|
-
//#region src/utils/normalize-plugin-option.ts
|
|
1070
|
-
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
1071
|
-
function checkOutputPluginOption(plugins, onLog) {
|
|
1072
|
-
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
1073
|
-
delete plugin[hook];
|
|
1074
|
-
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
|
|
1075
|
-
}
|
|
1076
|
-
return plugins;
|
|
293
|
+
//#region src/utils/normalize-plugin-option.ts
|
|
294
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
295
|
+
function checkOutputPluginOption(plugins, onLog) {
|
|
296
|
+
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
297
|
+
delete plugin[hook];
|
|
298
|
+
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
|
|
299
|
+
}
|
|
300
|
+
return plugins;
|
|
301
|
+
}
|
|
302
|
+
function normalizePlugins(plugins, anonymousPrefix) {
|
|
303
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
304
|
+
if ("_parallel" in plugin) continue;
|
|
305
|
+
if (plugin instanceof BuiltinPlugin) continue;
|
|
306
|
+
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
|
|
307
|
+
}
|
|
308
|
+
return plugins;
|
|
309
|
+
}
|
|
310
|
+
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
311
|
+
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
312
|
+
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/plugin/plugin-driver.ts
|
|
315
|
+
var PluginDriver = class {
|
|
316
|
+
static async callOptionsHook(inputOptions) {
|
|
317
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
318
|
+
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
319
|
+
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
|
|
320
|
+
for (const plugin of plugins) {
|
|
321
|
+
const name = plugin.name || "unknown";
|
|
322
|
+
const options = plugin.options;
|
|
323
|
+
if (options) {
|
|
324
|
+
const { handler } = normalizeHook(options);
|
|
325
|
+
const result = await handler.call({
|
|
326
|
+
debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
|
|
327
|
+
error: (e) => error(logPluginError(normalizeLog(e), name, { hook: "onLog" })),
|
|
328
|
+
info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
|
|
329
|
+
meta: {
|
|
330
|
+
rollupVersion: "4.23.0",
|
|
331
|
+
rolldownVersion: VERSION,
|
|
332
|
+
watchMode: false
|
|
333
|
+
},
|
|
334
|
+
warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
|
|
335
|
+
pluginName: name
|
|
336
|
+
}, inputOptions);
|
|
337
|
+
if (result) inputOptions = result;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return inputOptions;
|
|
341
|
+
}
|
|
342
|
+
static callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
343
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
344
|
+
for (const plugin of sortedPlugins) {
|
|
345
|
+
const options = plugin.outputOptions;
|
|
346
|
+
if (options) {
|
|
347
|
+
const { handler } = normalizeHook(options);
|
|
348
|
+
const result = handler.call(null, outputOptions);
|
|
349
|
+
if (result) outputOptions = result;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return outputOptions;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
function getObjectPlugins(plugins) {
|
|
356
|
+
return plugins.filter((plugin) => {
|
|
357
|
+
if (!plugin) return undefined;
|
|
358
|
+
if ("_parallel" in plugin) return undefined;
|
|
359
|
+
if (plugin instanceof BuiltinPlugin) return undefined;
|
|
360
|
+
return plugin;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function getSortedPlugins(hookName, plugins) {
|
|
364
|
+
const pre = [];
|
|
365
|
+
const normal = [];
|
|
366
|
+
const post = [];
|
|
367
|
+
for (const plugin of plugins) {
|
|
368
|
+
const hook = plugin[hookName];
|
|
369
|
+
if (hook) {
|
|
370
|
+
if (typeof hook === "object") {
|
|
371
|
+
if (hook.order === "pre") {
|
|
372
|
+
pre.push(plugin);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (hook.order === "post") {
|
|
376
|
+
post.push(plugin);
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
normal.push(plugin);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return [
|
|
384
|
+
...pre,
|
|
385
|
+
...normal,
|
|
386
|
+
...post
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/utils/asset-source.ts
|
|
392
|
+
function transformAssetSource(bindingAssetSource$1) {
|
|
393
|
+
return bindingAssetSource$1.inner;
|
|
394
|
+
}
|
|
395
|
+
function bindingAssetSource(source) {
|
|
396
|
+
return { inner: source };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/types/sourcemap.ts
|
|
401
|
+
function bindingifySourcemap$1(map) {
|
|
402
|
+
if (map == null) return;
|
|
403
|
+
return { inner: typeof map === "string" ? map : {
|
|
404
|
+
file: map.file ?? undefined,
|
|
405
|
+
mappings: map.mappings,
|
|
406
|
+
sourceRoot: map.sourceRoot,
|
|
407
|
+
sources: map.sources?.map((s) => s ?? undefined),
|
|
408
|
+
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
409
|
+
names: map.names
|
|
410
|
+
} };
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/utils/error.ts
|
|
415
|
+
function normalizeErrors(rawErrors) {
|
|
416
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
417
|
+
kind: e.kind,
|
|
418
|
+
message: e.message,
|
|
419
|
+
stack: undefined
|
|
420
|
+
}));
|
|
421
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
422
|
+
for (let i = 0; i < errors.length; i++) {
|
|
423
|
+
if (i >= 5) {
|
|
424
|
+
summary += "\n...";
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
summary += getErrorMessage(errors[i]) + "\n";
|
|
428
|
+
}
|
|
429
|
+
const wrapper = new Error(summary);
|
|
430
|
+
Object.defineProperty(wrapper, "errors", {
|
|
431
|
+
configurable: true,
|
|
432
|
+
enumerable: true,
|
|
433
|
+
get: () => errors,
|
|
434
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
435
|
+
configurable: true,
|
|
436
|
+
enumerable: true,
|
|
437
|
+
value
|
|
438
|
+
})
|
|
439
|
+
});
|
|
440
|
+
return wrapper;
|
|
441
|
+
}
|
|
442
|
+
function getErrorMessage(e) {
|
|
443
|
+
let s = "";
|
|
444
|
+
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
445
|
+
const id = e.id ?? e.loc?.file;
|
|
446
|
+
if (id) {
|
|
447
|
+
s += " " + id;
|
|
448
|
+
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
449
|
+
}
|
|
450
|
+
if (s) s += "\n";
|
|
451
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
452
|
+
s += message;
|
|
453
|
+
if (e.frame) s = joinNewLine(s, e.frame);
|
|
454
|
+
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
455
|
+
return s;
|
|
456
|
+
}
|
|
457
|
+
function joinNewLine(s1, s2) {
|
|
458
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/utils/transform-rendered-module.ts
|
|
463
|
+
function transformToRenderedModule(bindingRenderedModule) {
|
|
464
|
+
return {
|
|
465
|
+
get code() {
|
|
466
|
+
return bindingRenderedModule.code;
|
|
467
|
+
},
|
|
468
|
+
get renderedLength() {
|
|
469
|
+
return bindingRenderedModule.code?.length || 0;
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/utils/transform-rendered-chunk.ts
|
|
476
|
+
function transformRenderedChunk(chunk) {
|
|
477
|
+
return {
|
|
478
|
+
get name() {
|
|
479
|
+
return chunk.name;
|
|
480
|
+
},
|
|
481
|
+
get isEntry() {
|
|
482
|
+
return chunk.isEntry;
|
|
483
|
+
},
|
|
484
|
+
get isDynamicEntry() {
|
|
485
|
+
return chunk.isDynamicEntry;
|
|
486
|
+
},
|
|
487
|
+
get facadeModuleId() {
|
|
488
|
+
return chunk.facadeModuleId;
|
|
489
|
+
},
|
|
490
|
+
get moduleIds() {
|
|
491
|
+
return chunk.moduleIds;
|
|
492
|
+
},
|
|
493
|
+
get exports() {
|
|
494
|
+
return chunk.exports;
|
|
495
|
+
},
|
|
496
|
+
get fileName() {
|
|
497
|
+
return chunk.fileName;
|
|
498
|
+
},
|
|
499
|
+
get imports() {
|
|
500
|
+
return chunk.imports;
|
|
501
|
+
},
|
|
502
|
+
get dynamicImports() {
|
|
503
|
+
return chunk.dynamicImports;
|
|
504
|
+
},
|
|
505
|
+
get modules() {
|
|
506
|
+
return transformChunkModules(chunk.modules);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
1077
509
|
}
|
|
1078
|
-
function
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
510
|
+
function transformChunkModules(modules) {
|
|
511
|
+
const result = {};
|
|
512
|
+
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
513
|
+
let mod = modules.value[index];
|
|
514
|
+
result[id] = transformToRenderedModule(mod);
|
|
1083
515
|
}
|
|
1084
|
-
return
|
|
516
|
+
return result;
|
|
1085
517
|
}
|
|
1086
|
-
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
1087
|
-
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
1088
518
|
|
|
1089
519
|
//#endregion
|
|
1090
|
-
//#region src/
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
const { handler } = normalizeHook(options);
|
|
1101
|
-
const result = await handler.call({
|
|
1102
|
-
debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
|
|
1103
|
-
error: (e) => error(logPluginError(normalizeLog(e), name, { hook: "onLog" })),
|
|
1104
|
-
info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
|
|
1105
|
-
meta: {
|
|
1106
|
-
rollupVersion: "4.23.0",
|
|
1107
|
-
rolldownVersion: VERSION,
|
|
1108
|
-
watchMode: false
|
|
1109
|
-
},
|
|
1110
|
-
warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
|
|
1111
|
-
pluginName: name
|
|
1112
|
-
}, inputOptions);
|
|
1113
|
-
if (result) inputOptions = result;
|
|
1114
|
-
}
|
|
520
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
521
|
+
function transformToRollupSourceMap(map) {
|
|
522
|
+
const parsed = JSON.parse(map);
|
|
523
|
+
const obj = {
|
|
524
|
+
...parsed,
|
|
525
|
+
toString() {
|
|
526
|
+
return JSON.stringify(obj);
|
|
527
|
+
},
|
|
528
|
+
toUrl() {
|
|
529
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
1115
530
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
531
|
+
};
|
|
532
|
+
return obj;
|
|
533
|
+
}
|
|
534
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
535
|
+
const chunk = {
|
|
536
|
+
type: "chunk",
|
|
537
|
+
get code() {
|
|
538
|
+
return bindingChunk.code;
|
|
539
|
+
},
|
|
540
|
+
fileName: bindingChunk.fileName,
|
|
541
|
+
name: bindingChunk.name,
|
|
542
|
+
get modules() {
|
|
543
|
+
return transformChunkModules(bindingChunk.modules);
|
|
544
|
+
},
|
|
545
|
+
get imports() {
|
|
546
|
+
return bindingChunk.imports;
|
|
547
|
+
},
|
|
548
|
+
get dynamicImports() {
|
|
549
|
+
return bindingChunk.dynamicImports;
|
|
550
|
+
},
|
|
551
|
+
exports: bindingChunk.exports,
|
|
552
|
+
isEntry: bindingChunk.isEntry,
|
|
553
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
554
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
555
|
+
get moduleIds() {
|
|
556
|
+
return bindingChunk.moduleIds;
|
|
557
|
+
},
|
|
558
|
+
get map() {
|
|
559
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
560
|
+
},
|
|
561
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
562
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
563
|
+
};
|
|
564
|
+
const cache = {};
|
|
565
|
+
return new Proxy(chunk, {
|
|
566
|
+
get(target, p) {
|
|
567
|
+
if (p in cache) return cache[p];
|
|
568
|
+
return target[p];
|
|
569
|
+
},
|
|
570
|
+
set(target, p, newValue) {
|
|
571
|
+
cache[p] = newValue;
|
|
572
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
573
|
+
return true;
|
|
1127
574
|
}
|
|
1128
|
-
return outputOptions;
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
function getObjectPlugins(plugins) {
|
|
1132
|
-
return plugins.filter((plugin) => {
|
|
1133
|
-
if (!plugin) return undefined;
|
|
1134
|
-
if ("_parallel" in plugin) return undefined;
|
|
1135
|
-
if (plugin instanceof BuiltinPlugin) return undefined;
|
|
1136
|
-
return plugin;
|
|
1137
575
|
});
|
|
1138
576
|
}
|
|
1139
|
-
function
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
577
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
578
|
+
const asset = {
|
|
579
|
+
type: "asset",
|
|
580
|
+
fileName: bindingAsset.fileName,
|
|
581
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
582
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
583
|
+
get source() {
|
|
584
|
+
return transformAssetSource(bindingAsset.source);
|
|
585
|
+
},
|
|
586
|
+
name: bindingAsset.name ?? undefined,
|
|
587
|
+
names: bindingAsset.names
|
|
588
|
+
};
|
|
589
|
+
const cache = {};
|
|
590
|
+
return new Proxy(asset, {
|
|
591
|
+
get(target, p) {
|
|
592
|
+
if (p in cache) return cache[p];
|
|
593
|
+
return target[p];
|
|
594
|
+
},
|
|
595
|
+
set(target, p, newValue) {
|
|
596
|
+
cache[p] = newValue;
|
|
597
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
598
|
+
return true;
|
|
1157
599
|
}
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
function transformToRollupOutput(output, changed) {
|
|
603
|
+
handleOutputErrors(output);
|
|
604
|
+
const { chunks, assets } = output;
|
|
605
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
606
|
+
}
|
|
607
|
+
function handleOutputErrors(output) {
|
|
608
|
+
const rawErrors = output.errors;
|
|
609
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
610
|
+
}
|
|
611
|
+
function transformToOutputBundle(output, changed) {
|
|
612
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
613
|
+
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
614
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
615
|
+
return true;
|
|
616
|
+
} });
|
|
617
|
+
}
|
|
618
|
+
function collectChangedBundle(changed, bundle) {
|
|
619
|
+
const assets = [];
|
|
620
|
+
const chunks = [];
|
|
621
|
+
for (const key in bundle) {
|
|
622
|
+
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
623
|
+
const item = bundle[key];
|
|
624
|
+
if (item.type === "asset") assets.push({
|
|
625
|
+
filename: item.fileName,
|
|
626
|
+
originalFileNames: item.originalFileNames,
|
|
627
|
+
source: bindingAssetSource(item.source),
|
|
628
|
+
names: item.names
|
|
629
|
+
});
|
|
630
|
+
else chunks.push({
|
|
631
|
+
code: item.code,
|
|
632
|
+
filename: item.fileName,
|
|
633
|
+
name: item.name,
|
|
634
|
+
isEntry: item.isEntry,
|
|
635
|
+
exports: item.exports,
|
|
636
|
+
modules: {},
|
|
637
|
+
imports: item.imports,
|
|
638
|
+
dynamicImports: item.dynamicImports,
|
|
639
|
+
facadeModuleId: item.facadeModuleId || undefined,
|
|
640
|
+
isDynamicEntry: item.isDynamicEntry,
|
|
641
|
+
moduleIds: item.moduleIds,
|
|
642
|
+
map: bindingifySourcemap$1(item.map),
|
|
643
|
+
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
644
|
+
preliminaryFilename: item.preliminaryFileName
|
|
645
|
+
});
|
|
1158
646
|
}
|
|
1159
|
-
return
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
647
|
+
return {
|
|
648
|
+
assets,
|
|
649
|
+
chunks,
|
|
650
|
+
deleted: Array.from(changed.deleted)
|
|
651
|
+
};
|
|
1164
652
|
}
|
|
1165
653
|
|
|
1166
654
|
//#endregion
|
|
@@ -1297,6 +785,9 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1297
785
|
source: bindingAssetSource(file.source)
|
|
1298
786
|
});
|
|
1299
787
|
}
|
|
788
|
+
async emitChunk(chunk) {
|
|
789
|
+
return this.context.emitChunk(chunk);
|
|
790
|
+
}
|
|
1300
791
|
getFileName(referenceId) {
|
|
1301
792
|
return this.context.getFileName(referenceId);
|
|
1302
793
|
}
|
|
@@ -1389,7 +880,7 @@ function bindingifyTransformFilter(filterOption) {
|
|
|
1389
880
|
const { id, code, moduleType } = filterOption;
|
|
1390
881
|
let moduleTypeRet;
|
|
1391
882
|
if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
|
|
1392
|
-
else moduleTypeRet = moduleType.include;
|
|
883
|
+
else moduleTypeRet = moduleType.include;
|
|
1393
884
|
return {
|
|
1394
885
|
id: id ? bindingifyStringFilter(id) : undefined,
|
|
1395
886
|
code: code ? bindingifyStringFilter(code) : undefined,
|
|
@@ -2167,14 +1658,14 @@ function bindingifyTreeshakeOptions(config) {
|
|
|
2167
1658
|
};
|
|
2168
1659
|
let normalizedConfig = { moduleSideEffects: true };
|
|
2169
1660
|
if (config.moduleSideEffects === undefined) normalizedConfig.moduleSideEffects = true;
|
|
2170
|
-
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
1661
|
+
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
2171
1662
|
external: true,
|
|
2172
1663
|
sideEffects: false
|
|
2173
1664
|
}, {
|
|
2174
1665
|
external: false,
|
|
2175
1666
|
sideEffects: true
|
|
2176
1667
|
}];
|
|
2177
|
-
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
1668
|
+
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
2178
1669
|
normalizedConfig.annotations = config.annotations ?? true;
|
|
2179
1670
|
return normalizedConfig;
|
|
2180
1671
|
}
|
|
@@ -2460,7 +1951,7 @@ function createComposedPlugin(plugins) {
|
|
|
2460
1951
|
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
|
|
2461
1952
|
if (!isNullish(result)) {
|
|
2462
1953
|
if (typeof result === "string") updateOutput(result);
|
|
2463
|
-
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
1954
|
+
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
2464
1955
|
}
|
|
2465
1956
|
}
|
|
2466
1957
|
return {
|
|
@@ -2573,10 +2064,10 @@ function composeJsPlugins(plugins) {
|
|
|
2573
2064
|
const toBeComposed = [];
|
|
2574
2065
|
plugins.forEach((plugin) => {
|
|
2575
2066
|
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
2576
|
-
else {
|
|
2067
|
+
else {
|
|
2577
2068
|
if (toBeComposed.length > 0) {
|
|
2578
2069
|
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2579
|
-
else newPlugins.push(toBeComposed[0]);
|
|
2070
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2580
2071
|
toBeComposed.length = 0;
|
|
2581
2072
|
}
|
|
2582
2073
|
newPlugins.push(plugin);
|
|
@@ -2584,7 +2075,7 @@ else newPlugins.push(toBeComposed[0]);
|
|
|
2584
2075
|
});
|
|
2585
2076
|
if (toBeComposed.length > 0) {
|
|
2586
2077
|
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2587
|
-
else newPlugins.push(toBeComposed[0]);
|
|
2078
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2588
2079
|
toBeComposed.length = 0;
|
|
2589
2080
|
}
|
|
2590
2081
|
return newPlugins;
|
|
@@ -2633,7 +2124,7 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
|
2633
2124
|
await new Promise((resolve, reject) => {
|
|
2634
2125
|
worker.once("message", async (message) => {
|
|
2635
2126
|
if (message.type === "error") reject(message.error);
|
|
2636
|
-
else resolve();
|
|
2127
|
+
else resolve();
|
|
2637
2128
|
});
|
|
2638
2129
|
});
|
|
2639
2130
|
return worker;
|
|
@@ -2979,14 +2470,12 @@ function getJsonSchema() {
|
|
|
2979
2470
|
//#endregion
|
|
2980
2471
|
//#region src/utils/create-bundler-option.ts
|
|
2981
2472
|
async function createBundlerOptions(inputOptions, outputOptions) {
|
|
2982
|
-
const pluginDriver = new PluginDriver();
|
|
2983
|
-
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2984
2473
|
if (inputOptions.treeshake !== undefined) validateTreeShakingOptions(inputOptions.treeshake);
|
|
2985
2474
|
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
2986
2475
|
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2987
2476
|
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2988
2477
|
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
2989
|
-
outputOptions =
|
|
2478
|
+
outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
|
|
2990
2479
|
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
|
|
2991
2480
|
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
2992
2481
|
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
@@ -3065,7 +2554,8 @@ var RolldownBuild = class {
|
|
|
3065
2554
|
//#endregion
|
|
3066
2555
|
//#region src/api/rolldown/index.ts
|
|
3067
2556
|
const rolldown = async (input) => {
|
|
3068
|
-
|
|
2557
|
+
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
2558
|
+
return new RolldownBuild(inputOptions);
|
|
3069
2559
|
};
|
|
3070
2560
|
|
|
3071
2561
|
//#endregion
|
|
@@ -3083,7 +2573,7 @@ var WatcherEmitter = class {
|
|
|
3083
2573
|
on(event, listener) {
|
|
3084
2574
|
const listeners = this.listeners.get(event);
|
|
3085
2575
|
if (listeners) listeners.push(listener);
|
|
3086
|
-
else this.listeners.set(event, [listener]);
|
|
2576
|
+
else this.listeners.set(event, [listener]);
|
|
3087
2577
|
return this;
|
|
3088
2578
|
}
|
|
3089
2579
|
async onEvent(event) {
|
|
@@ -3163,7 +2653,10 @@ var Watcher = class {
|
|
|
3163
2653
|
};
|
|
3164
2654
|
async function createWatcher(emitter, input) {
|
|
3165
2655
|
const options = arraify(input);
|
|
3166
|
-
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map((output) =>
|
|
2656
|
+
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
2657
|
+
const inputOptions = await PluginDriver.callOptionsHook(option);
|
|
2658
|
+
return createBundlerOptions(inputOptions, output);
|
|
2659
|
+
})).flat());
|
|
3167
2660
|
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
3168
2661
|
const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
3169
2662
|
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
@@ -3190,19 +2683,19 @@ const watch = (input) => {
|
|
|
3190
2683
|
|
|
3191
2684
|
//#endregion
|
|
3192
2685
|
//#region package.json
|
|
3193
|
-
var version = "1.0.0-beta.1-commit.
|
|
2686
|
+
var version = "1.0.0-beta.1-commit.2fe52d4";
|
|
3194
2687
|
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
3195
2688
|
|
|
3196
2689
|
//#endregion
|
|
3197
2690
|
//#region src/api/build.ts
|
|
3198
2691
|
async function build(options) {
|
|
3199
2692
|
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
3200
|
-
else {
|
|
2693
|
+
else {
|
|
3201
2694
|
const { output, write = true,...inputOptions } = options;
|
|
3202
2695
|
const build$1 = await rolldown(inputOptions);
|
|
3203
2696
|
try {
|
|
3204
2697
|
if (write) return await build$1.write(output);
|
|
3205
|
-
else return await build$1.generate(output);
|
|
2698
|
+
else return await build$1.generate(output);
|
|
3206
2699
|
} finally {
|
|
3207
2700
|
await build$1.close();
|
|
3208
2701
|
}
|
|
@@ -3214,4 +2707,4 @@ else return await build$1.generate(output);
|
|
|
3214
2707
|
const VERSION = version;
|
|
3215
2708
|
|
|
3216
2709
|
//#endregion
|
|
3217
|
-
export { BuiltinPlugin, PluginContextData, VERSION,
|
|
2710
|
+
export { BuiltinPlugin, PluginContextData, VERSION, arraify, bindingifyPlugin, build, buildImportAnalysisPlugin, colors, composeJsPlugins, createBundler, defineConfig, description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch };
|