@stencil/dev-server 5.0.0-alpha.16 → 5.0.0-alpha.17

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.
Files changed (2) hide show
  1. package/README.md +105 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @stencil/dev-server
2
+
3
+ Development server for Stencil with DOM-based Hot Module Replacement (HMR).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --save-dev @stencil/dev-server @stencil/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ The dev server is configured via `stencil.config.ts` and started automatically with `stencil build --dev --watch --serve`.
14
+
15
+ ```ts
16
+ // stencil.config.ts
17
+ import { Config } from '@stencil/core';
18
+
19
+ export const config: Config = {
20
+ devServer: {
21
+ port: 3333,
22
+ openBrowser: true,
23
+ reloadStrategy: 'pageReload', // or 'hmr'
24
+ },
25
+ outputTargets: [{ type: 'www' }],
26
+ };
27
+ ```
28
+
29
+ ```bash
30
+ npx stencil build --dev --watch --serve
31
+ ```
32
+
33
+ ## Programmatic API
34
+
35
+ ### `start(config, logger, watcher?)` — start the dev server
36
+
37
+ ```ts
38
+ import { start } from '@stencil/dev-server';
39
+ import { createNodeLogger } from '@stencil/core/sys/node';
40
+
41
+ const server = await start(
42
+ {
43
+ root: './www', // directory to serve
44
+ port: 3333,
45
+ openBrowser: true,
46
+ reloadStrategy: 'hmr', // 'hmr' | 'pageReload' | null
47
+ },
48
+ createNodeLogger(),
49
+ );
50
+
51
+ console.log(`Listening at ${server.browserUrl}`);
52
+
53
+ // Shut down when done
54
+ await server.close();
55
+ ```
56
+
57
+ ### With a Stencil compiler watcher (full HMR)
58
+
59
+ Pass a `CompilerWatcher` to connect build output to the dev server — file changes trigger HMR or a page reload automatically.
60
+
61
+ ```ts
62
+ import * as coreCompiler from '@stencil/core/compiler';
63
+ import { start } from '@stencil/dev-server';
64
+ import { createNodeLogger, createNodeSys } from '@stencil/core/sys/node';
65
+
66
+ const logger = createNodeLogger();
67
+ const sys = createNodeSys();
68
+
69
+ const { config } = await coreCompiler.loadConfig({
70
+ configPath: './stencil.config.ts',
71
+ logger,
72
+ sys,
73
+ });
74
+
75
+ const compiler = await coreCompiler.createCompiler(config);
76
+ const watcher = await compiler.createWatcher();
77
+
78
+ const server = await start(
79
+ { root: './www', port: 3333, reloadStrategy: 'hmr' },
80
+ logger,
81
+ watcher,
82
+ );
83
+
84
+ // Start watching — builds trigger HMR updates in the browser
85
+ await watcher.start();
86
+
87
+ // To shut down:
88
+ // await watcher.close();
89
+ // await server.close();
90
+ ```
91
+
92
+ The returned `DevServer` exposes `address`, `browserUrl`, `protocol`, `port`, `root`, and `close()`.
93
+
94
+ #### Key config options
95
+
96
+ | Option | Default | Description |
97
+ |---|---|---|
98
+ | `root` | `'.'` | Directory to serve files from |
99
+ | `port` | `3333` | Port to listen on |
100
+ | `address` | `'0.0.0.0'` | Network interface to bind |
101
+ | `reloadStrategy` | `'hmr'` | `'hmr'`, `'pageReload'`, or `null` to disable |
102
+ | `openBrowser` | `false` | Open browser on start |
103
+ | `https` | — | `{ cert, key }` to enable HTTPS |
104
+ | `worker` | `true` | Fork server into a child process (disable for debugging) |
105
+ | `ssr` | `false` | Server-side render each page on request (dev only - you must have a `ssr` output target setup) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/dev-server",
3
- "version": "5.0.0-alpha.16",
3
+ "version": "5.0.0-alpha.17",
4
4
  "description": "Development server for Stencil with DOM-based HMR",
5
5
  "keywords": [
6
6
  "dev server",
@@ -46,7 +46,7 @@
46
46
  "typescript": ">4.0.0 <7.0.0",
47
47
  "vitest": "^4.1.7",
48
48
  "vitest-environment-stencil": "^1.12.1",
49
- "@stencil/core": "5.0.0-alpha.16"
49
+ "@stencil/core": "5.0.0-alpha.17"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@stencil/core": "^5.0.0-0"