bunup 0.8.39 → 0.8.41

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,13 +1,12 @@
1
1
  import { BunPlugin } from "bun";
2
- import { BuildConfig } from "bun";
3
2
  import { DtsPluginOptions } from "bun-dts";
4
- type Loader = NonNullable<BuildConfig["loader"]>[string];
5
- type Define = BuildConfig["define"];
6
- type Sourcemap = BuildConfig["sourcemap"];
7
- type Format = Exclude<BuildConfig["format"], undefined>;
8
- type Target = BuildConfig["target"];
3
+ type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
4
+ type Define = Record<string, string>;
5
+ type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
6
+ type Format = "esm" | "cjs" | "iife";
7
+ type Target = "bun" | "node" | "browser";
9
8
  type External = (string | RegExp)[];
10
- type Env = BuildConfig["env"] | Record<string, string>;
9
+ type Env = "inline" | "disable" | `${string}*` | Record<string, string>;
11
10
  interface BuildOptions {
12
11
  /**
13
12
  * Name of the build configuration
@@ -92,9 +91,17 @@ interface BuildOptions {
92
91
  */
93
92
  noExternal?: External;
94
93
  /**
95
- * The target environment for the bundle
94
+ * The target environment for the bundle.
96
95
  * Can be 'browser', 'bun', 'node', etc.
97
- * Defaults to 'node' if not specified
96
+ * Defaults to 'node' if not specified.
97
+ *
98
+ * Bun target is for generating bundles that are intended to be run by the Bun runtime. In many cases,
99
+ * it isn't necessary to bundle server-side code; you can directly execute the source code
100
+ * without modification. However, bundling your server code can reduce startup times and
101
+ * improve running performance.
102
+ *
103
+ * All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which
104
+ * indicates to the Bun runtime that there's no need to re-transpile the file before execution.
98
105
  */
99
106
  target?: Target;
100
107
  /**
@@ -159,7 +166,7 @@ interface BuildOptions {
159
166
  * ".txt": "file",
160
167
  * }
161
168
  */
162
- loader?: Record<string, Loader>;
169
+ loader?: { [k in string] : Loader };
163
170
  /**
164
171
  * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
165
172
  *
@@ -220,6 +227,16 @@ interface BuildOptions {
220
227
  * env: { API_URL: "https://api.example.com", DEBUG: "false" }
221
228
  */
222
229
  env?: Env;
230
+ /**
231
+ * Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
232
+ * "sideEffects" fields. This should only be used as a temporary workaround for incorrect
233
+ * annotations in libraries.
234
+ */
235
+ ignoreDCEAnnotations?: boolean;
236
+ /**
237
+ * Force emitting @__PURE__ annotations even if minify.whitespace is true.
238
+ */
239
+ emitDCEAnnotations?: boolean;
223
240
  plugins?: Plugin[];
224
241
  }
225
242
  type MaybePromise<T> = Promise<T> | T;
@@ -322,4 +339,4 @@ type BunupPlugin = {
322
339
  * Union type representing all supported plugin types
323
340
  */
324
341
  type Plugin = BunupBunPlugin | BunupPlugin;
325
- export { BunupPlugin, Plugin, BuildOptions, MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem };
342
+ export { BuildContext, BunupPlugin, Plugin, BuildOptions, MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem };
@@ -4,7 +4,7 @@ import {
4
4
  report,
5
5
  runPluginBuildDoneHooks,
6
6
  runPluginBuildStartHooks
7
- } from "./chunk-vpe2amgs.js";
7
+ } from "./plugins/index.js";
8
8
  import {
9
9
  loadPackageJson
10
10
  } from "./chunk-gh7z7s46.js";
@@ -199,6 +199,8 @@ async function build(partialOptions, rootDir = process.cwd()) {
199
199
  footer: options.footer,
200
200
  publicPath: options.publicPath,
201
201
  env: getResolvedEnv(options.env),
202
+ ignoreDCEAnnotations: options.ignoreDCEAnnotations,
203
+ emitDCEAnnotations: options.emitDCEAnnotations,
202
204
  throw: false,
203
205
  plugins
204
206
  });
package/dist/cli/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import {
4
4
  build,
5
5
  createBuildOptions
6
- } from "../chunk-m1145s0v.js";
7
- import"../chunk-vpe2amgs.js";
6
+ } from "../chunk-5ng6vk19.js";
7
+ import"../plugins/index.js";
8
8
  import {
9
9
  processLoadedConfigs
10
10
  } from "../chunk-gh7z7s46.js";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-76m1hp4m";
1
+ import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-4gbrfagt";
2
2
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
3
3
  declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
4
4
  declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./chunk-m1145s0v.js";
5
- import"./chunk-vpe2amgs.js";
4
+ } from "./chunk-5ng6vk19.js";
5
+ import"./plugins/index.js";
6
6
  import"./chunk-gh7z7s46.js";
7
7
  import"./chunk-c1eyecm3.js";
8
8
 
@@ -1,36 +1,53 @@
1
- import { BunupPlugin, MaybePromise, Plugin } from "./chunk-76m1hp4m";
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
+ *
5
+ * @see https://bunup.dev/docs/plugins/shims
4
6
  */
5
7
  declare function shims(): Plugin;
8
+ type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
6
9
  interface ExportsPluginOptions {
7
10
  /**
8
- * Additional export fields to preserve alongside generated exports
11
+ * Additional export fields to preserve alongside automatically generated exports
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * {
16
+ * customExports: (ctx) => {
17
+ * const { output, options, meta } = ctx
18
+ * return {
19
+ * './package.json': "package.json",
20
+ * }
21
+ * },
22
+ * }
23
+ * ```
9
24
  */
10
- extraExports?: Record<string, string | Record<string, string>>;
25
+ customExports?: (ctx: BuildContext) => CustomExports | undefined;
11
26
  }
12
27
  /**
13
28
  * A plugin that generates the exports field in the package.json file automatically.
29
+ *
30
+ * @see https://bunup.dev/docs/plugins/exports
14
31
  */
15
32
  declare function exports(options?: ExportsPluginOptions): BunupPlugin;
33
+ /**
34
+ * A plugin that copies files and directories to the output directory.
35
+ *
36
+ * @param patterns - Array of glob patterns to match files for copying
37
+ * @param outPath - Optional output path. If not provided, uses the build output directory
38
+ * @see https://bunup.dev/docs/plugins/copy
39
+ */
40
+ declare function copy(patterns: string[], outPath?: string): BunupPlugin;
16
41
  type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
17
42
  inject?: (css: string, filePath: string) => MaybePromise<string>
18
43
  };
19
44
  /**
20
45
  * A plugin that injects styles into the document head.
21
46
  *
22
- * @see https://bunup.dev/docs/plugins/css#injectstyles
47
+ * @see https://bunup.dev/docs/plugins/inject-styles
23
48
  */
24
49
  declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
25
50
  /**
26
- * A plugin that copies files and directories to the output directory.
27
- *
28
- * @param patterns - Array of glob patterns to match files for copying
29
- * @param outPath - Optional output path. If not provided, uses the build output directory
30
- * @see https://bunup.dev/docs/plugins/productivity#copy
31
- */
32
- declare function copy(patterns: string[], outPath?: string): BunupPlugin;
33
- /**
34
51
  * A plugin that logs a report of the bundle size.
35
52
  *
36
53
  * @deprecated This plugin is enabled by default. Bundle size reports are automatically logged without needing to use this plugin.
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import {
2
3
  BunupPluginError,
3
4
  cleanPath,
@@ -5,7 +6,7 @@ import {
5
6
  isDirectoryPath,
6
7
  logTable,
7
8
  logger
8
- } from "./chunk-c1eyecm3.js";
9
+ } from "../chunk-c1eyecm3.js";
9
10
 
10
11
  // src/constants/re.ts
11
12
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
@@ -15,7 +16,7 @@ var JS_TS_RE = new RegExp(`${JS_RE.source}|${TS_RE.source}`);
15
16
  var JS_DTS_RE = new RegExp(`${JS_RE.source}|${DTS_RE.source}`);
16
17
  var CSS_RE = /\.(css)$/;
17
18
 
18
- // src/plugins/built-in/node/shims.ts
19
+ // src/plugins/shims.ts
19
20
  function shims() {
20
21
  return {
21
22
  type: "bun",
@@ -69,15 +70,15 @@ const importMetaUrl = pathToFileURL(__filename).href;
69
70
  }
70
71
  };
71
72
  }
72
-
73
- // src/plugins/built-in/productivity/exports.ts
73
+ // src/plugins/exports.ts
74
74
  import path from "path";
75
75
  function exports(options = {}) {
76
76
  return {
77
77
  type: "bunup",
78
78
  name: "exports",
79
79
  hooks: {
80
- onBuildDone: async ({ output, options: buildOptions, meta }) => {
80
+ onBuildDone: async (ctx) => {
81
+ const { output, options: buildOptions, meta } = ctx;
81
82
  if (!meta.packageJson.path || !meta.packageJson.data) {
82
83
  return;
83
84
  }
@@ -90,8 +91,8 @@ function exports(options = {}) {
90
91
  ])
91
92
  ] : [buildOptions.outDir];
92
93
  const mergedExports = { ...exportsField };
93
- if (options.extraExports) {
94
- for (const [key, value] of Object.entries(options.extraExports)) {
94
+ if (options.customExports) {
95
+ for (const [key, value] of Object.entries(options.customExports(ctx) ?? {})) {
95
96
  if (typeof value === "string") {
96
97
  mergedExports[key] = value;
97
98
  } else {
@@ -107,6 +108,7 @@ function exports(options = {}) {
107
108
  }
108
109
  }
109
110
  }
111
+ const { main, module, types, ...restPackageJson } = meta.packageJson.data;
110
112
  const newPackageJson = {
111
113
  name: meta.packageJson.data.name,
112
114
  description: meta.packageJson.data.description,
@@ -117,9 +119,9 @@ function exports(options = {}) {
117
119
  ...entryPoints,
118
120
  exports: mergedExports
119
121
  };
120
- for (const key in meta.packageJson.data) {
121
- if (Object.prototype.hasOwnProperty.call(meta.packageJson.data, key) && !Object.prototype.hasOwnProperty.call(newPackageJson, key)) {
122
- newPackageJson[key] = meta.packageJson.data[key];
122
+ for (const key in restPackageJson) {
123
+ if (Object.prototype.hasOwnProperty.call(restPackageJson, key) && !Object.prototype.hasOwnProperty.call(newPackageJson, key)) {
124
+ newPackageJson[key] = restPackageJson[key];
123
125
  }
124
126
  }
125
127
  await Bun.write(meta.packageJson.path, JSON.stringify(newPackageJson, null, 2));
@@ -175,8 +177,31 @@ function removeExtension(filePath) {
175
177
  const directory = path.dirname(filePath);
176
178
  return directory === "." ? nameWithoutExtensions : path.join(directory, nameWithoutExtensions);
177
179
  }
178
-
179
- // src/plugins/built-in/css/inject-styles.ts
180
+ // src/plugins/copy.ts
181
+ import { join } from "path";
182
+ import { basename } from "path";
183
+ function copy(patterns, outPath) {
184
+ return {
185
+ type: "bunup",
186
+ name: "copy",
187
+ hooks: {
188
+ onBuildDone: async ({ options, meta }) => {
189
+ const destinationPath = outPath || options.outDir;
190
+ for (const pattern of patterns) {
191
+ const glob = new Bun.Glob(pattern);
192
+ for await (const filePath of glob.scan({
193
+ cwd: meta.rootDir,
194
+ dot: true
195
+ })) {
196
+ const sourceFile = Bun.file(join(meta.rootDir, filePath));
197
+ await Bun.write(outPath && isDirectoryPath(outPath) ? join(destinationPath, basename(filePath)) : destinationPath, sourceFile);
198
+ }
199
+ }
200
+ }
201
+ }
202
+ };
203
+ }
204
+ // src/plugins/inject-styles.ts
180
205
  import path2 from "path";
181
206
 
182
207
  // src/plugins/utils.ts
@@ -219,7 +244,7 @@ async function getPackageForPlugin(name, pluginName) {
219
244
  return pkg;
220
245
  }
221
246
 
222
- // src/plugins/built-in/css/inject-styles.ts
247
+ // src/plugins/inject-styles.ts
223
248
  function injectStyles(options) {
224
249
  const { inject, ...transformOptions } = options ?? {};
225
250
  return {
@@ -277,32 +302,6 @@ function injectStyles(options) {
277
302
  }
278
303
  };
279
304
  }
280
-
281
- // src/plugins/built-in/productivity/copy.ts
282
- import { join } from "path";
283
- import { basename } from "path";
284
- function copy(patterns, outPath) {
285
- return {
286
- type: "bunup",
287
- name: "copy",
288
- hooks: {
289
- onBuildDone: async ({ options, meta }) => {
290
- const destinationPath = outPath || options.outDir;
291
- for (const pattern of patterns) {
292
- const glob = new Bun.Glob(pattern);
293
- for await (const filePath of glob.scan({
294
- cwd: meta.rootDir,
295
- dot: true
296
- })) {
297
- const sourceFile = Bun.file(join(meta.rootDir, filePath));
298
- await Bun.write(outPath && isDirectoryPath(outPath) ? join(destinationPath, basename(filePath)) : destinationPath, sourceFile);
299
- }
300
- }
301
- }
302
- }
303
- };
304
- }
305
-
306
305
  // src/plugins/internal/report.ts
307
306
  import pc2 from "picocolors";
308
307
  function report() {
@@ -358,4 +357,11 @@ function report() {
358
357
  }
359
358
  };
360
359
  }
361
- export { shims, exports, filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, injectStyles, copy, report };
360
+ export {
361
+ shims,
362
+ report,
363
+ injectStyles,
364
+ exports,
365
+ copy
366
+ };
367
+ export { filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, report };
package/package.json CHANGED
@@ -1,102 +1,93 @@
1
1
  {
2
- "name": "bunup",
3
- "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
- "version": "0.8.39",
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
- }
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
+ }
package/dist/plugins.js DELETED
@@ -1,16 +0,0 @@
1
- // @bun
2
- import {
3
- copy,
4
- exports,
5
- injectStyles,
6
- report,
7
- shims
8
- } from "./chunk-vpe2amgs.js";
9
- import"./chunk-c1eyecm3.js";
10
- export {
11
- shims,
12
- report,
13
- injectStyles,
14
- exports,
15
- copy
16
- };