@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731
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/LICENSE +41 -0
- package/dist/pluginutils/filter/composable-filters.d.ts +90 -0
- package/dist/pluginutils/filter/composable-filters.js +256 -0
- package/dist/pluginutils/filter/filter-vite-plugins.d.ts +28 -0
- package/dist/pluginutils/filter/filter-vite-plugins.js +75 -0
- package/dist/pluginutils/filter/index.d.ts +3 -0
- package/dist/pluginutils/filter/index.js +3 -0
- package/dist/pluginutils/filter/simple-filters.d.ts +71 -0
- package/dist/pluginutils/filter/simple-filters.js +70 -0
- package/dist/pluginutils/index.d.ts +1 -0
- package/dist/pluginutils/index.js +1 -0
- package/dist/pluginutils/utils.d.ts +2 -0
- package/dist/pluginutils/utils.js +17 -0
- package/dist/rolldown/cli-setup.d.mts +1 -0
- package/dist/rolldown/cli-setup.mjs +17 -0
- package/dist/rolldown/cli.d.mts +1 -0
- package/dist/rolldown/cli.mjs +608 -0
- package/dist/rolldown/config.d.mts +7 -0
- package/dist/rolldown/config.mjs +10 -0
- package/dist/rolldown/experimental-index.d.mts +194 -0
- package/dist/rolldown/experimental-index.mjs +291 -0
- package/dist/rolldown/experimental-runtime-types.d.ts +98 -0
- package/dist/rolldown/filter-index.d.mts +197 -0
- package/dist/rolldown/filter-index.mjs +369 -0
- package/dist/rolldown/get-log-filter.d.mts +7 -0
- package/dist/rolldown/get-log-filter.mjs +47 -0
- package/dist/rolldown/index.d.mts +4 -0
- package/dist/rolldown/index.mjs +57 -0
- package/dist/rolldown/parallel-plugin-worker.d.mts +1 -0
- package/dist/rolldown/parallel-plugin-worker.mjs +32 -0
- package/dist/rolldown/parallel-plugin.d.mts +14 -0
- package/dist/rolldown/parallel-plugin.mjs +7 -0
- package/dist/rolldown/parse-ast-index.d.mts +8 -0
- package/dist/rolldown/parse-ast-index.mjs +47 -0
- package/dist/rolldown/plugins-index.d.mts +30 -0
- package/dist/rolldown/plugins-index.mjs +40 -0
- package/dist/rolldown/shared/binding-D-XMzSaG.d.mts +1665 -0
- package/dist/rolldown/shared/binding-DuOSzYPt.mjs +587 -0
- package/dist/rolldown/shared/bindingify-input-options-Bu6nUTgS.mjs +2257 -0
- package/dist/rolldown/shared/constructors-DZVRHTli.mjs +61 -0
- package/dist/rolldown/shared/constructors-KD7LvxpN.d.mts +28 -0
- package/dist/rolldown/shared/define-config-BVG4QvnP.mjs +7 -0
- package/dist/rolldown/shared/define-config-U4pj0ZDn.d.mts +3616 -0
- package/dist/rolldown/shared/load-config-O1K_tT_z.mjs +114 -0
- package/dist/rolldown/shared/logging-CE90D8JR.d.mts +50 -0
- package/dist/rolldown/shared/logs-NH298mHo.mjs +183 -0
- package/dist/rolldown/shared/misc-CCZIsXVO.mjs +22 -0
- package/dist/rolldown/shared/normalize-string-or-regex-DeZqg15i.mjs +61 -0
- package/dist/rolldown/shared/parse-DLraxqjd.mjs +56 -0
- package/dist/rolldown/shared/prompt-DeISmFRp.mjs +847 -0
- package/dist/rolldown/shared/rolldown-O0UKbTKf.mjs +42 -0
- package/dist/rolldown/shared/rolldown-build-BIs7C4B_.mjs +3354 -0
- package/dist/rolldown/shared/watch-DQXGaDjx.mjs +379 -0
- package/dist/tsdown/build-l5WhXg4M-BBPqZr0m.js +4933 -0
- package/dist/tsdown/chunk-CdeBBKNj.js +44 -0
- package/dist/tsdown/debug-Cb_Nqpo4-BueIRvg1.js +18 -0
- package/dist/tsdown/detect-CCATtVj7-B86m8IqW.js +165 -0
- package/dist/tsdown/dist-BUOkzr_P.js +201 -0
- package/dist/tsdown/dist-BVMGwPdF.js +32363 -0
- package/dist/tsdown/dist-dc0X0G6b.js +742 -0
- package/dist/tsdown/filename-7rlgePeo.js +31 -0
- package/dist/tsdown/index-node-BjDys8jy--sqPE5mM.js +251 -0
- package/dist/tsdown/index-types.d.ts +2163 -0
- package/dist/tsdown/index.js +14 -0
- package/dist/tsdown/main-d9yZSQqW.js +926 -0
- package/dist/tsdown/node-Cb5OsnKg.js +271 -0
- package/dist/tsdown/npm_cjs_chunk_chunk.cjs +11 -0
- package/dist/tsdown/npm_cjs_chunk_range.cjs +484 -0
- package/dist/tsdown/npm_cjs_chunk_semver.cjs +362 -0
- package/dist/tsdown/npm_entry_picomatch.cjs +1676 -0
- package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +52 -0
- package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +23 -0
- package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +48 -0
- package/dist/tsdown/npm_entry_tree-kill.cjs +103 -0
- package/dist/tsdown/resolver-j7HY1N36-CIu_7LX6.js +20 -0
- package/dist/tsdown/run.js +537 -0
- package/dist/tsdown/tsc-context-BNYuT3cE.js +25 -0
- package/dist/tsdown/tsc-reo6aLWc.js +423 -0
- package/dist/vite/client/client.mjs +1140 -0
- package/dist/vite/client/env.mjs +19 -0
- package/dist/vite/client.d.ts +279 -0
- package/dist/vite/misc/false.d.ts +2 -0
- package/dist/vite/misc/false.js +1 -0
- package/dist/vite/misc/true.d.ts +2 -0
- package/dist/vite/misc/true.js +1 -0
- package/dist/vite/node/chunks/build2.js +5538 -0
- package/dist/vite/node/chunks/chunk.js +45 -0
- package/dist/vite/node/chunks/dist.js +6758 -0
- package/dist/vite/node/chunks/dist2.js +6651 -0
- package/dist/vite/node/chunks/fetchableEnvironments.js +41395 -0
- package/dist/vite/node/chunks/lib.js +377 -0
- package/dist/vite/node/chunks/logger.js +332 -0
- package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/dist/vite/node/chunks/postcss-import.js +479 -0
- package/dist/vite/node/cli.js +699 -0
- package/dist/vite/node/index.d.ts +3807 -0
- package/dist/vite/node/index.js +15 -0
- package/dist/vite/node/internal.d.ts +2 -0
- package/dist/vite/node/internal.js +3 -0
- package/dist/vite/node/module-runner.d.ts +311 -0
- package/dist/vite/node/module-runner.js +1159 -0
- package/dist/vite/types/customEvent.d.ts +52 -0
- package/dist/vite/types/hmrPayload.d.ts +80 -0
- package/dist/vite/types/hot.d.ts +39 -0
- package/dist/vite/types/import-meta.d.ts +5 -0
- package/dist/vite/types/importGlob.d.ts +89 -0
- package/dist/vite/types/importMeta.d.ts +30 -0
- package/dist/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/dist/vite/types/internal/esbuildOptions.d.ts +28 -0
- package/dist/vite/types/internal/lightningcssOptions.d.ts +18 -0
- package/dist/vite/types/internal/rollupTypeCompat.d.ts +24 -0
- package/dist/vite/types/internal/terserOptions.d.ts +11 -0
- package/dist/vite/types/metadata.d.ts +47 -0
- package/package.json +204 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import "./shared/binding-DuOSzYPt.mjs";
|
|
2
|
+
import { n as onExit, t as watch } from "./shared/watch-DQXGaDjx.mjs";
|
|
3
|
+
import "./shared/normalize-string-or-regex-DeZqg15i.mjs";
|
|
4
|
+
import { E as version, T as description } from "./shared/bindingify-input-options-Bu6nUTgS.mjs";
|
|
5
|
+
import { t as arraify } from "./shared/misc-CCZIsXVO.mjs";
|
|
6
|
+
import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText$1, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-BIs7C4B_.mjs";
|
|
7
|
+
import "./shared/parse-DLraxqjd.mjs";
|
|
8
|
+
import { t as rolldown } from "./shared/rolldown-O0UKbTKf.mjs";
|
|
9
|
+
import { t as loadConfig } from "./shared/load-config-O1K_tT_z.mjs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { parseArgs } from "node:util";
|
|
12
|
+
import process$1 from "node:process";
|
|
13
|
+
import { performance } from "node:perf_hooks";
|
|
14
|
+
|
|
15
|
+
//#region src/cli/arguments/alias.ts
|
|
16
|
+
const alias = {
|
|
17
|
+
config: {
|
|
18
|
+
abbreviation: "c",
|
|
19
|
+
hint: "filename"
|
|
20
|
+
},
|
|
21
|
+
help: { abbreviation: "h" },
|
|
22
|
+
version: { abbreviation: "v" },
|
|
23
|
+
watch: { abbreviation: "w" },
|
|
24
|
+
dir: { abbreviation: "d" },
|
|
25
|
+
file: { abbreviation: "o" },
|
|
26
|
+
external: { abbreviation: "e" },
|
|
27
|
+
format: { abbreviation: "f" },
|
|
28
|
+
name: { abbreviation: "n" },
|
|
29
|
+
globals: { abbreviation: "g" },
|
|
30
|
+
sourcemap: {
|
|
31
|
+
abbreviation: "s",
|
|
32
|
+
default: true
|
|
33
|
+
},
|
|
34
|
+
minify: { abbreviation: "m" },
|
|
35
|
+
platform: { abbreviation: "p" },
|
|
36
|
+
assetFileNames: { hint: "name" },
|
|
37
|
+
chunkFileNames: { hint: "name" },
|
|
38
|
+
entryFileNames: { hint: "name" },
|
|
39
|
+
externalLiveBindings: {
|
|
40
|
+
default: true,
|
|
41
|
+
reverse: true
|
|
42
|
+
},
|
|
43
|
+
treeshake: {
|
|
44
|
+
default: true,
|
|
45
|
+
reverse: true
|
|
46
|
+
},
|
|
47
|
+
preserveEntrySignatures: {
|
|
48
|
+
default: "strict",
|
|
49
|
+
reverse: true
|
|
50
|
+
},
|
|
51
|
+
moduleTypes: { hint: "types" }
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/cli/arguments/utils.ts
|
|
56
|
+
function setNestedProperty(obj, path, value) {
|
|
57
|
+
const keys = path.split(".");
|
|
58
|
+
let current = obj;
|
|
59
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
60
|
+
if (!current[keys[i]]) current[keys[i]] = {};
|
|
61
|
+
current = current[keys[i]];
|
|
62
|
+
}
|
|
63
|
+
const finalKey = keys[keys.length - 1];
|
|
64
|
+
Object.defineProperty(current, finalKey, {
|
|
65
|
+
value,
|
|
66
|
+
writable: true,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function camelCaseToKebabCase(str) {
|
|
72
|
+
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
73
|
+
}
|
|
74
|
+
function kebabCaseToCamelCase(str) {
|
|
75
|
+
return str.replace(/-./g, (match) => match[1].toUpperCase());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/cli/arguments/normalize.ts
|
|
80
|
+
function normalizeCliOptions(cliOptions, positionals) {
|
|
81
|
+
const prototypePollutionKeys = [
|
|
82
|
+
"__proto__",
|
|
83
|
+
"constructor",
|
|
84
|
+
"prototype"
|
|
85
|
+
];
|
|
86
|
+
const unflattenedCliOptions = {};
|
|
87
|
+
for (let [key, value] of Object.entries(cliOptions)) if (prototypePollutionKeys.includes(key)) {} else if (key.includes(".")) {
|
|
88
|
+
const [parentKey] = key.split(".");
|
|
89
|
+
unflattenedCliOptions[parentKey] ??= {};
|
|
90
|
+
setNestedProperty(unflattenedCliOptions, key, value);
|
|
91
|
+
} else unflattenedCliOptions[key] = value;
|
|
92
|
+
const [data, errors] = validateCliOptions(unflattenedCliOptions);
|
|
93
|
+
if (errors?.length) {
|
|
94
|
+
errors.forEach((error) => {
|
|
95
|
+
logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
|
|
96
|
+
});
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
const options = data ?? {};
|
|
100
|
+
const result = {
|
|
101
|
+
input: {},
|
|
102
|
+
output: {},
|
|
103
|
+
help: options.help ?? false,
|
|
104
|
+
version: options.version ?? false,
|
|
105
|
+
watch: options.watch ?? false
|
|
106
|
+
};
|
|
107
|
+
if (typeof options.config === "string") result.config = options.config;
|
|
108
|
+
if (options.environment !== void 0) result.environment = options.environment;
|
|
109
|
+
const keysOfInput = getInputCliKeys();
|
|
110
|
+
const keysOfOutput = getOutputCliKeys();
|
|
111
|
+
const reservedKeys = [
|
|
112
|
+
"help",
|
|
113
|
+
"version",
|
|
114
|
+
"config",
|
|
115
|
+
"watch",
|
|
116
|
+
"environment"
|
|
117
|
+
];
|
|
118
|
+
for (let [key, value] of Object.entries(options)) {
|
|
119
|
+
const [primary] = key.split(".");
|
|
120
|
+
if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
|
|
121
|
+
else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
|
|
122
|
+
else if (!reservedKeys.includes(key)) {
|
|
123
|
+
logger.error(`Unknown option: ${key}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!result.config && positionals.length > 0) if (Array.isArray(result.input.input)) result.input.input.push(...positionals);
|
|
128
|
+
else result.input.input = positionals;
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/cli/arguments/index.ts
|
|
134
|
+
const schemaInfo = getCliSchemaInfo();
|
|
135
|
+
const options = Object.fromEntries(Object.entries(schemaInfo).filter(([_key, info]) => info.type !== "never").map(([key, info]) => {
|
|
136
|
+
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
137
|
+
const result = {
|
|
138
|
+
type: info.type === "boolean" ? "boolean" : "string",
|
|
139
|
+
description: info?.description ?? config?.description ?? "",
|
|
140
|
+
hint: config?.hint
|
|
141
|
+
};
|
|
142
|
+
if (config && config?.abbreviation) result.short = config?.abbreviation;
|
|
143
|
+
if (config && config.reverse) {
|
|
144
|
+
if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
|
|
145
|
+
else if (!result.description.startsWith("Avoid")) result.description = `disable ${result.description}`;
|
|
146
|
+
}
|
|
147
|
+
key = camelCaseToKebabCase(key);
|
|
148
|
+
return [config?.reverse ? `no-${key}` : key, result];
|
|
149
|
+
}));
|
|
150
|
+
function parseCliArguments() {
|
|
151
|
+
const { values, tokens, positionals } = parseArgs({
|
|
152
|
+
options,
|
|
153
|
+
tokens: true,
|
|
154
|
+
allowPositionals: true,
|
|
155
|
+
strict: false
|
|
156
|
+
});
|
|
157
|
+
let invalid_options = tokens.filter((token) => token.kind === "option").map((option) => {
|
|
158
|
+
let negative = false;
|
|
159
|
+
if (option.name.startsWith("no-")) {
|
|
160
|
+
const name = kebabCaseToCamelCase(option.name.substring(3));
|
|
161
|
+
if (name in schemaInfo) {
|
|
162
|
+
delete values[option.name];
|
|
163
|
+
option.name = name;
|
|
164
|
+
negative = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
delete values[option.name];
|
|
168
|
+
option.name = kebabCaseToCamelCase(option.name);
|
|
169
|
+
let originalInfo = schemaInfo[option.name];
|
|
170
|
+
if (!originalInfo) return {
|
|
171
|
+
name: option.name,
|
|
172
|
+
value: option.value
|
|
173
|
+
};
|
|
174
|
+
let type = originalInfo.type;
|
|
175
|
+
if (type === "string" && typeof option.value !== "string") {
|
|
176
|
+
let opt = option;
|
|
177
|
+
let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
|
|
178
|
+
Object.defineProperty(values, opt.name, {
|
|
179
|
+
value: defaultValue.default ?? "",
|
|
180
|
+
enumerable: true,
|
|
181
|
+
configurable: true,
|
|
182
|
+
writable: true
|
|
183
|
+
});
|
|
184
|
+
} else if (type === "object" && typeof option.value === "string") {
|
|
185
|
+
const pairs = option.value.split(",").map((x) => x.split("="));
|
|
186
|
+
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
187
|
+
value: {},
|
|
188
|
+
enumerable: true,
|
|
189
|
+
configurable: true,
|
|
190
|
+
writable: true
|
|
191
|
+
});
|
|
192
|
+
for (const [key, value] of pairs) if (key && value) Object.defineProperty(values[option.name], key, {
|
|
193
|
+
value,
|
|
194
|
+
enumerable: true,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true
|
|
197
|
+
});
|
|
198
|
+
} else if (type === "array" && typeof option.value === "string") {
|
|
199
|
+
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
200
|
+
value: [],
|
|
201
|
+
enumerable: true,
|
|
202
|
+
configurable: true,
|
|
203
|
+
writable: true
|
|
204
|
+
});
|
|
205
|
+
values[option.name].push(option.value);
|
|
206
|
+
} else if (type === "boolean") Object.defineProperty(values, option.name, {
|
|
207
|
+
value: !negative,
|
|
208
|
+
enumerable: true,
|
|
209
|
+
configurable: true,
|
|
210
|
+
writable: true
|
|
211
|
+
});
|
|
212
|
+
else if (type === "union") {
|
|
213
|
+
let defaultValue = Object.getOwnPropertyDescriptor(alias, option.name)?.value;
|
|
214
|
+
Object.defineProperty(values, option.name, {
|
|
215
|
+
value: option.value ?? defaultValue?.default ?? "",
|
|
216
|
+
enumerable: true,
|
|
217
|
+
configurable: true,
|
|
218
|
+
writable: true
|
|
219
|
+
});
|
|
220
|
+
} else Object.defineProperty(values, option.name, {
|
|
221
|
+
value: option.value ?? "",
|
|
222
|
+
enumerable: true,
|
|
223
|
+
configurable: true,
|
|
224
|
+
writable: true
|
|
225
|
+
});
|
|
226
|
+
}).filter((item) => {
|
|
227
|
+
return item !== void 0;
|
|
228
|
+
});
|
|
229
|
+
invalid_options.sort((a, b) => {
|
|
230
|
+
return a.name.localeCompare(b.name);
|
|
231
|
+
});
|
|
232
|
+
if (invalid_options.length !== 0) {
|
|
233
|
+
let single = invalid_options.length === 1;
|
|
234
|
+
logger.warn(`Option \`${invalid_options.map((item) => item.name).join(",")}\` ${single ? "is" : "are"} unrecognized. We will ignore ${single ? "this" : "those"} option${single ? "" : "s"}.`);
|
|
235
|
+
}
|
|
236
|
+
let rawArgs = {
|
|
237
|
+
...values,
|
|
238
|
+
...invalid_options.reduce((acc, cur) => {
|
|
239
|
+
acc[cur.name] = cur.value;
|
|
240
|
+
return acc;
|
|
241
|
+
}, Object.create(null))
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
...normalizeCliOptions(values, positionals),
|
|
245
|
+
rawArgs
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/utils/clear-screen.ts
|
|
251
|
+
const CLEAR_SCREEN = "\x1Bc";
|
|
252
|
+
function getClearScreenFunction(options) {
|
|
253
|
+
const isTTY = process.stdout.isTTY;
|
|
254
|
+
const isAnyOptionNotAllowingClearScreen = arraify(options).some(({ watch }) => watch === false || watch?.clearScreen === false);
|
|
255
|
+
if (isTTY && !isAnyOptionNotAllowingClearScreen) return () => {
|
|
256
|
+
process.stdout.write(CLEAR_SCREEN);
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/usingCtx.js
|
|
262
|
+
function _usingCtx() {
|
|
263
|
+
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
264
|
+
var n = Error();
|
|
265
|
+
return n.name = "SuppressedError", n.error = r, n.suppressed = e, n;
|
|
266
|
+
}, e = {}, n = [];
|
|
267
|
+
function using(r, e) {
|
|
268
|
+
if (null != e) {
|
|
269
|
+
if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
270
|
+
if (r) var o = e[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
271
|
+
if (void 0 === o && (o = e[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r)) var t = o;
|
|
272
|
+
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
273
|
+
t && (o = function o() {
|
|
274
|
+
try {
|
|
275
|
+
t.call(e);
|
|
276
|
+
} catch (r) {
|
|
277
|
+
return Promise.reject(r);
|
|
278
|
+
}
|
|
279
|
+
}), n.push({
|
|
280
|
+
v: e,
|
|
281
|
+
d: o,
|
|
282
|
+
a: r
|
|
283
|
+
});
|
|
284
|
+
} else r && n.push({
|
|
285
|
+
d: e,
|
|
286
|
+
a: r
|
|
287
|
+
});
|
|
288
|
+
return e;
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
e,
|
|
292
|
+
u: using.bind(null, !1),
|
|
293
|
+
a: using.bind(null, !0),
|
|
294
|
+
d: function d() {
|
|
295
|
+
var o, t = this.e, s = 0;
|
|
296
|
+
function next() {
|
|
297
|
+
for (; o = n.pop();) try {
|
|
298
|
+
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
299
|
+
if (o.d) {
|
|
300
|
+
var r = o.d.call(o.v);
|
|
301
|
+
if (o.a) return s |= 2, Promise.resolve(r).then(next, err);
|
|
302
|
+
} else s |= 1;
|
|
303
|
+
} catch (r) {
|
|
304
|
+
return err(r);
|
|
305
|
+
}
|
|
306
|
+
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
307
|
+
if (t !== e) throw t;
|
|
308
|
+
}
|
|
309
|
+
function err(n) {
|
|
310
|
+
return t = t !== e ? new r(n, t) : n, next();
|
|
311
|
+
}
|
|
312
|
+
return next();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/cli/commands/bundle.ts
|
|
319
|
+
async function bundleWithConfig(configPath, cliOptions, rawArgs = {}) {
|
|
320
|
+
if (cliOptions.watch) {
|
|
321
|
+
process.env.ROLLUP_WATCH = "true";
|
|
322
|
+
process.env.ROLLDOWN_WATCH = "true";
|
|
323
|
+
}
|
|
324
|
+
const config = await loadConfig(configPath);
|
|
325
|
+
const resolvedConfig = typeof config === "function" ? await config(rawArgs) : config;
|
|
326
|
+
if (typeof resolvedConfig !== "object" || resolvedConfig === null) {
|
|
327
|
+
logger.error(`Invalid configuration from ${configPath}: expected object or array, got ${resolvedConfig}`);
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
330
|
+
if (cliOptions.watch) await watchInner(resolvedConfig, cliOptions);
|
|
331
|
+
else await bundleInner(resolvedConfig, cliOptions);
|
|
332
|
+
}
|
|
333
|
+
async function bundleWithCliOptions(cliOptions) {
|
|
334
|
+
try {
|
|
335
|
+
var _usingCtx$1 = _usingCtx();
|
|
336
|
+
if (cliOptions.output.dir || cliOptions.output.file) {
|
|
337
|
+
await (cliOptions.watch ? watchInner : bundleInner)({}, cliOptions);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (cliOptions.watch) {
|
|
341
|
+
logger.error("You must specify `output.dir` to use watch mode");
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
const { output: outputs } = await _usingCtx$1.a(await rolldown(cliOptions.input)).generate(cliOptions.output);
|
|
345
|
+
if (outputs.length === 0) {
|
|
346
|
+
logger.error("No output generated");
|
|
347
|
+
process.exit(1);
|
|
348
|
+
}
|
|
349
|
+
for (const file of outputs) {
|
|
350
|
+
if (outputs.length > 1) logger.log(`\n${styleText$1(["cyan", "bold"], `|→ ${file.fileName}:`)}\n`);
|
|
351
|
+
console.log(file.type === "asset" ? file.source : file.code);
|
|
352
|
+
}
|
|
353
|
+
} catch (_) {
|
|
354
|
+
_usingCtx$1.e = _;
|
|
355
|
+
} finally {
|
|
356
|
+
await _usingCtx$1.d();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async function watchInner(config, cliOptions) {
|
|
360
|
+
let normalizedConfig = arraify(config).map((option) => {
|
|
361
|
+
return {
|
|
362
|
+
...option,
|
|
363
|
+
...cliOptions.input,
|
|
364
|
+
output: arraify(option.output || {}).map((output) => {
|
|
365
|
+
return {
|
|
366
|
+
...output,
|
|
367
|
+
...cliOptions.output
|
|
368
|
+
};
|
|
369
|
+
})
|
|
370
|
+
};
|
|
371
|
+
});
|
|
372
|
+
const watcher = watch(normalizedConfig);
|
|
373
|
+
onExit((code) => {
|
|
374
|
+
Promise.resolve(watcher.close()).finally(() => {
|
|
375
|
+
process.exit(typeof code === "number" ? code : 0);
|
|
376
|
+
});
|
|
377
|
+
return true;
|
|
378
|
+
});
|
|
379
|
+
const changedFile = [];
|
|
380
|
+
watcher.on("change", (id, event) => {
|
|
381
|
+
if (event.event === "update") changedFile.push(id);
|
|
382
|
+
});
|
|
383
|
+
const clearScreen = getClearScreenFunction(normalizedConfig);
|
|
384
|
+
watcher.on("event", async (event) => {
|
|
385
|
+
switch (event.code) {
|
|
386
|
+
case "START":
|
|
387
|
+
clearScreen?.();
|
|
388
|
+
break;
|
|
389
|
+
case "BUNDLE_START":
|
|
390
|
+
if (changedFile.length > 0) logger.log(`Found ${styleText$1("bold", changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
391
|
+
changedFile.length = 0;
|
|
392
|
+
break;
|
|
393
|
+
case "BUNDLE_END":
|
|
394
|
+
await event.result.close();
|
|
395
|
+
logger.success(`Rebuilt ${styleText$1("bold", relativeId(event.output[0]))} in ${styleText$1("green", ms(event.duration))}.`);
|
|
396
|
+
break;
|
|
397
|
+
case "ERROR":
|
|
398
|
+
await event.result.close();
|
|
399
|
+
logger.error(event.error);
|
|
400
|
+
break;
|
|
401
|
+
default: break;
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
logger.log(`Waiting for changes...`);
|
|
405
|
+
}
|
|
406
|
+
async function bundleInner(config, cliOptions) {
|
|
407
|
+
const startTime = performance.now();
|
|
408
|
+
const result = [];
|
|
409
|
+
const configList = arraify(config);
|
|
410
|
+
for (const config of configList) {
|
|
411
|
+
const outputList = arraify(config.output || {});
|
|
412
|
+
const build = await rolldown({
|
|
413
|
+
...config,
|
|
414
|
+
...cliOptions.input
|
|
415
|
+
});
|
|
416
|
+
try {
|
|
417
|
+
for (const output of outputList) result.push(await build.write({
|
|
418
|
+
...output,
|
|
419
|
+
...cliOptions.output
|
|
420
|
+
}));
|
|
421
|
+
} finally {
|
|
422
|
+
await build.close();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
result.forEach(printBundleOutputPretty);
|
|
426
|
+
logger.log(``);
|
|
427
|
+
const duration = performance.now() - startTime;
|
|
428
|
+
logger.success(`rolldown v${version} Finished in ${styleText$1("green", ms(duration))}`);
|
|
429
|
+
}
|
|
430
|
+
function printBundleOutputPretty(output) {
|
|
431
|
+
const outputEntries = collectOutputEntries(output.output);
|
|
432
|
+
printOutputEntries(outputEntries, collectOutputLayoutAdjustmentSizes(outputEntries), "<DIR>");
|
|
433
|
+
}
|
|
434
|
+
function collectOutputEntries(output) {
|
|
435
|
+
return output.map((chunk) => ({
|
|
436
|
+
type: chunk.type,
|
|
437
|
+
fileName: chunk.fileName,
|
|
438
|
+
size: chunk.type === "chunk" ? Buffer.byteLength(chunk.code) : Buffer.byteLength(chunk.source)
|
|
439
|
+
}));
|
|
440
|
+
}
|
|
441
|
+
function collectOutputLayoutAdjustmentSizes(entries) {
|
|
442
|
+
let longest = 0;
|
|
443
|
+
let biggestSize = 0;
|
|
444
|
+
for (const entry of entries) {
|
|
445
|
+
if (entry.fileName.length > longest) longest = entry.fileName.length;
|
|
446
|
+
if (entry.size > biggestSize) biggestSize = entry.size;
|
|
447
|
+
}
|
|
448
|
+
const sizePad = displaySize(biggestSize).length;
|
|
449
|
+
return {
|
|
450
|
+
longest,
|
|
451
|
+
biggestSize,
|
|
452
|
+
sizePad
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const numberFormatter = new Intl.NumberFormat("en", {
|
|
456
|
+
maximumFractionDigits: 2,
|
|
457
|
+
minimumFractionDigits: 2
|
|
458
|
+
});
|
|
459
|
+
function displaySize(bytes) {
|
|
460
|
+
return `${numberFormatter.format(bytes / 1e3)} kB`;
|
|
461
|
+
}
|
|
462
|
+
const CHUNK_GROUPS = [{
|
|
463
|
+
type: "asset",
|
|
464
|
+
color: "green"
|
|
465
|
+
}, {
|
|
466
|
+
type: "chunk",
|
|
467
|
+
color: "cyan"
|
|
468
|
+
}];
|
|
469
|
+
function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
470
|
+
for (const group of CHUNK_GROUPS) {
|
|
471
|
+
const filtered = entries.filter((e) => e.type === group.type);
|
|
472
|
+
if (!filtered.length) continue;
|
|
473
|
+
for (const entry of filtered.sort((a, z) => a.size - z.size)) {
|
|
474
|
+
let log = styleText$1("dim", withTrailingSlash(distPath));
|
|
475
|
+
log += styleText$1(group.color, entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
476
|
+
log += styleText$1("dim", entry.type);
|
|
477
|
+
log += styleText$1("dim", ` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
478
|
+
logger.log(log);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function withTrailingSlash(path) {
|
|
483
|
+
if (path[path.length - 1] !== "/") return `${path}/`;
|
|
484
|
+
return path;
|
|
485
|
+
}
|
|
486
|
+
function ms(duration) {
|
|
487
|
+
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
488
|
+
}
|
|
489
|
+
function relativeId(id) {
|
|
490
|
+
if (!path.isAbsolute(id)) return id;
|
|
491
|
+
return path.relative(path.resolve(), id);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/cli/commands/help.ts
|
|
496
|
+
const examples = [
|
|
497
|
+
{
|
|
498
|
+
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
499
|
+
command: "rolldown -c rolldown.config.mjs"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
title: "Bundle the `src/main.ts` to `dist` with `cjs` format",
|
|
503
|
+
command: "rolldown src/main.ts -d dist -f cjs"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
title: "Bundle the `src/main.ts` and handle the `.png` assets to Data URL",
|
|
507
|
+
command: "rolldown src/main.ts -d dist --moduleTypes .png=dataurl"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
title: "Bundle the `src/main.tsx` and minify the output with sourcemap",
|
|
511
|
+
command: "rolldown src/main.tsx -d dist -m -s"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
title: "Create self-executing IIFE using external jQuery as `$` and `_`",
|
|
515
|
+
command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
|
|
516
|
+
}
|
|
517
|
+
];
|
|
518
|
+
const notes = [
|
|
519
|
+
"Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.",
|
|
520
|
+
"If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.",
|
|
521
|
+
"CLI options will override the configuration file.",
|
|
522
|
+
"For more information, please visit https://rolldown.rs/."
|
|
523
|
+
];
|
|
524
|
+
/**
|
|
525
|
+
* Generates the CLI help text as a string.
|
|
526
|
+
*/
|
|
527
|
+
function generateHelpText() {
|
|
528
|
+
const lines = [];
|
|
529
|
+
lines.push(`${styleText$1("gray", `${description} (rolldown v${version})`)}`);
|
|
530
|
+
lines.push("");
|
|
531
|
+
lines.push(`${styleText$1(["bold", "underline"], "USAGE")} ${styleText$1("cyan", "rolldown -c <config>")} or ${styleText$1("cyan", "rolldown <input> <options>")}`);
|
|
532
|
+
lines.push("");
|
|
533
|
+
lines.push(`${styleText$1(["bold", "underline"], "OPTIONS")}`);
|
|
534
|
+
lines.push("");
|
|
535
|
+
lines.push(Object.entries(options).sort(([a], [b]) => {
|
|
536
|
+
if (options[a].short && !options[b].short) return -1;
|
|
537
|
+
if (!options[a].short && options[b].short) return 1;
|
|
538
|
+
if (options[a].short && options[b].short) return options[a].short.localeCompare(options[b].short);
|
|
539
|
+
return a.localeCompare(b);
|
|
540
|
+
}).map(([option, { type, short, hint, description }]) => {
|
|
541
|
+
let optionStr = ` --${option} `;
|
|
542
|
+
option = camelCaseToKebabCase(option);
|
|
543
|
+
if (short) optionStr += `-${short}, `;
|
|
544
|
+
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
545
|
+
if (description && description.length > 0) description = description[0].toUpperCase() + description.slice(1);
|
|
546
|
+
return styleText$1("cyan", optionStr.padEnd(30)) + description + (description && description?.endsWith(".") ? "" : ".");
|
|
547
|
+
}).join("\n"));
|
|
548
|
+
lines.push("");
|
|
549
|
+
lines.push(`${styleText$1(["bold", "underline"], "EXAMPLES")}`);
|
|
550
|
+
lines.push("");
|
|
551
|
+
examples.forEach(({ title, command }, ord) => {
|
|
552
|
+
lines.push(` ${ord + 1}. ${title}:`);
|
|
553
|
+
lines.push(` ${styleText$1("cyan", command)}`);
|
|
554
|
+
lines.push("");
|
|
555
|
+
});
|
|
556
|
+
lines.push(`${styleText$1(["bold", "underline"], "NOTES")}`);
|
|
557
|
+
lines.push("");
|
|
558
|
+
notes.forEach((note) => {
|
|
559
|
+
lines.push(` * ${styleText$1("gray", note)}`);
|
|
560
|
+
});
|
|
561
|
+
return lines.join("\n");
|
|
562
|
+
}
|
|
563
|
+
function showHelp() {
|
|
564
|
+
logger.log(generateHelpText());
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/cli/version-check.ts
|
|
569
|
+
function checkNodeVersion(nodeVersion) {
|
|
570
|
+
const currentVersion = nodeVersion.split(".");
|
|
571
|
+
const major = parseInt(currentVersion[0], 10);
|
|
572
|
+
const minor = parseInt(currentVersion[1], 10);
|
|
573
|
+
return major === 20 && minor >= 19 || major === 22 && minor >= 12 || major > 22;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/cli/index.ts
|
|
578
|
+
if (!checkNodeVersion(process$1.versions.node)) logger.warn(`You are using Node.js ${process$1.versions.node}. Rolldown requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.`);
|
|
579
|
+
async function main() {
|
|
580
|
+
const { rawArgs, ...cliOptions } = parseCliArguments();
|
|
581
|
+
if (cliOptions.environment) {
|
|
582
|
+
const environment = Array.isArray(cliOptions.environment) ? cliOptions.environment : [cliOptions.environment];
|
|
583
|
+
for (const argument of environment) for (const pair of argument.split(",")) {
|
|
584
|
+
const [key, ...value] = pair.split(":");
|
|
585
|
+
process$1.env[key] = value.length === 0 ? String(true) : value.join(":");
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (cliOptions.config || cliOptions.config === "") {
|
|
589
|
+
await bundleWithConfig(cliOptions.config, cliOptions, rawArgs);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if ("input" in cliOptions.input) {
|
|
593
|
+
await bundleWithCliOptions(cliOptions);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (cliOptions.version) {
|
|
597
|
+
logger.log(`rolldown v${version}`);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
showHelp();
|
|
601
|
+
}
|
|
602
|
+
main().catch((err) => {
|
|
603
|
+
logger.error(err);
|
|
604
|
+
process$1.exit(1);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
export { };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./shared/binding-D-XMzSaG.mjs";
|
|
2
|
+
import { P as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-U4pj0ZDn.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/load-config.d.ts
|
|
5
|
+
declare function loadConfig(configPath: string): Promise<ConfigExport>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { VERSION, defineConfig, loadConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./shared/binding-DuOSzYPt.mjs";
|
|
2
|
+
import "./shared/normalize-string-or-regex-DeZqg15i.mjs";
|
|
3
|
+
import { w as VERSION } from "./shared/bindingify-input-options-Bu6nUTgS.mjs";
|
|
4
|
+
import "./shared/rolldown-build-BIs7C4B_.mjs";
|
|
5
|
+
import "./shared/parse-DLraxqjd.mjs";
|
|
6
|
+
import "./shared/rolldown-O0UKbTKf.mjs";
|
|
7
|
+
import { t as defineConfig } from "./shared/define-config-BVG4QvnP.mjs";
|
|
8
|
+
import { t as loadConfig } from "./shared/load-config-O1K_tT_z.mjs";
|
|
9
|
+
|
|
10
|
+
export { VERSION, defineConfig, loadConfig };
|