http-server-rs 0.0.36 → 0.0.38

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 CHANGED
@@ -33,7 +33,9 @@ npx http-server-rs --help # Uses the override
33
33
 
34
34
  ### Manual Install
35
35
 
36
- Download the latest binary from [GitHub Releases](https://github.com/alshdavid-public/http-server-rs/releases/latest) and add it to your `PATH`
36
+ Download the latest binary from [GitHub Releases](https://github.com/alshdavid-public/http-server-rs/releases/latest) and add it to your `PATH`.
37
+
38
+ Update with `http-server-rs update`
37
39
 
38
40
  ```bash
39
41
  # Linux AMD64 (Change for your platform)
@@ -48,26 +50,41 @@ echo "\nexport \PATH=\$PATH:\$HOME/.local/bin\n" >> $HOME/.bashrc
48
50
 
49
51
  ```bash
50
52
  # Use default configuration
51
- http-server-rs
53
+ http-server-rs serve
52
54
 
53
55
  # Enable CORS, reroute requests to index.html and automatically compress served files
54
- http-server-rs --cors --spa -Z ./public
56
+ http-server-rs serve --cors --spa -Z ./public
55
57
 
56
58
  # Responds with headers required for SharedArrayBuffer
57
- http-server-rs --shared-array-buffer ./public
59
+ http-server-rs serve --shared-array-buffer ./public
58
60
 
59
61
  # Automatically transpiles TypeScript to JavaScript on request
60
- http-server-rs --transpile ./public
62
+ http-server-rs serve --transpile ./public
61
63
 
62
64
  # Proxy /api to an external backend (quotes are required)
63
- http-server-rs --proxy "path=/api&target=http://localhost:3000" ./public
65
+ http-server-rs serve --proxy "path=/api&target=http://localhost:3000" ./public
64
66
 
65
67
  # Custom Headers
66
- http-server-rs -H X-Custom-Header:some-value
68
+ http-server-rs serve -H X-Custom-Header:some-value
69
+
70
+ # Update the binary to the latest release
71
+ http-server-rs update
72
+ ```
73
+
74
+ ```
75
+ Usage: http-server-rs <COMMAND>
76
+
77
+ Commands:
78
+ serve Serve a target directory over HTTP
79
+ update Update the binary to the latest release
80
+ help Print this message or the help of the given subcommand(s)
81
+
82
+ Options:
83
+ -h, --help Print help
67
84
  ```
68
85
 
69
86
  ```
70
- Usage: http-server-rs [OPTIONS] [SERVE_DIR]
87
+ Usage: http-server-rs serve [OPTIONS] [SERVE_DIR]
71
88
 
72
89
  Arguments:
73
90
  [SERVE_DIR] Target directory to serve [default: .]
@@ -105,8 +122,6 @@ Options:
105
122
  Debounce delay in milliseconds before watched changes trigger a reload [default: 200]
106
123
  --no-watch-inject
107
124
  Don't automatically inject watch listener into html
108
- --upgrade
109
- Upgrade the binary to the latest release
110
125
  --skip-upgrade-check
111
126
  Skip checking for a newer release on startup
112
127
  --stream-buffer-size <STREAM_BUFFER_SIZE>
@@ -122,25 +137,35 @@ Options:
122
137
  Will live transpile TypeScript to JavaScript on request. This allows serving TypeScript sources
123
138
  directly to the browser without a build step.
124
139
 
140
+ This is designed to simplify local development for bundler-less configurations. Use native ESM imports built into your browser and create your project without a build step.
141
+
125
142
  ```bash
126
- http-server-rs --transpile --port 8080 ./testing/transpile/react
143
+ http-server-rs serve --transpile --port 8080 ./testing/transpile/react
127
144
 
128
145
  # Returns transpiled JavaScript that runs directly in the browser
129
146
  curl http://localhost:8080/app.tsx
130
147
  ```
131
148
 
149
+ https://github.com/user-attachments/assets/3d1bc313-e898-42bb-8c8f-a8023c41ec35
150
+
151
+ Notes;
152
+ - Use builtin `import` syntax and get npm packages from a CDN like [esm.sh](https://esm.sh/#tsx)
153
+ - Use [importmap](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to map ESM imports to Node.js resolution patterns
154
+ - `npm install` is only required for types. Unfortunately this requires full package installation until the TypeScript team [comes to a decision on remote declaration file](https://github.com/microsoft/TypeScript/issues/28985)
155
+ - For performance sensitive applications, you'll still probably want to use a bundler for production - but who know, this might be good enough for most use cases
156
+
132
157
  ## Watch Mode
133
158
 
134
159
  `http-server` under `--watch` mode can watch the served directory for changes and emit an event to the client notifying of a change. By default the server will intercept html files and inject a JavaScript script which subscribes to change events and triggers a page reload.
135
160
 
136
161
  ```bash
137
- http-server --watch ./dist
162
+ http-server-rs serve --watch ./dist
138
163
  ```
139
164
 
140
165
  To customize the reload functionality, disable the auto-inject script, manually subscribe to change events and trigger the desired functionality.
141
166
 
142
167
  ```bash
143
- http-server --watch --no-watch-inject ./dist
168
+ http-server-rs serve --watch --no-watch-inject ./dist
144
169
  ```
145
170
 
146
171
  ```html
@@ -156,31 +181,3 @@ http-server --watch --no-watch-inject ./dist
156
181
  </body>
157
182
  </html>
158
183
  ```
159
-
160
- ## Installation
161
-
162
- ### MacOS & Linux
163
-
164
- Download the binary from the [latest GitHub release](https://github.com/alshdavid/http-server-rs/releases/latest) and add it to your `PATH`
165
-
166
- ```shell
167
- # Linux AMD64
168
- curl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-rs-linux-amd64.tar.gz | tar -xvzf - -C $HOME/.local/bin
169
-
170
- # Linux ARM64
171
- curl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-rs-linux-arm64.tar.gz | tar -xvzf - -C $HOME/.local/bin
172
-
173
- # MacOS ARM64 (Apple Silicon)
174
- curl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-rs-macos-arm64.tar.gz | tar -xvzf - -C $HOME/.local/bin
175
-
176
- # MacOS AMD64 (Intel)
177
- curl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-rs-macos-amd64.tar.gz | tar -xvzf - -C $HOME/.local/bin
178
-
179
- # Add to PATH if not already there:
180
- echo "\nexport \PATH=\$PATH:\$HOME/.local/bin\n" >> $HOME/.zshrc
181
- echo "\nexport \PATH=\$PATH:\$HOME/.local/bin\n" >> $HOME/.bashrc
182
- ```
183
-
184
- ### Windows
185
-
186
- Download the binary from the [latest GitHub release](https://github.com/alshdavid/http-server-rs/releases/latest) and add it to your `PATH`
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-server-rs",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {