bun-dev-server 0.9.3 → 0.9.5
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/README.md +29 -22
- package/dist/bunServeConfig.d.ts +2 -2
- package/dist/index.js +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Bun Dev Server
|
|
2
2
|
A a dev server like Webpack dev server but only with bun, uses internal server available from [Bun.serve()](https://bun.sh/docs/api/http#bun-serve)
|
|
3
3
|
|
|
4
|
+
Available at [NPM Repository](https://www.npmjs.com/package/bun-dev-server)
|
|
5
|
+
|
|
6
|
+
#### Bun
|
|
7
|
+
`bun i bun-dev-server`
|
|
8
|
+
#### Npm
|
|
9
|
+
`npm i bun-dev-server`
|
|
10
|
+
|
|
4
11
|
## Example config
|
|
5
12
|
```ts
|
|
6
13
|
//devserver.ts
|
|
@@ -44,26 +51,26 @@ bun run devserver.ts
|
|
|
44
51
|
Options that are available for configuration
|
|
45
52
|
| **Option** | **Required** | **Default** | **Description** |
|
|
46
53
|
|------------------------|--------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
47
|
-
| port | true | N/A
|
|
48
|
-
| buildConfig | true | N/A
|
|
49
|
-
| watchDir | true | N/A
|
|
50
|
-
| watchDelay
|
|
51
|
-
| enableTSC
|
|
52
|
-
| tscConfigPath
|
|
53
|
-
| writeManifest
|
|
54
|
-
| manifestName
|
|
55
|
-
| manifestWithHash
|
|
56
|
-
| hotReload
|
|
57
|
-
| reloadOnChange
|
|
58
|
-
| logRequests
|
|
59
|
-
| servePath
|
|
60
|
-
| cleanServePath
|
|
61
|
-
| serveOutputEjs
|
|
62
|
-
| serveIndexHtmlEjs | false | Built-in template
|
|
63
|
-
|
|
|
64
|
-
| beforeBuild
|
|
65
|
-
| afterBuild
|
|
66
|
-
| tls
|
|
67
|
-
| websocketPath | false | `/hmr-ws`
|
|
68
|
-
| static
|
|
54
|
+
| port | true | N/A | The port to run the server on. |
|
|
55
|
+
| buildConfig | true | N/A | The build configuration to use for the server. |
|
|
56
|
+
| watchDir | true | N/A | The directory to watch for changes. |
|
|
57
|
+
| watchDelay | false | 1000 | The delay in milliseconds to wait before starting <br> a new build once a file has changed.<br> Used in debounce function, in case many changes <br>happen in file system at once. |
|
|
58
|
+
| enableTSC | false | false | Whether to enable TypeScript checking <br>it will use `tscConfigPath` in your project directory. |
|
|
59
|
+
| tscConfigPath | false | `./tsconfig.json` | The path to the TypeScript configuration file. |
|
|
60
|
+
| writeManifest | false | false | Whether to write the manifest file. |
|
|
61
|
+
| manifestName | false | `bun_server_manifest.json`| The name of the manifest file. |
|
|
62
|
+
| manifestWithHash| false | false | Whether to include the hash with the entrypoints in the manifest file. |
|
|
63
|
+
| hotReload | false | none | Where to place hot reload script. Available values: "plugin" | "footer" | "none" |
|
|
64
|
+
| reloadOnChange | false | false | Whether to reload the page when a file changes. <br> This requires property `hotReload` to be set<br> to `"plugin"` or `"footer"`. |
|
|
65
|
+
| logRequests | false | false | Whether to log HTTP requests to the console. |
|
|
66
|
+
| servePath | false | `outdir` in build config or `./dist` | The path to the directory to serve files from.<br> Takes precedence over `buildConfig.outdir`. |
|
|
67
|
+
| cleanServePath | false | false | Whether to clean the `servePath` before building a new batch. |
|
|
68
|
+
| serveOutputEjs | false | Built-in template | The EJS template used for <br> the output of the `/` path on the server. <br> When supplying your own template,<br> the properties that are provided during rendering <br>are `files` and `dirs` both are arrays. |
|
|
69
|
+
| serveIndexHtmlEjs | false | Built-in template | he EJS template used for the output of the `/index.html` path on the server. <br> When supplying your own template, <br>the property that is provided during rendering <br>is `hashedImports` that is an array of strings. |
|
|
70
|
+
| createIndexHTML | false | true | Whether to create index.html using `serveIndexHtmlEjs` template. |
|
|
71
|
+
| beforeBuild | false | undefined | Event listener to execute before Bun builds |
|
|
72
|
+
| afterBuild | false | undefined | Event listener to execute after Bun builds |
|
|
73
|
+
| tls | false | undefined | Secure options for the server. Forwards buns `TLSOptions` |
|
|
74
|
+
| websocketPath | false | `/hmr-ws` | The websocket path to use for the server. |
|
|
75
|
+
| static | false | undefined | Static bun responses, can be used for things like `/favicon.ico` etc. |
|
|
69
76
|
|
package/dist/bunServeConfig.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export interface BunDevServerConfig extends Partial<BunServeConfig> {
|
|
|
92
92
|
* Whether to create index.html using `serveIndexHtmlEjs` template.
|
|
93
93
|
* @default true.
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
createIndexHTML?: boolean;
|
|
96
96
|
/**
|
|
97
97
|
* Event listener to execute before Bun builds
|
|
98
98
|
* @param env Supplied environment for the build
|
|
@@ -119,5 +119,5 @@ export interface BunServeConfig {
|
|
|
119
119
|
/**
|
|
120
120
|
* Static bun responses
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
routes?: Record<`/${string}`, Response>;
|
|
123
123
|
}
|
package/dist/index.js
CHANGED
|
@@ -1139,7 +1139,7 @@ async function startBunDevServer(serverConfig, importMeta) {
|
|
|
1139
1139
|
websocketPath: DEFAULT_HMR_PATH,
|
|
1140
1140
|
serveOutputEjs: serveOutputTemplate_default,
|
|
1141
1141
|
serveIndexHtmlEjs: indexHTMLTemplate_default,
|
|
1142
|
-
|
|
1142
|
+
createIndexHTML: true,
|
|
1143
1143
|
tscConfigPath: resolve(importMeta.dir, "./tsconfig.json")
|
|
1144
1144
|
};
|
|
1145
1145
|
const finalConfig = { ...defaultConfig, ...serverConfig };
|
|
@@ -1195,9 +1195,9 @@ async function startBunDevServer(serverConfig, importMeta) {
|
|
|
1195
1195
|
port: finalConfig.port,
|
|
1196
1196
|
development: true,
|
|
1197
1197
|
tls: finalConfig.tls,
|
|
1198
|
-
|
|
1198
|
+
routes: {
|
|
1199
1199
|
"/favicon.ico": withCORSHeaders(new Response("", { status: 404 })),
|
|
1200
|
-
...finalConfig.
|
|
1200
|
+
...finalConfig.routes
|
|
1201
1201
|
},
|
|
1202
1202
|
async fetch(req, server) {
|
|
1203
1203
|
if (req.method === "OPTIONS") {
|
|
@@ -1245,7 +1245,7 @@ var debouncedbuildAndNotify = import_debounce.default(async (importerMeta, final
|
|
|
1245
1245
|
try {
|
|
1246
1246
|
const output = await Bun.build(buildCfg);
|
|
1247
1247
|
publishOutputLogs(bunServer, output, event);
|
|
1248
|
-
if (finalConfig.
|
|
1248
|
+
if (finalConfig.createIndexHTML) {
|
|
1249
1249
|
publishIndexHTML(destinationPath, finalConfig.serveIndexHtmlEjs, output, event);
|
|
1250
1250
|
}
|
|
1251
1251
|
if (finalConfig.writeManifest) {
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
-
"version": "0.9.
|
|
27
|
+
"version": "0.9.5",
|
|
28
28
|
"module": "index.ts",
|
|
29
29
|
"type": "module",
|
|
30
30
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build": "bun run ./build.ts"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/bun": "^1.2.
|
|
35
|
+
"@types/bun": "^1.2.4"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"typescript": "^5.7.3"
|