@swissjs/swite 0.3.5 → 0.4.2

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 (78) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/DIRECTIVE.md +57 -2
  3. package/__tests__/import-rewriter-bug.test.ts +100 -113
  4. package/__tests__/security-r001-r002.test.ts +190 -0
  5. package/dist/build-engine/builder.js +9 -9
  6. package/dist/cli.js +0 -0
  7. package/dist/config/config.d.ts +0 -5
  8. package/dist/config/config.d.ts.map +1 -1
  9. package/dist/dev-engine/handlers/base-handler.d.ts +6 -0
  10. package/dist/dev-engine/handlers/base-handler.d.ts.map +1 -1
  11. package/dist/dev-engine/handlers/base-handler.js +91 -0
  12. package/dist/dev-engine/handlers/ui-handler.d.ts +0 -1
  13. package/dist/dev-engine/handlers/ui-handler.d.ts.map +1 -1
  14. package/dist/dev-engine/handlers/ui-handler.js +2 -64
  15. package/dist/dev-engine/handlers/uix-handler.d.ts +0 -1
  16. package/dist/dev-engine/handlers/uix-handler.d.ts.map +1 -1
  17. package/dist/dev-engine/handlers/uix-handler.js +2 -58
  18. package/dist/dev-engine/hmr/hmr-client-template.js +111 -111
  19. package/dist/dev-engine/hmr/hmr.d.ts +10 -1
  20. package/dist/dev-engine/hmr/hmr.d.ts.map +1 -1
  21. package/dist/dev-engine/hmr/hmr.js +40 -2
  22. package/dist/dev-engine/middleware/middleware-setup.js +4 -3
  23. package/dist/dev-engine/middleware/static-files.d.ts.map +1 -1
  24. package/dist/dev-engine/middleware/static-files.js +145 -62
  25. package/dist/dev-engine/pythonDevManager.js +1 -1
  26. package/dist/dev-engine/router/file-router.d.ts.map +1 -1
  27. package/dist/dev-engine/router/file-router.js +2 -29
  28. package/dist/dev-engine/server.d.ts +7 -0
  29. package/dist/dev-engine/server.d.ts.map +1 -1
  30. package/dist/dev-engine/server.js +31 -3
  31. package/dist/kernel/package-finder.d.ts +0 -8
  32. package/dist/kernel/package-finder.d.ts.map +1 -1
  33. package/dist/kernel/package-finder.js +2 -2
  34. package/dist/kernel/package-registry.d.ts +6 -0
  35. package/dist/kernel/package-registry.d.ts.map +1 -1
  36. package/dist/kernel/package-registry.js +8 -0
  37. package/dist/kernel/workspace.d.ts.map +1 -1
  38. package/dist/kernel/workspace.js +12 -9
  39. package/docs/architecture/build-pipeline.md +97 -97
  40. package/docs/architecture/dev-server.md +87 -87
  41. package/docs/architecture/hmr.md +78 -78
  42. package/docs/architecture/import-rewriting.md +101 -101
  43. package/docs/architecture/index.md +16 -16
  44. package/docs/architecture/python-integration.md +93 -93
  45. package/docs/architecture/resolution.md +92 -92
  46. package/docs/cli/build.md +78 -78
  47. package/docs/cli/dev.md +90 -90
  48. package/docs/cli/index.md +15 -15
  49. package/docs/cli/start.md +45 -45
  50. package/docs/development/contributing.md +74 -74
  51. package/docs/development/index.md +12 -12
  52. package/docs/development/internals.md +101 -101
  53. package/docs/guide/configuration.md +89 -89
  54. package/docs/guide/index.md +13 -13
  55. package/docs/guide/project-structure.md +75 -75
  56. package/docs/guide/quickstart.md +113 -113
  57. package/docs/index.md +16 -16
  58. package/package.json +29 -16
  59. package/src/build-engine/builder.ts +9 -9
  60. package/src/config/config.ts +0 -5
  61. package/src/config/env.ts +98 -98
  62. package/src/dev-engine/handlers/base-handler.ts +109 -0
  63. package/src/dev-engine/handlers/ui-handler.ts +30 -110
  64. package/src/dev-engine/handlers/uix-handler.ts +21 -95
  65. package/src/dev-engine/hmr/hmr-client-template.ts +122 -122
  66. package/src/dev-engine/hmr/hmr.ts +46 -1
  67. package/src/dev-engine/middleware/middleware-setup.ts +354 -354
  68. package/src/dev-engine/middleware/static-files.ts +203 -121
  69. package/src/dev-engine/pythonDevManager.ts +1 -1
  70. package/src/dev-engine/router/file-router.ts +2 -45
  71. package/src/dev-engine/server.ts +33 -3
  72. package/src/kernel/package-finder.ts +2 -2
  73. package/src/kernel/package-registry.ts +9 -0
  74. package/src/kernel/workspace.ts +8 -10
  75. package/src/resolution/cdn/cdn-fallback.ts +40 -40
  76. package/src/resolution/path/path-fixup.ts +27 -27
  77. package/src/resolution/rewriting/import-rewriter.ts +237 -237
  78. package/src/resolution/symlink-registry.ts +114 -114
package/docs/cli/build.md CHANGED
@@ -1,78 +1,78 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # swite build
8
-
9
- Compiles the application for production.
10
-
11
- ```bash
12
- swite build
13
- ```
14
-
15
- ---
16
-
17
- ## What it does
18
-
19
- `swite build` runs `SwiteBuilder` with a fixed configuration derived from the project root:
20
-
21
- | Parameter | Value |
22
- |-----------|-------|
23
- | Entry point | `<root>/src/index.ui` |
24
- | Output directory | `<root>/dist` |
25
- | Format | ESM |
26
- | Target | `es2020` |
27
- | Minify | `true` |
28
- | Sourcemap | `false` |
29
-
30
- These defaults are not yet configurable via `swiss.config.ts`; the builder reads config only for future extensibility.
31
-
32
- ---
33
-
34
- ## Build pipeline
35
-
36
- The build runs in three phases:
37
-
38
- ### Phase 1: Compile Swiss files
39
-
40
- All `.ui` and `.uix` files in `src/` are passed through `@swissjs/compiler` (`UiCompiler.compileAsync`), which outputs TypeScript/JSX. The resulting code is written to a temporary `.swite-build/` directory as `.tsx` files. Plain `.ts` files are copied as-is, with `.ui`/`.uix` import references rewritten to `.tsx`. CSS files are copied verbatim.
41
-
42
- Workspace dependencies declared as `workspace:*` in `package.json` are discovered and compiled into the same temp directory, preserving the workspace directory structure so esbuild can resolve cross-package imports.
43
-
44
- ### Phase 2: Bundle with esbuild
45
-
46
- esbuild is invoked with `bundle: true`, targeting the compiled entry point in `.swite-build/`. Three custom plugins are active:
47
-
48
- - `js-tsx-fallback` — redirects `.js` import resolutions to `.tsx` when the `.tsx` file exists in the temp directory (handles UiCompiler emitting `.js` references)
49
- - `css-stub` — stubs all `.css` imports with `export {}` so they do not block the bundle
50
- - `workspace-resolver` — resolves `@scope/pkg` imports to compiled files in `.swite-build/`, using `package.json` exports fields and falling back to `src/index.js`
51
-
52
- Node built-in modules (`fs`, `path`, `os`, etc., including `node:` prefixed forms) are marked external.
53
-
54
- ### Phase 3: Copy public assets
55
-
56
- The contents of `public/` are copied verbatim to `dist/`.
57
-
58
- ---
59
-
60
- ## Output
61
-
62
- `dist/` contains the bundled JavaScript (one or more chunks for ESM splitting), copied public assets, and any CSS files the build chose to emit. The `.swite-build/` temporary directory is removed regardless of whether the build succeeded or failed.
63
-
64
- Build stats (file count and sizes) are printed to stdout after a successful bundle.
65
-
66
- ---
67
-
68
- ## Workspace dependencies
69
-
70
- The builder scans `package.json` `dependencies`, `devDependencies`, and `peerDependencies` for `workspace:*` entries and also scans source files for `@scope/pkg` import patterns to discover transitive workspace dependencies. For each discovered package, it looks in these directories under the workspace root (in order):
71
-
72
- ```
73
- lib/<pkgName>
74
- packages/<pkgName>
75
- packages/runtime/<pkgName>
76
- packages/plugins/<pkgName>
77
- packages/domain/<pkgName>
78
- ```
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # swite build
8
+
9
+ Compiles the application for production.
10
+
11
+ ```bash
12
+ swite build
13
+ ```
14
+
15
+ ---
16
+
17
+ ## What it does
18
+
19
+ `swite build` runs `SwiteBuilder` with a fixed configuration derived from the project root:
20
+
21
+ | Parameter | Value |
22
+ |-----------|-------|
23
+ | Entry point | `<root>/src/index.ui` |
24
+ | Output directory | `<root>/dist` |
25
+ | Format | ESM |
26
+ | Target | `es2020` |
27
+ | Minify | `true` |
28
+ | Sourcemap | `false` |
29
+
30
+ These defaults are not yet configurable via `swiss.config.ts`; the builder reads config only for future extensibility.
31
+
32
+ ---
33
+
34
+ ## Build pipeline
35
+
36
+ The build runs in three phases:
37
+
38
+ ### Phase 1: Compile Swiss files
39
+
40
+ All `.ui` and `.uix` files in `src/` are passed through `@swissjs/compiler` (`UiCompiler.compileAsync`), which outputs TypeScript/JSX. The resulting code is written to a temporary `.swite-build/` directory as `.tsx` files. Plain `.ts` files are copied as-is, with `.ui`/`.uix` import references rewritten to `.tsx`. CSS files are copied verbatim.
41
+
42
+ Workspace dependencies declared as `workspace:*` in `package.json` are discovered and compiled into the same temp directory, preserving the workspace directory structure so esbuild can resolve cross-package imports.
43
+
44
+ ### Phase 2: Bundle with esbuild
45
+
46
+ esbuild is invoked with `bundle: true`, targeting the compiled entry point in `.swite-build/`. Three custom plugins are active:
47
+
48
+ - `js-tsx-fallback` — redirects `.js` import resolutions to `.tsx` when the `.tsx` file exists in the temp directory (handles UiCompiler emitting `.js` references)
49
+ - `css-stub` — stubs all `.css` imports with `export {}` so they do not block the bundle
50
+ - `workspace-resolver` — resolves `@scope/pkg` imports to compiled files in `.swite-build/`, using `package.json` exports fields and falling back to `src/index.js`
51
+
52
+ Node built-in modules (`fs`, `path`, `os`, etc., including `node:` prefixed forms) are marked external.
53
+
54
+ ### Phase 3: Copy public assets
55
+
56
+ The contents of `public/` are copied verbatim to `dist/`.
57
+
58
+ ---
59
+
60
+ ## Output
61
+
62
+ `dist/` contains the bundled JavaScript (one or more chunks for ESM splitting), copied public assets, and any CSS files the build chose to emit. The `.swite-build/` temporary directory is removed regardless of whether the build succeeded or failed.
63
+
64
+ Build stats (file count and sizes) are printed to stdout after a successful bundle.
65
+
66
+ ---
67
+
68
+ ## Workspace dependencies
69
+
70
+ The builder scans `package.json` `dependencies`, `devDependencies`, and `peerDependencies` for `workspace:*` entries and also scans source files for `@scope/pkg` import patterns to discover transitive workspace dependencies. For each discovered package, it looks in these directories under the workspace root (in order):
71
+
72
+ ```
73
+ lib/<pkgName>
74
+ packages/<pkgName>
75
+ packages/runtime/<pkgName>
76
+ packages/plugins/<pkgName>
77
+ packages/domain/<pkgName>
78
+ ```
package/docs/cli/dev.md CHANGED
@@ -1,90 +1,90 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # swite dev
8
-
9
- Starts the SWITE development server.
10
-
11
- ```bash
12
- swite dev
13
- ```
14
-
15
- ---
16
-
17
- ## What it does
18
-
19
- 1. Loads `swiss.config.ts` from the project root via esbuild transpilation.
20
- 2. If `services.python.autoStart` is `true` in the config, spawns the Python process at `python3 {entry}` (or `python` on Windows), passes `PORT={port}` plus any `env` fields, and polls the health endpoint until it responds 200 or the 15-second timeout is reached.
21
- 3. Registers `SIGINT` and `process.exit` handlers to send `SIGTERM` to the Python process when Node shuts down.
22
- 4. Starts `SwiteServer` on the configured port and host, then begins the HMR WebSocket server on port 24678 (or the next available port).
23
-
24
- ---
25
-
26
- ## Python autostart
27
-
28
- When `autoStart: true` is set, the Python process is started before the Node HTTP server. SWITE streams Python stdout prefixed with `[python]` (cyan) and stderr prefixed with `[python]` (yellow). If the health check times out, SWITE kills the Python process and exits with an error.
29
-
30
- ```typescript
31
- // swiss.config.ts
32
- export default defineConfig({
33
- services: {
34
- python: {
35
- entry: 'server/main.py',
36
- port: 8000,
37
- autoStart: true,
38
- healthCheck: '/health',
39
- env: { ENVIRONMENT: 'development' },
40
- },
41
- },
42
- });
43
- ```
44
-
45
- ---
46
-
47
- ## HMR
48
-
49
- The HMR WebSocket server starts on port 24678. If that port is occupied, SWITE probes the OS for the next free port. The actual port is embedded into the HMR client script served at `/__swite_hmr_client`.
50
-
51
- Every `.ui`, `.uix`, `.ts`, and `.js` file under the project root is watched by chokidar (excluding `node_modules/`, `.git/`, and `dist/`). When a file changes, SWITE broadcasts a JSON message to all connected WebSocket clients:
52
-
53
- ```json
54
- { "type": "update", "path": "/abs/path/to/file", "updateType": "hot|reload|style", "timestamp": 1234567890 }
55
- ```
56
-
57
- Update type classification:
58
-
59
- | Update type | Condition |
60
- |-------------|-----------|
61
- | `style` | `.css`, `.scss`, or `.sass` file |
62
- | `hot` | `.js` or `.ts` file under `components/` or `pages/` |
63
- | `reload` | everything else |
64
-
65
- The browser client handles `style` by cache-busting stylesheet `href` attributes. It handles `hot` by re-importing the module and calling `instance.update()` on registered instances. Everything else triggers `window.location.reload()`.
66
-
67
- ---
68
-
69
- ## Development headers
70
-
71
- All compiled source files are served with aggressive no-cache headers:
72
-
73
- ```
74
- Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
75
- Pragma: no-cache
76
- Expires: 0
77
- ```
78
-
79
- This prevents browsers from serving stale compiled output between reloads.
80
-
81
- ---
82
-
83
- ## Diagnostic endpoints
84
-
85
- | Endpoint | Description |
86
- |----------|-------------|
87
- | `/__swite_hmr_client` | HMR client JavaScript (injected by index.html) |
88
- | `/__swite_routes` | JSON array of route definitions from the file router |
89
- | `/__swite_diagnose?url=<path>` | Fetches the given path and reports bare imports found in the response |
90
- | `/__swite_clear_cache` | HTML page that clears browser caches and service workers, then redirects to `/` |
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # swite dev
8
+
9
+ Starts the SWITE development server.
10
+
11
+ ```bash
12
+ swite dev
13
+ ```
14
+
15
+ ---
16
+
17
+ ## What it does
18
+
19
+ 1. Loads `swiss.config.ts` from the project root via esbuild transpilation.
20
+ 2. If `services.python.autoStart` is `true` in the config, spawns the Python process at `python3 {entry}` (or `python` on Windows), passes `PORT={port}` plus any `env` fields, and polls the health endpoint until it responds 200 or the 15-second timeout is reached.
21
+ 3. Registers `SIGINT` and `process.exit` handlers to send `SIGTERM` to the Python process when Node shuts down.
22
+ 4. Starts `SwiteServer` on the configured port and host, then begins the HMR WebSocket server on port 24678 (or the next available port).
23
+
24
+ ---
25
+
26
+ ## Python autostart
27
+
28
+ When `autoStart: true` is set, the Python process is started before the Node HTTP server. SWITE streams Python stdout prefixed with `[python]` (cyan) and stderr prefixed with `[python]` (yellow). If the health check times out, SWITE kills the Python process and exits with an error.
29
+
30
+ ```typescript
31
+ // swiss.config.ts
32
+ export default defineConfig({
33
+ services: {
34
+ python: {
35
+ entry: 'server/main.py',
36
+ port: 8000,
37
+ autoStart: true,
38
+ healthCheck: '/health',
39
+ env: { ENVIRONMENT: 'development' },
40
+ },
41
+ },
42
+ });
43
+ ```
44
+
45
+ ---
46
+
47
+ ## HMR
48
+
49
+ The HMR WebSocket server starts on port 24678. If that port is occupied, SWITE probes the OS for the next free port. The actual port is embedded into the HMR client script served at `/__swite_hmr_client`.
50
+
51
+ Every `.ui`, `.uix`, `.ts`, and `.js` file under the project root is watched by chokidar (excluding `node_modules/`, `.git/`, and `dist/`). When a file changes, SWITE broadcasts a JSON message to all connected WebSocket clients:
52
+
53
+ ```json
54
+ { "type": "update", "path": "/abs/path/to/file", "updateType": "hot|reload|style", "timestamp": 1234567890 }
55
+ ```
56
+
57
+ Update type classification:
58
+
59
+ | Update type | Condition |
60
+ |-------------|-----------|
61
+ | `style` | `.css`, `.scss`, or `.sass` file |
62
+ | `hot` | `.js` or `.ts` file under `components/` or `pages/` |
63
+ | `reload` | everything else |
64
+
65
+ The browser client handles `style` by cache-busting stylesheet `href` attributes. It handles `hot` by re-importing the module and calling `instance.update()` on registered instances. Everything else triggers `window.location.reload()`.
66
+
67
+ ---
68
+
69
+ ## Development headers
70
+
71
+ All compiled source files are served with aggressive no-cache headers:
72
+
73
+ ```
74
+ Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
75
+ Pragma: no-cache
76
+ Expires: 0
77
+ ```
78
+
79
+ This prevents browsers from serving stale compiled output between reloads.
80
+
81
+ ---
82
+
83
+ ## Diagnostic endpoints
84
+
85
+ | Endpoint | Description |
86
+ |----------|-------------|
87
+ | `/__swite_hmr_client` | HMR client JavaScript (injected by index.html) |
88
+ | `/__swite_routes` | JSON array of route definitions from the file router |
89
+ | `/__swite_diagnose?url=<path>` | Fetches the given path and reports bare imports found in the response |
90
+ | `/__swite_clear_cache` | HTML page that clears browser caches and service workers, then redirects to `/` |
package/docs/cli/index.md CHANGED
@@ -1,15 +1,15 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # CLI
8
-
9
- SWITE is invoked as `swite <command>`. There are three commands:
10
-
11
- - [swite dev](./dev.md) — Start the development server with HMR and optional Python autostart
12
- - [swite build](./build.md) — Build the application for production using esbuild
13
- - [swite start](./start.md) — Start the development server in production mode (no HMR, no Python autostart)
14
-
15
- All three commands read `swiss.config.ts` (or `swiss.config.js`) from the current working directory before doing anything else. The current working directory is the project root; SWITE does not accept a path argument.
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # CLI
8
+
9
+ SWITE is invoked as `swite <command>`. There are three commands:
10
+
11
+ - [swite dev](./dev.md) — Start the development server with HMR and optional Python autostart
12
+ - [swite build](./build.md) — Build the application for production using esbuild
13
+ - [swite start](./start.md) — Start the development server in production mode (no HMR, no Python autostart)
14
+
15
+ All three commands read `swiss.config.ts` (or `swiss.config.js`) from the current working directory before doing anything else. The current working directory is the project root; SWITE does not accept a path argument.
package/docs/cli/start.md CHANGED
@@ -1,45 +1,45 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # swite start
8
-
9
- Starts the SWITE server in production mode.
10
-
11
- ```bash
12
- swite start
13
- ```
14
-
15
- ---
16
-
17
- ## What it does
18
-
19
- `swite start` starts the same `SwiteServer` as `swite dev` but with one critical difference: it calls `setProductionMode()` before the server starts. Production mode changes how `proxyToPython` resolves the Python service URL:
20
-
21
- - **Dev mode**: if `PYTHON_SERVICE_URL` is not set, `proxyToPython` falls back to `http://localhost:{python.port}` from the config.
22
- - **Production mode**: if `PYTHON_SERVICE_URL` is not set, `proxyToPython` throws immediately with an error rather than attempting a localhost connection.
23
-
24
- `swite start` does not spawn the Python process. It does not start HMR. The HMR WebSocket server is still initialized (as part of `SwiteServer`), but since no file watcher is started and the client script is still served, the client will connect and wait — which is harmless in a production container.
25
-
26
- ---
27
-
28
- ## PYTHON_SERVICE_URL warning
29
-
30
- If `services.python` is configured in `swiss.config.ts` and `PYTHON_SERVICE_URL` is not set in the environment at startup, SWITE prints a warning:
31
-
32
- ```
33
- [swite] WARNING: services.python is configured but PYTHON_SERVICE_URL is not set.
34
- Proxy calls to Python will fail. Set PYTHON_SERVICE_URL to the running service URL.
35
- ```
36
-
37
- The server starts regardless. The warning is there because proxy calls that happen before `PYTHON_SERVICE_URL` is set will throw at request time.
38
-
39
- ---
40
-
41
- ## Production deployment notes
42
-
43
- `swite start` serves source files through the same compilation and import-rewriting middleware as `swite dev`. It is not a static file server for pre-built output. If you want to serve the output of `swite build`, use a regular static HTTP server pointed at `dist/`.
44
-
45
- `swite start` is intended for fullstack deployments where the Node server handles server-side logic and proxies to a separately deployed Python service, while continuing to serve the SwissJS frontend from source.
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # swite start
8
+
9
+ Starts the SWITE server in production mode.
10
+
11
+ ```bash
12
+ swite start
13
+ ```
14
+
15
+ ---
16
+
17
+ ## What it does
18
+
19
+ `swite start` starts the same `SwiteServer` as `swite dev` but with one critical difference: it calls `setProductionMode()` before the server starts. Production mode changes how `proxyToPython` resolves the Python service URL:
20
+
21
+ - **Dev mode**: if `PYTHON_SERVICE_URL` is not set, `proxyToPython` falls back to `http://localhost:{python.port}` from the config.
22
+ - **Production mode**: if `PYTHON_SERVICE_URL` is not set, `proxyToPython` throws immediately with an error rather than attempting a localhost connection.
23
+
24
+ `swite start` does not spawn the Python process. It does not start HMR. The HMR WebSocket server is still initialized (as part of `SwiteServer`), but since no file watcher is started and the client script is still served, the client will connect and wait — which is harmless in a production container.
25
+
26
+ ---
27
+
28
+ ## PYTHON_SERVICE_URL warning
29
+
30
+ If `services.python` is configured in `swiss.config.ts` and `PYTHON_SERVICE_URL` is not set in the environment at startup, SWITE prints a warning:
31
+
32
+ ```
33
+ [swite] WARNING: services.python is configured but PYTHON_SERVICE_URL is not set.
34
+ Proxy calls to Python will fail. Set PYTHON_SERVICE_URL to the running service URL.
35
+ ```
36
+
37
+ The server starts regardless. The warning is there because proxy calls that happen before `PYTHON_SERVICE_URL` is set will throw at request time.
38
+
39
+ ---
40
+
41
+ ## Production deployment notes
42
+
43
+ `swite start` serves source files through the same compilation and import-rewriting middleware as `swite dev`. It is not a static file server for pre-built output. If you want to serve the output of `swite build`, use a regular static HTTP server pointed at `dist/`.
44
+
45
+ `swite start` is intended for fullstack deployments where the Node server handles server-side logic and proxies to a separately deployed Python service, while continuing to serve the SwissJS frontend from source.
@@ -1,74 +1,74 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # Contributing
8
-
9
- ---
10
-
11
- ## Build
12
-
13
- SWITE is compiled from TypeScript to `dist/` using the TypeScript compiler:
14
-
15
- ```bash
16
- pnpm build # single build
17
- pnpm dev # watch mode (tsc -b --watch)
18
- ```
19
-
20
- The `bin.swite` field in `package.json` points to `dist/cli.js`. After a build, the CLI is runnable as `node dist/cli.js dev` from the package root, or via the `swite` binary when the package is installed.
21
-
22
- To clean build artifacts and `node_modules`:
23
-
24
- ```bash
25
- pnpm clean
26
- ```
27
-
28
- ---
29
-
30
- ## Running tests
31
-
32
- ```bash
33
- pnpm test
34
- ```
35
-
36
- Tests run via Node's built-in test runner (`node --import tsx --test`). Test files live in `__tests__/`. Add new test files with a `.test.ts` extension.
37
-
38
- ---
39
-
40
- ## Generating an import map
41
-
42
- The import map generation CLI is separate from the main build:
43
-
44
- ```bash
45
- pnpm generate-import-map
46
- ```
47
-
48
- This runs `src/internal/generate-import-map-cli.ts` via `tsx` and writes `.swite/import-map.json` in the current directory. Run this from the project root of an application, not from the SWITE package root.
49
-
50
- ---
51
-
52
- ## Changesets and releases
53
-
54
- SWITE uses `@changesets/cli` for versioning.
55
-
56
- ```bash
57
- pnpm changeset # create a changeset for your changes
58
- pnpm release:version # bump versions from pending changesets
59
- pnpm release:publish # publish to npm
60
- ```
61
-
62
- ---
63
-
64
- ## Branch conventions
65
-
66
- - Work in feature branches named `feat/<topic>` or `fix/<topic>`.
67
- - Do not push directly to the default branch.
68
- - Each PR should include a changeset unless the change is documentation-only.
69
-
70
- ---
71
-
72
- ## Package scope
73
-
74
- SWITE is published as `@swissjs/swite`. The npm registry is `registry.npmjs.org` with `access: public`. The repository is part of the `kibologic/alpine-erp-core` GitHub repo.
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # Contributing
8
+
9
+ ---
10
+
11
+ ## Build
12
+
13
+ SWITE is compiled from TypeScript to `dist/` using the TypeScript compiler:
14
+
15
+ ```bash
16
+ pnpm build # single build
17
+ pnpm dev # watch mode (tsc -b --watch)
18
+ ```
19
+
20
+ The `bin.swite` field in `package.json` points to `dist/cli.js`. After a build, the CLI is runnable as `node dist/cli.js dev` from the package root, or via the `swite` binary when the package is installed.
21
+
22
+ To clean build artifacts and `node_modules`:
23
+
24
+ ```bash
25
+ pnpm clean
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Running tests
31
+
32
+ ```bash
33
+ pnpm test
34
+ ```
35
+
36
+ Tests run via Node's built-in test runner (`node --import tsx --test`). Test files live in `__tests__/`. Add new test files with a `.test.ts` extension.
37
+
38
+ ---
39
+
40
+ ## Generating an import map
41
+
42
+ The import map generation CLI is separate from the main build:
43
+
44
+ ```bash
45
+ pnpm generate-import-map
46
+ ```
47
+
48
+ This runs `src/internal/generate-import-map-cli.ts` via `tsx` and writes `.swite/import-map.json` in the current directory. Run this from the project root of an application, not from the SWITE package root.
49
+
50
+ ---
51
+
52
+ ## Changesets and releases
53
+
54
+ SWITE uses `@changesets/cli` for versioning.
55
+
56
+ ```bash
57
+ pnpm changeset # create a changeset for your changes
58
+ pnpm release:version # bump versions from pending changesets
59
+ pnpm release:publish # publish to npm
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Branch conventions
65
+
66
+ - Work in feature branches named `feat/<topic>` or `fix/<topic>`.
67
+ - Do not push directly to the default branch.
68
+ - Each PR should include a changeset unless the change is documentation-only.
69
+
70
+ ---
71
+
72
+ ## Package scope
73
+
74
+ SWITE is published as `@swissjs/swite`. The npm registry is `registry.npmjs.org` with `access: public`. The repository is part of the `kibologic/alpine-erp-core` GitHub repo.
@@ -1,12 +1,12 @@
1
- <!--
2
- Copyright (c) 2024 Themba Mzumara
3
- SWITE - SWISS Development Server
4
- Licensed under the MIT License.
5
- -->
6
-
7
- # Development
8
-
9
- Notes for contributors and maintainers working on SWITE itself.
10
-
11
- - [Contributing](./contributing.md) — local build, running tests, branch conventions
12
- - [Internals](./internals.md) — workspace root detection algorithm, import map generation, symlink registry, package registry
1
+ <!--
2
+ Copyright (c) 2024 Themba Mzumara
3
+ SWITE - SWISS Development Server
4
+ Licensed under the MIT License.
5
+ -->
6
+
7
+ # Development
8
+
9
+ Notes for contributors and maintainers working on SWITE itself.
10
+
11
+ - [Contributing](./contributing.md) — local build, running tests, branch conventions
12
+ - [Internals](./internals.md) — workspace root detection algorithm, import map generation, symlink registry, package registry