bunup 0.16.16 → 0.16.18

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
  processLoadedConfigs,
6
6
  resolveBuildOptions
7
- } from "../shared/bunup-kmfn2mv3.js";
7
+ } from "../shared/bunup-4m73cpyq.js";
8
8
  import {
9
9
  BunupBuildError,
10
10
  BunupCLIError,
@@ -21,13 +21,13 @@ import {
21
21
  logTime,
22
22
  logger,
23
23
  parseErrorMessage
24
- } from "../shared/bunup-qb65sm3k.js";
24
+ } from "../shared/bunup-rmbrx2hr.js";
25
25
 
26
26
  // packages/bunup/src/cli/index.ts
27
27
  import { loadConfig } from "coffi";
28
28
  import pc4 from "picocolors";
29
29
  // packages/bunup/package.json
30
- var version = "0.16.16";
30
+ var version = "0.16.18";
31
31
 
32
32
  // packages/bunup/src/printer/print-build-report.ts
33
33
  import { promisify } from "util";
@@ -343,7 +343,7 @@ async function main(args = Bun.argv.slice(2)) {
343
343
  });
344
344
  }
345
345
  logger.info("Build started");
346
- const startTime = performance.now();
346
+ let buildTimeMs = 0;
347
347
  for (const { options, rootDir } of configsToProcess) {
348
348
  const optionsArray = ensureArray(options);
349
349
  for await (const o of optionsArray) {
@@ -354,14 +354,15 @@ async function main(args = Bun.argv.slice(2)) {
354
354
  if (userOptions.watch) {
355
355
  await watch(userOptions, rootDir, filepath);
356
356
  } else {
357
+ const startTime = performance.now();
357
358
  const result = await build(userOptions, rootDir);
359
+ buildTimeMs += performance.now() - startTime;
358
360
  if (!cliOptions.watch && !shouldSilent) {
359
361
  await printBuildReport(result);
360
362
  }
361
363
  }
362
364
  }
363
365
  }
364
- const buildTimeMs = performance.now() - startTime;
365
366
  if (cliOptions.watch) {
366
367
  console.log(`
367
368
  ${pc4.bgMagentaBright(" WATCH ")} Watching for file changes...
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./shared/bunup-kmfn2mv3.js";
5
- import"./shared/bunup-qb65sm3k.js";
4
+ } from "./shared/bunup-4m73cpyq.js";
5
+ import"./shared/bunup-rmbrx2hr.js";
6
6
  // packages/bunup/src/define.ts
7
7
  function defineConfig(options) {
8
8
  return options;
package/dist/plugins.js CHANGED
@@ -7,10 +7,11 @@ import {
7
7
  logger,
8
8
  shims,
9
9
  unused
10
- } from "./shared/bunup-qb65sm3k.js";
10
+ } from "./shared/bunup-rmbrx2hr.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
- import { basename, extname, join } from "path";
13
+ import fs from "fs";
14
+ import { basename, isAbsolute, join } from "path";
14
15
  function copy(pattern) {
15
16
  return new CopyBuilder(pattern);
16
17
  }
@@ -80,7 +81,7 @@ class CopyBuilder {
80
81
  }
81
82
  this._fileCache.set(sourcePath, lastModified);
82
83
  }
83
- const finalDestinationPath = resolveDestinationPath(destinationPath, scannedPath, meta.rootDir);
84
+ const finalDestinationPath = resolveDestinationPath(destinationPath, sourcePath, meta.rootDir);
84
85
  const shouldOverride = this._options?.override ?? true;
85
86
  if (!shouldOverride) {
86
87
  const destinationExists = await Bun.file(finalDestinationPath).exists();
@@ -127,7 +128,7 @@ class CopyBuilder {
127
128
  }
128
129
  }
129
130
  function resolveDestinationPath(destinationPath, scannedPath, rootDir) {
130
- const fullDestinationPath = join(rootDir, destinationPath);
131
+ const fullDestinationPath = isAbsolute(destinationPath) ? destinationPath : join(rootDir, destinationPath);
131
132
  const isScannedPathDir = isDirectoryPath(scannedPath);
132
133
  const isDestinationDir = isDirectoryPath(fullDestinationPath);
133
134
  if (isDestinationDir && !isScannedPathDir) {
@@ -136,7 +137,12 @@ function resolveDestinationPath(destinationPath, scannedPath, rootDir) {
136
137
  return fullDestinationPath;
137
138
  }
138
139
  function isDirectoryPath(filePath) {
139
- return extname(filePath) === "";
140
+ try {
141
+ const stats = fs.statSync(filePath);
142
+ return stats.isDirectory();
143
+ } catch {
144
+ return false;
145
+ }
140
146
  }
141
147
  async function copyDirectory(sourcePath, finalDestinationPath) {
142
148
  await Bun.$`cp -r ${sourcePath} ${finalDestinationPath}`;
@@ -19,7 +19,7 @@ import {
19
19
  parseErrorMessage,
20
20
  shims,
21
21
  unused
22
- } from "./bunup-qb65sm3k.js";
22
+ } from "./bunup-rmbrx2hr.js";
23
23
 
24
24
  // packages/bunup/src/loaders.ts
25
25
  import path from "path";
@@ -62,13 +62,13 @@ async function loadPackageJson(cwd = process.cwd()) {
62
62
  }
63
63
 
64
64
  // packages/bunup/src/build.ts
65
- import path3 from "path";
65
+ import path4 from "path";
66
66
  import { generateDts, logIsolatedDeclarationErrors } from "@bunup/dts";
67
67
  import pc2 from "picocolors";
68
68
 
69
69
  // packages/bunup/src/ensure-bun-version.ts
70
70
  import pc from "picocolors";
71
- var MINIMUM_BUN_VERSION = "1.0.11";
71
+ var MINIMUM_BUN_VERSION = "1.3.6";
72
72
  function ensureBunVersion(requiredVersion, feature) {
73
73
  const currentVersion = Bun.version;
74
74
  const satisfiesRequirement = Bun.semver.satisfies(currentVersion, `>=${requiredVersion}`);
@@ -390,6 +390,13 @@ async function runPluginBuildDoneHooks(bunupPlugins, ctx) {
390
390
  }
391
391
  }
392
392
 
393
+ // packages/bunup/src/utils/bun.ts
394
+ import path3 from "path";
395
+ function getOriginalEntrypointFromOutputPath(metafile, outputPath, rootDir) {
396
+ const entryPoint = metafile?.outputs[outputPath]?.entryPoint;
397
+ return path3.relative(rootDir, entryPoint);
398
+ }
399
+
393
400
  // packages/bunup/src/utils/extension.ts
394
401
  function getDefaultJsOutputExtension(format, packageType) {
395
402
  switch (format) {
@@ -461,13 +468,6 @@ async function build(userOptions, rootDir = process.cwd()) {
461
468
  }
462
469
  throw new BunupBuildError(formatInvalidEntryPointsError(entryArray));
463
470
  }
464
- console.log("");
465
- console.log(`${options.name ? ` ${pc2.bgBlueBright(` ${options.name} `)} ` : " "}${logger.formatMessage({
466
- message: formatListWithAnd(entrypoints),
467
- muted: true,
468
- noIcon: true
469
- })}`);
470
- console.log("");
471
471
  const buildOutputFiles = [];
472
472
  const absoluteEntrypoints = entrypoints.map((file) => `${rootDir}/${file}`);
473
473
  const resolvedDefine = getResolvedDefine(options.define, options.env);
@@ -495,17 +495,18 @@ async function build(userOptions, rootDir = process.cwd()) {
495
495
  banner: options.banner,
496
496
  footer: options.footer,
497
497
  publicPath: options.publicPath,
498
- root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
498
+ root: options.sourceBase ? path4.resolve(rootDir, options.sourceBase) : undefined,
499
499
  env: resolvedEnv,
500
500
  ignoreDCEAnnotations: options.ignoreDCEAnnotations,
501
501
  emitDCEAnnotations: options.emitDCEAnnotations,
502
502
  packages: options.packages,
503
503
  jsx: options.jsx,
504
504
  compile: options.compile,
505
- outdir: options.compile ? path3.resolve(rootDir, options.outDir) : undefined,
505
+ outdir: options.compile ? path4.resolve(rootDir, options.outDir) : undefined,
506
506
  throw: false,
507
507
  plugins: bunPlugins,
508
- tsconfig: options.preferredTsconfig ? path3.resolve(rootDir, options.preferredTsconfig) : undefined
508
+ tsconfig: options.preferredTsconfig ? path4.resolve(rootDir, options.preferredTsconfig) : undefined,
509
+ metafile: true
509
510
  });
510
511
  for (const log of result.logs) {
511
512
  if (log.level === "error") {
@@ -518,13 +519,12 @@ async function build(userOptions, rootDir = process.cwd()) {
518
519
  else if (log.level === "info")
519
520
  logger.info(log.message);
520
521
  }
521
- let entrypointIndex = 0;
522
522
  for (const file of result.outputs) {
523
523
  if (options.compile) {
524
524
  const fullPath2 = file.path;
525
- const pathRelativeToRootDir2 = path3.relative(rootDir, fullPath2);
526
- const absoluteOutDir = path3.resolve(rootDir, options.outDir);
527
- const pathRelativeToOutdir2 = path3.relative(absoluteOutDir, fullPath2);
525
+ const pathRelativeToRootDir2 = path4.relative(rootDir, fullPath2);
526
+ const absoluteOutDir = path4.resolve(rootDir, options.outDir);
527
+ const pathRelativeToOutdir2 = path4.relative(absoluteOutDir, fullPath2);
528
528
  buildOutputFiles.push({
529
529
  fullPath: fullPath2,
530
530
  pathRelativeToRootDir: pathRelativeToRootDir2,
@@ -539,8 +539,8 @@ async function build(userOptions, rootDir = process.cwd()) {
539
539
  }
540
540
  const content = await file.text();
541
541
  const pathRelativeToOutdir = cleanPath(isJavascriptFile(file.path) && file.kind === "entry-point" ? replaceExtension(file.path, getDefaultJsOutputExtension(fmt, packageType)) : file.path);
542
- const pathRelativeToRootDir = path3.join(options.outDir, pathRelativeToOutdir);
543
- const fullPath = path3.resolve(rootDir, pathRelativeToRootDir);
542
+ const pathRelativeToRootDir = path4.join(options.outDir, pathRelativeToOutdir);
543
+ const fullPath = path4.resolve(rootDir, pathRelativeToRootDir);
544
544
  await Bun.write(fullPath, content);
545
545
  if (!buildOutputFiles.some((f) => f.fullPath === fullPath)) {
546
546
  buildOutputFiles.push({
@@ -550,12 +550,9 @@ async function build(userOptions, rootDir = process.cwd()) {
550
550
  dts: false,
551
551
  format: fmt,
552
552
  kind: file.kind,
553
- entrypoint: file.kind === "entry-point" ? cleanPath(entrypoints[entrypointIndex] ?? "") : undefined,
553
+ entrypoint: file.kind === "entry-point" ? getOriginalEntrypointFromOutputPath(result.metafile, file.path, rootDir) : undefined,
554
554
  size: file.size
555
555
  });
556
- if (file.kind === "entry-point") {
557
- entrypointIndex++;
558
- }
559
556
  }
560
557
  }
561
558
  });
@@ -570,7 +567,7 @@ async function build(userOptions, rootDir = process.cwd()) {
570
567
  naming: {
571
568
  chunk: getDefaultChunkNaming(options.name)
572
569
  },
573
- root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
570
+ root: options.sourceBase ? path4.resolve(rootDir, options.sourceBase) : undefined,
574
571
  ...dtsOptions
575
572
  });
576
573
  if (dtsResult.errors.length && !logger.isSilent()) {
@@ -581,7 +578,7 @@ async function build(userOptions, rootDir = process.cwd()) {
581
578
  const dtsExtension = getDefaultDtsOutputExtention(fmt, packageType, file.kind);
582
579
  const pathRelativeToOutdir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
583
580
  const pathRelativeToRootDir = cleanPath(`${options.outDir}/${pathRelativeToOutdir}`);
584
- const fullPath = path3.join(rootDir, pathRelativeToRootDir);
581
+ const fullPath = path4.join(rootDir, pathRelativeToRootDir);
585
582
  await Bun.write(fullPath, file.dts);
586
583
  buildOutputFiles.push({
587
584
  fullPath,
@@ -590,7 +587,7 @@ async function build(userOptions, rootDir = process.cwd()) {
590
587
  dts: true,
591
588
  format: fmt,
592
589
  kind: file.kind,
593
- entrypoint: file.entrypoint ? cleanPath(file.entrypoint) : undefined,
590
+ entrypoint: file.entrypoint,
594
591
  size: file.dts.length
595
592
  });
596
593
  }
@@ -620,6 +617,13 @@ async function build(userOptions, rootDir = process.cwd()) {
620
617
  if (options.onSuccess) {
621
618
  await executeOnSuccess(options.onSuccess, options, ac.signal);
622
619
  }
620
+ logger.log("");
621
+ logger.log(`${options.name ? ` ${pc2.bgBlueBright(` ${options.name} `)} ` : " "}${logger.formatMessage({
622
+ message: formatListWithAnd(entrypoints),
623
+ muted: true,
624
+ noIcon: true
625
+ })}`);
626
+ console.log("");
623
627
  return buildResult;
624
628
  }
625
629
 
@@ -644,7 +644,7 @@ function mergeCustomExportsWithGenerated(baseExports, customExportsProvider, ctx
644
644
  return mergedExports;
645
645
  }
646
646
  function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
647
- const { main, module, types, ...restPackageJson } = originalData;
647
+ const { main: _, module: __, types: ___, ...restPackageJson } = originalData;
648
648
  const newPackageJson = {
649
649
  ...Object.fromEntries(Object.entries({
650
650
  name: originalData.name,
@@ -652,7 +652,7 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
652
652
  version: originalData.version,
653
653
  type: originalData.type,
654
654
  private: originalData.private
655
- }).filter(([_, value]) => value !== undefined)),
655
+ }).filter(([_2, value]) => value !== undefined)),
656
656
  files,
657
657
  ...entryPoints,
658
658
  exports: exports2
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.16.16",
4
+ "version": "0.16.18",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -24,12 +24,12 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "license": "MIT",
27
- "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
27
+ "author": "Arshad Yaseen <arshadpyaseen@gmail.com> (https://arshad.fyi)",
28
28
  "maintainers": [
29
29
  {
30
30
  "name": "Arshad Yaseen",
31
- "email": "m@arshadyaseen.com",
32
- "url": "https://arshadyaseen.com"
31
+ "email": "arshadpyaseen@gmail.com",
32
+ "url": "https://arshad.fyi"
33
33
  }
34
34
  ],
35
35
  "repository": {
@@ -50,8 +50,8 @@
50
50
  "type-check": "tsc --noEmit"
51
51
  },
52
52
  "dependencies": {
53
- "@bunup/dts": "^0.14.46",
54
- "@bunup/shared": "0.16.12",
53
+ "@bunup/dts": "^0.14.47",
54
+ "@bunup/shared": "0.16.17",
55
55
  "chokidar": "^5.0.0",
56
56
  "coffi": "^0.1.37",
57
57
  "lightningcss": "^1.30.2",
@@ -69,6 +69,6 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@types/bun": "^1.3.5"
72
+ "@types/bun": "^1.3.6"
73
73
  }
74
74
  }