bunup 0.8.56 → 0.8.58
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/README.md +3 -3
- package/dist/{chunk-zpjpa5th.js → chunk-0j56xynx.js} +1 -1
- package/dist/{chunk-cakmscpb.js → chunk-2g0gpaee.js} +7 -2
- package/dist/{chunk-p86qvgaa.js → chunk-8dk0fkzd.js} +17 -32
- package/dist/{chunk-c4xe90dt.js → chunk-kspt827v.js} +2 -2
- package/dist/{chunk-4cgw2ywa.js → chunk-qteft286.js} +1 -1
- package/dist/{chunk-zgjvecs6.js → chunk-wav05ehp.js} +6 -5
- package/dist/cli/index.js +14 -14
- package/dist/index.d.ts +352 -1
- package/dist/index.js +3 -3
- package/dist/plugins.d.ts +343 -3
- package/dist/plugins.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-w6swmckt.d.ts +0 -353
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/bunup) [](https://npmjs.com/package/bunup) [](https://bun.sh) [](https://github.com/sponsors/arshad-yaseen)
|
|
14
14
|
|
|
15
|
-
Bunup is the **blazing-fast build tool** for TypeScript
|
|
15
|
+
Bunup is the **blazing-fast build tool** for TypeScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+

|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
*The benchmark above shows build times for a project with 1,000 files, functions, and types, with TypeScript declaration generation enabled. For detailed benchmarks, visit [here](https://gugustinette.github.io/bundler-benchmark/)*
|
|
20
20
|
|
|
21
21
|
</div>
|
|
22
22
|
<!-- markdownlint-restore -->
|
|
@@ -69,7 +69,7 @@ class Logger {
|
|
|
69
69
|
tick = false,
|
|
70
70
|
type = "info"
|
|
71
71
|
} = options;
|
|
72
|
-
const icon = this.getIcon(type, tick);
|
|
72
|
+
const icon = options.icon ?? this.getIcon(type, tick);
|
|
73
73
|
const styledMessage = muted ? pc.dim(message) : type === "error" ? pc.red(message) : type === "warn" ? pc.yellow(message) : message;
|
|
74
74
|
const identifierPart = this.formatIdentifier(identifier);
|
|
75
75
|
return `${icon} ${styledMessage}${identifierPart}`;
|
|
@@ -458,5 +458,10 @@ async function getFilesFromGlobs(patterns, cwd) {
|
|
|
458
458
|
}
|
|
459
459
|
return Array.from(includedFiles);
|
|
460
460
|
}
|
|
461
|
+
function isTypeScriptFile(path2) {
|
|
462
|
+
if (!path2)
|
|
463
|
+
return false;
|
|
464
|
+
return TS_RE.test(path2);
|
|
465
|
+
}
|
|
461
466
|
|
|
462
|
-
export { __toESM, __require, setSilent, logTable, link, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs };
|
|
467
|
+
export { __toESM, __require, setSilent, logTable, link, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile };
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-gh7z7s46.js";
|
|
5
5
|
import {
|
|
6
6
|
displayBunupGradientArt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-qteft286.js";
|
|
8
8
|
import {
|
|
9
9
|
formatListWithAnd,
|
|
10
10
|
link
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2g0gpaee.js";
|
|
12
12
|
|
|
13
13
|
// src/cli/init.ts
|
|
14
14
|
import fs from "fs";
|
|
@@ -65,10 +65,9 @@ async function initializeWorkspace(packageJsonPath) {
|
|
|
65
65
|
async function initializeSinglePackage(packageJsonPath) {
|
|
66
66
|
const entryFiles = await collectEntryFiles();
|
|
67
67
|
const outputFormats = await selectOutputFormats();
|
|
68
|
-
const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
|
|
69
68
|
const configMethod = await selectConfigurationMethod();
|
|
70
|
-
await generateConfiguration(configMethod, entryFiles, outputFormats,
|
|
71
|
-
await handleBuildScripts(packageJsonPath, entryFiles, outputFormats,
|
|
69
|
+
await generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath);
|
|
70
|
+
await handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod);
|
|
72
71
|
}
|
|
73
72
|
async function collectWorkspacePackages() {
|
|
74
73
|
const packages = [];
|
|
@@ -98,13 +97,11 @@ async function collectWorkspacePackages() {
|
|
|
98
97
|
});
|
|
99
98
|
const entryFiles = await collectEntryFilesForPackage(packageRoot, packageName);
|
|
100
99
|
const outputFormats = await selectOutputFormats();
|
|
101
|
-
const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
|
|
102
100
|
packages.push({
|
|
103
101
|
name: packageName,
|
|
104
102
|
root: packageRoot,
|
|
105
103
|
entryFiles,
|
|
106
|
-
outputFormats
|
|
107
|
-
shouldGenerateDts
|
|
104
|
+
outputFormats
|
|
108
105
|
});
|
|
109
106
|
const shouldAddMore = await confirm({
|
|
110
107
|
message: "Do you want to add another package?",
|
|
@@ -183,15 +180,6 @@ async function selectOutputFormats() {
|
|
|
183
180
|
initialValues: ["esm", "cjs"]
|
|
184
181
|
});
|
|
185
182
|
}
|
|
186
|
-
async function promptForTypeScriptDeclarations(entryFiles) {
|
|
187
|
-
const hasTypeScriptFiles = entryFiles.some((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
|
|
188
|
-
if (!hasTypeScriptFiles)
|
|
189
|
-
return false;
|
|
190
|
-
return await confirm({
|
|
191
|
-
message: "Generate TypeScript declarations?",
|
|
192
|
-
initialValue: true
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
183
|
async function selectWorkspaceConfigurationMethod() {
|
|
196
184
|
return await select({
|
|
197
185
|
message: "How would you like to configure your workspace?",
|
|
@@ -222,18 +210,18 @@ async function generateWorkspaceConfiguration(configMethod, workspacePackages) {
|
|
|
222
210
|
const configContent = createWorkspaceConfigFileContent(workspacePackages);
|
|
223
211
|
await Bun.write(`bunup.config.${configMethod}`, configContent);
|
|
224
212
|
}
|
|
225
|
-
async function generateConfiguration(configMethod, entryFiles, outputFormats,
|
|
213
|
+
async function generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath) {
|
|
226
214
|
if (configMethod === "none") {
|
|
227
215
|
log.info("If you need more control (such as adding plugins or customizing output), you can always create a config file later.");
|
|
228
216
|
return;
|
|
229
217
|
}
|
|
230
218
|
if (configMethod === "ts" || configMethod === "js") {
|
|
231
|
-
await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats
|
|
219
|
+
await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats));
|
|
232
220
|
} else if (configMethod === "json") {
|
|
233
221
|
const { data: packageJsonConfig } = await loadPackageJson();
|
|
234
222
|
const updatedConfig = {
|
|
235
223
|
...packageJsonConfig,
|
|
236
|
-
bunup: createPackageJsonConfig(entryFiles, outputFormats
|
|
224
|
+
bunup: createPackageJsonConfig(entryFiles, outputFormats)
|
|
237
225
|
};
|
|
238
226
|
await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
|
|
239
227
|
}
|
|
@@ -259,10 +247,10 @@ async function handleWorkspaceBuildScripts(packageJsonPath) {
|
|
|
259
247
|
};
|
|
260
248
|
await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
|
|
261
249
|
}
|
|
262
|
-
async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats,
|
|
250
|
+
async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod) {
|
|
263
251
|
const { data: packageJsonConfig } = await loadPackageJson();
|
|
264
252
|
const existingScripts = packageJsonConfig?.scripts ?? {};
|
|
265
|
-
const newScripts = createBuildScripts(entryFiles, outputFormats,
|
|
253
|
+
const newScripts = createBuildScripts(entryFiles, outputFormats, configMethod);
|
|
266
254
|
const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
|
|
267
255
|
if (conflictingScripts.length > 0) {
|
|
268
256
|
const shouldOverride = await confirm({
|
|
@@ -287,8 +275,7 @@ function createWorkspaceConfigFileContent(workspacePackages) {
|
|
|
287
275
|
root: '${pkg.root}',
|
|
288
276
|
config: {
|
|
289
277
|
entry: [${pkg.entryFiles.map((file) => `'${file}'`).join(", ")}],
|
|
290
|
-
format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}]
|
|
291
|
-
dts: true,` : ""}
|
|
278
|
+
format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}],
|
|
292
279
|
},
|
|
293
280
|
}`;
|
|
294
281
|
}).join(`,
|
|
@@ -300,21 +287,19 @@ ${packagesConfig}
|
|
|
300
287
|
])
|
|
301
288
|
`;
|
|
302
289
|
}
|
|
303
|
-
function createConfigFileContent(entryFiles, outputFormats
|
|
290
|
+
function createConfigFileContent(entryFiles, outputFormats) {
|
|
304
291
|
return `import { defineConfig } from 'bunup'
|
|
305
292
|
|
|
306
293
|
export default defineConfig({
|
|
307
294
|
entry: [${entryFiles.map((file) => `'${file}'`).join(", ")}],
|
|
308
|
-
format: [${outputFormats.map((format) => `'${format}'`).join(", ")}]
|
|
309
|
-
dts: true,` : ""}
|
|
295
|
+
format: [${outputFormats.map((format) => `'${format}'`).join(", ")}],
|
|
310
296
|
})
|
|
311
297
|
`;
|
|
312
298
|
}
|
|
313
|
-
function createPackageJsonConfig(entryFiles, outputFormats
|
|
299
|
+
function createPackageJsonConfig(entryFiles, outputFormats) {
|
|
314
300
|
return {
|
|
315
301
|
entry: entryFiles,
|
|
316
|
-
format: outputFormats
|
|
317
|
-
...shouldGenerateDts && { dts: true }
|
|
302
|
+
format: outputFormats
|
|
318
303
|
};
|
|
319
304
|
}
|
|
320
305
|
function createWorkspaceBuildScripts() {
|
|
@@ -323,8 +308,8 @@ function createWorkspaceBuildScripts() {
|
|
|
323
308
|
dev: "bunup --watch"
|
|
324
309
|
};
|
|
325
310
|
}
|
|
326
|
-
function createBuildScripts(entryFiles, outputFormats,
|
|
327
|
-
const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}
|
|
311
|
+
function createBuildScripts(entryFiles, outputFormats, configMethod) {
|
|
312
|
+
const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}` : "";
|
|
328
313
|
return {
|
|
329
314
|
build: `bunup${cliOptions}`,
|
|
330
315
|
dev: `bunup${cliOptions} --watch`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
displayBunupGradientArt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-qteft286.js";
|
|
5
5
|
import {
|
|
6
6
|
link,
|
|
7
7
|
pathExistsSync
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2g0gpaee.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/new.ts
|
|
11
11
|
import { renameSync } from "fs";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
filterBunupPlugins,
|
|
4
4
|
runPluginBuildDoneHooks,
|
|
5
5
|
runPluginBuildStartHooks
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-0j56xynx.js";
|
|
7
7
|
import {
|
|
8
8
|
loadPackageJson
|
|
9
9
|
} from "./chunk-gh7z7s46.js";
|
|
@@ -19,12 +19,13 @@ import {
|
|
|
19
19
|
getFilesFromGlobs,
|
|
20
20
|
getPackageDeps,
|
|
21
21
|
getShortFilePath,
|
|
22
|
+
isTypeScriptFile,
|
|
22
23
|
link,
|
|
23
24
|
logTable,
|
|
24
25
|
logger,
|
|
25
26
|
parseErrorMessage,
|
|
26
27
|
setSilent
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-2g0gpaee.js";
|
|
28
29
|
|
|
29
30
|
// src/build.ts
|
|
30
31
|
import path from "path";
|
|
@@ -145,7 +146,7 @@ ${text}`;
|
|
|
145
146
|
// src/options.ts
|
|
146
147
|
var DEFAULT_OPTIONS = {
|
|
147
148
|
entry: ["src/index.ts"],
|
|
148
|
-
format: ["cjs"],
|
|
149
|
+
format: ["esm", "cjs"],
|
|
149
150
|
outDir: "dist",
|
|
150
151
|
target: "node",
|
|
151
152
|
clean: true
|
|
@@ -193,7 +194,7 @@ function getResolvedSplitting(splitting, format) {
|
|
|
193
194
|
return splitting === undefined ? format === "esm" : splitting;
|
|
194
195
|
}
|
|
195
196
|
function getResolvedDtsSplitting(buildSplitting, dtsSplitting) {
|
|
196
|
-
return dtsSplitting ?? buildSplitting ??
|
|
197
|
+
return dtsSplitting ?? buildSplitting ?? false;
|
|
197
198
|
}
|
|
198
199
|
var DEFAULT_ENTRY_NAMING = "[dir]/[name].[ext]";
|
|
199
200
|
function getResolvedNaming(fmt, packageType) {
|
|
@@ -325,7 +326,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
325
326
|
}
|
|
326
327
|
});
|
|
327
328
|
await Promise.all(buildPromises);
|
|
328
|
-
if (options.dts) {
|
|
329
|
+
if (options.dts ?? entrypoints.some(isTypeScriptFile)) {
|
|
329
330
|
try {
|
|
330
331
|
const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
|
|
331
332
|
const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
|
package/dist/cli/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import {
|
|
4
4
|
build,
|
|
5
5
|
createBuildOptions
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import"../chunk-
|
|
6
|
+
} from "../chunk-wav05ehp.js";
|
|
7
|
+
import"../chunk-0j56xynx.js";
|
|
8
8
|
import {
|
|
9
9
|
processLoadedConfigs
|
|
10
10
|
} from "../chunk-gh7z7s46.js";
|
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
logger,
|
|
22
22
|
parseErrorMessage,
|
|
23
23
|
setSilent
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-2g0gpaee.js";
|
|
25
25
|
|
|
26
26
|
// src/cli/index.ts
|
|
27
27
|
import { loadConfig } from "coffi";
|
|
28
28
|
import pc3 from "picocolors";
|
|
29
29
|
import { exec } from "tinyexec";
|
|
30
30
|
// package.json
|
|
31
|
-
var version = "0.8.
|
|
31
|
+
var version = "0.8.58";
|
|
32
32
|
|
|
33
33
|
// src/watch.ts
|
|
34
34
|
import path from "path";
|
|
@@ -63,7 +63,9 @@ async function watch(partialOptions, rootDir) {
|
|
|
63
63
|
const start = performance.now();
|
|
64
64
|
await build(options, rootDir);
|
|
65
65
|
if (!initial) {
|
|
66
|
-
logger.success(
|
|
66
|
+
logger.success(`Rebuild finished in ${pc.green(formatTime(performance.now() - start))}`, {
|
|
67
|
+
icon: "\uD83D\uDCE6"
|
|
68
|
+
});
|
|
67
69
|
}
|
|
68
70
|
} catch (error) {
|
|
69
71
|
handleError(error);
|
|
@@ -71,12 +73,7 @@ async function watch(partialOptions, rootDir) {
|
|
|
71
73
|
isRebuilding = false;
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
|
-
watcher.on("change", (
|
|
75
|
-
const changedFile = path.relative(rootDir, filePath);
|
|
76
|
-
logger.info(`File changed: ${changedFile}`, {
|
|
77
|
-
muted: true,
|
|
78
|
-
once: changedFile
|
|
79
|
-
});
|
|
76
|
+
watcher.on("change", () => {
|
|
80
77
|
triggerRebuild();
|
|
81
78
|
});
|
|
82
79
|
watcher.on("error", (error) => {
|
|
@@ -485,12 +482,12 @@ var parseCliOptions = (argv) => {
|
|
|
485
482
|
async function main(args = Bun.argv.slice(2)) {
|
|
486
483
|
const cliOptions = parseCliOptions(args);
|
|
487
484
|
if (cliOptions.new) {
|
|
488
|
-
const { newProject } = await import("../chunk-
|
|
485
|
+
const { newProject } = await import("../chunk-kspt827v.js");
|
|
489
486
|
await newProject();
|
|
490
487
|
return;
|
|
491
488
|
}
|
|
492
489
|
if (cliOptions.init) {
|
|
493
|
-
const { init } = await import("../chunk-
|
|
490
|
+
const { init } = await import("../chunk-8dk0fkzd.js");
|
|
494
491
|
await init();
|
|
495
492
|
return;
|
|
496
493
|
}
|
|
@@ -532,7 +529,10 @@ async function main(args = Bun.argv.slice(2)) {
|
|
|
532
529
|
const timeDisplay = formatTime(buildTimeMs);
|
|
533
530
|
logger.success(`Build completed in ${pc3.green(timeDisplay)}`);
|
|
534
531
|
if (cliOptions.watch) {
|
|
535
|
-
logger.info("Watching for file changes..."
|
|
532
|
+
logger.info("Watching for file changes...", {
|
|
533
|
+
icon: "\uD83D\uDC40",
|
|
534
|
+
verticalSpace: true
|
|
535
|
+
});
|
|
536
536
|
}
|
|
537
537
|
if (cliOptions.onSuccess) {
|
|
538
538
|
logger.info(`Running command: ${cliOptions.onSuccess}`, {
|