@hypernym/bundler 0.14.4 → 0.20.0

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.
@@ -1,506 +1,205 @@
1
1
  #!/usr/bin/env node
2
- import process, { cwd } from 'node:process';
3
- import { createArgs } from '@hypernym/args';
4
- import { resolve, dirname, parse } from 'node:path';
5
- import { read, exists, write, copy, readdir } from '@hypernym/utils/fs';
6
- import { dim, cyan } from '@hypernym/colors';
7
- import { build as build$1, transform } from 'esbuild';
8
- import { stat } from 'node:fs/promises';
9
- import { isString, isUndefined, isObject } from '@hypernym/utils';
10
- import { rollup } from 'rollup';
11
- import { getLogFilter } from 'rollup/getLogFilter';
12
- import replacePlugin from '@rollup/plugin-replace';
13
- import jsonPlugin from '@rollup/plugin-json';
14
- import resolvePlugin from '@rollup/plugin-node-resolve';
15
- import aliasPlugin from '@rollup/plugin-alias';
16
- import { dts } from 'rollup-plugin-dts';
17
- import { createFilter } from '@rollup/pluginutils';
18
-
19
- const externals = [
20
- /^node:/,
21
- /^@types/,
22
- /^@rollup/,
23
- /^@hypernym/,
24
- /^rollup/
25
- ];
2
+ import { createArgs } from "@hypernym/args";
3
+ import process, { cwd } from "node:process";
4
+ import { cyan, dim } from "@hypernym/colors";
5
+ import { isAbsolute, resolve } from "node:path";
6
+ import { exists, read, write } from "@hypernym/utils/fs";
7
+ import { build } from "rolldown";
8
+ import { build as build$1 } from "../build/index.mjs";
26
9
 
10
+ //#region src/bin/meta.ts
27
11
  const name = `Hyperbundler`;
28
- const version = `0.14.4`;
12
+ const version = `0.20.0`;
29
13
 
14
+ //#endregion
15
+ //#region src/utils/logger.ts
30
16
  const cl = console.log;
31
- const separator = `/`;
17
+ const separator = `|`;
32
18
  const logger = {
33
- info: (...args) => {
34
- cl(name, dim(separator), ...args);
35
- },
36
- error: (...args) => {
37
- cl();
38
- cl(name, dim(separator), ...args);
39
- cl();
40
- },
41
- exit: (message) => {
42
- cl();
43
- cl(name, dim(separator), message);
44
- cl();
45
- return process.exit();
46
- }
19
+ info: (...args) => {
20
+ cl(name, dim(separator), ...args);
21
+ },
22
+ error: (...args) => {
23
+ cl();
24
+ cl(name, dim(separator), ...args);
25
+ cl();
26
+ },
27
+ exit: (message) => {
28
+ cl();
29
+ cl(name, dim(separator), message);
30
+ cl();
31
+ return process.exit();
32
+ }
47
33
  };
48
34
 
35
+ //#endregion
36
+ //#region src/utils/error.ts
49
37
  function error(err) {
50
- logger.error("Something went wrong...");
51
- console.error(err);
52
- return process.exit();
38
+ logger.error("Something went wrong...");
39
+ console.error(err);
40
+ return process.exit();
53
41
  }
54
42
 
43
+ //#endregion
44
+ //#region src/utils/format-ms.ts
55
45
  function formatMs(ms) {
56
- const s = 1e3;
57
- const m = s * 60;
58
- const h = m * 60;
59
- const msAbs = Math.abs(ms);
60
- if (msAbs >= h) return `${(ms / h).toFixed(2)}h`;
61
- if (msAbs >= m) return `${(ms / m).toFixed(2)}m`;
62
- if (msAbs >= s) return `${(ms / s).toFixed(2)}s`;
63
- return `${ms}ms`;
46
+ const s = 1e3;
47
+ const m = s * 60;
48
+ const h = m * 60;
49
+ const msAbs = Math.abs(ms);
50
+ if (msAbs >= h) return `${(ms / h).toFixed(2)}h`;
51
+ if (msAbs >= m) return `${(ms / m).toFixed(2)}m`;
52
+ if (msAbs >= s) return `${(ms / s).toFixed(2)}s`;
53
+ return `${ms}ms`;
64
54
  }
65
55
 
56
+ //#endregion
57
+ //#region src/utils/format-bytes.ts
66
58
  function formatBytes(bytes) {
67
- const decimals = 2;
68
- const units = ["B", "KB", "MB", "GB", "TB"];
69
- if (bytes === 0) return `0 B`;
70
- const k = 1024;
71
- const dm = decimals;
72
- const i = Math.floor(Math.log(bytes) / Math.log(k));
73
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${units[i]}`;
74
- }
75
-
76
- function getOutputPath(outDir, input, dts) {
77
- const _input = input.startsWith("./") ? input.slice(2) : input;
78
- let output = _input.replace(_input.split("/")[0], outDir);
79
- const ext = dts ? "d.mts" : "mjs";
80
- const cts = dts ? "d.cts" : "cjs";
81
- if (output.endsWith(".js")) output = `${output.slice(0, -2)}${ext}`;
82
- else if (output.endsWith(".ts")) output = `${output.slice(0, -2)}${ext}`;
83
- else if (output.endsWith(".mts")) output = `${output.slice(0, -3)}${ext}`;
84
- else if (output.endsWith(".cts")) output = `${output.slice(0, -3)}${cts}`;
85
- if (outDir.startsWith("./") || outDir.startsWith("../")) return output;
86
- else return `./${output}`;
87
- }
88
-
89
- function getLongestOutput(outDir, entries) {
90
- const outputs = [];
91
- for (const entry of entries) {
92
- if (entry.copy) outputs.push(entry.copy.output);
93
- if (entry.input) {
94
- const out = entry.output || getOutputPath(outDir, entry.input);
95
- outputs.push(out);
96
- }
97
- if (entry.declaration || entry.dts) {
98
- const dts = entry.declaration || entry.dts;
99
- const out = entry.output || getOutputPath(outDir, dts, true);
100
- outputs.push(out);
101
- }
102
- if (entry.template) outputs.push(entry.output);
103
- }
104
- return Math.max(...outputs.map((v) => v.length));
59
+ const decimals = 2;
60
+ const units = [
61
+ "B",
62
+ "KB",
63
+ "MB",
64
+ "GB",
65
+ "TB"
66
+ ];
67
+ if (bytes === 0) return `0 B`;
68
+ const k = 1024;
69
+ const dm = decimals < 0 ? 0 : decimals;
70
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
71
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${units[i]}`;
105
72
  }
106
73
 
107
- async function loadConfig(cwd, filePath, defaults) {
108
- const result = await build$1({
109
- entryPoints: [resolve(cwd, filePath)],
110
- bundle: true,
111
- write: false,
112
- format: "esm",
113
- target: "esnext",
114
- packages: "external"
115
- });
116
- const code = result.outputFiles[0].text;
117
- const tempConfig = resolve(cwd, "node_modules/.hypernym/bundler/config.mjs");
118
- await write(tempConfig, code);
119
- const content = await import(tempConfig);
120
- const config = {
121
- ...defaults,
122
- ...content.default
123
- };
124
- return { options: config, path: filePath };
125
- }
126
- async function createConfigLoader(cwd, args) {
127
- const pkgPath = resolve(cwd, "package.json");
128
- const pkg = await read(pkgPath).catch(error);
129
- const { dependencies } = JSON.parse(pkg);
130
- const warnMessage = `Missing required configuration. To start bundling, add the ${cyan(
131
- `'bundler.config.{js,mjs,ts,mts}'`
132
- )} file to the project's root.`;
133
- const defaults = {
134
- externals: [...Object.keys(dependencies || {}), ...externals],
135
- entries: []
136
- };
137
- if (args.config) {
138
- const path = args.config;
139
- const isConfig = await exists(path);
140
- if (isConfig) return await loadConfig(cwd, path, defaults);
141
- else return logger.exit(warnMessage);
142
- }
143
- const configName = "bundler.config";
144
- const configExts = [".ts", ".js", ".mts", ".mjs"];
145
- for (const ext of configExts) {
146
- const path = `${configName}${ext}`;
147
- const isConfig = await exists(path);
148
- if (isConfig) return await loadConfig(cwd, path, defaults);
149
- }
150
- return logger.exit(warnMessage);
151
- }
74
+ //#endregion
75
+ //#region src/config.ts
76
+ /**
77
+ * List of global default patterns for external module identifiers.
78
+ *
79
+ * @example
80
+ *
81
+ * ```ts
82
+ * import { externals } from '@hypernym/bundler'
83
+ *
84
+ * export default defineConfig({
85
+ * entries: [
86
+ * {
87
+ * input: './src/index.ts',
88
+ * externals: [...externals, 'id', /regexp/]
89
+ * },
90
+ * ]
91
+ * })
92
+ * ```
93
+ */
94
+ const externals = [
95
+ /^node:/,
96
+ /^@types/,
97
+ /^@rollup/,
98
+ /^@rolldown/,
99
+ /^@hypernym/,
100
+ /^rollup/,
101
+ /^rolldown/
102
+ ];
152
103
 
153
- async function resolvePath(path, index = false) {
154
- const extensions = [".js", ".ts", "jsx", ".tsx"];
155
- const fileWithoutExt = path.replace(/\.[jt]sx?$/, "");
156
- for (const ext of extensions) {
157
- const file = index ? `${path}/index${ext}` : `${fileWithoutExt}${ext}`;
158
- if (await exists(file)) return file;
159
- }
160
- return null;
104
+ //#endregion
105
+ //#region src/bin/loader.ts
106
+ async function getTSConfigPath(cwd$1, filePath = "tsconfig.json") {
107
+ const tsconfigPath = resolve(cwd$1, filePath);
108
+ const tsconfigFile = await exists(tsconfigPath);
109
+ if (tsconfigFile) return tsconfigPath;
161
110
  }
162
- function esbuild(options) {
163
- const filter = createFilter(/\.([cm]?ts|[jt]sx)$/);
164
- return {
165
- name: "esbuild",
166
- async resolveId(id, importer) {
167
- if (importer) {
168
- const resolved = resolve(importer ? dirname(importer) : cwd(), id);
169
- let file = await resolvePath(resolved);
170
- if (file) return file;
171
- if (!file && await exists(resolved) && (await stat(resolved)).isDirectory()) {
172
- file = await resolvePath(resolved, true);
173
- if (file) return file;
174
- }
175
- }
176
- return null;
177
- },
178
- async transform(code, id) {
179
- if (!filter(id)) return null;
180
- const result = await transform(code, {
181
- loader: "default",
182
- ...options,
183
- sourcefile: id
184
- });
185
- return {
186
- code: result.code,
187
- map: result.map || null
188
- };
189
- },
190
- async renderChunk(code, { fileName }) {
191
- if (!options?.minify) return null;
192
- if (/\.d\.(c|m)?tsx?$/.test(fileName)) return null;
193
- const result = await transform(code, {
194
- ...options,
195
- sourcefile: fileName,
196
- minify: true
197
- });
198
- return {
199
- code: result.code,
200
- map: result.map || null
201
- };
202
- }
203
- };
111
+ async function loadConfig(filePath, defaults) {
112
+ const cwd$1 = defaults.cwd;
113
+ const result = await build({
114
+ input: resolve(cwd$1, filePath),
115
+ write: false,
116
+ external: (id) => !(isAbsolute(id) || /^(\.|@\/|~\/)/.test(id)),
117
+ resolve: { tsconfigFilename: defaults.tsconfig },
118
+ output: { format: "esm" }
119
+ });
120
+ const tempConfig = resolve(cwd$1, "node_modules/.hypernym/bundler/config.mjs");
121
+ await write(tempConfig, result.output[0].code);
122
+ const config = (await import(tempConfig)).default;
123
+ const options = {
124
+ ...defaults,
125
+ ...config
126
+ };
127
+ return {
128
+ options,
129
+ path: filePath
130
+ };
204
131
  }
205
-
206
- function logModuleStats(file, longestOutput) {
207
- const cl = console.log;
208
- const base = parse(file.path).base;
209
- const path = file.path.replace(base, "");
210
- let format = file.format;
211
- if (format.includes("system")) format = "sys";
212
- if (format === "commonjs") format = "cjs";
213
- if (format === "module") format = "esm";
214
- longestOutput = longestOutput + 2;
215
- const ansiCode = 9;
216
- const pathDim = dim(path);
217
- const output = pathDim + base;
218
- const pathDimNoAnsi = pathDim.length - ansiCode;
219
- const difference = longestOutput - pathDimNoAnsi - base.length;
220
- const padLength = output.length + difference;
221
- cl(
222
- dim("+"),
223
- format.padEnd(5),
224
- output.padEnd(padLength),
225
- dim("time"),
226
- formatMs(file.buildTime).padEnd(7),
227
- dim("size"),
228
- formatBytes(file.size)
229
- );
230
- if (file.logs) {
231
- for (const log of file.logs) {
232
- cl(
233
- dim("!"),
234
- log.level.padEnd(5),
235
- output.padEnd(padLength),
236
- dim(log.log.message)
237
- );
238
- }
239
- }
240
- }
241
- async function build(cwd, options) {
242
- const { outDir = "dist", hooks } = options;
243
- let start = 0;
244
- const buildStats = {
245
- cwd,
246
- size: 0,
247
- buildTime: 0,
248
- files: []
249
- };
250
- await hooks?.["build:start"]?.(options, buildStats);
251
- if (options.entries) {
252
- const longestOutput = getLongestOutput(outDir, options.entries);
253
- start = Date.now();
254
- const aliasDir = resolve(cwd, "./src");
255
- let aliasOptions = {
256
- entries: options.alias || [
257
- { find: "@", replacement: aliasDir },
258
- { find: "~", replacement: aliasDir }
259
- ]
260
- };
261
- for (const entry of options.entries) {
262
- const entryStart = Date.now();
263
- if (entry.copy) {
264
- const _entry = {
265
- input: isString(entry.copy.input) ? [entry.copy.input] : entry.copy.input,
266
- output: entry.copy.output,
267
- recursive: entry.copy.recursive || true,
268
- filter: entry.copy.filter
269
- };
270
- const buildLogs = [];
271
- for (const copyInput of _entry.input) {
272
- const fileSrc = resolve(cwd, copyInput);
273
- const fileDist = resolve(cwd, _entry.output, copyInput);
274
- await copy(fileSrc, fileDist, {
275
- recursive: _entry.recursive,
276
- filter: _entry.filter
277
- }).catch(error);
278
- const stats = await stat(fileDist);
279
- let totalSize = 0;
280
- if (!stats.isDirectory()) totalSize = stats.size;
281
- else {
282
- const files = await readdir(fileDist);
283
- for (const file of files) {
284
- const filePath = resolve(fileDist, file);
285
- const fileStat = await stat(filePath);
286
- totalSize = totalSize + fileStat.size;
287
- }
288
- }
289
- const parseInput = (path) => {
290
- if (path.startsWith("./")) return path.slice(2);
291
- else return path;
292
- };
293
- const parseOutput = (path) => {
294
- if (path.startsWith("./")) return path;
295
- else return `./${path}`;
296
- };
297
- const fileStats = {
298
- cwd,
299
- path: `${parseOutput(_entry.output)}/${parseInput(copyInput)}`,
300
- size: totalSize,
301
- buildTime: Date.now() - entryStart,
302
- format: "copy",
303
- logs: buildLogs
304
- };
305
- buildStats.files.push(fileStats);
306
- buildStats.size = buildStats.size + stats.size;
307
- logModuleStats(fileStats, longestOutput);
308
- }
309
- }
310
- if (entry.input) {
311
- const logFilter = getLogFilter(entry.logFilter || []);
312
- const _output = entry.output || getOutputPath(outDir, entry.input);
313
- let _format = "esm";
314
- if (_output.endsWith(".cjs")) _format = "cjs";
315
- const buildLogs = [];
316
- const _entry = {
317
- input: entry.input,
318
- output: _output,
319
- externals: entry.externals || options.externals,
320
- format: entry.format || _format,
321
- ...entry,
322
- defaultPlugins: [
323
- esbuild({
324
- minify: !isUndefined(entry.minify) ? entry.minify : options.minify,
325
- ...entry.transformers?.esbuild
326
- })
327
- ]
328
- };
329
- if (!entry.plugins) {
330
- if (_entry.transformers?.json) {
331
- const jsonOptions = isObject(_entry.transformers.json) ? _entry.transformers.json : void 0;
332
- _entry.defaultPlugins.push(jsonPlugin(jsonOptions));
333
- }
334
- if (_entry.transformers?.replace) {
335
- _entry.defaultPlugins.unshift(
336
- replacePlugin({
337
- preventAssignment: true,
338
- ..._entry.transformers.replace
339
- })
340
- );
341
- }
342
- if (_entry.transformers?.resolve) {
343
- const resolveOptions = isObject(_entry.transformers.resolve) ? _entry.transformers.resolve : void 0;
344
- _entry.defaultPlugins.unshift(resolvePlugin(resolveOptions));
345
- }
346
- _entry.defaultPlugins.unshift(
347
- aliasPlugin(_entry.transformers?.alias || aliasOptions)
348
- );
349
- }
350
- const fileStats = {
351
- cwd,
352
- path: _entry.output,
353
- size: 0,
354
- buildTime: entryStart,
355
- format: _entry.format,
356
- logs: buildLogs
357
- };
358
- await hooks?.["build:entry:start"]?.(_entry, fileStats);
359
- const _build = await rollup({
360
- input: resolve(cwd, _entry.input),
361
- external: _entry.externals,
362
- plugins: _entry.plugins || _entry.defaultPlugins,
363
- onLog: (level, log) => {
364
- if (logFilter(log)) buildLogs.push({ level, log });
365
- }
366
- });
367
- await _build.write({
368
- file: resolve(cwd, _entry.output),
369
- format: _entry.format,
370
- banner: _entry.banner,
371
- footer: _entry.footer,
372
- intro: _entry.intro,
373
- outro: _entry.outro,
374
- paths: _entry.paths,
375
- name: _entry.name,
376
- globals: _entry.globals,
377
- extend: _entry.extend
378
- });
379
- const stats = await stat(resolve(cwd, _entry.output));
380
- fileStats.size = stats.size;
381
- fileStats.buildTime = Date.now() - entryStart;
382
- fileStats.logs = buildLogs;
383
- buildStats.files.push(fileStats);
384
- buildStats.size = buildStats.size + stats.size;
385
- logModuleStats(fileStats, longestOutput);
386
- await hooks?.["build:entry:end"]?.(_entry, fileStats);
387
- }
388
- if (entry.dts || entry.declaration) {
389
- const logFilter = getLogFilter(entry.logFilter || []);
390
- const buildLogs = [];
391
- const dts$1 = entry.dts || entry.declaration;
392
- const _entry = {
393
- dts: dts$1,
394
- output: entry.output || getOutputPath(outDir, dts$1, true),
395
- externals: entry.externals || options.externals,
396
- format: entry.format || "esm",
397
- ...entry,
398
- defaultPlugins: [dts(entry.transformers?.dts)]
399
- };
400
- if (!entry.plugins) {
401
- _entry.defaultPlugins.unshift(
402
- aliasPlugin(_entry.transformers?.alias || aliasOptions)
403
- );
404
- }
405
- const fileStats = {
406
- cwd,
407
- path: _entry.output,
408
- size: 0,
409
- buildTime: entryStart,
410
- format: "dts",
411
- logs: buildLogs
412
- };
413
- await hooks?.["build:entry:start"]?.(_entry, fileStats);
414
- const _build = await rollup({
415
- input: resolve(cwd, _entry.dts),
416
- external: _entry.externals,
417
- plugins: _entry.plugins || _entry.defaultPlugins,
418
- onLog: (level, log) => {
419
- if (logFilter(log)) buildLogs.push({ level, log });
420
- }
421
- });
422
- await _build.write({
423
- file: resolve(cwd, _entry.output),
424
- format: _entry.format,
425
- banner: _entry.banner,
426
- footer: _entry.footer,
427
- intro: _entry.intro,
428
- outro: _entry.outro,
429
- paths: _entry.paths
430
- });
431
- const stats = await stat(resolve(cwd, _entry.output));
432
- fileStats.size = stats.size;
433
- fileStats.buildTime = Date.now() - entryStart;
434
- fileStats.logs = buildLogs;
435
- buildStats.files.push(fileStats);
436
- buildStats.size = buildStats.size + stats.size;
437
- logModuleStats(fileStats, longestOutput);
438
- await hooks?.["build:entry:end"]?.(_entry, fileStats);
439
- }
440
- if (entry.template && entry.output) {
441
- const buildLogs = [];
442
- await write(entry.output, entry.template);
443
- const stats = await stat(resolve(cwd, entry.output));
444
- const fileStats = {
445
- cwd,
446
- path: entry.output,
447
- size: stats.size,
448
- buildTime: Date.now() - entryStart,
449
- format: "tmp",
450
- logs: buildLogs
451
- };
452
- buildStats.files.push(fileStats);
453
- buildStats.size = buildStats.size + stats.size;
454
- logModuleStats(fileStats, longestOutput);
455
- }
456
- }
457
- buildStats.buildTime = Date.now() - start;
458
- }
459
- await hooks?.["build:end"]?.(options, buildStats);
460
- return buildStats;
132
+ async function createConfigLoader(args) {
133
+ const cwdir = args.cwd && args.cwd.trim() !== "" ? resolve(args.cwd) : cwd();
134
+ const tsconfig = await getTSConfigPath(cwdir, args.tsconfig);
135
+ const pkgPath = resolve(cwdir, "package.json");
136
+ const pkgFile = await read(pkgPath).catch(error);
137
+ const { dependencies } = JSON.parse(pkgFile);
138
+ const defaults = {
139
+ cwd: cwdir,
140
+ tsconfig,
141
+ externals: [...Object.keys(dependencies || {}), ...externals],
142
+ entries: []
143
+ };
144
+ const warnMessage = `Missing required configuration. To start bundling, add the ${cyan(`'bundler.config.{js,mjs,ts,mts}'`)} file to the project's root.`;
145
+ if (args.config) {
146
+ const path = resolve(args.config);
147
+ const isConfig = await exists(path);
148
+ if (isConfig) return await loadConfig(path, defaults);
149
+ else return logger.exit(warnMessage);
150
+ }
151
+ const configName = "bundler.config";
152
+ const configExts = [
153
+ ".ts",
154
+ ".mts",
155
+ ".mjs",
156
+ ".js"
157
+ ];
158
+ for (const ext of configExts) {
159
+ const path = resolve(cwdir, `${configName}${ext}`);
160
+ const isConfig = await exists(path);
161
+ if (isConfig) return await loadConfig(path, defaults);
162
+ }
163
+ return logger.exit(warnMessage);
461
164
  }
462
165
 
463
- async function createBuilder(cwd, config) {
464
- const { options, path: configPath } = config;
465
- const { hooks } = options;
466
- const cl = console.log;
467
- await hooks?.["bundle:start"]?.(options);
468
- logger.info(dim(`v${version}`));
469
- cl("Config", dim(configPath));
470
- cl();
471
- cl("Bundling started...");
472
- cl(
473
- "Processing",
474
- dim(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`),
475
- "Transforming files"
476
- );
477
- cl();
478
- await build(cwd, options).then((stats) => {
479
- const buildTime = dim(formatMs(stats.buildTime));
480
- const buildSize = dim(formatBytes(stats.size));
481
- const totalModules = stats.files.length;
482
- const modules = totalModules > 1 ? `${totalModules} modules` : `${totalModules} module`;
483
- cl();
484
- cl(
485
- "Succeeded",
486
- dim(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`),
487
- "Module transformation is done"
488
- );
489
- cl(`Bundling fully completed in ${buildTime}`);
490
- cl();
491
- cl(`${modules} transformed. Total size is ${buildSize}`);
492
- cl(`Bundle is generated and ready for production`);
493
- cl();
494
- }).catch(error);
495
- await hooks?.["bundle:end"]?.(options);
166
+ //#endregion
167
+ //#region src/bin/builder.ts
168
+ async function createBuilder(config) {
169
+ const { options, path: configPath } = config;
170
+ const { hooks } = options;
171
+ const cl$1 = console.log;
172
+ await hooks?.["bundle:start"]?.(options);
173
+ cl$1();
174
+ logger.info(dim(`v${version}`));
175
+ cl$1("Config", dim(configPath));
176
+ cl$1();
177
+ cl$1("Processing specified entries...");
178
+ cl$1();
179
+ await build$1(options).then((stats) => {
180
+ const entriesLength = options.entries.length;
181
+ const totalEntries = `${entriesLength} ${entriesLength > 1 ? "entries" : "entry"}`;
182
+ const filesLength = stats.files.length;
183
+ const totalFiles = `${stats.files.length} file${filesLength > 1 ? "s" : ""}`;
184
+ const buildTime = formatMs(stats.buildTime);
185
+ const buildSize = formatBytes(stats.size);
186
+ cl$1();
187
+ cl$1("Stats:", dim(`${totalEntries}, ${totalFiles}, ${buildSize}, ${buildTime}`));
188
+ cl$1();
189
+ cl$1("All entries successfully processed.");
190
+ cl$1("Bundle is optimized and ready for production.");
191
+ cl$1();
192
+ }).catch(error);
193
+ await hooks?.["bundle:end"]?.(options);
496
194
  }
497
195
 
196
+ //#endregion
197
+ //#region src/bin/index.ts
498
198
  async function main() {
499
- const cwd$1 = cwd();
500
- const args = createArgs({
501
- alias: { config: "c" }
502
- });
503
- const config = await createConfigLoader(cwd$1, args);
504
- await createBuilder(cwd$1, config);
199
+ const args = createArgs({ alias: { config: "c" } });
200
+ const config = await createConfigLoader(args);
201
+ await createBuilder(config);
505
202
  }
506
203
  main().catch(error);
204
+
205
+ //#endregion