bun-dev-server 0.9.0 → 0.9.1

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,4 +1,13 @@
1
- import { type BuildConfig, type TLSOptions } from "bun";
1
+ import { type BuildConfig, type TLSOptions, type Server, type BuildOutput } from "bun";
2
+ import type { FileChangeInfo } from "fs/promises";
3
+ export interface BuildEnv {
4
+ importerMeta: ImportMeta;
5
+ finalConfig: BunDevServerConfig;
6
+ destinationPath: string;
7
+ buildCfg: BuildConfig;
8
+ bunServer: Server;
9
+ event: FileChangeInfo<any>;
10
+ }
2
11
  export interface BunDevServerConfig extends Partial<BunServeConfig> {
3
12
  port: number;
4
13
  buildConfig: BuildConfig;
@@ -35,6 +44,8 @@ export interface BunDevServerConfig extends Partial<BunServeConfig> {
35
44
  * Defaults to true.
36
45
  */
37
46
  createDefaultIndexHTML?: boolean;
47
+ beforeBuild?: (env: BuildEnv) => void;
48
+ afterBuild?: (outpug: BuildOutput, env: BuildEnv) => void;
38
49
  }
39
50
  export interface BunServeConfig {
40
51
  port: number;
package/dist/index.js CHANGED
@@ -1098,7 +1098,7 @@ function getBunHMRFooter(config) {
1098
1098
 
1099
1099
  // src/bunManifest.ts
1100
1100
  var {write, pathToFileURL } = globalThis.Bun;
1101
- function writeManifest(output, outdir, withHash = false, manifestName = "bunmanifest.txt") {
1101
+ function writeManifest(output, outdir, withHash = false, manifestName = "bun_server_manifest.json") {
1102
1102
  const entryPoints = output.outputs.filter((o) => o.kind === "entry-point");
1103
1103
  const epTable = [];
1104
1104
  for (const ep of entryPoints) {
@@ -1234,6 +1234,15 @@ var debouncedbuildAndNotify = import_debounce.default(async (importerMeta, final
1234
1234
  if (finalConfig.cleanServePath) {
1235
1235
  await cleanDirectory(destinationPath);
1236
1236
  }
1237
+ const buildEnv = {
1238
+ importerMeta,
1239
+ finalConfig,
1240
+ destinationPath,
1241
+ buildCfg,
1242
+ bunServer,
1243
+ event
1244
+ };
1245
+ finalConfig.beforeBuild?.(buildEnv);
1237
1246
  const output = await Bun.build(buildCfg);
1238
1247
  publishOutputLogs(bunServer, output, event);
1239
1248
  if (finalConfig.createDefaultIndexHTML) {
@@ -1242,6 +1251,7 @@ var debouncedbuildAndNotify = import_debounce.default(async (importerMeta, final
1242
1251
  if (finalConfig.writeManifest) {
1243
1252
  writeManifest(output, destinationPath, finalConfig.manifestWithHash, finalConfig.manifestName);
1244
1253
  }
1254
+ finalConfig.afterBuild?.(output, buildEnv);
1245
1255
  const tscSuccess = await performTSC(finalConfig, importerMeta);
1246
1256
  if (finalConfig.reloadOnChange && tscSuccess) {
1247
1257
  bunServer.publish("message", JSON.stringify({ type: "reload" }));
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "exports": {
22
22
  ".": "./dist/index.js"
23
23
  },
24
- "version": "0.9.0",
24
+ "version": "0.9.1",
25
25
  "module": "index.ts",
26
26
  "type": "module",
27
27
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "build": "bun run ./build.ts"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/bun": "latest"
32
+ "@types/bun": "^1.2.2"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "typescript": "^5.7.3"