bunup 0.8.41 → 0.8.43

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.
@@ -0,0 +1,45 @@
1
+ import {
2
+ BunupPluginError
3
+ } from "./chunk-c1eyecm3.js";
4
+
5
+ // src/plugins/utils.ts
6
+ import pc from "picocolors";
7
+ function filterBunupBunPlugins(plugins) {
8
+ if (!plugins)
9
+ return [];
10
+ return plugins.filter((p) => p.type === "bun");
11
+ }
12
+ function filterBunupPlugins(plugins) {
13
+ if (!plugins)
14
+ return [];
15
+ return plugins.filter((p) => p.type === "bunup");
16
+ }
17
+ async function runPluginBuildStartHooks(bunupPlugins, options) {
18
+ if (!bunupPlugins)
19
+ return;
20
+ for (const plugin of bunupPlugins) {
21
+ if (plugin.hooks.onBuildStart) {
22
+ await plugin.hooks.onBuildStart(options);
23
+ }
24
+ }
25
+ }
26
+ async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
27
+ if (!bunupPlugins)
28
+ return;
29
+ for (const plugin of bunupPlugins) {
30
+ if (plugin.hooks.onBuildDone) {
31
+ await plugin.hooks.onBuildDone({ options, output, meta });
32
+ }
33
+ }
34
+ }
35
+ async function getPackageForPlugin(name, pluginName) {
36
+ let pkg;
37
+ try {
38
+ pkg = await import(name);
39
+ } catch {
40
+ throw new BunupPluginError(`[${pc.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc.blue(`bun add ${name} --dev`)}`);
41
+ }
42
+ return pkg;
43
+ }
44
+
45
+ export { filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  filterBunupBunPlugins,
3
3
  filterBunupPlugins,
4
- report,
5
4
  runPluginBuildDoneHooks,
6
5
  runPluginBuildStartHooks
7
- } from "./plugins/index.js";
6
+ } from "./chunk-6gvmfnmt.js";
8
7
  import {
9
8
  loadPackageJson
10
9
  } from "./chunk-gh7z7s46.js";
@@ -13,11 +12,13 @@ import {
13
12
  cleanOutDir,
14
13
  cleanPath,
15
14
  ensureArray,
15
+ formatFileSize,
16
16
  getDefaultDtsExtention,
17
17
  getDefaultOutputExtension,
18
18
  getFilesFromGlobs,
19
19
  getPackageDeps,
20
20
  getShortFilePath,
21
+ logTable,
21
22
  logger,
22
23
  setSilent
23
24
  } from "./chunk-c1eyecm3.js";
@@ -25,7 +26,91 @@ import {
25
26
  // src/build.ts
26
27
  import path from "path";
27
28
  import { generateDts, logIsolatedDeclarationErrors } from "bun-dts";
29
+ import pc2 from "picocolors";
30
+
31
+ // src/plugins/internal/linter.ts
32
+ var rules = [
33
+ {
34
+ check: (ctx) => ctx.meta.packageJson.data?.type !== "module" && ctx.options.format.length === 1 && ctx.options.format[0] === "esm",
35
+ message: 'You are using ESM format but your package.json does not have "type": "module". This may cause issues with module resolution.'
36
+ }
37
+ ];
38
+ function linter() {
39
+ return {
40
+ type: "bunup",
41
+ name: "linter",
42
+ hooks: {
43
+ onBuildDone: (ctx) => {
44
+ let hasWarnings = false;
45
+ for (const rule of rules) {
46
+ if (rule.check(ctx)) {
47
+ if (!hasWarnings) {
48
+ logger.space();
49
+ }
50
+ logger.warn(rule.message);
51
+ hasWarnings = true;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ // src/plugins/internal/report.ts
28
60
  import pc from "picocolors";
61
+ function report() {
62
+ return {
63
+ type: "bunup",
64
+ name: "report",
65
+ hooks: {
66
+ onBuildDone: async ({ options, output }) => {
67
+ if (options.watch)
68
+ return;
69
+ const files = await Promise.all(output.files.map(async (file) => {
70
+ const name = file.relativePathToRootDir;
71
+ const size = Bun.file(file.fullPath).size;
72
+ const gzipSize = Bun.gzipSync(new Uint8Array(await Bun.file(file.fullPath).arrayBuffer())).length;
73
+ const formattedGzipSize = formatFileSize(gzipSize);
74
+ return {
75
+ name,
76
+ size,
77
+ formattedSize: formatFileSize(size),
78
+ gzipSize,
79
+ formattedGzipSize
80
+ };
81
+ }));
82
+ const totalSize = files.reduce((sum, file) => sum + file.size, 0);
83
+ const formattedTotalSize = formatFileSize(totalSize);
84
+ const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
85
+ const formattedTotalGzipSize = formatFileSize(totalGzipSize);
86
+ const columns = [
87
+ { header: "File", align: "left", color: pc.blue },
88
+ { header: "Size", align: "right", color: pc.green },
89
+ {
90
+ header: "Gzip",
91
+ align: "right",
92
+ color: pc.magenta
93
+ }
94
+ ];
95
+ const data = files.map((file) => {
96
+ return {
97
+ File: file.name,
98
+ Size: file.formattedSize,
99
+ Gzip: file.formattedGzipSize
100
+ };
101
+ });
102
+ const footer = {
103
+ File: "Total",
104
+ Size: formattedTotalSize,
105
+ Gzip: formattedTotalGzipSize
106
+ };
107
+ logger.space();
108
+ logTable(columns, data, footer);
109
+ logger.space();
110
+ }
111
+ }
112
+ };
113
+ }
29
114
 
30
115
  // src/plugins/internal/use-client.ts
31
116
  function useClient() {
@@ -65,11 +150,7 @@ function createBuildOptions(partialOptions) {
65
150
  };
66
151
  return {
67
152
  ...options,
68
- plugins: [
69
- ...options.plugins?.filter((p) => p.name !== "report") ?? [],
70
- useClient(),
71
- report()
72
- ]
153
+ plugins: [useClient(), linter(), report(), ...options.plugins ?? []]
73
154
  };
74
155
  }
75
156
  function getResolvedMinify(options) {
@@ -217,7 +298,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
217
298
  const relativePathToRootDir = getRelativePathToRootDir(file.path, rootDir);
218
299
  const relativePathToOutputDir = getRelativePathToOutputDir(relativePathToRootDir, options.outDir);
219
300
  if (file.kind === "entry-point") {
220
- logger.success(`${pc.dim(options.outDir)}/${relativePathToOutputDir}`, {
301
+ logger.success(`${pc2.dim(options.outDir)}/${relativePathToOutputDir}`, {
221
302
  identifier: options.name
222
303
  });
223
304
  }
@@ -250,9 +331,11 @@ async function build(partialOptions, rootDir = process.cwd()) {
250
331
  const dtsExtension = getDefaultDtsExtention(fmt, packageType);
251
332
  const relativePathToOutputDir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
252
333
  const relativePathToRootDir = cleanPath(`${options.outDir}/${relativePathToOutputDir}`);
253
- logger.success(`${pc.dim(options.outDir)}/${relativePathToOutputDir}`, {
254
- identifier: options.name
255
- });
334
+ if (file.kind === "entry-point") {
335
+ logger.success(`${pc2.dim(options.outDir)}/${relativePathToOutputDir}`, {
336
+ identifier: options.name
337
+ });
338
+ }
256
339
  const fullPath = path.join(rootDir, relativePathToRootDir);
257
340
  await Bun.write(fullPath, file.dts);
258
341
  buildOutput.files.push({
package/dist/cli/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import {
4
4
  build,
5
5
  createBuildOptions
6
- } from "../chunk-5ng6vk19.js";
7
- import"../plugins/index.js";
6
+ } from "../chunk-mw1zvnvs.js";
7
+ import"../chunk-6gvmfnmt.js";
8
8
  import {
9
9
  processLoadedConfigs
10
10
  } from "../chunk-gh7z7s46.js";
@@ -26,7 +26,7 @@ import {
26
26
  // src/cli/index.ts
27
27
  import { exec } from "tinyexec";
28
28
  // package.json
29
- var version = "0.8.39";
29
+ var version = "0.8.43";
30
30
 
31
31
  // src/cli/options.ts
32
32
  import pc from "picocolors";
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./chunk-5ng6vk19.js";
5
- import"./plugins/index.js";
4
+ } from "./chunk-mw1zvnvs.js";
5
+ import"./chunk-6gvmfnmt.js";
6
6
  import"./chunk-gh7z7s46.js";
7
7
  import"./chunk-c1eyecm3.js";
8
8
 
@@ -1,4 +1,4 @@
1
- import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "../chunk-4gbrfagt";
1
+ import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-4gbrfagt";
2
2
  /**
3
3
  * A plugin that provides shims for Node.js globals and ESM/CJS interoperability.
4
4
  *
@@ -47,10 +47,4 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
47
47
  * @see https://bunup.dev/docs/plugins/inject-styles
48
48
  */
49
49
  declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
50
- /**
51
- * A plugin that logs a report of the bundle size.
52
- *
53
- * @deprecated This plugin is enabled by default. Bundle size reports are automatically logged without needing to use this plugin.
54
- */
55
- declare function report(): BunupPlugin;
56
- export { shims, report, injectStyles, exports, copy };
50
+ export { shims, injectStyles, exports, copy };
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
- BunupPluginError,
3
+ getPackageForPlugin
4
+ } from "./chunk-6gvmfnmt.js";
5
+ import {
4
6
  cleanPath,
5
- formatFileSize,
6
7
  isDirectoryPath,
7
- logTable,
8
8
  logger
9
- } from "../chunk-c1eyecm3.js";
9
+ } from "./chunk-c1eyecm3.js";
10
10
 
11
11
  // src/constants/re.ts
12
12
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
@@ -203,48 +203,6 @@ function copy(patterns, outPath) {
203
203
  }
204
204
  // src/plugins/inject-styles.ts
205
205
  import path2 from "path";
206
-
207
- // src/plugins/utils.ts
208
- import pc from "picocolors";
209
- function filterBunupBunPlugins(plugins) {
210
- if (!plugins)
211
- return [];
212
- return plugins.filter((p) => p.type === "bun");
213
- }
214
- function filterBunupPlugins(plugins) {
215
- if (!plugins)
216
- return [];
217
- return plugins.filter((p) => p.type === "bunup");
218
- }
219
- async function runPluginBuildStartHooks(bunupPlugins, options) {
220
- if (!bunupPlugins)
221
- return;
222
- for (const plugin of bunupPlugins) {
223
- if (plugin.hooks.onBuildStart) {
224
- await plugin.hooks.onBuildStart(options);
225
- }
226
- }
227
- }
228
- async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
229
- if (!bunupPlugins)
230
- return;
231
- for (const plugin of bunupPlugins) {
232
- if (plugin.hooks.onBuildDone) {
233
- await plugin.hooks.onBuildDone({ options, output, meta });
234
- }
235
- }
236
- }
237
- async function getPackageForPlugin(name, pluginName) {
238
- let pkg;
239
- try {
240
- pkg = await import(name);
241
- } catch {
242
- throw new BunupPluginError(`[${pc.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc.blue(`bun add ${name} --dev`)}`);
243
- }
244
- return pkg;
245
- }
246
-
247
- // src/plugins/inject-styles.ts
248
206
  function injectStyles(options) {
249
207
  const { inject, ...transformOptions } = options ?? {};
250
208
  return {
@@ -302,66 +260,9 @@ function injectStyles(options) {
302
260
  }
303
261
  };
304
262
  }
305
- // src/plugins/internal/report.ts
306
- import pc2 from "picocolors";
307
- function report() {
308
- return {
309
- type: "bunup",
310
- name: "report",
311
- hooks: {
312
- onBuildDone: async ({ options, output }) => {
313
- if (options.watch)
314
- return;
315
- const files = await Promise.all(output.files.map(async (file) => {
316
- const name = file.relativePathToRootDir;
317
- const size = Bun.file(file.fullPath).size;
318
- const gzipSize = Bun.gzipSync(new Uint8Array(await Bun.file(file.fullPath).arrayBuffer())).length;
319
- const formattedGzipSize = formatFileSize(gzipSize);
320
- return {
321
- name,
322
- size,
323
- formattedSize: formatFileSize(size),
324
- gzipSize,
325
- formattedGzipSize
326
- };
327
- }));
328
- const totalSize = files.reduce((sum, file) => sum + file.size, 0);
329
- const formattedTotalSize = formatFileSize(totalSize);
330
- const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
331
- const formattedTotalGzipSize = formatFileSize(totalGzipSize);
332
- const columns = [
333
- { header: "File", align: "left", color: pc2.blue },
334
- { header: "Size", align: "right", color: pc2.green },
335
- {
336
- header: "Gzip",
337
- align: "right",
338
- color: pc2.magenta
339
- }
340
- ];
341
- const data = files.map((file) => {
342
- return {
343
- File: file.name,
344
- Size: file.formattedSize,
345
- Gzip: file.formattedGzipSize
346
- };
347
- });
348
- const footer = {
349
- File: "Total",
350
- Size: formattedTotalSize,
351
- Gzip: formattedTotalGzipSize
352
- };
353
- logger.space();
354
- logTable(columns, data, footer);
355
- logger.space();
356
- }
357
- }
358
- };
359
- }
360
263
  export {
361
264
  shims,
362
- report,
363
265
  injectStyles,
364
266
  exports,
365
267
  copy
366
268
  };
367
- export { filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, report };
package/package.json CHANGED
@@ -1,93 +1,102 @@
1
1
  {
2
- "name": "bunup",
3
- "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
- "version": "0.8.41",
5
- "type": "module",
6
- "files": ["dist"],
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- },
14
- "./cli": {
15
- "import": "./dist/cli/index.js"
16
- },
17
- "./plugins": {
18
- "import": "./dist/plugins/index.js",
19
- "types": "./dist/plugins/index.d.ts"
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": "dist/cli/index.js"
40
- },
41
- "dependencies": {
42
- "@clack/prompts": "^0.10.1",
43
- "bun-dts": "^0.1.70",
44
- "chokidar": "^4.0.3",
45
- "coffi": "^0.1.31",
46
- "giget": "^2.0.0",
47
- "picocolors": "^1.1.1",
48
- "replace-in-file": "^8.3.0",
49
- "tinyexec": "^1.0.1"
50
- },
51
- "devDependencies": {
52
- "@biomejs/biome": "^1.9.4",
53
- "@types/bun": "^1.2.5",
54
- "bumpp": "^10.1.0",
55
- "husky": "^9.1.7",
56
- "lightningcss": "^1.30.1",
57
- "lint-staged": "^15.5.1",
58
- "typescript": "^5.8.3"
59
- },
60
- "peerDependencies": {
61
- "typescript": ">=4.5.0",
62
- "lightningcss": ">=1.17.0"
63
- },
64
- "peerDependenciesMeta": {
65
- "typescript": {
66
- "optional": true
67
- },
68
- "lightningcss": {
69
- "optional": true
70
- }
71
- },
72
- "scripts": {
73
- "build": "bunx bunup@latest",
74
- "build:docs": "bun run --cwd docs build",
75
- "dev": "bunx bunup@latest --watch",
76
- "dev:docs": "bun run --cwd docs dev",
77
- "format": "biome format .",
78
- "format:fix": "biome format --write .",
79
- "lint": "biome check .",
80
- "lint:fix": "biome check --write .",
81
- "prepare": "husky",
82
- "test": "bun test",
83
- "test-build": "bun run --cwd tests build",
84
- "tsc": "tsc --noEmit",
85
- "publish:ci": "bun publish --access public --no-git-checks",
86
- "release": "bumpp"
87
- },
88
- "lint-staged": {
89
- "*": "bun run format:fix && git add .",
90
- "src/**/*.(m|c)?(j|t)s": "bun run tsc"
91
- },
92
- "workspaces": ["docs", "tests"]
93
- }
2
+ "name": "bunup",
3
+ "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
+ "version": "0.8.43",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "./plugins": {
17
+ "import": "./dist/plugins.js",
18
+ "types": "./dist/plugins.d.ts"
19
+ },
20
+ "./cli": {
21
+ "import": "./dist/cli/index.js"
22
+ }
23
+ },
24
+ "license": "MIT",
25
+ "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
26
+ "maintainers": [
27
+ {
28
+ "name": "Arshad Yaseen",
29
+ "email": "m@arshadyaseen.com",
30
+ "url": "https://arshadyaseen.com"
31
+ }
32
+ ],
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/arshad-yaseen/bunup.git"
36
+ },
37
+ "funding": "https://github.com/sponsors/arshad-yaseen",
38
+ "homepage": "https://bunup.dev",
39
+ "keywords": [
40
+ "bun",
41
+ "bunup",
42
+ "bun-bundler"
43
+ ],
44
+ "bin": {
45
+ "bunup": "dist/cli/index.js"
46
+ },
47
+ "dependencies": {
48
+ "@clack/prompts": "^0.10.1",
49
+ "bun-dts": "^0.1.70",
50
+ "chokidar": "^4.0.3",
51
+ "coffi": "^0.1.31",
52
+ "giget": "^2.0.0",
53
+ "picocolors": "^1.1.1",
54
+ "replace-in-file": "^8.3.0",
55
+ "tinyexec": "^1.0.1"
56
+ },
57
+ "devDependencies": {
58
+ "@biomejs/biome": "^1.9.4",
59
+ "@types/bun": "^1.2.5",
60
+ "bumpp": "^10.1.0",
61
+ "husky": "^9.1.7",
62
+ "lightningcss": "^1.30.1",
63
+ "lint-staged": "^15.5.1",
64
+ "typescript": "^5.8.3"
65
+ },
66
+ "peerDependencies": {
67
+ "typescript": ">=4.5.0",
68
+ "lightningcss": ">=1.17.0"
69
+ },
70
+ "peerDependenciesMeta": {
71
+ "typescript": {
72
+ "optional": true
73
+ },
74
+ "lightningcss": {
75
+ "optional": true
76
+ }
77
+ },
78
+ "scripts": {
79
+ "build": "bunx bunup@latest",
80
+ "build:docs": "bun run --cwd docs build",
81
+ "dev": "bunx bunup@latest --watch",
82
+ "dev:docs": "bun run --cwd docs dev",
83
+ "format": "biome format .",
84
+ "format:fix": "biome format --write .",
85
+ "lint": "biome check .",
86
+ "lint:fix": "biome check --write .",
87
+ "prepare": "husky",
88
+ "test": "bun test",
89
+ "test-build": "bun run --cwd tests build",
90
+ "tsc": "tsc --noEmit",
91
+ "publish:ci": "bun publish --access public --no-git-checks",
92
+ "release": "bumpp"
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
+ }