bunup 0.8.28 → 0.8.29
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/index.d.ts +73 -1
- package/dist/index.js +18 -10
- package/package.json +91 -101
- package/dist/cli.js +0 -1816
- package/dist/index.cjs +0 -811
- package/dist/index.d.cts +0 -392
- package/dist/plugins.cjs +0 -639
- package/dist/plugins.d.cts +0 -411
- package/dist/plugins.d.ts +0 -411
- package/dist/plugins.js +0 -610
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
|
+
|
|
3
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/loaders.d.ts
|
|
2
4
|
type PackageJson = {
|
|
3
5
|
/** The parsed content of the package.json file */
|
|
4
6
|
data: Record<string, any> | null
|
|
5
7
|
/** The path to the package.json file */
|
|
6
8
|
path: string | null
|
|
7
9
|
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/plugins/types.d.ts
|
|
8
13
|
/**
|
|
9
14
|
* Represents a Bun plugin that can be used with Bunup
|
|
10
15
|
*/
|
|
@@ -92,6 +97,9 @@ type BunupPlugin = {
|
|
|
92
97
|
* Union type representing all supported plugin types
|
|
93
98
|
*/
|
|
94
99
|
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/options.d.ts
|
|
95
103
|
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
96
104
|
type Define = BunBuildOptions["define"];
|
|
97
105
|
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
@@ -244,6 +252,18 @@ interface BuildOptions {
|
|
|
244
252
|
* sourcemap: true // equivalent to 'inline'
|
|
245
253
|
*/
|
|
246
254
|
sourcemap?: Sourcemap;
|
|
255
|
+
/**
|
|
256
|
+
* Define global constants for the build
|
|
257
|
+
* These values will be replaced at build time
|
|
258
|
+
*
|
|
259
|
+
* @see https://bun.sh/docs/bundler#define
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* define: {
|
|
263
|
+
* 'process.env.NODE_ENV': '"production"',
|
|
264
|
+
* 'PACKAGE_VERSION': '"1.0.0"'
|
|
265
|
+
* }
|
|
266
|
+
*/
|
|
247
267
|
define?: Define;
|
|
248
268
|
/**
|
|
249
269
|
* A callback function that runs after the build process completes
|
|
@@ -255,6 +275,14 @@ interface BuildOptions {
|
|
|
255
275
|
* @param options The build options that were used
|
|
256
276
|
*/
|
|
257
277
|
onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.
|
|
280
|
+
*
|
|
281
|
+
* @see https://bun.sh/docs/bundler#banner
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* banner: '"use client";'
|
|
285
|
+
*/
|
|
258
286
|
banner?: string;
|
|
259
287
|
/**
|
|
260
288
|
* A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
|
|
@@ -346,6 +374,39 @@ interface BuildOptions {
|
|
|
346
374
|
* env: { API_URL: "https://api.example.com", DEBUG: "false" }
|
|
347
375
|
*/
|
|
348
376
|
env?: Env;
|
|
377
|
+
/**
|
|
378
|
+
* Plugins to extend the build process functionality
|
|
379
|
+
*
|
|
380
|
+
* The Plugin type uses a discriminated union pattern with the 'type' field
|
|
381
|
+
* to support different plugin systems. Both "bun" and "bunup" plugins are supported.
|
|
382
|
+
*
|
|
383
|
+
* Each plugin type has its own specific plugin implementation:
|
|
384
|
+
* - "bun": Uses Bun's native plugin system (BunPlugin)
|
|
385
|
+
* - "bunup": Uses bunup's own plugin system with lifecycle hooks
|
|
386
|
+
*
|
|
387
|
+
* This architecture allows for extensibility as more plugin systems are added.
|
|
388
|
+
*
|
|
389
|
+
* @see https://bunup.dev/docs/advanced/plugin-development for more information on plugins
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* plugins: [
|
|
393
|
+
* {
|
|
394
|
+
* type: "bun",
|
|
395
|
+
* plugin: myBunPlugin()
|
|
396
|
+
* },
|
|
397
|
+
* {
|
|
398
|
+
* type: "bunup",
|
|
399
|
+
* hooks: {
|
|
400
|
+
* onBuildStart: (options) => {
|
|
401
|
+
* console.log('Build started with options:', options)
|
|
402
|
+
* },
|
|
403
|
+
* onBuildDone: ({ options, output }) => {
|
|
404
|
+
* console.log('Build completed with output:', output)
|
|
405
|
+
* }
|
|
406
|
+
* }
|
|
407
|
+
* }
|
|
408
|
+
* ]
|
|
409
|
+
*/
|
|
349
410
|
plugins?: Plugin[];
|
|
350
411
|
/**
|
|
351
412
|
* Whether to only generate TypeScript declaration files (.d.ts)
|
|
@@ -371,6 +432,9 @@ interface BuildOptions {
|
|
|
371
432
|
dts?: string
|
|
372
433
|
};
|
|
373
434
|
}
|
|
435
|
+
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/types.d.ts
|
|
374
438
|
type MaybePromise<T> = Promise<T> | T;
|
|
375
439
|
type WithOptional<
|
|
376
440
|
T,
|
|
@@ -386,7 +450,15 @@ type DefineWorkspaceItem = {
|
|
|
386
450
|
root: string
|
|
387
451
|
config: DefineConfigItem | DefineConfigItem[]
|
|
388
452
|
};
|
|
453
|
+
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/define.d.ts
|
|
389
456
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
390
457
|
declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
|
|
458
|
+
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/build.d.ts
|
|
391
461
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
|
392
|
-
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, build, defineConfig, defineWorkspace };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -95,7 +95,7 @@ function defineWorkspace(options) {
|
|
|
95
95
|
return options;
|
|
96
96
|
}
|
|
97
97
|
// src/build.ts
|
|
98
|
-
import
|
|
98
|
+
import path4 from "node:path";
|
|
99
99
|
import {
|
|
100
100
|
generateDts,
|
|
101
101
|
logIsolatedDeclarationErrors
|
|
@@ -322,8 +322,9 @@ var parseErrorMessage = (error) => {
|
|
|
322
322
|
};
|
|
323
323
|
|
|
324
324
|
// src/utils.ts
|
|
325
|
-
import
|
|
326
|
-
import
|
|
325
|
+
import fsSync from "node:fs";
|
|
326
|
+
import fs from "node:fs/promises";
|
|
327
|
+
import path, { normalize } from "node:path";
|
|
327
328
|
function getDefaultJsOutputExtension(format, packageType) {
|
|
328
329
|
switch (format) {
|
|
329
330
|
case "esm":
|
|
@@ -419,6 +420,7 @@ function getResolvedNaming(outputBasePath, extension) {
|
|
|
419
420
|
}
|
|
420
421
|
|
|
421
422
|
// src/loaders.ts
|
|
423
|
+
import path2 from "node:path";
|
|
422
424
|
import { loadConfig } from "coffi";
|
|
423
425
|
async function loadPackageJson(cwd = process.cwd()) {
|
|
424
426
|
const { config, filepath } = await loadConfig({
|
|
@@ -438,6 +440,9 @@ var TS_RE = /\.(ts|tsx|mts|cts)$/;
|
|
|
438
440
|
var DTS_RE = /\.(d\.(ts|mts|cts))$/;
|
|
439
441
|
var JS_TS_RE = new RegExp(`${JS_RE.source}|${TS_RE.source}`);
|
|
440
442
|
var JS_DTS_RE = new RegExp(`${JS_RE.source}|${DTS_RE.source}`);
|
|
443
|
+
// src/plugins/built-in/css/inject-styles.ts
|
|
444
|
+
import path3 from "node:path";
|
|
445
|
+
|
|
441
446
|
// src/plugins/utils.ts
|
|
442
447
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
443
448
|
function filterBunupBunPlugins(plugins) {
|
|
@@ -468,6 +473,9 @@ async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
|
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
475
|
}
|
|
476
|
+
// src/plugins/built-in/productivity/copy.ts
|
|
477
|
+
import { join } from "node:path";
|
|
478
|
+
import { basename } from "node:path";
|
|
471
479
|
// src/plugins/internal/report.ts
|
|
472
480
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
473
481
|
function report() {
|
|
@@ -608,13 +616,13 @@ function getResolvedEnv(env) {
|
|
|
608
616
|
function getPackageDepsPatterns(packageJson) {
|
|
609
617
|
return getPackageDeps(packageJson).map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`));
|
|
610
618
|
}
|
|
611
|
-
function matchesPattern(
|
|
612
|
-
return typeof pattern === "string" ? pattern ===
|
|
619
|
+
function matchesPattern(path4, pattern) {
|
|
620
|
+
return typeof pattern === "string" ? pattern === path4 : pattern.test(path4);
|
|
613
621
|
}
|
|
614
|
-
function isExternal(
|
|
622
|
+
function isExternal(path4, options, packageJson) {
|
|
615
623
|
const packageDepsPatterns = getPackageDepsPatterns(packageJson);
|
|
616
|
-
const matchesExternalPattern = packageDepsPatterns.some((pattern) => pattern.test(
|
|
617
|
-
const isExcludedFromExternal = options.noExternal?.some((pattern) => matchesPattern(
|
|
624
|
+
const matchesExternalPattern = packageDepsPatterns.some((pattern) => pattern.test(path4)) || options.external?.some((pattern) => matchesPattern(path4, pattern));
|
|
625
|
+
const isExcludedFromExternal = options.noExternal?.some((pattern) => matchesPattern(path4, pattern));
|
|
618
626
|
return matchesExternalPattern && !isExcludedFromExternal;
|
|
619
627
|
}
|
|
620
628
|
|
|
@@ -744,7 +752,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
744
752
|
options,
|
|
745
753
|
entry
|
|
746
754
|
}).dts ?? getDefaultDtsOutputExtension(fmt, packageType);
|
|
747
|
-
const filePath =
|
|
755
|
+
const filePath = path4.join(rootDir, options.outDir, `${outputBasePath}${extension}`);
|
|
748
756
|
const relativePathToRootDir = getRelativePathToRootDir(filePath, rootDir);
|
|
749
757
|
buildOutput.files.push({
|
|
750
758
|
fullPath: filePath,
|
package/package.json
CHANGED
|
@@ -1,102 +1,92 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
"lint-staged": {
|
|
95
|
-
"*": "bun run format:fix && git add .",
|
|
96
|
-
"src/**/*.(m|c)?(j|t)s": "bun run tsc"
|
|
97
|
-
},
|
|
98
|
-
"workspaces": [
|
|
99
|
-
"docs",
|
|
100
|
-
"tests"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
2
|
+
"name": "bunup",
|
|
3
|
+
"description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
|
|
4
|
+
"version": "0.8.29",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": ["dist", "bin"],
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"types": "./dist/index.d.cts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs",
|
|
14
|
+
"types": "./dist/index.d.cts"
|
|
15
|
+
},
|
|
16
|
+
"./plugins": {
|
|
17
|
+
"import": "./dist/plugins.js",
|
|
18
|
+
"require": "./dist/plugins.cjs",
|
|
19
|
+
"types": "./dist/plugins.d.cts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
|
|
24
|
+
"maintainers": [
|
|
25
|
+
{
|
|
26
|
+
"name": "Arshad Yaseen",
|
|
27
|
+
"email": "m@arshadyaseen.com",
|
|
28
|
+
"url": "https://arshadyaseen.com"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/arshad-yaseen/bunup.git"
|
|
34
|
+
},
|
|
35
|
+
"funding": "https://github.com/sponsors/arshad-yaseen",
|
|
36
|
+
"homepage": "https://bunup.dev",
|
|
37
|
+
"keywords": ["bun", "bunup", "bun-bundler"],
|
|
38
|
+
"bin": {
|
|
39
|
+
"bunup": "bin/bunup.mjs"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@clack/prompts": "^0.10.1",
|
|
43
|
+
"bun-dts": "^0.1.54",
|
|
44
|
+
"chokidar": "^4.0.3",
|
|
45
|
+
"coffi": "^0.1.31",
|
|
46
|
+
"giget": "^2.0.0",
|
|
47
|
+
"replace-in-file": "^8.3.0",
|
|
48
|
+
"tinyexec": "^1.0.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@biomejs/biome": "^1.9.4",
|
|
52
|
+
"@types/bun": "^1.2.5",
|
|
53
|
+
"bumpp": "^10.1.0",
|
|
54
|
+
"husky": "^9.1.7",
|
|
55
|
+
"lightningcss": "^1.30.1",
|
|
56
|
+
"lint-staged": "^15.5.1",
|
|
57
|
+
"typescript": "^5.8.3"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"typescript": ">=4.5.0",
|
|
61
|
+
"lightningcss": ">=1.17.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"typescript": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"lightningcss": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "bunx bunup@latest",
|
|
73
|
+
"build:docs": "bun run --cwd docs build",
|
|
74
|
+
"dev": "bunx bunup@latest --watch",
|
|
75
|
+
"dev:docs": "bun run --cwd docs dev",
|
|
76
|
+
"format": "biome format .",
|
|
77
|
+
"format:fix": "biome format --write .",
|
|
78
|
+
"lint": "biome check .",
|
|
79
|
+
"lint:fix": "biome check --write .",
|
|
80
|
+
"prepare": "husky",
|
|
81
|
+
"test": "bun test",
|
|
82
|
+
"test-build": "bun run --cwd tests build",
|
|
83
|
+
"tsc": "tsc --noEmit",
|
|
84
|
+
"publish:ci": "bun publish --access public --no-git-checks",
|
|
85
|
+
"release": "bumpp"
|
|
86
|
+
},
|
|
87
|
+
"lint-staged": {
|
|
88
|
+
"*": "bun run format:fix && git add .",
|
|
89
|
+
"src/**/*.(m|c)?(j|t)s": "bun run tsc"
|
|
90
|
+
},
|
|
91
|
+
"workspaces": ["docs", "tests"]
|
|
92
|
+
}
|