bun-dev-server 0.7.0 → 0.7.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.
@@ -25,6 +25,11 @@ export interface BunDevServerConfig extends Partial<BunServeConfig> {
25
25
  cleanServePath?: boolean;
26
26
  serveOutputEjs?: string;
27
27
  serveOutputHtml?: string;
28
+ /**
29
+ * Using EJS Index HTML template.
30
+ * Defaults to true.
31
+ */
32
+ createDefaultIndexHTML?: boolean;
28
33
  }
29
34
  export interface BunServeConfig {
30
35
  port: number;
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  return to;
17
17
  };
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __require = import.meta.require;
19
20
 
20
21
  // node_modules/ejs/lib/utils.js
21
22
  var require_utils = __commonJS((exports) => {
@@ -197,8 +198,8 @@ var require_package = __commonJS((exports, module) => {
197
198
 
198
199
  // node_modules/ejs/lib/ejs.js
199
200
  var require_ejs = __commonJS((exports) => {
200
- var fs = import.meta.require("fs");
201
- var path = import.meta.require("path");
201
+ var fs = __require("fs");
202
+ var path = __require("path");
202
203
  var utils = require_utils();
203
204
  var scopeOptionWarned = false;
204
205
  var _VERSION_STRING = require_package().version;
@@ -1138,7 +1139,8 @@ async function startBunDevServer(serverConfig) {
1138
1139
  port: 3000,
1139
1140
  websocketPath: DEFAULT_HMR_PATH,
1140
1141
  serveOutputEjs: serveOutputTemplate_default,
1141
- serveOutputHtml: indexHTMLTemplate_default
1142
+ serveOutputHtml: indexHTMLTemplate_default,
1143
+ createDefaultIndexHTML: true
1142
1144
  };
1143
1145
  const finalConfig = { ...defaultConfig, ...serverConfig };
1144
1146
  if (finalConfig.watchDelay) {
@@ -1204,9 +1206,6 @@ async function startBunDevServer(serverConfig) {
1204
1206
  }
1205
1207
  const url = new URL(req.url);
1206
1208
  let requestPath = url.pathname;
1207
- if (requestPath.toLowerCase() === "/index.html") {
1208
- requestPath = "/";
1209
- }
1210
1209
  return handlePathRequest(requestPath, req, finalConfig, destinationPath);
1211
1210
  },
1212
1211
  websocket: {
@@ -1230,7 +1229,9 @@ var debouncedbuildAndNotify = import_debounce.default(async (finalConfig, destin
1230
1229
  }
1231
1230
  const output = await Bun.build(buildCfg);
1232
1231
  publishOutputLogs(bunServer, output, event);
1233
- publishIndexHTML(destinationPath, finalConfig.serveOutputHtml, output, event);
1232
+ if (finalConfig.createDefaultIndexHTML) {
1233
+ publishIndexHTML(destinationPath, finalConfig.serveOutputHtml, output, event);
1234
+ }
1234
1235
  if (finalConfig.writeManifest) {
1235
1236
  writeManifest(output, destinationPath, finalConfig.manifestWithHash, finalConfig.manifestName);
1236
1237
  }
@@ -1299,7 +1300,7 @@ function convertBytes(bytes) {
1299
1300
  return (bytes / Math.pow(1024, i)).toFixed(1) + " " + sizes[i];
1300
1301
  }
1301
1302
  async function handlePathRequest(requestPath, req, finalConfig, destinationPath) {
1302
- const fsPath = destinationPath + requestPath;
1303
+ let fsPath = destinationPath + requestPath;
1303
1304
  const objThere = await checkObjectExists(fsPath, req);
1304
1305
  let isDirectory = false;
1305
1306
  if (objThere) {
@@ -1313,8 +1314,13 @@ async function handlePathRequest(requestPath, req, finalConfig, destinationPath)
1313
1314
  }
1314
1315
  }
1315
1316
  } else {
1316
- finalConfig.logRequests && console.log(`${404} ${req.url}`);
1317
- return withCORSHeaders(new Response("", { status: 404 }), req);
1317
+ if (requestPath.toLowerCase() !== "/index.html") {
1318
+ finalConfig.logRequests && console.log(`${404} ${req.url}`);
1319
+ return withCORSHeaders(new Response("", { status: 404 }), req);
1320
+ }
1321
+ requestPath = "/";
1322
+ isDirectory = true;
1323
+ fsPath = destinationPath + requestPath;
1318
1324
  }
1319
1325
  if (!isDirectory) {
1320
1326
  try {
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "exports": {
22
22
  ".": "./dist/index.js"
23
23
  },
24
- "version": "0.7.0",
24
+ "version": "0.7.1",
25
25
  "module": "index.ts",
26
26
  "type": "module",
27
27
  "license": "MIT",