rolldown 0.14.0-snapshot-d42ea8a-20241202003632 → 0.15.0-commit.ac58858
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 +189 -175
- package/dist/cjs/experimental-index.cjs +12 -3
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/esm/cli.mjs +282 -268
- package/dist/esm/experimental-index.mjs +10 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{chunk-BK2Ye-xa.cjs → chunk-BFvIen8E.cjs} +0 -11
- package/dist/shared/{consola_36c0034f-_8_dG1Nr.cjs → consola_36c0034f-B7L-radJ.cjs} +2 -2
- package/dist/shared/{consola_36c0034f-DWsVjwtA.mjs → consola_36c0034f-D9ce-831.mjs} +10 -10
- package/dist/shared/{prompt-RFvZMmjc.cjs → prompt-BiXtYIJ2.cjs} +3 -3
- package/dist/shared/{prompt-DGW8ZJmn.mjs → prompt-DlQ-08lk.mjs} +2 -2
- package/dist/shared/{src-CfQyqNSn.cjs → src-Bs7g4_us.cjs} +227 -121
- package/dist/shared/{src-DhHfkqAC.mjs → src-C-NQjnqV.mjs} +226 -136
- package/dist/tsconfig.dts.tsbuildinfo +1 -0
- package/dist/types/api/build.d.ts +16 -0
- package/dist/types/api/experimental.d.ts +7 -0
- package/dist/types/api/rolldown/index.d.ts +3 -0
- package/dist/types/{rolldown-build.d.ts → api/rolldown/rolldown-build.d.ts} +3 -3
- package/dist/types/api/watch/index.d.ts +3 -0
- package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +15 -17
- package/dist/types/api/watch/watcher.d.ts +13 -0
- package/dist/types/binding.d.ts +108 -15
- package/dist/types/builtin-plugin/constructors.d.ts +1 -5
- package/dist/types/cli/arguments/index.d.ts +5 -3
- package/dist/types/cli/arguments/schema.d.ts +10 -397
- package/dist/types/cli/colors.d.ts +11 -1
- package/dist/types/cli/utils.d.ts +2 -1
- package/dist/types/constants/plugin.d.ts +8 -1
- package/dist/types/experimental-index.d.ts +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/log/logging.d.ts +6 -6
- package/dist/types/log/logs.d.ts +1 -0
- package/dist/types/options/input-options-schema.d.ts +3 -595
- package/dist/types/options/input-options.d.ts +16 -1
- package/dist/types/options/normalized-input-options.d.ts +1 -1
- package/dist/types/options/normalized-output-options.d.ts +20 -17
- package/dist/types/options/output-options-schema.d.ts +2 -146
- package/dist/types/options/output-options.d.ts +1 -0
- package/dist/types/plugin/plugin-context-data.d.ts +2 -1
- package/dist/types/rollup.d.ts +4 -0
- package/dist/types/treeshake/module-side-effects.d.ts +14 -115
- package/dist/types/types/rolldown-output.d.ts +6 -0
- package/dist/types/utils/bindingify-input-options.d.ts +1 -1
- package/dist/types/utils/create-bundler-option.d.ts +11 -0
- package/dist/types/utils/error.d.ts +2 -1
- package/dist/types/utils/misc.d.ts +1 -0
- package/dist/types/utils/transform-sourcemap.d.ts +1 -1
- package/dist/types/utils/zod-ext.d.ts +6 -5
- package/package.json +15 -15
- package/dist/types/log/locate-character/index.d.ts +0 -13
- package/dist/types/rolldown.d.ts +0 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createRequire
|
|
2
|
-
import {
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import path, { default as path$1 } from "node:path";
|
|
4
5
|
import { Worker } from "node:worker_threads";
|
|
5
6
|
import { availableParallelism } from "node:os";
|
|
@@ -14,12 +15,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
14
15
|
var __commonJS = (cb, mod) => function() {
|
|
15
16
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
17
|
};
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all) __defProp(target, name, {
|
|
19
|
-
get: all[name],
|
|
20
|
-
enumerable: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
18
|
var __copyProps = (to, from, except, desc) => {
|
|
24
19
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
20
|
key = keys[i];
|
|
@@ -34,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
29
|
value: mod,
|
|
35
30
|
enumerable: true
|
|
36
31
|
}) : target, mod));
|
|
37
|
-
var __require = /* @__PURE__ */ createRequire
|
|
32
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
38
33
|
|
|
39
34
|
//#endregion
|
|
40
35
|
//#region src/utils/define-config.ts
|
|
@@ -68,7 +63,11 @@ function bindingifySourcemap$1(map) {
|
|
|
68
63
|
//#endregion
|
|
69
64
|
//#region src/utils/error.ts
|
|
70
65
|
function normalizeErrors(rawErrors) {
|
|
71
|
-
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(),
|
|
66
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
67
|
+
kind: e.kind,
|
|
68
|
+
message: e.message,
|
|
69
|
+
stack: undefined
|
|
70
|
+
}));
|
|
72
71
|
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
73
72
|
for (let i = 0; i < errors.length; i++) {
|
|
74
73
|
if (i >= 5) {
|
|
@@ -140,6 +139,19 @@ function transformChunkModules(modules) {
|
|
|
140
139
|
|
|
141
140
|
//#endregion
|
|
142
141
|
//#region src/utils/transform-to-rollup-output.ts
|
|
142
|
+
function transformToRollupSourceMap(map) {
|
|
143
|
+
const parsed = JSON.parse(map);
|
|
144
|
+
const obj = {
|
|
145
|
+
...parsed,
|
|
146
|
+
toString() {
|
|
147
|
+
return JSON.stringify(obj);
|
|
148
|
+
},
|
|
149
|
+
toUrl() {
|
|
150
|
+
return `data:application/json;charset=utf-8;base64,${Buffer$1.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return obj;
|
|
154
|
+
}
|
|
143
155
|
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
144
156
|
const chunk = {
|
|
145
157
|
type: "chunk",
|
|
@@ -165,7 +177,7 @@ function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
|
165
177
|
return bindingChunk.moduleIds;
|
|
166
178
|
},
|
|
167
179
|
get map() {
|
|
168
|
-
return bindingChunk.map ?
|
|
180
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
169
181
|
},
|
|
170
182
|
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
171
183
|
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
@@ -188,10 +200,12 @@ function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
|
188
200
|
type: "asset",
|
|
189
201
|
fileName: bindingAsset.fileName,
|
|
190
202
|
originalFileName: bindingAsset.originalFileName || null,
|
|
203
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
191
204
|
get source() {
|
|
192
205
|
return transformAssetSource(bindingAsset.source);
|
|
193
206
|
},
|
|
194
|
-
name: bindingAsset.name ?? undefined
|
|
207
|
+
name: bindingAsset.name ?? undefined,
|
|
208
|
+
names: bindingAsset.names
|
|
195
209
|
};
|
|
196
210
|
const cache = {};
|
|
197
211
|
return new Proxy(asset, {
|
|
@@ -230,9 +244,9 @@ function collectChangedBundle(changed, bundle) {
|
|
|
230
244
|
const item = bundle[key];
|
|
231
245
|
if (item.type === "asset") assets.push({
|
|
232
246
|
filename: item.fileName,
|
|
233
|
-
|
|
247
|
+
originalFileNames: item.originalFileNames,
|
|
234
248
|
source: bindingAssetSource(item.source),
|
|
235
|
-
|
|
249
|
+
names: item.names
|
|
236
250
|
});
|
|
237
251
|
else chunks.push({
|
|
238
252
|
code: item.code,
|
|
@@ -240,7 +254,7 @@ else chunks.push({
|
|
|
240
254
|
name: item.name,
|
|
241
255
|
isEntry: item.isEntry,
|
|
242
256
|
exports: item.exports,
|
|
243
|
-
modules:
|
|
257
|
+
modules: {},
|
|
244
258
|
imports: item.imports,
|
|
245
259
|
dynamicImports: item.dynamicImports,
|
|
246
260
|
facadeModuleId: item.facadeModuleId || undefined,
|
|
@@ -261,7 +275,7 @@ else chunks.push({
|
|
|
261
275
|
//#endregion
|
|
262
276
|
//#region src/binding.js
|
|
263
277
|
var require_binding = __commonJS({ "src/binding.js"(exports, module) {
|
|
264
|
-
const { createRequire } = __require("node:module");
|
|
278
|
+
const { createRequire: createRequire$1 } = __require("node:module");
|
|
265
279
|
const { readFileSync } = __require("node:fs");
|
|
266
280
|
let nativeBinding = null;
|
|
267
281
|
const loadErrors = [];
|
|
@@ -549,6 +563,7 @@ else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architectur
|
|
|
549
563
|
}
|
|
550
564
|
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
|
|
551
565
|
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
|
|
566
|
+
module.exports.BindingError = nativeBinding.BindingError;
|
|
552
567
|
module.exports.BindingLog = nativeBinding.BindingLog;
|
|
553
568
|
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
|
|
554
569
|
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
|
|
@@ -567,8 +582,10 @@ else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architectur
|
|
|
567
582
|
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
568
583
|
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
569
584
|
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
585
|
+
module.exports.HelperMode = nativeBinding.HelperMode;
|
|
570
586
|
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
571
587
|
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
588
|
+
module.exports.Severity = nativeBinding.Severity;
|
|
572
589
|
module.exports.transform = nativeBinding.transform;
|
|
573
590
|
} });
|
|
574
591
|
|
|
@@ -597,9 +614,9 @@ function noop(..._args) {}
|
|
|
597
614
|
|
|
598
615
|
//#endregion
|
|
599
616
|
//#region src/log/logging.ts
|
|
600
|
-
const LogLevelSchema = z
|
|
601
|
-
const LogLevelOptionSchema = LogLevelSchema.or(z
|
|
602
|
-
const LogLevelWithErrorSchema = LogLevelSchema.or(z
|
|
617
|
+
const LogLevelSchema = z.literal("info").or(z.literal("debug")).or(z.literal("warn"));
|
|
618
|
+
const LogLevelOptionSchema = LogLevelSchema.or(z.literal("silent"));
|
|
619
|
+
const LogLevelWithErrorSchema = LogLevelSchema.or(z.literal("error"));
|
|
603
620
|
const LOG_LEVEL_SILENT = "silent";
|
|
604
621
|
const LOG_LEVEL_ERROR = "error";
|
|
605
622
|
const LOG_LEVEL_WARN = "warn";
|
|
@@ -611,8 +628,8 @@ const logLevelPriority = {
|
|
|
611
628
|
[LOG_LEVEL_WARN]: 2,
|
|
612
629
|
[LOG_LEVEL_SILENT]: 3
|
|
613
630
|
};
|
|
614
|
-
const RollupLogSchema = z
|
|
615
|
-
const RollupLogWithStringSchema = RollupLogSchema.or(z
|
|
631
|
+
const RollupLogSchema = z.any();
|
|
632
|
+
const RollupLogWithStringSchema = RollupLogSchema.or(z.string());
|
|
616
633
|
|
|
617
634
|
//#endregion
|
|
618
635
|
//#region src/utils/code-frame.ts
|
|
@@ -706,7 +723,7 @@ function locate(source, search, options) {
|
|
|
706
723
|
|
|
707
724
|
//#endregion
|
|
708
725
|
//#region src/log/logs.ts
|
|
709
|
-
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";
|
|
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";
|
|
710
727
|
function logInvalidLogPosition(pluginName) {
|
|
711
728
|
return {
|
|
712
729
|
code: INVALID_LOG_POSITION,
|
|
@@ -725,6 +742,12 @@ function logCycleLoading(pluginName, moduleId) {
|
|
|
725
742
|
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
726
743
|
};
|
|
727
744
|
}
|
|
745
|
+
function logMultiplyNotifyOption() {
|
|
746
|
+
return {
|
|
747
|
+
code: MULTIPLY_NOTIFY_OPTION,
|
|
748
|
+
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
749
|
+
};
|
|
750
|
+
}
|
|
728
751
|
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
729
752
|
const code = error$1.code;
|
|
730
753
|
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
@@ -880,9 +903,9 @@ function relativeId(id) {
|
|
|
880
903
|
|
|
881
904
|
//#endregion
|
|
882
905
|
//#region src/builtin-plugin/utils.ts
|
|
883
|
-
var import_binding$
|
|
906
|
+
var import_binding$6 = __toESM(require_binding());
|
|
884
907
|
function makeBuiltinPluginCallable(plugin) {
|
|
885
|
-
let callablePlugin = new import_binding$
|
|
908
|
+
let callablePlugin = new import_binding$6.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
886
909
|
const wrappedPlugin = plugin;
|
|
887
910
|
for (const key in callablePlugin) wrappedPlugin[key] = function(...args) {
|
|
888
911
|
return callablePlugin[key](...args);
|
|
@@ -1115,7 +1138,7 @@ const ModuleSideEffectsRuleSchema = z.object({
|
|
|
1115
1138
|
}).refine((data) => {
|
|
1116
1139
|
return data.test !== undefined || data.external !== undefined;
|
|
1117
1140
|
}, "Either `test` or `external` should be set.");
|
|
1118
|
-
const ModuleSideEffectsOptionSchema = z.boolean().or(z.array(ModuleSideEffectsRuleSchema)).or(z.literal("no-external"));
|
|
1141
|
+
const ModuleSideEffectsOptionSchema = z.boolean().or(z.array(ModuleSideEffectsRuleSchema)).or(z.function().args(z.string(), z.boolean()).returns(z.boolean().optional())).or(z.literal("no-external"));
|
|
1119
1142
|
const TreeshakingOptionsSchema = z.object({
|
|
1120
1143
|
moduleSideEffects: ModuleSideEffectsOptionSchema.optional(),
|
|
1121
1144
|
annotations: z.boolean().optional()
|
|
@@ -1182,12 +1205,12 @@ var MinimalPluginContext = class {
|
|
|
1182
1205
|
|
|
1183
1206
|
//#endregion
|
|
1184
1207
|
//#region src/utils/transform-side-effects.ts
|
|
1185
|
-
var import_binding$
|
|
1208
|
+
var import_binding$5 = __toESM(require_binding());
|
|
1186
1209
|
function bindingifySideEffects(sideEffects) {
|
|
1187
1210
|
switch (sideEffects) {
|
|
1188
|
-
case true: return import_binding$
|
|
1189
|
-
case false: return import_binding$
|
|
1190
|
-
case "no-treeshake": return import_binding$
|
|
1211
|
+
case true: return import_binding$5.BindingHookSideEffects.True;
|
|
1212
|
+
case false: return import_binding$5.BindingHookSideEffects.False;
|
|
1213
|
+
case "no-treeshake": return import_binding$5.BindingHookSideEffects.NoTreeshake;
|
|
1191
1214
|
case null:
|
|
1192
1215
|
case undefined: return undefined;
|
|
1193
1216
|
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
@@ -1298,14 +1321,14 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1298
1321
|
|
|
1299
1322
|
//#endregion
|
|
1300
1323
|
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1301
|
-
var import_binding$
|
|
1324
|
+
var import_binding$4 = __toESM(require_binding());
|
|
1302
1325
|
function bindingifyPluginHookMeta(options) {
|
|
1303
1326
|
return { order: bindingPluginOrder(options.order) };
|
|
1304
1327
|
}
|
|
1305
1328
|
function bindingPluginOrder(order) {
|
|
1306
1329
|
switch (order) {
|
|
1307
|
-
case "post": return import_binding$
|
|
1308
|
-
case "pre": return import_binding$
|
|
1330
|
+
case "post": return import_binding$4.BindingPluginOrder.Post;
|
|
1331
|
+
case "pre": return import_binding$4.BindingPluginOrder.Pre;
|
|
1309
1332
|
case null:
|
|
1310
1333
|
case undefined: return undefined;
|
|
1311
1334
|
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
@@ -1386,7 +1409,7 @@ function bindingifyBuildEnd(args) {
|
|
|
1386
1409
|
const { handler, meta } = normalizeHook(hook);
|
|
1387
1410
|
return {
|
|
1388
1411
|
plugin: async (ctx, err) => {
|
|
1389
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), err ?
|
|
1412
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), err ? normalizeErrors(err) : undefined);
|
|
1390
1413
|
},
|
|
1391
1414
|
meta: bindingifyPluginHookMeta(meta)
|
|
1392
1415
|
};
|
|
@@ -1613,6 +1636,9 @@ var NormalizedOutputOptionsImpl = class {
|
|
|
1613
1636
|
get comments() {
|
|
1614
1637
|
return this.inner.comments;
|
|
1615
1638
|
}
|
|
1639
|
+
get polyfillRequire() {
|
|
1640
|
+
return this.inner.polyfillRequire;
|
|
1641
|
+
}
|
|
1616
1642
|
};
|
|
1617
1643
|
|
|
1618
1644
|
//#endregion
|
|
@@ -1663,7 +1689,7 @@ function bindingifyRenderError(args) {
|
|
|
1663
1689
|
const { handler, meta } = normalizeHook(hook);
|
|
1664
1690
|
return {
|
|
1665
1691
|
plugin: async (ctx, err) => {
|
|
1666
|
-
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel),
|
|
1692
|
+
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), normalizeErrors(err));
|
|
1667
1693
|
},
|
|
1668
1694
|
meta: bindingifyPluginHookMeta(meta)
|
|
1669
1695
|
};
|
|
@@ -1964,7 +1990,7 @@ function normalizedStringOrRegex(pattern) {
|
|
|
1964
1990
|
|
|
1965
1991
|
//#endregion
|
|
1966
1992
|
//#region src/utils/bindingify-input-options.ts
|
|
1967
|
-
var import_binding$
|
|
1993
|
+
var import_binding$3 = __toESM(require_binding());
|
|
1968
1994
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog, logLevel) {
|
|
1969
1995
|
const pluginContextData = new PluginContextData();
|
|
1970
1996
|
const plugins = rawPlugins.map((plugin) => {
|
|
@@ -1995,7 +2021,9 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog,
|
|
|
1995
2021
|
profilerNames: inputOptions?.profilerNames,
|
|
1996
2022
|
jsx: bindingifyJsx(inputOptions.jsx),
|
|
1997
2023
|
watch: bindingifyWatch(inputOptions.watch),
|
|
1998
|
-
dropLabels: inputOptions.dropLabels
|
|
2024
|
+
dropLabels: inputOptions.dropLabels,
|
|
2025
|
+
keepNames: inputOptions.keepNames,
|
|
2026
|
+
checks: inputOptions.checks
|
|
1999
2027
|
};
|
|
2000
2028
|
}
|
|
2001
2029
|
function bindingifyExternal(external) {
|
|
@@ -2019,7 +2047,7 @@ function bindingifyResolve(resolve) {
|
|
|
2019
2047
|
return {
|
|
2020
2048
|
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
2021
2049
|
find: name,
|
|
2022
|
-
replacements:
|
|
2050
|
+
replacements: arraify(replacement)
|
|
2023
2051
|
})) : undefined,
|
|
2024
2052
|
extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
2025
2053
|
target: name,
|
|
@@ -2053,10 +2081,10 @@ function bindingifyInject(inject) {
|
|
|
2053
2081
|
}
|
|
2054
2082
|
function bindingifyLogLevel(logLevel) {
|
|
2055
2083
|
switch (logLevel) {
|
|
2056
|
-
case "silent": return import_binding$
|
|
2057
|
-
case "debug": return import_binding$
|
|
2058
|
-
case "warn": return import_binding$
|
|
2059
|
-
case "info": return import_binding$
|
|
2084
|
+
case "silent": return import_binding$3.BindingLogLevel.Silent;
|
|
2085
|
+
case "debug": return import_binding$3.BindingLogLevel.Debug;
|
|
2086
|
+
case "warn": return import_binding$3.BindingLogLevel.Warn;
|
|
2087
|
+
case "info": return import_binding$3.BindingLogLevel.Info;
|
|
2060
2088
|
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
2061
2089
|
}
|
|
2062
2090
|
}
|
|
@@ -2091,10 +2119,6 @@ function bindingifyWatch(watch$1) {
|
|
|
2091
2119
|
include: normalizedStringOrRegex(watch$1.include),
|
|
2092
2120
|
exclude: normalizedStringOrRegex(watch$1.exclude)
|
|
2093
2121
|
};
|
|
2094
|
-
if (watch$1.notify) value.notify = {
|
|
2095
|
-
pollInterval: watch$1.notify.pollInterval,
|
|
2096
|
-
compareContents: watch$1.notify.compareContents
|
|
2097
|
-
};
|
|
2098
2122
|
if (watch$1.chokidar) unsupported("The watch chokidar option is deprecated, please use notify options instead of it.");
|
|
2099
2123
|
return value;
|
|
2100
2124
|
}
|
|
@@ -2149,7 +2173,8 @@ function bindingifyOutputOptions(outputOptions) {
|
|
|
2149
2173
|
minify: outputOptions.minify,
|
|
2150
2174
|
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2151
2175
|
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2152
|
-
advancedChunks: outputOptions.advancedChunks
|
|
2176
|
+
advancedChunks: outputOptions.advancedChunks,
|
|
2177
|
+
polyfillRequire: outputOptions.polyfillRequire
|
|
2153
2178
|
};
|
|
2154
2179
|
}
|
|
2155
2180
|
function bindingifyAddon(configAddon) {
|
|
@@ -2535,7 +2560,7 @@ else newPlugins.push(toBeComposed[0]);
|
|
|
2535
2560
|
|
|
2536
2561
|
//#endregion
|
|
2537
2562
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
2538
|
-
var import_binding$
|
|
2563
|
+
var import_binding$2 = __toESM(require_binding());
|
|
2539
2564
|
async function initializeParallelPlugins(plugins) {
|
|
2540
2565
|
const pluginInfos = [];
|
|
2541
2566
|
for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
|
|
@@ -2548,7 +2573,7 @@ async function initializeParallelPlugins(plugins) {
|
|
|
2548
2573
|
}
|
|
2549
2574
|
if (pluginInfos.length <= 0) return undefined;
|
|
2550
2575
|
const count = Math.min(availableParallelism(), 8);
|
|
2551
|
-
const parallelJsPluginRegistry = new import_binding$
|
|
2576
|
+
const parallelJsPluginRegistry = new import_binding$2.ParallelJsPluginRegistry(count);
|
|
2552
2577
|
const registryId = parallelJsPluginRegistry.id;
|
|
2553
2578
|
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2554
2579
|
const stopWorkers = async () => {
|
|
@@ -2564,14 +2589,14 @@ function initializeWorkers(registryId, count, pluginInfos) {
|
|
|
2564
2589
|
}
|
|
2565
2590
|
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2566
2591
|
const urlString = import.meta.resolve("#parallel-plugin-worker");
|
|
2567
|
-
const workerData = {
|
|
2592
|
+
const workerData$1 = {
|
|
2568
2593
|
registryId,
|
|
2569
2594
|
pluginInfos,
|
|
2570
2595
|
threadNumber
|
|
2571
2596
|
};
|
|
2572
2597
|
let worker;
|
|
2573
2598
|
try {
|
|
2574
|
-
worker = new Worker(new URL(urlString), { workerData });
|
|
2599
|
+
worker = new Worker(new URL(urlString), { workerData: workerData$1 });
|
|
2575
2600
|
worker.unref();
|
|
2576
2601
|
await new Promise((resolve, reject) => {
|
|
2577
2602
|
worker.once("message", async (message) => {
|
|
@@ -2587,9 +2612,8 @@ else resolve();
|
|
|
2587
2612
|
}
|
|
2588
2613
|
|
|
2589
2614
|
//#endregion
|
|
2590
|
-
//#region src/utils/create-bundler.ts
|
|
2591
|
-
|
|
2592
|
-
async function createBundler(inputOptions, outputOptions) {
|
|
2615
|
+
//#region src/utils/create-bundler-option.ts
|
|
2616
|
+
async function createBundlerOptions(inputOptions, outputOptions) {
|
|
2593
2617
|
const pluginDriver = new PluginDriver();
|
|
2594
2618
|
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2595
2619
|
if (inputOptions.treeshake !== undefined) TreeshakingOptionsSchema.parse(inputOptions.treeshake);
|
|
@@ -2605,7 +2629,13 @@ async function createBundler(inputOptions, outputOptions) {
|
|
|
2605
2629
|
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, onLog, logLevel);
|
|
2606
2630
|
const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
|
|
2607
2631
|
return {
|
|
2608
|
-
|
|
2632
|
+
bundlerOptions: {
|
|
2633
|
+
inputOptions: bindingInputOptions,
|
|
2634
|
+
outputOptions: bindingOutputOptions,
|
|
2635
|
+
parallelPluginsRegistry: parallelPluginInitResult?.registry
|
|
2636
|
+
},
|
|
2637
|
+
inputOptions,
|
|
2638
|
+
onLog,
|
|
2609
2639
|
stopWorkers: parallelPluginInitResult?.stopWorkers
|
|
2610
2640
|
};
|
|
2611
2641
|
} catch (e) {
|
|
@@ -2615,7 +2645,23 @@ async function createBundler(inputOptions, outputOptions) {
|
|
|
2615
2645
|
}
|
|
2616
2646
|
|
|
2617
2647
|
//#endregion
|
|
2618
|
-
//#region src/
|
|
2648
|
+
//#region src/utils/create-bundler.ts
|
|
2649
|
+
var import_binding$1 = __toESM(require_binding());
|
|
2650
|
+
async function createBundler(inputOptions, outputOptions) {
|
|
2651
|
+
const option = await createBundlerOptions(inputOptions, outputOptions);
|
|
2652
|
+
try {
|
|
2653
|
+
return {
|
|
2654
|
+
bundler: new import_binding$1.Bundler(option.bundlerOptions),
|
|
2655
|
+
stopWorkers: option.stopWorkers
|
|
2656
|
+
};
|
|
2657
|
+
} catch (e) {
|
|
2658
|
+
await option.stopWorkers?.();
|
|
2659
|
+
throw e;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
//#endregion
|
|
2664
|
+
//#region src/api/rolldown/rolldown-build.ts
|
|
2619
2665
|
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
2620
2666
|
var RolldownBuild = class {
|
|
2621
2667
|
#inputOptions;
|
|
@@ -2651,111 +2697,155 @@ var RolldownBuild = class {
|
|
|
2651
2697
|
};
|
|
2652
2698
|
|
|
2653
2699
|
//#endregion
|
|
2654
|
-
//#region src/
|
|
2700
|
+
//#region src/api/rolldown/index.ts
|
|
2701
|
+
const rolldown = async (input) => {
|
|
2702
|
+
return new RolldownBuild(input);
|
|
2703
|
+
};
|
|
2704
|
+
|
|
2705
|
+
//#endregion
|
|
2706
|
+
//#region src/api/watch/watch-emitter.ts
|
|
2707
|
+
var WatcherEmitter = class {
|
|
2708
|
+
listeners = new Map();
|
|
2709
|
+
timer;
|
|
2710
|
+
constructor() {
|
|
2711
|
+
this.timer = setInterval(
|
|
2712
|
+
() => {},
|
|
2713
|
+
1e9
|
|
2714
|
+
/* Low power usage */
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
on(event, listener) {
|
|
2718
|
+
const listeners = this.listeners.get(event);
|
|
2719
|
+
if (listeners) listeners.push(listener);
|
|
2720
|
+
else this.listeners.set(event, [listener]);
|
|
2721
|
+
return this;
|
|
2722
|
+
}
|
|
2723
|
+
async onEvent(event) {
|
|
2724
|
+
const listeners = this.listeners.get(event.eventKind());
|
|
2725
|
+
if (listeners) switch (event.eventKind()) {
|
|
2726
|
+
case "close":
|
|
2727
|
+
case "restart":
|
|
2728
|
+
for (const listener of listeners) await listener();
|
|
2729
|
+
break;
|
|
2730
|
+
case "event":
|
|
2731
|
+
for (const listener of listeners) {
|
|
2732
|
+
const code = event.bundleEventKind();
|
|
2733
|
+
switch (code) {
|
|
2734
|
+
case "BUNDLE_END":
|
|
2735
|
+
const { duration, output } = event.bundleEndData();
|
|
2736
|
+
await listener({
|
|
2737
|
+
code: "BUNDLE_END",
|
|
2738
|
+
duration,
|
|
2739
|
+
output: [output]
|
|
2740
|
+
});
|
|
2741
|
+
break;
|
|
2742
|
+
case "ERROR":
|
|
2743
|
+
const errors = event.errors();
|
|
2744
|
+
await listener({
|
|
2745
|
+
code: "ERROR",
|
|
2746
|
+
error: normalizeErrors(errors)
|
|
2747
|
+
});
|
|
2748
|
+
break;
|
|
2749
|
+
default:
|
|
2750
|
+
await listener({ code });
|
|
2751
|
+
break;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
break;
|
|
2755
|
+
case "change":
|
|
2756
|
+
for (const listener of listeners) {
|
|
2757
|
+
const { path: path$2, kind } = event.watchChangeData();
|
|
2758
|
+
await listener(path$2, { event: kind });
|
|
2759
|
+
}
|
|
2760
|
+
break;
|
|
2761
|
+
default: throw new Error(`Unknown event: ${event}`);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
async close() {
|
|
2765
|
+
clearInterval(this.timer);
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
|
|
2769
|
+
//#endregion
|
|
2770
|
+
//#region src/api/watch/watcher.ts
|
|
2771
|
+
var import_binding = __toESM(require_binding());
|
|
2655
2772
|
var Watcher = class {
|
|
2656
2773
|
closed;
|
|
2657
|
-
controller;
|
|
2658
2774
|
inner;
|
|
2775
|
+
emitter;
|
|
2659
2776
|
stopWorkers;
|
|
2660
|
-
|
|
2661
|
-
constructor(inner, stopWorkers) {
|
|
2777
|
+
constructor(emitter, inner, stopWorkers) {
|
|
2662
2778
|
this.closed = false;
|
|
2663
|
-
this.controller = new AbortController();
|
|
2664
2779
|
this.inner = inner;
|
|
2780
|
+
this.emitter = emitter;
|
|
2781
|
+
const originClose = emitter.close.bind(emitter);
|
|
2782
|
+
emitter.close = async () => {
|
|
2783
|
+
await this.close();
|
|
2784
|
+
originClose();
|
|
2785
|
+
};
|
|
2665
2786
|
this.stopWorkers = stopWorkers;
|
|
2666
2787
|
}
|
|
2667
2788
|
async close() {
|
|
2789
|
+
if (this.closed) return;
|
|
2668
2790
|
this.closed = true;
|
|
2669
|
-
|
|
2791
|
+
for (const stop of this.stopWorkers) await stop?.();
|
|
2670
2792
|
await this.inner.close();
|
|
2671
|
-
this.controller.abort();
|
|
2672
|
-
}
|
|
2673
|
-
on(event, listener) {
|
|
2674
|
-
const listeners = this.listeners.get(event);
|
|
2675
|
-
if (listeners) listeners.push(listener);
|
|
2676
|
-
else this.listeners.set(event, [listener]);
|
|
2677
|
-
return this;
|
|
2678
2793
|
}
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
() => {},
|
|
2682
|
-
1e9
|
|
2683
|
-
/* Low power usage */
|
|
2684
|
-
);
|
|
2685
|
-
this.controller.signal.addEventListener("abort", () => {
|
|
2686
|
-
clearInterval(timer);
|
|
2687
|
-
});
|
|
2688
|
-
process.nextTick(() => this.inner.start(async (event) => {
|
|
2689
|
-
const listeners = this.listeners.get(event.eventKind());
|
|
2690
|
-
if (listeners) switch (event.eventKind()) {
|
|
2691
|
-
case "close":
|
|
2692
|
-
case "restart":
|
|
2693
|
-
for (const listener of listeners) await listener();
|
|
2694
|
-
break;
|
|
2695
|
-
case "event":
|
|
2696
|
-
for (const listener of listeners) {
|
|
2697
|
-
const code = event.bundleEventKind();
|
|
2698
|
-
switch (code) {
|
|
2699
|
-
case "BUNDLE_END":
|
|
2700
|
-
const { duration, output } = event.bundleEndData();
|
|
2701
|
-
await listener({
|
|
2702
|
-
code: "BUNDLE_END",
|
|
2703
|
-
duration,
|
|
2704
|
-
output: [output]
|
|
2705
|
-
});
|
|
2706
|
-
break;
|
|
2707
|
-
case "ERROR":
|
|
2708
|
-
const errors = event.errors();
|
|
2709
|
-
await listener({
|
|
2710
|
-
code: "ERROR",
|
|
2711
|
-
error: normalizeErrors(errors)
|
|
2712
|
-
});
|
|
2713
|
-
break;
|
|
2714
|
-
default:
|
|
2715
|
-
await listener({ code });
|
|
2716
|
-
break;
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
break;
|
|
2720
|
-
case "change":
|
|
2721
|
-
for (const listener of listeners) {
|
|
2722
|
-
const { path: path$2, kind } = event.watchChangeData();
|
|
2723
|
-
await listener(path$2, { event: kind });
|
|
2724
|
-
}
|
|
2725
|
-
break;
|
|
2726
|
-
default: throw new Error(`Unknown event: ${event}`);
|
|
2727
|
-
}
|
|
2728
|
-
}));
|
|
2794
|
+
start() {
|
|
2795
|
+
process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
|
|
2729
2796
|
}
|
|
2730
2797
|
};
|
|
2798
|
+
async function createWatcher(emitter, input) {
|
|
2799
|
+
const options = Array.isArray(input) ? input : [input];
|
|
2800
|
+
const bundlerOptions = await Promise.all(options.map((option) => createBundlerOptions(option, option.output || {})));
|
|
2801
|
+
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
2802
|
+
const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
2803
|
+
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
2804
|
+
watcher.start();
|
|
2805
|
+
}
|
|
2806
|
+
function getValidNotifyOption(bundlerOptions) {
|
|
2807
|
+
let result;
|
|
2808
|
+
for (const option of bundlerOptions) if (option.inputOptions.watch) {
|
|
2809
|
+
const notifyOption = option.inputOptions.watch.notify;
|
|
2810
|
+
if (notifyOption) if (result) {
|
|
2811
|
+
option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
|
|
2812
|
+
return result;
|
|
2813
|
+
} else result = notifyOption;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2731
2816
|
|
|
2732
2817
|
//#endregion
|
|
2733
|
-
//#region src/
|
|
2734
|
-
const
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
const { bundler, stopWorkers } = await createBundler(input, input.output || {});
|
|
2739
|
-
const bindingWatcher = await bundler.watch();
|
|
2740
|
-
const watcher = new Watcher(bindingWatcher, stopWorkers);
|
|
2741
|
-
watcher.watch();
|
|
2742
|
-
return watcher;
|
|
2743
|
-
};
|
|
2744
|
-
const experimental_scan = async (input) => {
|
|
2745
|
-
const { bundler, stopWorkers } = await createBundler(input, {});
|
|
2746
|
-
const output = await bundler.scan();
|
|
2747
|
-
handleOutputErrors(output);
|
|
2748
|
-
await stopWorkers?.();
|
|
2818
|
+
//#region src/api/watch/index.ts
|
|
2819
|
+
const watch = (input) => {
|
|
2820
|
+
const emitter = new WatcherEmitter();
|
|
2821
|
+
createWatcher(emitter, input);
|
|
2822
|
+
return emitter;
|
|
2749
2823
|
};
|
|
2750
2824
|
|
|
2751
2825
|
//#endregion
|
|
2752
2826
|
//#region package.json
|
|
2753
|
-
var version = "0.
|
|
2827
|
+
var version = "0.15.0-commit.ac58858";
|
|
2754
2828
|
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
2755
2829
|
|
|
2830
|
+
//#endregion
|
|
2831
|
+
//#region src/api/build.ts
|
|
2832
|
+
async function build(options) {
|
|
2833
|
+
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
2834
|
+
else {
|
|
2835
|
+
const { output, write = true,...inputOptions } = options;
|
|
2836
|
+
const build$1 = await rolldown(inputOptions);
|
|
2837
|
+
try {
|
|
2838
|
+
if (write) return await build$1.write(output);
|
|
2839
|
+
else return await build$1.generate(output);
|
|
2840
|
+
} finally {
|
|
2841
|
+
await build$1.close();
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2756
2846
|
//#endregion
|
|
2757
2847
|
//#region src/index.ts
|
|
2758
2848
|
const VERSION = version;
|
|
2759
2849
|
|
|
2760
2850
|
//#endregion
|
|
2761
|
-
export { BuiltinPlugin, LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, PluginContextData, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, VERSION,
|
|
2851
|
+
export { BuiltinPlugin, LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, PluginContextData, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, VERSION, __toESM, arraify, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, rolldown, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch };
|