@rudderjs/vite 0.0.6 → 1.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rudderjs/vite
2
2
 
3
- Vite plugin for RudderJS. Registers Vike (SSR), sets the `@/` path alias, externalizes server-only packages from the client bundle, and wires up WebSocket upgrade handling for `@rudderjs/broadcast` and `@rudderjs/live`.
3
+ Vite plugin for RudderJS. Registers Vike (SSR), sets the `@/` path alias, externalizes server-only packages from the client bundle, and wires up WebSocket upgrade handling for `@rudderjs/broadcast` and `@rudderjs/sync`.
4
4
 
5
5
  ```bash
6
6
  pnpm add @rudderjs/vite
@@ -25,23 +25,34 @@ export default defineConfig({
25
25
  That's it. `rudderjs()` handles:
26
26
 
27
27
  - **Vike registration** — auto-detects and registers `vike/plugin` for SSR + file-based routing
28
- - **Path alias** — `@/` resolves to `src/` in the project root
28
+ - **View scanner** — scans `app/Views/**` and generates virtual Vike pages under `pages/__view/` for `@rudderjs/view`
29
+ - **HMR route reload** — watches `routes/`, `bootstrap/`, and `app/` so edits there invalidate the SSR module graph without restarting the dev server
30
+ - **Path alias** — `@/` and `App/` resolve to the app directory
29
31
  - **SSR externals** — server-only packages (database drivers, Redis, queue adapters) are externalized from the client bundle
30
32
  - **SSR no-externals** — `@rudderjs/server-hono` is forced non-external so Vite processes virtual module imports
31
- - **WebSocket upgrade** — intercepts `http.createServer` to attach the `__rudderjs_ws_upgrade__` handler for `@rudderjs/broadcast` and `@rudderjs/live`
33
+ - **WebSocket upgrade** — intercepts `http.createServer` to attach the `__rudderjs_ws_upgrade__` handler for `@rudderjs/broadcast` and `@rudderjs/sync`
34
+ - **`x-real-ip` injection** — dev-only, populates the header from the Node socket so `req.ip` works through Vike's universal middleware
32
35
  - **Sourcemap warnings** — suppresses noisy "missing source files" warnings for `@rudderjs/*` packages
33
36
  - **Build externals** — server-only packages are excluded from production builds
34
37
 
35
38
  ## What it produces
36
39
 
37
- Three Vite plugins:
40
+ Five Vite plugins:
38
41
 
39
42
  | Plugin | Purpose |
40
43
  |--------|---------|
41
- | `rudderjs:ws` | WebSocket upgrade handler via `configureServer` |
42
44
  | `rudderjs:config` | SSR externals, path alias, warning suppression |
45
+ | `rudderjs:ws` | WebSocket upgrade handler via `configureServer` |
46
+ | `rudderjs:ip` | Dev-only `x-real-ip` injection from Node socket |
47
+ | `rudderjs:routes` | HMR watcher for `routes/` + `bootstrap/` + `app/`; invalidates SSR modules + clears `__rudderjs_instance__` and `__rudderjs_app__` globals so the next request re-bootstraps cleanly |
48
+ | `rudderjs:views` | View scanner — generates virtual Vike pages from `app/Views/**` |
43
49
  | *(vike plugins)* | SSR rendering, file-based routing (auto-registered) |
44
50
 
51
+ ### HMR notes
52
+
53
+ - `rudderjs:routes` never calls `server.restart()` — doing so closes Vite's module runner and breaks in-flight SSR requests. Module invalidation + globalThis cleanup is enough to force a full re-bootstrap on the next request.
54
+ - Changes under `app/` require the full cleanup (not just invalidation) because models, controllers, and resources are captured in provider closures during boot.
55
+
45
56
  ## SSR Externals
46
57
 
47
58
  These packages are externalized from the SSR bundle (Node.js-only, not browser-compatible):
package/dist/index.js CHANGED
@@ -105,7 +105,7 @@ export function rudderjs() {
105
105
  name: 'rudderjs:ws',
106
106
  configureServer(server) {
107
107
  // Attach the WebSocket upgrade handler to Vite's own HTTP server.
108
- // @rudderjs/broadcast and @rudderjs/live register their handlers on
108
+ // @rudderjs/broadcast and @rudderjs/sync register their handlers on
109
109
  // globalThis['__rudderjs_ws_upgrade__'] during provider boot. We listen
110
110
  // for 'upgrade' events and forward them to that handler.
111
111
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rudderjs/vite",
3
- "version": "0.0.6",
3
+ "version": "1.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",