robuild 0.1.6 → 0.1.7
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/_chunks/{build-rD4AllYV.mjs → build-9ZPSBYPy.mjs} +122 -130
- package/dist/_chunks/build-BUwxGP7o.mjs +3 -0
- package/dist/_chunks/{package-TbcsjHHu.mjs → package-clDWYcua.mjs} +2 -1
- package/dist/cli.mjs +5 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
- package/dist/_chunks/build-CelwCERM.mjs +0 -3
|
@@ -12,8 +12,8 @@ import { existsSync, promises, readFileSync, readdirSync, statSync, writeFileSyn
|
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
13
|
import { gzipSync } from "node:zlib";
|
|
14
14
|
import { minify } from "oxc-minify";
|
|
15
|
-
import { consola } from "consola";
|
|
16
15
|
import { createHash } from "node:crypto";
|
|
16
|
+
import { consola } from "consola";
|
|
17
17
|
import { glob } from "glob";
|
|
18
18
|
import MagicString from "magic-string";
|
|
19
19
|
import { transform } from "oxc-transform";
|
|
@@ -21,95 +21,6 @@ import { glob as glob$1 } from "tinyglobby";
|
|
|
21
21
|
import { exec } from "node:child_process";
|
|
22
22
|
import { promisify } from "node:util";
|
|
23
23
|
|
|
24
|
-
//#region src/core/logger.ts
|
|
25
|
-
/**
|
|
26
|
-
* Logger instance with configurable log level
|
|
27
|
-
*/
|
|
28
|
-
var Logger = class {
|
|
29
|
-
level = "info";
|
|
30
|
-
warningCount = 0;
|
|
31
|
-
errorCount = 0;
|
|
32
|
-
constructor(level = "info") {
|
|
33
|
-
this.level = level;
|
|
34
|
-
this.updateConsolaLevel();
|
|
35
|
-
}
|
|
36
|
-
setLevel(level) {
|
|
37
|
-
this.level = level;
|
|
38
|
-
this.updateConsolaLevel();
|
|
39
|
-
}
|
|
40
|
-
updateConsolaLevel() {
|
|
41
|
-
consola.level = {
|
|
42
|
-
silent: 0,
|
|
43
|
-
error: 1,
|
|
44
|
-
warn: 2,
|
|
45
|
-
info: 3,
|
|
46
|
-
verbose: 4
|
|
47
|
-
}[this.level];
|
|
48
|
-
}
|
|
49
|
-
silent(message, ...args) {
|
|
50
|
-
consola.log(message, ...args);
|
|
51
|
-
}
|
|
52
|
-
error(message, ...args) {
|
|
53
|
-
this.errorCount++;
|
|
54
|
-
consola.error(message, ...args);
|
|
55
|
-
}
|
|
56
|
-
warn(message, ...args) {
|
|
57
|
-
this.warningCount++;
|
|
58
|
-
consola.warn(message, ...args);
|
|
59
|
-
}
|
|
60
|
-
info(message, ...args) {
|
|
61
|
-
consola.info(message, ...args);
|
|
62
|
-
}
|
|
63
|
-
verbose(message, ...args) {
|
|
64
|
-
if (this.level === "verbose") consola.debug(message, ...args);
|
|
65
|
-
}
|
|
66
|
-
success(message, ...args) {
|
|
67
|
-
consola.success(message, ...args);
|
|
68
|
-
}
|
|
69
|
-
log(message, ...args) {
|
|
70
|
-
consola.log(message, ...args);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Debug output - only visible with INSPECT_BUILD env var
|
|
74
|
-
*/
|
|
75
|
-
debug(message, ...args) {
|
|
76
|
-
if (process.env.INSPECT_BUILD) consola.log(message, ...args);
|
|
77
|
-
}
|
|
78
|
-
getWarningCount() {
|
|
79
|
-
return this.warningCount;
|
|
80
|
-
}
|
|
81
|
-
getErrorCount() {
|
|
82
|
-
return this.errorCount;
|
|
83
|
-
}
|
|
84
|
-
resetCounts() {
|
|
85
|
-
this.warningCount = 0;
|
|
86
|
-
this.errorCount = 0;
|
|
87
|
-
}
|
|
88
|
-
shouldFailOnWarnings(failOnWarn) {
|
|
89
|
-
return failOnWarn && this.warningCount > 0;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const logger = new Logger();
|
|
93
|
-
/**
|
|
94
|
-
* Configure global logger
|
|
95
|
-
*/
|
|
96
|
-
function configureLogger(level) {
|
|
97
|
-
logger.setLevel(level);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Reset warning and error counts
|
|
101
|
-
*/
|
|
102
|
-
function resetLogCounts() {
|
|
103
|
-
logger.resetCounts();
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Check if build should fail due to warnings
|
|
107
|
-
*/
|
|
108
|
-
function shouldFailOnWarnings(failOnWarn) {
|
|
109
|
-
return logger.shouldFailOnWarnings(failOnWarn);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
24
|
//#region src/utils/extensions.ts
|
|
114
25
|
/**
|
|
115
26
|
* Get file extension for a given format (with leading dot).
|
|
@@ -356,14 +267,16 @@ function analyzeDir(dir) {
|
|
|
356
267
|
throw error;
|
|
357
268
|
}
|
|
358
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Calculate size metrics for a built file.
|
|
272
|
+
* Reads the file directly from disk instead of rebuilding with rolldown.
|
|
273
|
+
*
|
|
274
|
+
* @param dir - The output directory
|
|
275
|
+
* @param entry - The entry filename
|
|
276
|
+
* @returns Size metrics (raw, minified, gzipped)
|
|
277
|
+
*/
|
|
359
278
|
async function distSize(dir, entry) {
|
|
360
|
-
const
|
|
361
|
-
input: join(dir, entry),
|
|
362
|
-
plugins: [],
|
|
363
|
-
platform: "neutral",
|
|
364
|
-
external: (id) => id[0] !== "." && !id.startsWith(dir)
|
|
365
|
-
})).generate({ codeSplitting: false });
|
|
366
|
-
const code = output[0].code;
|
|
279
|
+
const code = readFileSync(join(dir, entry), "utf-8");
|
|
367
280
|
const { code: minified } = await minify(entry, code);
|
|
368
281
|
return {
|
|
369
282
|
size: Buffer.byteLength(code),
|
|
@@ -371,32 +284,17 @@ async function distSize(dir, entry) {
|
|
|
371
284
|
minGzipSize: gzipSync(minified).length
|
|
372
285
|
};
|
|
373
286
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
resolved.moduleSideEffects = null;
|
|
386
|
-
return resolved;
|
|
387
|
-
},
|
|
388
|
-
load(id) {
|
|
389
|
-
if (id === "#entry") return `import * as _lib from "${join(dir, entry)}";`;
|
|
390
|
-
}
|
|
391
|
-
}]
|
|
392
|
-
})).generate({ codeSplitting: false });
|
|
393
|
-
if (process.env.INSPECT_BUILD) {
|
|
394
|
-
logger.debug("---------[side effects]---------");
|
|
395
|
-
logger.debug(entry);
|
|
396
|
-
logger.debug(output[0].code);
|
|
397
|
-
logger.debug("-------------------------------");
|
|
398
|
-
}
|
|
399
|
-
return Buffer.byteLength(output[0].code.trim());
|
|
287
|
+
/**
|
|
288
|
+
* Calculate side effect size.
|
|
289
|
+
* For now, returns 0 as calculating true side effects requires complex analysis.
|
|
290
|
+
* This avoids the expensive rolldown rebuild that was causing performance issues.
|
|
291
|
+
*
|
|
292
|
+
* @param _dir - The output directory (unused)
|
|
293
|
+
* @param _entry - The entry filename (unused)
|
|
294
|
+
* @returns Side effect size (always 0 for now)
|
|
295
|
+
*/
|
|
296
|
+
async function sideEffectSize(_dir, _entry) {
|
|
297
|
+
return 0;
|
|
400
298
|
}
|
|
401
299
|
|
|
402
300
|
//#endregion
|
|
@@ -541,6 +439,95 @@ function resolveExternalConfig(ctx, options) {
|
|
|
541
439
|
return externalDeps;
|
|
542
440
|
}
|
|
543
441
|
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/core/logger.ts
|
|
444
|
+
/**
|
|
445
|
+
* Logger instance with configurable log level
|
|
446
|
+
*/
|
|
447
|
+
var Logger = class {
|
|
448
|
+
level = "info";
|
|
449
|
+
warningCount = 0;
|
|
450
|
+
errorCount = 0;
|
|
451
|
+
constructor(level = "info") {
|
|
452
|
+
this.level = level;
|
|
453
|
+
this.updateConsolaLevel();
|
|
454
|
+
}
|
|
455
|
+
setLevel(level) {
|
|
456
|
+
this.level = level;
|
|
457
|
+
this.updateConsolaLevel();
|
|
458
|
+
}
|
|
459
|
+
updateConsolaLevel() {
|
|
460
|
+
consola.level = {
|
|
461
|
+
silent: 0,
|
|
462
|
+
error: 1,
|
|
463
|
+
warn: 2,
|
|
464
|
+
info: 3,
|
|
465
|
+
verbose: 4
|
|
466
|
+
}[this.level];
|
|
467
|
+
}
|
|
468
|
+
silent(message, ...args) {
|
|
469
|
+
consola.log(message, ...args);
|
|
470
|
+
}
|
|
471
|
+
error(message, ...args) {
|
|
472
|
+
this.errorCount++;
|
|
473
|
+
consola.error(message, ...args);
|
|
474
|
+
}
|
|
475
|
+
warn(message, ...args) {
|
|
476
|
+
this.warningCount++;
|
|
477
|
+
consola.warn(message, ...args);
|
|
478
|
+
}
|
|
479
|
+
info(message, ...args) {
|
|
480
|
+
consola.info(message, ...args);
|
|
481
|
+
}
|
|
482
|
+
verbose(message, ...args) {
|
|
483
|
+
if (this.level === "verbose") consola.debug(message, ...args);
|
|
484
|
+
}
|
|
485
|
+
success(message, ...args) {
|
|
486
|
+
consola.success(message, ...args);
|
|
487
|
+
}
|
|
488
|
+
log(message, ...args) {
|
|
489
|
+
consola.log(message, ...args);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Debug output - only visible with INSPECT_BUILD env var
|
|
493
|
+
*/
|
|
494
|
+
debug(message, ...args) {
|
|
495
|
+
if (process.env.INSPECT_BUILD) consola.log(message, ...args);
|
|
496
|
+
}
|
|
497
|
+
getWarningCount() {
|
|
498
|
+
return this.warningCount;
|
|
499
|
+
}
|
|
500
|
+
getErrorCount() {
|
|
501
|
+
return this.errorCount;
|
|
502
|
+
}
|
|
503
|
+
resetCounts() {
|
|
504
|
+
this.warningCount = 0;
|
|
505
|
+
this.errorCount = 0;
|
|
506
|
+
}
|
|
507
|
+
shouldFailOnWarnings(failOnWarn) {
|
|
508
|
+
return failOnWarn && this.warningCount > 0;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
const logger = new Logger();
|
|
512
|
+
/**
|
|
513
|
+
* Configure global logger
|
|
514
|
+
*/
|
|
515
|
+
function configureLogger(level) {
|
|
516
|
+
logger.setLevel(level);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Reset warning and error counts
|
|
520
|
+
*/
|
|
521
|
+
function resetLogCounts() {
|
|
522
|
+
logger.resetCounts();
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Check if build should fail due to warnings
|
|
526
|
+
*/
|
|
527
|
+
function shouldFailOnWarnings(failOnWarn) {
|
|
528
|
+
return logger.shouldFailOnWarnings(failOnWarn);
|
|
529
|
+
}
|
|
530
|
+
|
|
544
531
|
//#endregion
|
|
545
532
|
//#region src/plugins/builtin/glob-import.ts
|
|
546
533
|
/**
|
|
@@ -1130,13 +1117,15 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1130
1117
|
plugins: [...rolldownPlugins, ...Array.isArray(userPlugins) ? userPlugins : userPlugins ? [userPlugins] : []]
|
|
1131
1118
|
};
|
|
1132
1119
|
await hooks.rolldownConfig?.(baseRolldownConfig, ctx);
|
|
1133
|
-
const allOutputEntries = [];
|
|
1134
1120
|
const filePathMap = /* @__PURE__ */ new Map();
|
|
1135
|
-
|
|
1121
|
+
const buildFormat = async (format) => {
|
|
1136
1122
|
const extension = getFormatExtension(format, platform, entry.fixedExtension);
|
|
1137
1123
|
const formatConfig = { ...baseRolldownConfig };
|
|
1138
1124
|
if (entry.dts !== false && (format === "es" || format === "esm" || format === "module")) {
|
|
1139
|
-
const dtsPlugins = dts({
|
|
1125
|
+
const dtsPlugins = dts({
|
|
1126
|
+
cwd: ctx.pkgDir,
|
|
1127
|
+
...typeof entry.dts === "object" ? entry.dts : {}
|
|
1128
|
+
});
|
|
1140
1129
|
formatConfig.plugins = [...Array.isArray(formatConfig.plugins) ? formatConfig.plugins : [formatConfig.plugins], ...Array.isArray(dtsPlugins) ? dtsPlugins : [dtsPlugins]];
|
|
1141
1130
|
}
|
|
1142
1131
|
const res = await rolldown(formatConfig);
|
|
@@ -1187,6 +1176,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1187
1176
|
}
|
|
1188
1177
|
return Array.from(deps).sort();
|
|
1189
1178
|
};
|
|
1179
|
+
const formatOutputEntries = [];
|
|
1190
1180
|
for (const chunk of output) {
|
|
1191
1181
|
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
1192
1182
|
if (chunk.fileName.endsWith("ts")) continue;
|
|
@@ -1205,7 +1195,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1205
1195
|
finalFilePath = hashedFilePath;
|
|
1206
1196
|
}
|
|
1207
1197
|
filePathMap.set(finalFileName, finalFilePath);
|
|
1208
|
-
|
|
1198
|
+
formatOutputEntries.push({
|
|
1209
1199
|
format,
|
|
1210
1200
|
name: finalFileName,
|
|
1211
1201
|
exports: chunk.exports,
|
|
@@ -1214,7 +1204,9 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1214
1204
|
sideEffectSize: await sideEffectSize(formatOutDir, finalFileName)
|
|
1215
1205
|
});
|
|
1216
1206
|
}
|
|
1217
|
-
|
|
1207
|
+
return formatOutputEntries;
|
|
1208
|
+
};
|
|
1209
|
+
const allOutputEntries = (await Promise.all(formats.map(buildFormat))).flat();
|
|
1218
1210
|
if (entry.dtsOnly) {
|
|
1219
1211
|
const jsFilesToDelete = [];
|
|
1220
1212
|
for (const outputEntry of allOutputEntries) {
|
|
@@ -1840,7 +1832,7 @@ function createBuildResult(entries, startTime) {
|
|
|
1840
1832
|
* Perform watch build using rolldown's built-in watch mode
|
|
1841
1833
|
*/
|
|
1842
1834
|
async function performWatchBuild(config, ctx, startTime) {
|
|
1843
|
-
const { performBuild } = await import("./build-
|
|
1835
|
+
const { performBuild } = await import("./build-BUwxGP7o.mjs");
|
|
1844
1836
|
await performBuild(config, ctx, startTime);
|
|
1845
1837
|
const bundleEntries = (config.entries || []).filter((entry) => {
|
|
1846
1838
|
if (typeof entry === "string") return !entry.endsWith("/");
|
|
@@ -2042,7 +2034,7 @@ async function performBuild(config, ctx, startTime) {
|
|
|
2042
2034
|
await hooks.entries?.(entries, ctx);
|
|
2043
2035
|
const outDirs = [];
|
|
2044
2036
|
for (const outDir of entries.map((e) => e.outDir).sort()) if (!outDirs.some((dir) => outDir.startsWith(dir))) outDirs.push(outDir);
|
|
2045
|
-
|
|
2037
|
+
await Promise.all(entries.map((entry) => entry.type === "bundle" ? rolldownBuild(ctx, entry, hooks, config) : transformDir(ctx, entry)));
|
|
2046
2038
|
await hooks.end?.(ctx);
|
|
2047
2039
|
if (config.exports?.enabled) {
|
|
2048
2040
|
const packageExports = generatePackageExports({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "robuild",
|
|
4
4
|
type: "module",
|
|
5
|
-
version: "0.1.
|
|
5
|
+
version: "0.1.7",
|
|
6
6
|
packageManager: "pnpm@10.11.1",
|
|
7
7
|
description: "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
|
|
8
8
|
license: "MIT",
|
|
@@ -45,6 +45,7 @@ var package_default = {
|
|
|
45
45
|
dependencies: {
|
|
46
46
|
"c12": "4.0.0-beta.3",
|
|
47
47
|
"cac": "^6.7.14",
|
|
48
|
+
"jiti": "^2.6.1",
|
|
48
49
|
"chokidar": "^5.0.0",
|
|
49
50
|
"consola": "^3.4.2",
|
|
50
51
|
"exsolve": "^1.0.8",
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { g as logger, h as configureLogger, t as build } from "./_chunks/build-
|
|
2
|
+
import { g as logger, h as configureLogger, t as build } from "./_chunks/build-9ZPSBYPy.mjs";
|
|
3
|
+
import module from "node:module";
|
|
3
4
|
import { colors } from "consola/utils";
|
|
4
5
|
import process from "node:process";
|
|
5
6
|
import { loadConfig } from "c12";
|
|
6
7
|
import { cac } from "cac";
|
|
7
8
|
|
|
8
9
|
//#region src/cli.ts
|
|
10
|
+
try {
|
|
11
|
+
module.enableCompileCache?.();
|
|
12
|
+
} catch {}
|
|
9
13
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
|
10
14
|
const cli = cac("robuild");
|
|
11
15
|
cli.version(pkg.default.version).help();
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createBrowserShimsPlugin, c as SHEBANG_RE, d as shebangPlugin, f as nodeProtocolPlugin, g as logger, i as DEFAULT_SHIMS_CONFIG, l as hasShebang, m as hasGlobImports, o as createNodeShimsPlugin, p as createGlobImportPlugin, r as createSkipNodeModulesPlugin, s as createShimsPlugin, t as build, u as makeExecutable } from "./_chunks/build-
|
|
1
|
+
import { a as createBrowserShimsPlugin, c as SHEBANG_RE, d as shebangPlugin, f as nodeProtocolPlugin, g as logger, i as DEFAULT_SHIMS_CONFIG, l as hasShebang, m as hasGlobImports, o as createNodeShimsPlugin, p as createGlobImportPlugin, r as createSkipNodeModulesPlugin, s as createShimsPlugin, t as build, u as makeExecutable } from "./_chunks/build-9ZPSBYPy.mjs";
|
|
2
2
|
import { t as RobuildPluginManager } from "./_chunks/manager-uQxDLzY6.mjs";
|
|
3
3
|
import { t as defineConfig } from "./_chunks/config-BlC5U5aX.mjs";
|
|
4
4
|
import { extname } from "node:path";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robuild",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"packageManager": "pnpm@10.11.1",
|
|
6
6
|
"description": "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"c12": "4.0.0-beta.3",
|
|
48
48
|
"cac": "^6.7.14",
|
|
49
|
+
"jiti": "^2.6.1",
|
|
49
50
|
"chokidar": "^5.0.0",
|
|
50
51
|
"consola": "^3.4.2",
|
|
51
52
|
"exsolve": "^1.0.8",
|