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,600 +1,19 @@
|
|
|
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
|
-
const
|
|
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-Cw1COxB5.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 node_process = require_chunk.__toESM(require("node:process"));
|
|
10
|
+
const tty = require_chunk.__toESM(require("tty"));
|
|
11
|
+
const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
|
|
12
|
+
|
|
13
|
+
//#region src/utils/define-config.ts
|
|
14
|
+
function defineConfig(config) {
|
|
15
|
+
return config;
|
|
16
|
+
}
|
|
598
17
|
|
|
599
18
|
//#endregion
|
|
600
19
|
//#region src/utils/misc.ts
|
|
@@ -631,180 +50,13 @@ const logLevelPriority = {
|
|
|
631
50
|
[LOG_LEVEL_SILENT]: 3
|
|
632
51
|
};
|
|
633
52
|
|
|
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
53
|
//#endregion
|
|
802
54
|
//#region src/log/logHandler.ts
|
|
803
55
|
const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
804
56
|
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
805
57
|
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
806
58
|
return (log, pos) => {
|
|
807
|
-
if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
59
|
+
if (pos != null) logger(LOG_LEVEL_WARN, require_binding$1.logInvalidLogPosition(pluginName));
|
|
808
60
|
log = normalizeLog(log);
|
|
809
61
|
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
810
62
|
log.code = code;
|
|
@@ -850,7 +102,7 @@ function getLogger(plugins, onLog, logLevel) {
|
|
|
850
102
|
const handler = "handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
851
103
|
if (handler.call({
|
|
852
104
|
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
853
|
-
error: (log$1) => error(normalizeLog(log$1)),
|
|
105
|
+
error: (log$1) => require_binding$1.error(normalizeLog(log$1)),
|
|
854
106
|
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
855
107
|
meta: {
|
|
856
108
|
rollupVersion: "4.23.0",
|
|
@@ -872,7 +124,7 @@ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
|
872
124
|
if (onLog) {
|
|
873
125
|
const minimalPriority = logLevelPriority[logLevel];
|
|
874
126
|
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
875
|
-
if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
|
|
127
|
+
if (level$1 === LOG_LEVEL_ERROR) return require_binding$1.error(normalizeLog(handledLog));
|
|
876
128
|
if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
|
|
877
129
|
});
|
|
878
130
|
}
|
|
@@ -880,7 +132,7 @@ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
|
880
132
|
};
|
|
881
133
|
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
882
134
|
if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
883
|
-
else printLog(level, log);
|
|
135
|
+
else printLog(level, log);
|
|
884
136
|
} : printLog;
|
|
885
137
|
const addLogToString = (log) => {
|
|
886
138
|
Object.defineProperty(log, "toString", {
|
|
@@ -910,7 +162,7 @@ function relativeId(id) {
|
|
|
910
162
|
|
|
911
163
|
//#endregion
|
|
912
164
|
//#region src/builtin-plugin/utils.ts
|
|
913
|
-
var import_binding$6 = require_chunk.__toESM(require_binding());
|
|
165
|
+
var import_binding$6 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
914
166
|
function makeBuiltinPluginCallable(plugin) {
|
|
915
167
|
let callablePlugin = new import_binding$6.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
916
168
|
const wrappedPlugin = plugin;
|
|
@@ -974,7 +226,7 @@ function viteResolvePlugin(config) {
|
|
|
974
226
|
//#endregion
|
|
975
227
|
//#region src/utils/async-flatten.ts
|
|
976
228
|
async function asyncFlatten(array) {
|
|
977
|
-
do
|
|
229
|
+
do
|
|
978
230
|
array = (await Promise.all(array)).flat(Infinity);
|
|
979
231
|
while (array.some((v) => v?.then));
|
|
980
232
|
return array;
|
|
@@ -1040,101 +292,365 @@ const DEFINED_HOOK_NAMES = {
|
|
|
1040
292
|
};
|
|
1041
293
|
|
|
1042
294
|
//#endregion
|
|
1043
|
-
//#region src/utils/normalize-plugin-option.ts
|
|
1044
|
-
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
1045
|
-
function checkOutputPluginOption(plugins, onLog) {
|
|
1046
|
-
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
1047
|
-
delete plugin[hook];
|
|
1048
|
-
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
|
|
1049
|
-
}
|
|
1050
|
-
return plugins;
|
|
295
|
+
//#region src/utils/normalize-plugin-option.ts
|
|
296
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
297
|
+
function checkOutputPluginOption(plugins, onLog) {
|
|
298
|
+
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
299
|
+
delete plugin[hook];
|
|
300
|
+
onLog(LOG_LEVEL_WARN, require_binding$1.logInputHookInOutputPlugin(plugin.name, hook));
|
|
301
|
+
}
|
|
302
|
+
return plugins;
|
|
303
|
+
}
|
|
304
|
+
function normalizePlugins(plugins, anonymousPrefix) {
|
|
305
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
306
|
+
if ("_parallel" in plugin) continue;
|
|
307
|
+
if (plugin instanceof BuiltinPlugin) continue;
|
|
308
|
+
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
|
|
309
|
+
}
|
|
310
|
+
return plugins;
|
|
311
|
+
}
|
|
312
|
+
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
313
|
+
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
314
|
+
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/plugin/plugin-driver.ts
|
|
317
|
+
var PluginDriver = class {
|
|
318
|
+
static async callOptionsHook(inputOptions) {
|
|
319
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
320
|
+
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
321
|
+
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
|
|
322
|
+
for (const plugin of plugins) {
|
|
323
|
+
const name = plugin.name || "unknown";
|
|
324
|
+
const options = plugin.options;
|
|
325
|
+
if (options) {
|
|
326
|
+
const { handler } = normalizeHook(options);
|
|
327
|
+
const result = await handler.call({
|
|
328
|
+
debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
|
|
329
|
+
error: (e) => require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), name, { hook: "onLog" })),
|
|
330
|
+
info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
|
|
331
|
+
meta: {
|
|
332
|
+
rollupVersion: "4.23.0",
|
|
333
|
+
rolldownVersion: VERSION,
|
|
334
|
+
watchMode: false
|
|
335
|
+
},
|
|
336
|
+
warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
|
|
337
|
+
pluginName: name
|
|
338
|
+
}, inputOptions);
|
|
339
|
+
if (result) inputOptions = result;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return inputOptions;
|
|
343
|
+
}
|
|
344
|
+
static callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
345
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
346
|
+
for (const plugin of sortedPlugins) {
|
|
347
|
+
const options = plugin.outputOptions;
|
|
348
|
+
if (options) {
|
|
349
|
+
const { handler } = normalizeHook(options);
|
|
350
|
+
const result = handler.call(null, outputOptions);
|
|
351
|
+
if (result) outputOptions = result;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return outputOptions;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
function getObjectPlugins(plugins) {
|
|
358
|
+
return plugins.filter((plugin) => {
|
|
359
|
+
if (!plugin) return undefined;
|
|
360
|
+
if ("_parallel" in plugin) return undefined;
|
|
361
|
+
if (plugin instanceof BuiltinPlugin) return undefined;
|
|
362
|
+
return plugin;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function getSortedPlugins(hookName, plugins) {
|
|
366
|
+
const pre = [];
|
|
367
|
+
const normal = [];
|
|
368
|
+
const post = [];
|
|
369
|
+
for (const plugin of plugins) {
|
|
370
|
+
const hook = plugin[hookName];
|
|
371
|
+
if (hook) {
|
|
372
|
+
if (typeof hook === "object") {
|
|
373
|
+
if (hook.order === "pre") {
|
|
374
|
+
pre.push(plugin);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (hook.order === "post") {
|
|
378
|
+
post.push(plugin);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
normal.push(plugin);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return [
|
|
386
|
+
...pre,
|
|
387
|
+
...normal,
|
|
388
|
+
...post
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/utils/asset-source.ts
|
|
394
|
+
function transformAssetSource(bindingAssetSource$1) {
|
|
395
|
+
return bindingAssetSource$1.inner;
|
|
396
|
+
}
|
|
397
|
+
function bindingAssetSource(source) {
|
|
398
|
+
return { inner: source };
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/types/sourcemap.ts
|
|
403
|
+
function bindingifySourcemap$1(map) {
|
|
404
|
+
if (map == null) return;
|
|
405
|
+
return { inner: typeof map === "string" ? map : {
|
|
406
|
+
file: map.file ?? undefined,
|
|
407
|
+
mappings: map.mappings,
|
|
408
|
+
sourceRoot: map.sourceRoot,
|
|
409
|
+
sources: map.sources?.map((s) => s ?? undefined),
|
|
410
|
+
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
411
|
+
names: map.names
|
|
412
|
+
} };
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/utils/error.ts
|
|
417
|
+
function normalizeErrors(rawErrors) {
|
|
418
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
419
|
+
kind: e.kind,
|
|
420
|
+
message: e.message,
|
|
421
|
+
stack: undefined
|
|
422
|
+
}));
|
|
423
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
424
|
+
for (let i = 0; i < errors.length; i++) {
|
|
425
|
+
if (i >= 5) {
|
|
426
|
+
summary += "\n...";
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
summary += getErrorMessage(errors[i]) + "\n";
|
|
430
|
+
}
|
|
431
|
+
const wrapper = new Error(summary);
|
|
432
|
+
Object.defineProperty(wrapper, "errors", {
|
|
433
|
+
configurable: true,
|
|
434
|
+
enumerable: true,
|
|
435
|
+
get: () => errors,
|
|
436
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
437
|
+
configurable: true,
|
|
438
|
+
enumerable: true,
|
|
439
|
+
value
|
|
440
|
+
})
|
|
441
|
+
});
|
|
442
|
+
return wrapper;
|
|
443
|
+
}
|
|
444
|
+
function getErrorMessage(e) {
|
|
445
|
+
let s = "";
|
|
446
|
+
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
447
|
+
const id = e.id ?? e.loc?.file;
|
|
448
|
+
if (id) {
|
|
449
|
+
s += " " + id;
|
|
450
|
+
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
451
|
+
}
|
|
452
|
+
if (s) s += "\n";
|
|
453
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
454
|
+
s += message;
|
|
455
|
+
if (e.frame) s = joinNewLine(s, e.frame);
|
|
456
|
+
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
457
|
+
return s;
|
|
458
|
+
}
|
|
459
|
+
function joinNewLine(s1, s2) {
|
|
460
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/utils/transform-rendered-module.ts
|
|
465
|
+
function transformToRenderedModule(bindingRenderedModule) {
|
|
466
|
+
return {
|
|
467
|
+
get code() {
|
|
468
|
+
return bindingRenderedModule.code;
|
|
469
|
+
},
|
|
470
|
+
get renderedLength() {
|
|
471
|
+
return bindingRenderedModule.code?.length || 0;
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/utils/transform-rendered-chunk.ts
|
|
478
|
+
function transformRenderedChunk(chunk) {
|
|
479
|
+
return {
|
|
480
|
+
get name() {
|
|
481
|
+
return chunk.name;
|
|
482
|
+
},
|
|
483
|
+
get isEntry() {
|
|
484
|
+
return chunk.isEntry;
|
|
485
|
+
},
|
|
486
|
+
get isDynamicEntry() {
|
|
487
|
+
return chunk.isDynamicEntry;
|
|
488
|
+
},
|
|
489
|
+
get facadeModuleId() {
|
|
490
|
+
return chunk.facadeModuleId;
|
|
491
|
+
},
|
|
492
|
+
get moduleIds() {
|
|
493
|
+
return chunk.moduleIds;
|
|
494
|
+
},
|
|
495
|
+
get exports() {
|
|
496
|
+
return chunk.exports;
|
|
497
|
+
},
|
|
498
|
+
get fileName() {
|
|
499
|
+
return chunk.fileName;
|
|
500
|
+
},
|
|
501
|
+
get imports() {
|
|
502
|
+
return chunk.imports;
|
|
503
|
+
},
|
|
504
|
+
get dynamicImports() {
|
|
505
|
+
return chunk.dynamicImports;
|
|
506
|
+
},
|
|
507
|
+
get modules() {
|
|
508
|
+
return transformChunkModules(chunk.modules);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
1051
511
|
}
|
|
1052
|
-
function
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
512
|
+
function transformChunkModules(modules) {
|
|
513
|
+
const result = {};
|
|
514
|
+
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
515
|
+
let mod = modules.value[index];
|
|
516
|
+
result[id] = transformToRenderedModule(mod);
|
|
1057
517
|
}
|
|
1058
|
-
return
|
|
518
|
+
return result;
|
|
1059
519
|
}
|
|
1060
|
-
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
1061
|
-
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
1062
520
|
|
|
1063
521
|
//#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
|
-
}
|
|
522
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
523
|
+
function transformToRollupSourceMap(map) {
|
|
524
|
+
const parsed = JSON.parse(map);
|
|
525
|
+
const obj = {
|
|
526
|
+
...parsed,
|
|
527
|
+
toString() {
|
|
528
|
+
return JSON.stringify(obj);
|
|
529
|
+
},
|
|
530
|
+
toUrl() {
|
|
531
|
+
return `data:application/json;charset=utf-8;base64,${node_buffer.Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
1089
532
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
533
|
+
};
|
|
534
|
+
return obj;
|
|
535
|
+
}
|
|
536
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
537
|
+
const chunk = {
|
|
538
|
+
type: "chunk",
|
|
539
|
+
get code() {
|
|
540
|
+
return bindingChunk.code;
|
|
541
|
+
},
|
|
542
|
+
fileName: bindingChunk.fileName,
|
|
543
|
+
name: bindingChunk.name,
|
|
544
|
+
get modules() {
|
|
545
|
+
return transformChunkModules(bindingChunk.modules);
|
|
546
|
+
},
|
|
547
|
+
get imports() {
|
|
548
|
+
return bindingChunk.imports;
|
|
549
|
+
},
|
|
550
|
+
get dynamicImports() {
|
|
551
|
+
return bindingChunk.dynamicImports;
|
|
552
|
+
},
|
|
553
|
+
exports: bindingChunk.exports,
|
|
554
|
+
isEntry: bindingChunk.isEntry,
|
|
555
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
556
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
557
|
+
get moduleIds() {
|
|
558
|
+
return bindingChunk.moduleIds;
|
|
559
|
+
},
|
|
560
|
+
get map() {
|
|
561
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
562
|
+
},
|
|
563
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
564
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
565
|
+
};
|
|
566
|
+
const cache = {};
|
|
567
|
+
return new Proxy(chunk, {
|
|
568
|
+
get(target, p) {
|
|
569
|
+
if (p in cache) return cache[p];
|
|
570
|
+
return target[p];
|
|
571
|
+
},
|
|
572
|
+
set(target, p, newValue) {
|
|
573
|
+
cache[p] = newValue;
|
|
574
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
575
|
+
return true;
|
|
1101
576
|
}
|
|
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
577
|
});
|
|
1112
578
|
}
|
|
1113
|
-
function
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
579
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
580
|
+
const asset = {
|
|
581
|
+
type: "asset",
|
|
582
|
+
fileName: bindingAsset.fileName,
|
|
583
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
584
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
585
|
+
get source() {
|
|
586
|
+
return transformAssetSource(bindingAsset.source);
|
|
587
|
+
},
|
|
588
|
+
name: bindingAsset.name ?? undefined,
|
|
589
|
+
names: bindingAsset.names
|
|
590
|
+
};
|
|
591
|
+
const cache = {};
|
|
592
|
+
return new Proxy(asset, {
|
|
593
|
+
get(target, p) {
|
|
594
|
+
if (p in cache) return cache[p];
|
|
595
|
+
return target[p];
|
|
596
|
+
},
|
|
597
|
+
set(target, p, newValue) {
|
|
598
|
+
cache[p] = newValue;
|
|
599
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
600
|
+
return true;
|
|
1131
601
|
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
function transformToRollupOutput(output, changed) {
|
|
605
|
+
handleOutputErrors(output);
|
|
606
|
+
const { chunks, assets } = output;
|
|
607
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
608
|
+
}
|
|
609
|
+
function handleOutputErrors(output) {
|
|
610
|
+
const rawErrors = output.errors;
|
|
611
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
612
|
+
}
|
|
613
|
+
function transformToOutputBundle(output, changed) {
|
|
614
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
615
|
+
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
616
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
617
|
+
return true;
|
|
618
|
+
} });
|
|
619
|
+
}
|
|
620
|
+
function collectChangedBundle(changed, bundle) {
|
|
621
|
+
const assets = [];
|
|
622
|
+
const chunks = [];
|
|
623
|
+
for (const key in bundle) {
|
|
624
|
+
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
625
|
+
const item = bundle[key];
|
|
626
|
+
if (item.type === "asset") assets.push({
|
|
627
|
+
filename: item.fileName,
|
|
628
|
+
originalFileNames: item.originalFileNames,
|
|
629
|
+
source: bindingAssetSource(item.source),
|
|
630
|
+
names: item.names
|
|
631
|
+
});
|
|
632
|
+
else chunks.push({
|
|
633
|
+
code: item.code,
|
|
634
|
+
filename: item.fileName,
|
|
635
|
+
name: item.name,
|
|
636
|
+
isEntry: item.isEntry,
|
|
637
|
+
exports: item.exports,
|
|
638
|
+
modules: {},
|
|
639
|
+
imports: item.imports,
|
|
640
|
+
dynamicImports: item.dynamicImports,
|
|
641
|
+
facadeModuleId: item.facadeModuleId || undefined,
|
|
642
|
+
isDynamicEntry: item.isDynamicEntry,
|
|
643
|
+
moduleIds: item.moduleIds,
|
|
644
|
+
map: bindingifySourcemap$1(item.map),
|
|
645
|
+
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
646
|
+
preliminaryFilename: item.preliminaryFileName
|
|
647
|
+
});
|
|
1132
648
|
}
|
|
1133
|
-
return
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
649
|
+
return {
|
|
650
|
+
assets,
|
|
651
|
+
chunks,
|
|
652
|
+
deleted: Array.from(changed.deleted)
|
|
653
|
+
};
|
|
1138
654
|
}
|
|
1139
655
|
|
|
1140
656
|
//#endregion
|
|
@@ -1192,13 +708,13 @@ var MinimalPluginContext = class {
|
|
|
1192
708
|
};
|
|
1193
709
|
}
|
|
1194
710
|
error(e) {
|
|
1195
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
711
|
+
return require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), this.pluginName));
|
|
1196
712
|
}
|
|
1197
713
|
};
|
|
1198
714
|
|
|
1199
715
|
//#endregion
|
|
1200
716
|
//#region src/utils/transform-side-effects.ts
|
|
1201
|
-
var import_binding$5 = require_chunk.__toESM(require_binding());
|
|
717
|
+
var import_binding$5 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1202
718
|
function bindingifySideEffects(sideEffects) {
|
|
1203
719
|
switch (sideEffects) {
|
|
1204
720
|
case true: return import_binding$5.BindingHookSideEffects.True;
|
|
@@ -1222,7 +738,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1222
738
|
}
|
|
1223
739
|
async load(options) {
|
|
1224
740
|
const id = options.id;
|
|
1225
|
-
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
741
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, require_binding$1.logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
1226
742
|
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
1227
743
|
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
1228
744
|
const rawOptions = {
|
|
@@ -1271,6 +787,9 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1271
787
|
source: bindingAssetSource(file.source)
|
|
1272
788
|
});
|
|
1273
789
|
}
|
|
790
|
+
async emitChunk(chunk) {
|
|
791
|
+
return this.context.emitChunk(chunk);
|
|
792
|
+
}
|
|
1274
793
|
getFileName(referenceId) {
|
|
1275
794
|
return this.context.getFileName(referenceId);
|
|
1276
795
|
}
|
|
@@ -1301,7 +820,7 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1301
820
|
this.moduleSource = moduleSource;
|
|
1302
821
|
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
1303
822
|
log = normalizeLog(log);
|
|
1304
|
-
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
823
|
+
if (pos) require_binding$1.augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
1305
824
|
log.id = moduleId;
|
|
1306
825
|
log.hook = "transform";
|
|
1307
826
|
handler(log);
|
|
@@ -1312,10 +831,10 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1312
831
|
}
|
|
1313
832
|
error(e, pos) {
|
|
1314
833
|
if (typeof e === "string") e = { message: e };
|
|
1315
|
-
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
834
|
+
if (pos) require_binding$1.augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1316
835
|
e.id = this.moduleId;
|
|
1317
836
|
e.hook = "transform";
|
|
1318
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
837
|
+
return require_binding$1.error(require_binding$1.logPluginError(normalizeLog(e), this.pluginName));
|
|
1319
838
|
}
|
|
1320
839
|
getCombinedSourcemap() {
|
|
1321
840
|
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
@@ -1324,7 +843,7 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1324
843
|
|
|
1325
844
|
//#endregion
|
|
1326
845
|
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1327
|
-
var import_binding$4 = require_chunk.__toESM(require_binding());
|
|
846
|
+
var import_binding$4 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1328
847
|
function bindingifyPluginHookMeta(options) {
|
|
1329
848
|
return { order: bindingPluginOrder(options.order) };
|
|
1330
849
|
}
|
|
@@ -1363,7 +882,7 @@ function bindingifyTransformFilter(filterOption) {
|
|
|
1363
882
|
const { id, code, moduleType } = filterOption;
|
|
1364
883
|
let moduleTypeRet;
|
|
1365
884
|
if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
|
|
1366
|
-
else moduleTypeRet = moduleType.include;
|
|
885
|
+
else moduleTypeRet = moduleType.include;
|
|
1367
886
|
return {
|
|
1368
887
|
id: id ? bindingifyStringFilter(id) : undefined,
|
|
1369
888
|
code: code ? bindingifyStringFilter(code) : undefined,
|
|
@@ -1925,7 +1444,7 @@ function wrapHandlers(plugin) {
|
|
|
1925
1444
|
try {
|
|
1926
1445
|
return await handler(...args);
|
|
1927
1446
|
} catch (e) {
|
|
1928
|
-
return error(logPluginError(e, plugin.name, {
|
|
1447
|
+
return require_binding$1.error(require_binding$1.logPluginError(e, plugin.name, {
|
|
1929
1448
|
hook: hookName,
|
|
1930
1449
|
id: hookName === "transform" ? args[2] : undefined
|
|
1931
1450
|
}));
|
|
@@ -1995,7 +1514,7 @@ function normalizedStringOrRegex(pattern) {
|
|
|
1995
1514
|
|
|
1996
1515
|
//#endregion
|
|
1997
1516
|
//#region src/utils/bindingify-input-options.ts
|
|
1998
|
-
var import_binding$3 = require_chunk.__toESM(require_binding());
|
|
1517
|
+
var import_binding$3 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
1999
1518
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog, logLevel) {
|
|
2000
1519
|
const pluginContextData = new PluginContextData();
|
|
2001
1520
|
const plugins = rawPlugins.map((plugin) => {
|
|
@@ -2141,14 +1660,14 @@ function bindingifyTreeshakeOptions(config) {
|
|
|
2141
1660
|
};
|
|
2142
1661
|
let normalizedConfig = { moduleSideEffects: true };
|
|
2143
1662
|
if (config.moduleSideEffects === undefined) normalizedConfig.moduleSideEffects = true;
|
|
2144
|
-
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
1663
|
+
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
2145
1664
|
external: true,
|
|
2146
1665
|
sideEffects: false
|
|
2147
1666
|
}, {
|
|
2148
1667
|
external: false,
|
|
2149
1668
|
sideEffects: true
|
|
2150
1669
|
}];
|
|
2151
|
-
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
1670
|
+
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
2152
1671
|
normalizedConfig.annotations = config.annotations ?? true;
|
|
2153
1672
|
return normalizedConfig;
|
|
2154
1673
|
}
|
|
@@ -2434,7 +1953,7 @@ function createComposedPlugin(plugins) {
|
|
|
2434
1953
|
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
|
|
2435
1954
|
if (!isNullish(result)) {
|
|
2436
1955
|
if (typeof result === "string") updateOutput(result);
|
|
2437
|
-
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
1956
|
+
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
2438
1957
|
}
|
|
2439
1958
|
}
|
|
2440
1959
|
return {
|
|
@@ -2547,10 +2066,10 @@ function composeJsPlugins(plugins) {
|
|
|
2547
2066
|
const toBeComposed = [];
|
|
2548
2067
|
plugins.forEach((plugin) => {
|
|
2549
2068
|
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
2550
|
-
else {
|
|
2069
|
+
else {
|
|
2551
2070
|
if (toBeComposed.length > 0) {
|
|
2552
2071
|
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2553
|
-
else newPlugins.push(toBeComposed[0]);
|
|
2072
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2554
2073
|
toBeComposed.length = 0;
|
|
2555
2074
|
}
|
|
2556
2075
|
newPlugins.push(plugin);
|
|
@@ -2558,7 +2077,7 @@ else newPlugins.push(toBeComposed[0]);
|
|
|
2558
2077
|
});
|
|
2559
2078
|
if (toBeComposed.length > 0) {
|
|
2560
2079
|
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2561
|
-
else newPlugins.push(toBeComposed[0]);
|
|
2080
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2562
2081
|
toBeComposed.length = 0;
|
|
2563
2082
|
}
|
|
2564
2083
|
return newPlugins;
|
|
@@ -2566,7 +2085,7 @@ else newPlugins.push(toBeComposed[0]);
|
|
|
2566
2085
|
|
|
2567
2086
|
//#endregion
|
|
2568
2087
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
2569
|
-
var import_binding$2 = require_chunk.__toESM(require_binding());
|
|
2088
|
+
var import_binding$2 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
2570
2089
|
async function initializeParallelPlugins(plugins) {
|
|
2571
2090
|
const pluginInfos = [];
|
|
2572
2091
|
for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
|
|
@@ -2607,7 +2126,7 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
|
2607
2126
|
await new Promise((resolve, reject) => {
|
|
2608
2127
|
worker.once("message", async (message) => {
|
|
2609
2128
|
if (message.type === "error") reject(message.error);
|
|
2610
|
-
else resolve();
|
|
2129
|
+
else resolve();
|
|
2611
2130
|
});
|
|
2612
2131
|
});
|
|
2613
2132
|
return worker;
|
|
@@ -2953,15 +2472,13 @@ function getJsonSchema() {
|
|
|
2953
2472
|
//#endregion
|
|
2954
2473
|
//#region src/utils/create-bundler-option.ts
|
|
2955
2474
|
async function createBundlerOptions(inputOptions, outputOptions) {
|
|
2956
|
-
const pluginDriver = new PluginDriver();
|
|
2957
|
-
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2958
2475
|
if (inputOptions.treeshake !== undefined) validateTreeShakingOptions(inputOptions.treeshake);
|
|
2959
2476
|
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
2960
2477
|
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2961
2478
|
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2962
2479
|
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
2963
|
-
outputOptions =
|
|
2964
|
-
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
|
|
2480
|
+
outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
|
|
2481
|
+
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, require_binding$1.logMinifyWarning());
|
|
2965
2482
|
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
2966
2483
|
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
2967
2484
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
@@ -2986,7 +2503,7 @@ async function createBundlerOptions(inputOptions, outputOptions) {
|
|
|
2986
2503
|
|
|
2987
2504
|
//#endregion
|
|
2988
2505
|
//#region src/utils/create-bundler.ts
|
|
2989
|
-
var import_binding$1 = require_chunk.__toESM(require_binding());
|
|
2506
|
+
var import_binding$1 = require_chunk.__toESM(require_binding$1.require_binding());
|
|
2990
2507
|
async function createBundler(inputOptions, outputOptions) {
|
|
2991
2508
|
const option = await createBundlerOptions(inputOptions, outputOptions);
|
|
2992
2509
|
try {
|
|
@@ -3039,7 +2556,8 @@ var RolldownBuild = class {
|
|
|
3039
2556
|
//#endregion
|
|
3040
2557
|
//#region src/api/rolldown/index.ts
|
|
3041
2558
|
const rolldown = async (input) => {
|
|
3042
|
-
|
|
2559
|
+
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
2560
|
+
return new RolldownBuild(inputOptions);
|
|
3043
2561
|
};
|
|
3044
2562
|
|
|
3045
2563
|
//#endregion
|
|
@@ -3057,7 +2575,7 @@ var WatcherEmitter = class {
|
|
|
3057
2575
|
on(event, listener) {
|
|
3058
2576
|
const listeners = this.listeners.get(event);
|
|
3059
2577
|
if (listeners) listeners.push(listener);
|
|
3060
|
-
else this.listeners.set(event, [listener]);
|
|
2578
|
+
else this.listeners.set(event, [listener]);
|
|
3061
2579
|
return this;
|
|
3062
2580
|
}
|
|
3063
2581
|
async onEvent(event) {
|
|
@@ -3108,7 +2626,7 @@ else this.listeners.set(event, [listener]);
|
|
|
3108
2626
|
|
|
3109
2627
|
//#endregion
|
|
3110
2628
|
//#region src/api/watch/watcher.ts
|
|
3111
|
-
var import_binding = require_chunk.__toESM(require_binding());
|
|
2629
|
+
var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
|
|
3112
2630
|
var Watcher = class {
|
|
3113
2631
|
closed;
|
|
3114
2632
|
inner;
|
|
@@ -3137,7 +2655,10 @@ var Watcher = class {
|
|
|
3137
2655
|
};
|
|
3138
2656
|
async function createWatcher(emitter, input) {
|
|
3139
2657
|
const options = arraify(input);
|
|
3140
|
-
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map((output) =>
|
|
2658
|
+
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
2659
|
+
const inputOptions = await PluginDriver.callOptionsHook(option);
|
|
2660
|
+
return createBundlerOptions(inputOptions, output);
|
|
2661
|
+
})).flat());
|
|
3141
2662
|
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
3142
2663
|
const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
3143
2664
|
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
@@ -3148,7 +2669,7 @@ function getValidNotifyOption(bundlerOptions) {
|
|
|
3148
2669
|
for (const option of bundlerOptions) if (option.inputOptions.watch) {
|
|
3149
2670
|
const notifyOption = option.inputOptions.watch.notify;
|
|
3150
2671
|
if (notifyOption) if (result) {
|
|
3151
|
-
option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
|
|
2672
|
+
option.onLog(LOG_LEVEL_WARN, require_binding$1.logMultiplyNotifyOption());
|
|
3152
2673
|
return result;
|
|
3153
2674
|
} else result = notifyOption;
|
|
3154
2675
|
}
|
|
@@ -3164,19 +2685,19 @@ const watch = (input) => {
|
|
|
3164
2685
|
|
|
3165
2686
|
//#endregion
|
|
3166
2687
|
//#region package.json
|
|
3167
|
-
var version = "1.0.0-beta.1-commit.
|
|
2688
|
+
var version = "1.0.0-beta.1-commit.2fe52d4";
|
|
3168
2689
|
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
3169
2690
|
|
|
3170
2691
|
//#endregion
|
|
3171
2692
|
//#region src/api/build.ts
|
|
3172
2693
|
async function build(options) {
|
|
3173
2694
|
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
3174
|
-
else {
|
|
2695
|
+
else {
|
|
3175
2696
|
const { output, write = true,...inputOptions } = options;
|
|
3176
2697
|
const build$1 = await rolldown(inputOptions);
|
|
3177
2698
|
try {
|
|
3178
2699
|
if (write) return await build$1.write(output);
|
|
3179
|
-
else return await build$1.generate(output);
|
|
2700
|
+
else return await build$1.generate(output);
|
|
3180
2701
|
} finally {
|
|
3181
2702
|
await build$1.close();
|
|
3182
2703
|
}
|
|
@@ -3326,12 +2847,6 @@ Object.defineProperty(exports, 'normalizedStringOrRegex', {
|
|
|
3326
2847
|
return normalizedStringOrRegex;
|
|
3327
2848
|
}
|
|
3328
2849
|
});
|
|
3329
|
-
Object.defineProperty(exports, 'require_binding', {
|
|
3330
|
-
enumerable: true,
|
|
3331
|
-
get: function () {
|
|
3332
|
-
return require_binding;
|
|
3333
|
-
}
|
|
3334
|
-
});
|
|
3335
2850
|
Object.defineProperty(exports, 'rolldown', {
|
|
3336
2851
|
enumerable: true,
|
|
3337
2852
|
get: function () {
|