bun-dev-server 0.1.0 → 0.2.0

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/bunManifest.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { type BuildOutput, write, pathToFileURL } from "bun";
2
- export function writeManifest(output: BuildOutput, outdir: string, manifestName = "manifest.txt") {
2
+ export function writeManifest(output: BuildOutput, outdir: string, withHash = false, manifestName = "bunmanifest.txt") {
3
3
  const entryPoints = output.outputs.filter(o => o.kind === "entry-point");
4
- const epTable = [];
4
+ const epTable: string[] = [];
5
5
  for (const ep of entryPoints) {
6
6
  const basePathUrl = pathToFileURL(outdir);
7
7
  const epUrl = pathToFileURL(ep.path);
8
8
  const relativePath = epUrl.href.replace(`${basePathUrl.href}/`, "");
9
- const nameNoJs = relativePath.replace(".js", "");
10
- const hashedImport = `${relativePath}?${ep.hash}`;
11
- epTable.push({ name: nameNoJs, path: hashedImport });
12
- }
13
- const outObj = {};
14
- for (const element of epTable) {
15
- Object.assign(outObj, { [element.name]: { js: [`${element.path}`] } });
9
+ // const nameNoJs = relativePath.replace(".js", "");
10
+ const hashedImport = `${relativePath}${withHash ? `?${ep.hash}` : ``}`;
11
+ epTable.push(hashedImport);
16
12
  }
13
+ const outObj = { js: epTable };
14
+ // for (const element of epTable) {
15
+ // Object.assign(outObj, { [element.name]: { js: [`${element.path}`] } });
16
+ // }
17
17
  write(`${outdir}/${manifestName}`, JSON.stringify(outObj));
18
18
  }
package/bunServeConfig.ts CHANGED
@@ -7,6 +7,7 @@ export interface BunDevServerConfig extends Partial<BunDevServerSocketConfig> {
7
7
  enableTypeScriptWatch?: boolean;
8
8
  writeManifest?: boolean;
9
9
  manifestName?: string;
10
+ manifestWithHash?: boolean;
10
11
  reloadOnChange?: boolean;
11
12
  /**
12
13
  * The path to the directory to serve files from.
package/index.ts CHANGED
@@ -151,7 +151,7 @@ export async function startBunDevServer(serverConfig: BunDevServerConfig) {
151
151
  publishOutputLogs(output, { filename: "Initial", eventType: "change" });
152
152
  publishIndexHTML(output, { filename: "Initial", eventType: "change" });
153
153
  if (finalConfig.writeManifest) {
154
- writeManifest(output, dst, finalConfig.manifestName);
154
+ writeManifest(output, dst, finalConfig.manifestWithHash, finalConfig.manifestName);
155
155
  }
156
156
  // $`tsc --watch`.then((tsc) => {
157
157
  // console.log("ASDASD");
@@ -173,7 +173,7 @@ export async function startBunDevServer(serverConfig: BunDevServerConfig) {
173
173
  publishOutputLogs(output, event);
174
174
  publishIndexHTML(output, event);
175
175
  if (finalConfig.writeManifest) {
176
- writeManifest(output, dst, finalConfig.manifestName);
176
+ writeManifest(output, dst, finalConfig.manifestWithHash, finalConfig.manifestName);
177
177
  }
178
178
  if (finalConfig.reloadOnChange) {
179
179
  bunServer.publish("message", JSON.stringify({ type: "reload" }));
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "type": "git",
7
7
  "url": "https://github.com/SPWizard01/bun-dev-server"
8
8
  },
9
- "version": "0.1.0",
9
+ "version": "0.2.0",
10
10
  "module": "index.ts",
11
11
  "type": "module",
12
12
  "license": "MIT",