bunup 0.11.13 → 0.11.16

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/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  build,
5
5
  createBuildOptions,
6
6
  processLoadedConfigs
7
- } from "../shared/bunup-rvdh0cgz.js";
7
+ } from "../shared/bunup-6vfygtwp.js";
8
8
  import {
9
9
  BunupCLIError,
10
10
  BunupWatchError,
@@ -18,15 +18,15 @@ import {
18
18
  logger,
19
19
  parseErrorMessage,
20
20
  setSilent
21
- } from "../shared/bunup-knmb0tyv.js";
21
+ } from "../shared/bunup-jber4h9a.js";
22
22
 
23
- // src/cli/index.ts
23
+ // packages/bunup/src/cli/index.ts
24
24
  import { loadConfig } from "coffi";
25
25
  import pc3 from "picocolors";
26
- // package.json
27
- var version = "0.11.13";
26
+ // packages/bunup/package.json
27
+ var version = "0.11.16";
28
28
 
29
- // src/watch.ts
29
+ // packages/bunup/src/watch.ts
30
30
  import path from "path";
31
31
  import pc from "picocolors";
32
32
  async function watch(partialOptions, rootDir) {
@@ -79,13 +79,13 @@ async function watch(partialOptions, rootDir) {
79
79
  await triggerRebuild(true);
80
80
  }
81
81
 
82
- // src/cli/options.ts
82
+ // packages/bunup/src/cli/options.ts
83
83
  import pc2 from "picocolors";
84
84
 
85
- // src/constants/index.ts
85
+ // packages/bunup/src/constants/index.ts
86
86
  var BUNUP_DOCS_URL = "https://bunup.dev/docs";
87
87
 
88
- // src/cli/options.ts
88
+ // packages/bunup/src/cli/options.ts
89
89
  var createHandlers = () => ({
90
90
  boolean: (key) => (value, options) => {
91
91
  options[key] = value === true || value === "true";
@@ -285,14 +285,6 @@ var OPTION_DEFINITIONS = {
285
285
  type: "string",
286
286
  category: "development"
287
287
  },
288
- bytecode: {
289
- flags: ["bc", "bytecode"],
290
- handler: handlers.boolean("bytecode"),
291
- description: "Generate bytecode for the output (CJS only)",
292
- type: "boolean",
293
- default: "false",
294
- category: "output"
295
- },
296
288
  silent: {
297
289
  flags: ["silent"],
298
290
  handler: handlers.boolean("silent"),
@@ -475,7 +467,7 @@ var parseCliOptions = (argv) => {
475
467
  return options;
476
468
  };
477
469
 
478
- // src/cli/index.ts
470
+ // packages/bunup/src/cli/index.ts
479
471
  async function main(args = Bun.argv.slice(2)) {
480
472
  const cliOptions = parseCliOptions(args);
481
473
  setSilent(cliOptions.silent);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, WithOptional } from "./shared/bunup-2hbptr8j";
1
+ import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-7rvhqvrm";
2
2
  declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
3
3
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
4
4
  declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: Partial<DefineConfigItem>): DefineWorkspaceItem[];
5
- export { defineWorkspace, defineConfig, build, Plugin, DefineWorkspaceItem, DefineConfigItem, BuildOptions };
5
+ export { defineWorkspace, defineConfig, build, DefineWorkspaceItem, DefineConfigItem, BunupPlugin, BuildOutputFile, BuildOutput, BuildOptions, BuildMeta, BuildContext };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./shared/bunup-rvdh0cgz.js";
5
- import"./shared/bunup-knmb0tyv.js";
6
- // src/define.ts
4
+ } from "./shared/bunup-6vfygtwp.js";
5
+ import"./shared/bunup-jber4h9a.js";
6
+ // packages/bunup/src/define.ts
7
7
  function defineConfig(options) {
8
8
  return options;
9
9
  }
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./shared/bunup-2hbptr8j";
1
+ import { BuildContext, BunupPlugin, MaybePromise } from "./shared/bunup-7rvhqvrm";
2
2
  /**
3
3
  * A plugin that copies files and directories to the output directory.
4
4
  *
@@ -22,6 +22,12 @@ interface ExportsPluginOptions {
22
22
  * @see https://bunup.dev/docs/plugins/exports#exclude
23
23
  */
24
24
  exclude?: Exclude;
25
+ /**
26
+ * Whether to exclude CSS files from being added to the exports field
27
+ *
28
+ * @default false
29
+ */
30
+ excludeCss?: boolean;
25
31
  }
26
32
  /**
27
33
  * A plugin that generates the exports field in the package.json file automatically.
@@ -29,6 +35,7 @@ interface ExportsPluginOptions {
29
35
  * @see https://bunup.dev/docs/plugins/exports
30
36
  */
31
37
  declare function exports(options?: ExportsPluginOptions): BunupPlugin;
38
+ import { BunPlugin } from "bun";
32
39
  type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "targets" | "nonStandard" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
33
40
  inject?: (css: string, filePath: string) => MaybePromise<string>
34
41
  /** Whether to minify the CSS.
@@ -41,13 +48,14 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
41
48
  *
42
49
  * @see https://bunup.dev/docs/plugins/inject-styles
43
50
  */
44
- declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
51
+ declare function injectStyles(options?: InjectStylesPluginOptions): BunPlugin;
52
+ import { BunPlugin as BunPlugin2 } from "bun";
45
53
  /**
46
54
  * A plugin that provides shims for Node.js globals and ESM/CJS interoperability.
47
55
  *
48
56
  * @see https://bunup.dev/docs/plugins/shims
49
57
  */
50
- declare function shims(): Plugin;
58
+ declare function shims(): BunPlugin2;
51
59
  interface UnusedOptions {
52
60
  /**
53
61
  * The level of reporting for unused dependencies
@@ -65,5 +73,5 @@ interface UnusedOptions {
65
73
  *
66
74
  * @see https://bunup.dev/docs/plugins/unused
67
75
  */
68
- declare function unused(options?: UnusedOptions): Plugin;
76
+ declare function unused(options?: UnusedOptions): BunupPlugin;
69
77
  export { unused, shims, injectStyles, exports, copy };
package/dist/plugins.js CHANGED
@@ -9,9 +9,9 @@ import {
9
9
  getPackageForPlugin,
10
10
  isDirectoryPath,
11
11
  logger
12
- } from "./shared/bunup-knmb0tyv.js";
12
+ } from "./shared/bunup-jber4h9a.js";
13
13
 
14
- // src/plugins/built-in/copy.ts
14
+ // packages/bunup/src/plugins/built-in/copy.ts
15
15
  import { basename, join } from "path";
16
16
  function copy(pattern, outPath) {
17
17
  return {
@@ -34,7 +34,7 @@ function copy(pattern, outPath) {
34
34
  }
35
35
  };
36
36
  }
37
- // src/plugins/built-in/exports.ts
37
+ // packages/bunup/src/plugins/built-in/exports.ts
38
38
  import path from "path";
39
39
  function exports(options = {}) {
40
40
  return {
@@ -53,7 +53,7 @@ async function processPackageJsonExports(ctx, options) {
53
53
  return;
54
54
  }
55
55
  try {
56
- const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, ctx);
56
+ const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCss, ctx);
57
57
  const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
58
58
  const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
59
59
  const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, mergedExports, updatedFiles);
@@ -65,18 +65,26 @@ async function processPackageJsonExports(ctx, options) {
65
65
  logger.error("Failed to update package.json");
66
66
  }
67
67
  }
68
- function generateExportsFields(files, exclude, ctx) {
68
+ function generateExportsFields(files, exclude, excludeCss, ctx) {
69
69
  const filteredFiles = filterFiles(files, exclude, ctx);
70
- const { filesByExportKey, allDtsFiles } = groupFilesByExportKey(filteredFiles);
70
+ const { filesByExportKey, allDtsFiles, cssFiles } = groupFilesByExportKey(filteredFiles);
71
71
  const exportsField = createExportEntries(filesByExportKey);
72
+ if (!excludeCss) {
73
+ addCssToExports(exportsField, cssFiles);
74
+ }
72
75
  const entryPoints = extractEntryPoints(exportsField, allDtsFiles);
73
76
  return { exportsField, entryPoints };
74
77
  }
75
78
  function groupFilesByExportKey(files) {
76
79
  const filesByExportKey = new Map;
77
80
  const allDtsFiles = new Map;
81
+ const cssFiles = [];
78
82
  for (const file of files) {
79
83
  const exportKey = getExportKey(cleanPath(file.pathRelativeToOutdir));
84
+ if (CSS_RE.test(file.fullPath)) {
85
+ cssFiles.push(file);
86
+ continue;
87
+ }
80
88
  const format = file.format === "esm" ? "import" : "require";
81
89
  if (!filesByExportKey.has(exportKey)) {
82
90
  filesByExportKey.set(exportKey, new Map);
@@ -99,7 +107,7 @@ function groupFilesByExportKey(files) {
99
107
  }
100
108
  }
101
109
  }
102
- return { filesByExportKey, allDtsFiles };
110
+ return { filesByExportKey, allDtsFiles, cssFiles };
103
111
  }
104
112
  function createExportEntries(filesByExportKey) {
105
113
  const exportsField = {};
@@ -136,7 +144,7 @@ function createExportEntries(filesByExportKey) {
136
144
  function extractEntryPoints(exportsField, allDtsFiles) {
137
145
  const entryPoints = {};
138
146
  const dotExport = exportsField["."];
139
- if (!dotExport) {
147
+ if (!dotExport || typeof dotExport === "string") {
140
148
  return entryPoints;
141
149
  }
142
150
  for (const [field, value] of Object.entries(dotExport)) {
@@ -226,13 +234,18 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
226
234
  return newPackageJson;
227
235
  }
228
236
  function filterFiles(files, exclude, ctx) {
229
- return files.filter((file) => JS_DTS_RE.test(file.fullPath) && file.kind === "entry-point" && file.entrypoint && (file.format === "esm" || file.format === "cjs") && !isExcluded(file.entrypoint, exclude, ctx));
237
+ return files.filter((file) => (JS_DTS_RE.test(file.fullPath) || CSS_RE.test(file.fullPath)) && (file.kind === "entry-point" || file.kind === "asset") && (file.format === "esm" || file.format === "cjs" || CSS_RE.test(file.fullPath)) && (!file.entrypoint || !isExcluded(file.entrypoint, exclude, ctx)));
230
238
  }
239
+ var DEFAULT_CLI_EXCLUSIONS = [
240
+ "cli.ts",
241
+ "cli/index.ts",
242
+ "src/cli.ts",
243
+ "src/cli/index.ts"
244
+ ];
231
245
  function isExcluded(entrypoint, exclude, ctx) {
232
- if (!exclude)
233
- return false;
234
- const patterns = typeof exclude === "function" ? exclude(ctx) : exclude;
235
- return patterns?.some((pattern) => new Bun.Glob(pattern).match(entrypoint)) ?? false;
246
+ const userPatterns = typeof exclude === "function" ? exclude(ctx) : exclude;
247
+ const allPatterns = [...DEFAULT_CLI_EXCLUSIONS, ...userPatterns ?? []];
248
+ return allPatterns.some((pattern) => new Bun.Glob(pattern).match(entrypoint));
236
249
  }
237
250
  function getExportKey(pathRelativeToOutdir) {
238
251
  const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
@@ -251,6 +264,27 @@ function removeExtension(filePath) {
251
264
  const directory = path.dirname(filePath);
252
265
  return directory === "." ? nameWithoutExtensions : path.join(directory, nameWithoutExtensions);
253
266
  }
267
+ function addCssToExports(exportsField, cssFiles) {
268
+ if (cssFiles.length === 0)
269
+ return;
270
+ for (const cssFile of cssFiles) {
271
+ const exportKey = getCssExportKey(cleanPath(cssFile.pathRelativeToOutdir));
272
+ exportsField[exportKey] = `./${cleanPath(cssFile.pathRelativeToRootDir)}`;
273
+ }
274
+ }
275
+ function getCssExportKey(pathRelativeToOutdir) {
276
+ const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
277
+ const fileName = pathSegments[pathSegments.length - 1];
278
+ if (fileName === "index") {
279
+ if (pathSegments.length === 1) {
280
+ return "./styles.css";
281
+ } else {
282
+ return `./${pathSegments.slice(0, -1).join("/")}.css`;
283
+ }
284
+ } else {
285
+ return `./${pathSegments.join("/")}.css`;
286
+ }
287
+ }
254
288
  function exportFieldToEntryPoint(exportField) {
255
289
  switch (exportField) {
256
290
  case "types":
@@ -261,26 +295,23 @@ function exportFieldToEntryPoint(exportField) {
261
295
  return "module";
262
296
  }
263
297
  }
264
- // src/plugins/built-in/inject-styles.ts
298
+ // packages/bunup/src/plugins/built-in/inject-styles.ts
265
299
  import path2 from "path";
266
300
  function injectStyles(options) {
267
301
  const { inject, ...transformOptions } = options ?? {};
268
302
  return {
269
- type: "bun",
270
- name: "inject-styles",
271
- plugin: {
272
- name: "bunup:inject-styles",
273
- async setup(build) {
274
- const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
275
- build.onResolve({ filter: /^__inject-style$/ }, () => {
276
- return {
277
- path: "__inject-style",
278
- namespace: "__inject-style"
279
- };
280
- });
281
- build.onLoad({ filter: /^__inject-style$/, namespace: "__inject-style" }, () => {
282
- return {
283
- contents: `
303
+ name: "bunup:inject-styles",
304
+ async setup(build) {
305
+ const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
306
+ build.onResolve({ filter: /^__inject-style$/ }, () => {
307
+ return {
308
+ path: "__inject-style",
309
+ namespace: "__inject-style"
310
+ };
311
+ });
312
+ build.onLoad({ filter: /^__inject-style$/, namespace: "__inject-style" }, () => {
313
+ return {
314
+ contents: `
284
315
  export default function injectStyle(css) {
285
316
  if (!css || typeof document === 'undefined') return
286
317
 
@@ -295,86 +326,81 @@ function injectStyles(options) {
295
326
  }
296
327
  }
297
328
  `,
298
- loader: "js"
299
- };
300
- });
301
- build.onLoad({ filter: CSS_RE }, async (args) => {
302
- const source = await Bun.file(args.path).text();
303
- const { code, warnings } = lightningcss.transform({
304
- ...transformOptions,
305
- filename: path2.basename(args.path),
306
- code: Buffer.from(source),
307
- minify: transformOptions.minify ?? true
308
- });
309
- for (const warning of warnings) {
310
- logger.warn(warning.message);
311
- }
312
- const stringifiedCode = JSON.stringify(code.toString());
313
- const js = inject ? await inject(stringifiedCode, args.path) : `import injectStyle from '__inject-style';injectStyle(${stringifiedCode})`;
314
- return {
315
- contents: js,
316
- loader: "js"
317
- };
329
+ loader: "js"
330
+ };
331
+ });
332
+ build.onLoad({ filter: CSS_RE }, async (args) => {
333
+ const source = await Bun.file(args.path).text();
334
+ const { code, warnings } = lightningcss.transform({
335
+ ...transformOptions,
336
+ filename: path2.basename(args.path),
337
+ code: Buffer.from(source),
338
+ minify: transformOptions.minify ?? true
318
339
  });
319
- }
340
+ for (const warning of warnings) {
341
+ logger.warn(warning.message);
342
+ }
343
+ const stringifiedCode = JSON.stringify(code.toString());
344
+ const js = inject ? await inject(stringifiedCode, args.path) : `import injectStyle from '__inject-style';injectStyle(${stringifiedCode})`;
345
+ return {
346
+ contents: js,
347
+ loader: "js"
348
+ };
349
+ });
320
350
  }
321
351
  };
322
352
  }
323
- // src/plugins/built-in/shims.ts
353
+ // packages/bunup/src/plugins/built-in/shims.ts
324
354
  function shims() {
325
355
  return {
326
- type: "bun",
327
- name: "shims",
328
- plugin: {
329
- name: "bunup:shims",
330
- setup(build) {
331
- const isNodeCompatibleTarget = build.config.target === "node" || build.config.target === "bun";
332
- const isEsm = build.config.format === "esm";
333
- const isCjs = build.config.format === "cjs";
334
- if (!isNodeCompatibleTarget || !isEsm && !isCjs) {
335
- return;
356
+ name: "bunup:shims",
357
+ setup(build) {
358
+ const isNodeCompatibleTarget = build.config.target === "node" || build.config.target === "bun";
359
+ const isEsm = build.config.format === "esm";
360
+ const isCjs = build.config.format === "cjs";
361
+ if (!isNodeCompatibleTarget || !isEsm && !isCjs) {
362
+ return;
363
+ }
364
+ build.config.define = {
365
+ ...build.config.define,
366
+ ...isCjs && {
367
+ "import.meta.url": "importMetaUrl"
336
368
  }
337
- build.config.define = {
338
- ...build.config.define,
339
- ...isCjs && {
340
- "import.meta.url": "importMetaUrl"
341
- }
342
- };
343
- build.onLoad({ filter: JS_TS_RE }, async ({ path: path3 }) => {
344
- const content = await Bun.file(path3).text();
345
- let shimCode = "";
346
- if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
347
- shimCode = `import { fileURLToPath } from 'url';
369
+ };
370
+ build.onLoad({ filter: JS_TS_RE }, async ({ path: path3 }) => {
371
+ const content = await Bun.file(path3).text();
372
+ let shimCode = "";
373
+ if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
374
+ shimCode = `import { fileURLToPath } from 'url';
348
375
  import { dirname } from 'path';
349
376
 
350
377
  const __filename = fileURLToPath(import.meta.url);
351
378
  const __dirname = dirname(__filename);
352
379
 
353
380
  `;
354
- }
355
- if (isCjs && /\bimport\.meta\.url\b/.test(content)) {
356
- shimCode = `import { pathToFileURL } from 'url';
381
+ }
382
+ if (isCjs && /\bimport\.meta\.url\b/.test(content)) {
383
+ shimCode = `import { pathToFileURL } from 'url';
357
384
 
358
385
  const importMetaUrl = pathToFileURL(__filename).href;
359
386
 
360
387
  `;
361
- }
362
- if (!shimCode)
363
- return;
364
- const lines = content.split(`
388
+ }
389
+ if (!shimCode)
390
+ return;
391
+ const lines = content.split(`
365
392
  `);
366
- const firstLine = lines[0];
367
- const restLines = lines.slice(1);
368
- return {
369
- contents: [firstLine, shimCode, ...restLines].join(`
393
+ const firstLine = lines[0];
394
+ const restLines = lines.slice(1);
395
+ return {
396
+ contents: [firstLine, shimCode, ...restLines].join(`
370
397
  `)
371
- };
372
- });
373
- }
398
+ };
399
+ });
374
400
  }
375
401
  };
376
402
  }
377
- // src/plugins/built-in/unused.ts
403
+ // packages/bunup/src/plugins/built-in/unused.ts
378
404
  import pc from "picocolors";
379
405
  function unused(options = {}) {
380
406
  const { level = "warn", ignore = [] } = options;
@@ -422,7 +448,7 @@ function unused(options = {}) {
422
448
  const removeCommand = pc.cyan(`bun remove ${unusedDependencies.join(" ")}`);
423
449
  const message = [
424
450
  `
425
- Your project has ${count} unused ${depText}: ${coloredDeps}.`,
451
+ Your project${buildOptions.name ? ` ${buildOptions.name}` : ""} has ${count} unused ${depText}: ${coloredDeps}.`,
426
452
  `You can remove ${count === 1 ? "it" : "them"} with ${removeCommand}`
427
453
  ].join(" ");
428
454
  if (level === "error") {
@@ -4,7 +4,7 @@ import {
4
4
  cleanOutDir,
5
5
  cleanPath,
6
6
  ensureArray,
7
- filterBunupBunPlugins,
7
+ filterBunPlugins,
8
8
  filterBunupPlugins,
9
9
  formatFileSize,
10
10
  getDefaultDtsOutputExtention,
@@ -22,9 +22,9 @@ import {
22
22
  runPluginBuildStartHooks,
23
23
  setSilent,
24
24
  silent
25
- } from "./bunup-knmb0tyv.js";
25
+ } from "./bunup-jber4h9a.js";
26
26
 
27
- // src/loaders.ts
27
+ // packages/bunup/src/loaders.ts
28
28
  import path from "path";
29
29
  import { loadConfig } from "coffi";
30
30
  async function processLoadedConfigs(config, cwd, filter) {
@@ -53,12 +53,12 @@ async function loadPackageJson(cwd = process.cwd()) {
53
53
  };
54
54
  }
55
55
 
56
- // src/build.ts
56
+ // packages/bunup/src/build.ts
57
57
  import path2 from "path";
58
+ import { generateDts, logIsolatedDeclarationErrors } from "@bunup/dts";
58
59
  import pc2 from "picocolors";
59
- import { generateDts, logIsolatedDeclarationErrors } from "typeroll";
60
60
 
61
- // src/helpers/on-success.ts
61
+ // packages/bunup/src/helpers/on-success.ts
62
62
  import { exec } from "tinyexec";
63
63
  import treeKill from "tree-kill";
64
64
  async function executeOnSuccess(onSuccess, options, signal) {
@@ -97,7 +97,7 @@ async function executeOnSuccess(onSuccess, options, signal) {
97
97
  }
98
98
  }
99
99
 
100
- // src/plugins/internal/report.ts
100
+ // packages/bunup/src/plugins/internal/report.ts
101
101
  import pc from "picocolors";
102
102
  function report() {
103
103
  return {
@@ -157,7 +157,7 @@ function report() {
157
157
  };
158
158
  }
159
159
 
160
- // src/plugins/internal/use-client.ts
160
+ // packages/bunup/src/plugins/internal/use-client.ts
161
161
  function useClient() {
162
162
  return {
163
163
  type: "bunup",
@@ -180,7 +180,7 @@ ${text}`;
180
180
  };
181
181
  }
182
182
 
183
- // src/options.ts
183
+ // packages/bunup/src/options.ts
184
184
  var DEFAULT_OPTIONS = {
185
185
  entry: "src/index.ts",
186
186
  format: "esm",
@@ -207,9 +207,6 @@ function getResolvedMinify(options) {
207
207
  syntax: minifySyntax ?? defaultValue
208
208
  };
209
209
  }
210
- function getResolvedBytecode(bytecode, format) {
211
- return format === "cjs" ? bytecode : undefined;
212
- }
213
210
  function getResolvedSourcemap(sourcemap) {
214
211
  if (sourcemap === true) {
215
212
  return "inline";
@@ -240,7 +237,7 @@ function getResolvedEnv(env) {
240
237
  return typeof env === "string" ? env : undefined;
241
238
  }
242
239
 
243
- // src/helpers/external.ts
240
+ // packages/bunup/src/helpers/external.ts
244
241
  function getPackageDepsPatterns(packageJson) {
245
242
  return getPackageDeps(packageJson).map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`));
246
243
  }
@@ -254,7 +251,7 @@ function isExternal(path2, options, packageJson) {
254
251
  return matchesExternalPattern && !isExcludedFromExternal;
255
252
  }
256
253
 
257
- // src/plugins/internal/external-option.ts
254
+ // packages/bunup/src/plugins/internal/external-option.ts
258
255
  function externalOptionPlugin(options, packageJson) {
259
256
  return {
260
257
  name: "bunup:external-option-plugin",
@@ -273,7 +270,7 @@ function externalOptionPlugin(options, packageJson) {
273
270
  };
274
271
  }
275
272
 
276
- // src/build.ts
273
+ // packages/bunup/src/build.ts
277
274
  var ac = null;
278
275
  async function build(partialOptions, rootDir = process.cwd()) {
279
276
  if (ac) {
@@ -304,7 +301,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
304
301
  const packageType = packageJson.data?.type;
305
302
  const plugins = [
306
303
  externalOptionPlugin(options, packageJson.data),
307
- ...filterBunupBunPlugins(options.plugins).map((p) => p.plugin)
304
+ ...filterBunPlugins(options.plugins)
308
305
  ];
309
306
  const entrypoints = await getFilesFromGlobs(ensureArray(options.entry), rootDir);
310
307
  if (!entrypoints.length) {
@@ -315,7 +312,6 @@ async function build(partialOptions, rootDir = process.cwd()) {
315
312
  entrypoints: entrypoints.map((file) => `${rootDir}/${file}`),
316
313
  format: fmt,
317
314
  splitting: getResolvedSplitting(options.splitting, fmt),
318
- bytecode: getResolvedBytecode(options.bytecode, fmt),
319
315
  define: getResolvedDefine(options.define, options.env),
320
316
  minify: getResolvedMinify(options),
321
317
  target: options.target,
@@ -1,4 +1,4 @@
1
- import { GenerateDtsOptions } from "typeroll";
1
+ import { GenerateDtsOptions } from "@bunup/dts";
2
2
  import { BunPlugin } from "bun";
3
3
  type PackageJson = {
4
4
  /** The parsed content of the package.json file */
@@ -7,17 +7,6 @@ type PackageJson = {
7
7
  path: string | null
8
8
  };
9
9
  /**
10
- * Represents a Bun plugin that can be used with Bunup
11
- */
12
- type BunupBunPlugin = {
13
- /** Identifies this as a native Bun plugin */
14
- type: "bun"
15
- /** Optional name for the plugin */
16
- name?: string
17
- /** The actual Bun plugin implementation */
18
- plugin: BunPlugin
19
- };
20
- /**
21
10
  * Represents the meta data of the build
22
11
  */
23
12
  type BuildMeta = {
@@ -35,7 +24,7 @@ type BuildOutputFile = {
35
24
  entrypoint: string | undefined
36
25
  /** The kind of the file */
37
26
  kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
38
- /** Path to the generated file */
27
+ /** Absolute path to the generated file */
39
28
  fullPath: string
40
29
  /** Path to the generated file relative to the root directory */
41
30
  pathRelativeToRootDir: string
@@ -44,7 +33,7 @@ type BuildOutputFile = {
44
33
  /** Whether the file is a dts file */
45
34
  dts: boolean
46
35
  /** The format of the output file */
47
- format: Format | Format[]
36
+ format: Format
48
37
  };
49
38
  /**
50
39
  * Represents the output of a build operation
@@ -90,10 +79,6 @@ type BunupPlugin = {
90
79
  /** The hooks implemented by this plugin */
91
80
  hooks: BunupPluginHooks
92
81
  };
93
- /**
94
- * Union type representing all supported plugin types
95
- */
96
- type Plugin = BunupBunPlugin | BunupPlugin;
97
82
  type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
98
83
  type Define = Record<string, string>;
99
84
  type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
@@ -333,18 +318,6 @@ interface BuildOptions {
333
318
  */
334
319
  loader?: { [k in string] : Loader };
335
320
  /**
336
- * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
337
- *
338
- * Bytecode is currently only supported for CommonJS (format: "cjs").
339
- *
340
- * Must be target: "bun"
341
- *
342
- * @see https://bun.sh/docs/bundler#bytecode
343
- *
344
- * @default false
345
- */
346
- bytecode?: boolean;
347
- /**
348
321
  * Disable logging during the build process. When set to true, no logs will be printed to the console.
349
322
  *
350
323
  * @default false
@@ -435,7 +408,7 @@ interface BuildOptions {
435
408
  * }
436
409
  * ]
437
410
  */
438
- plugins?: Plugin[];
411
+ plugins?: (BunupPlugin | BunPlugin)[];
439
412
  }
440
413
  type MaybePromise<T> = Promise<T> | T;
441
414
  type WithOptional<
@@ -449,4 +422,4 @@ type DefineWorkspaceItem = {
449
422
  root: string
450
423
  config: DefineConfigItem | DefineConfigItem[]
451
424
  };
452
- export { MaybePromise, WithOptional, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin, Plugin, BuildOptions };
425
+ export { MaybePromise, WithOptional, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildMeta, BuildOutputFile, BuildOutput, BuildContext, BunupPlugin, BuildOptions };
@@ -16,7 +16,7 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  };
17
17
  var __require = import.meta.require;
18
18
 
19
- // src/logger.ts
19
+ // packages/bunup/src/logger.ts
20
20
  import pc from "picocolors";
21
21
  var silent = false;
22
22
  function setSilent(value) {
@@ -174,7 +174,7 @@ var link = (url, label) => {
174
174
  };
175
175
  var logger = Logger.getInstance();
176
176
 
177
- // src/errors.ts
177
+ // packages/bunup/src/errors.ts
178
178
  import pc2 from "picocolors";
179
179
  class BunupError extends Error {
180
180
  constructor(message) {
@@ -302,11 +302,11 @@ var handleErrorAndExit = (error, context) => {
302
302
  process.exit(1);
303
303
  };
304
304
 
305
- // src/utils.ts
305
+ // packages/bunup/src/utils.ts
306
306
  import fs from "fs/promises";
307
307
  import path, { normalize } from "path";
308
308
 
309
- // src/constants/re.ts
309
+ // packages/bunup/src/constants/re.ts
310
310
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
311
311
  var TS_RE = /\.(ts|tsx|mts|cts)$/;
312
312
  var DTS_RE = /\.(d\.(ts|mts|cts))$/;
@@ -314,7 +314,7 @@ var JS_TS_RE = new RegExp(`${JS_RE.source}|${TS_RE.source}`);
314
314
  var JS_DTS_RE = new RegExp(`${JS_RE.source}|${DTS_RE.source}`);
315
315
  var CSS_RE = /\.(css)$/;
316
316
 
317
- // src/utils.ts
317
+ // packages/bunup/src/utils.ts
318
318
  function ensureArray(value) {
319
319
  return Array.isArray(value) ? value : [value];
320
320
  }
@@ -436,17 +436,17 @@ function replaceExtension(filePath, newExtension) {
436
436
  return directory + nameWithoutExtension + normalizedExtension;
437
437
  }
438
438
 
439
- // src/plugins/utils.ts
439
+ // packages/bunup/src/plugins/utils.ts
440
440
  import pc3 from "picocolors";
441
- function filterBunupBunPlugins(plugins) {
441
+ function filterBunPlugins(plugins) {
442
442
  if (!plugins)
443
443
  return [];
444
- return plugins.filter((p) => p.type === "bun");
444
+ return plugins.filter((p) => ("setup" in p));
445
445
  }
446
446
  function filterBunupPlugins(plugins) {
447
447
  if (!plugins)
448
448
  return [];
449
- return plugins.filter((p) => p.type === "bunup");
449
+ return plugins.filter((p) => ("hooks" in p));
450
450
  }
451
451
  async function runPluginBuildStartHooks(bunupPlugins, options) {
452
452
  if (!bunupPlugins)
@@ -476,4 +476,4 @@ async function getPackageForPlugin(name, pluginName) {
476
476
  return pkg;
477
477
  }
478
478
 
479
- export { __toESM, __require, silent, setSilent, logTable, logTime, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultJsOutputExtension, getDefaultDtsOutputExtention, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, isJavascriptFile, replaceExtension, filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
479
+ export { __toESM, __require, silent, setSilent, logTable, logTime, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultJsOutputExtension, getDefaultDtsOutputExtention, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, isJavascriptFile, replaceExtension, filterBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunup",
3
3
  "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
- "version": "0.11.13",
4
+ "version": "0.11.16",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -51,15 +51,7 @@
51
51
  "picocolors": "^1.1.1",
52
52
  "tinyexec": "^1.0.1",
53
53
  "tree-kill": "^1.2.2",
54
- "typeroll": "^0.7.5"
55
- },
56
- "devDependencies": {
57
- "@biomejs/biome": "2.2.0",
58
- "@types/bun": "^1.2.20",
59
- "bumpp": "^10.2.3",
60
- "lightningcss": "^1.30.1",
61
- "simple-git-hooks": "^2.13.1",
62
- "typescript": "^5.9.2"
54
+ "@bunup/dts": "workspace:*"
63
55
  },
64
56
  "peerDependencies": {
65
57
  "typescript": ">=4.5.0",
@@ -73,27 +65,7 @@
73
65
  "optional": true
74
66
  }
75
67
  },
76
- "scripts": {
77
- "build": "bun run src/cli/index.ts",
78
- "build:docs": "bun run --cwd docs build",
79
- "dev": "bun run src/cli/index.ts --watch",
80
- "dev:docs": "bun run --cwd docs dev",
81
- "format": "biome format .",
82
- "format:fix": "biome format --write .",
83
- "lint": "biome check .",
84
- "lint:fix": "biome check --write .",
85
- "test": "bun test",
86
- "tsc": "tsc --noEmit",
87
- "publish:ci": "npm i -g npm@latest && npm publish",
88
- "release": "bumpp -r --commit --push --tag",
89
- "prepare": "simple-git-hooks"
90
- },
91
- "simple-git-hooks": {
92
- "pre-commit": "bun run lint:fix && git add ."
93
- },
94
- "workspaces": [
95
- "docs",
96
- "tests",
97
- "examples/**"
98
- ]
68
+ "devDependencies": {
69
+ "@types/bun": "^1.2.21"
70
+ }
99
71
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024-present Arshad Yaseen
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,46 +0,0 @@
1
- <!-- markdownlint-disable first-line-h1 -->
2
-
3
- <!-- markdownlint-start-capture -->
4
- <!-- markdownlint-disable-file no-inline-html -->
5
- <div align="center">
6
-
7
- <!-- markdownlint-disable-next-line no-alt-text -->
8
-
9
-
10
- ![Logo](https://raw.githubusercontent.com/bunup/bunup/refs/heads/main/docs/public/logo.svg)
11
-
12
- ![Bunup](https://raw.githubusercontent.com/bunup/bunup/refs/heads/main/assets/bunup-title.svg)
13
-
14
- [![NPM Version](https://img.shields.io/npm/v/bunup?logo=npm&logoColor=212121&label=version&labelColor=ffc44e&color=212121)](https://npmjs.com/package/bunup) [![Built with Bun](https://img.shields.io/badge/Built_with-Bun-fbf0df?logo=bun&labelColor=212121)](https://bun.sh) [![sponsor](https://img.shields.io/badge/sponsor-EA4AAA?logo=githubsponsors&labelColor=FAFAFA)](https://github.com/sponsors/arshad-yaseen)
15
-
16
- Bunup is the **blazing-fast build tool** for TypeScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
17
-
18
- </div>
19
- <!-- markdownlint-restore -->
20
-
21
- ## Features
22
-
23
- - ⚡ **Instant Builds**: Instant builds and rebuilds by default.
24
- - 📝 **Top-Notch TypeScript Declarations**: Clean, minimal, accurate `.d.ts` files generated automatically.
25
- - 📦 **ESM by Default**: Modern ESM output by default.
26
- - 🪓 **[Declaration Splitting](https://bunup.dev/docs/guide/typescript-declarations#declaration-splitting)**: Splits shared types for smaller, cleaner `.d.ts` files.
27
- - 🔥 **[Declaration Minification](https://bunup.dev/docs/guide/typescript-declarations#minification)**: Aggressively minifies and shortens type names while preserving public API.
28
- - 🔋 **Batteries Included**: Auto-generates package exports, detects unused dependencies, and more.
29
- - 🏗️ **[Workspace](https://bunup.dev/docs/guide/workspaces) Ready**: Builds multiple packages from one config and command.
30
-
31
- ## 📚 Documentation
32
-
33
- To get started, visit the [documentation](https://bunup.dev).
34
-
35
- ## ❤️ Contributing
36
-
37
- For guidelines on contributing, please read the [contributing guide](CONTRIBUTING.md).
38
-
39
- We welcome contributions from the community to enhance Bunup's capabilities and make it even more powerful.
40
-
41
- ![Sponsors](https://cdn.jsdelivr.net/gh/arshad-yaseen/static/sponsors.svg)
42
-
43
- <div align="center">
44
-
45
- ![______ 🐈‍⬛ _____________](assets/cat-footer.svg)
46
- </div>