@solidjs/start 2.0.0-beta.1 → 2.0.0-beta.10

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 (238) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/client/StartClient.d.ts +7 -0
  3. package/{src/client/StartClient.tsx → dist/client/StartClient.jsx} +7 -15
  4. package/dist/client/index.jsx +2 -0
  5. package/dist/client/mount.d.ts +1 -0
  6. package/dist/client/mount.js +1 -0
  7. package/dist/client/spa/index.d.ts +4 -0
  8. package/dist/client/spa/index.jsx +5 -0
  9. package/dist/config/boundary-modules.d.ts +14 -0
  10. package/dist/config/boundary-modules.js +41 -0
  11. package/dist/config/constants.d.ts +16 -0
  12. package/dist/config/constants.js +16 -0
  13. package/dist/config/dev-server.d.ts +4 -0
  14. package/dist/config/dev-server.js +146 -0
  15. package/dist/config/env.d.ts +19 -0
  16. package/dist/config/env.js +85 -0
  17. package/dist/config/fs-router.d.ts +37 -0
  18. package/dist/config/fs-router.js +148 -0
  19. package/dist/config/fs-routes/fs-watcher.d.ts +3 -0
  20. package/dist/config/fs-routes/fs-watcher.js +53 -0
  21. package/dist/config/fs-routes/index.d.ts +7 -0
  22. package/dist/config/fs-routes/index.js +107 -0
  23. package/dist/config/fs-routes/router.d.ts +43 -0
  24. package/dist/config/fs-routes/router.js +146 -0
  25. package/dist/config/fs-routes/tree-shake.d.ts +2 -0
  26. package/dist/config/fs-routes/tree-shake.js +305 -0
  27. package/dist/config/index.d.ts +25 -0
  28. package/dist/config/index.js +252 -0
  29. package/dist/config/lazy.d.ts +3 -0
  30. package/dist/config/lazy.js +114 -0
  31. package/dist/config/manifest.d.ts +3 -0
  32. package/dist/config/manifest.js +109 -0
  33. package/dist/config/utils.d.ts +4 -0
  34. package/dist/config/utils.js +6 -0
  35. package/dist/config/vite-utils.d.ts +21 -0
  36. package/dist/config/vite-utils.js +85 -0
  37. package/dist/directives/bubble-function-declaration.d.ts +3 -0
  38. package/dist/directives/bubble-function-declaration.js +23 -0
  39. package/dist/directives/compile.d.ts +9 -0
  40. package/dist/directives/compile.js +40 -0
  41. package/dist/directives/generate-unique-name.d.ts +3 -0
  42. package/dist/directives/generate-unique-name.js +16 -0
  43. package/dist/directives/get-descriptive-name.d.ts +2 -0
  44. package/dist/directives/get-descriptive-name.js +37 -0
  45. package/dist/directives/get-import-identifier.d.ts +4 -0
  46. package/dist/directives/get-import-identifier.js +19 -0
  47. package/dist/directives/get-root-statement-path.d.ts +2 -0
  48. package/dist/directives/get-root-statement-path.js +12 -0
  49. package/dist/directives/index.d.ts +14 -0
  50. package/dist/directives/index.js +202 -0
  51. package/dist/directives/is-statement-top-level.d.ts +3 -0
  52. package/dist/directives/is-statement-top-level.js +9 -0
  53. package/dist/directives/paths.d.ts +9 -0
  54. package/dist/directives/paths.js +36 -0
  55. package/dist/directives/plugin.d.ts +21 -0
  56. package/dist/directives/plugin.js +302 -0
  57. package/dist/directives/remove-unused-variables.d.ts +3 -0
  58. package/dist/directives/remove-unused-variables.js +66 -0
  59. package/{src/directives/types.ts → dist/directives/types.d.ts} +5 -7
  60. package/dist/directives/types.js +1 -0
  61. package/dist/directives/xxhash32.d.ts +6 -0
  62. package/dist/directives/xxhash32.js +193 -0
  63. package/dist/fns/client.d.ts +3 -0
  64. package/dist/fns/client.js +106 -0
  65. package/dist/fns/handler.d.ts +5 -0
  66. package/dist/fns/handler.js +305 -0
  67. package/dist/fns/registration.d.ts +3 -0
  68. package/dist/fns/registration.js +15 -0
  69. package/dist/fns/serialization.d.ts +6 -0
  70. package/dist/fns/serialization.js +208 -0
  71. package/dist/fns/server.d.ts +7 -0
  72. package/dist/fns/server.js +38 -0
  73. package/dist/fns/shared.d.ts +17 -0
  74. package/dist/fns/shared.js +105 -0
  75. package/dist/http/http.d.ts +81 -0
  76. package/dist/http/http.js +129 -0
  77. package/dist/http/index.d.ts +2 -0
  78. package/dist/http/index.js +6 -0
  79. package/{src/index.tsx → dist/index.d.ts} +0 -2
  80. package/dist/index.jsx +6 -0
  81. package/dist/middleware/index.d.ts +39 -0
  82. package/dist/middleware/index.js +60 -0
  83. package/dist/router.d.ts +6 -0
  84. package/dist/router.jsx +29 -0
  85. package/dist/server/StartServer.d.ts +9 -0
  86. package/dist/server/StartServer.jsx +34 -0
  87. package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
  88. package/{src/server/assets/PatchVirtualDevStyles.tsx → dist/server/assets/PatchVirtualDevStyles.jsx} +7 -10
  89. package/dist/server/assets/index.d.ts +2 -0
  90. package/dist/server/assets/index.js +52 -0
  91. package/dist/server/assets/render.d.ts +19 -0
  92. package/dist/server/assets/render.jsx +14 -0
  93. package/dist/server/collect-styles.d.ts +3 -0
  94. package/dist/server/collect-styles.js +57 -0
  95. package/dist/server/fetchEvent.d.ts +7 -0
  96. package/dist/server/fetchEvent.js +26 -0
  97. package/dist/server/handler.d.ts +6 -0
  98. package/dist/server/handler.js +218 -0
  99. package/dist/server/index.d.ts +9 -0
  100. package/{src/server/index.tsx → dist/server/index.jsx} +4 -19
  101. package/dist/server/manifest/client-manifest.d.ts +9 -0
  102. package/dist/server/manifest/client-manifest.js +6 -0
  103. package/dist/server/manifest/dev-client-manifest.d.ts +4 -0
  104. package/dist/server/manifest/dev-client-manifest.js +24 -0
  105. package/dist/server/manifest/dev-ssr-manifest.d.ts +5 -0
  106. package/dist/server/manifest/dev-ssr-manifest.js +23 -0
  107. package/dist/server/manifest/prod-client-manifest.d.ts +5 -0
  108. package/dist/server/manifest/prod-client-manifest.js +26 -0
  109. package/dist/server/manifest/prod-ssr-manifest.d.ts +6 -0
  110. package/dist/server/manifest/prod-ssr-manifest.js +85 -0
  111. package/dist/server/manifest/ssr-manifest.d.ts +4 -0
  112. package/dist/server/manifest/ssr-manifest.js +6 -0
  113. package/dist/server/routes.d.ts +23 -0
  114. package/dist/server/routes.js +74 -0
  115. package/dist/server/spa/StartServer.d.ts +9 -0
  116. package/dist/server/spa/StartServer.jsx +25 -0
  117. package/dist/server/spa/handler.d.ts +8 -0
  118. package/dist/server/spa/handler.js +20 -0
  119. package/{src/server/spa/index.tsx → dist/server/spa/index.d.ts} +0 -1
  120. package/dist/server/spa/index.jsx +5 -0
  121. package/dist/server/types.d.ts +75 -0
  122. package/dist/server/types.js +1 -0
  123. package/dist/server/util.d.ts +2 -0
  124. package/dist/server/util.js +8 -0
  125. package/dist/server/web-stream.d.ts +9 -0
  126. package/dist/server/web-stream.js +26 -0
  127. package/dist/shared/ErrorBoundary.d.ts +3 -0
  128. package/dist/shared/ErrorBoundary.jsx +36 -0
  129. package/dist/shared/GET.d.ts +5 -0
  130. package/dist/shared/GET.js +8 -0
  131. package/dist/shared/HttpHeader.d.ts +10 -0
  132. package/dist/shared/HttpHeader.jsx +38 -0
  133. package/dist/shared/HttpStatusCode.d.ts +9 -0
  134. package/dist/shared/HttpStatusCode.js +18 -0
  135. package/dist/shared/clientOnly.d.ts +12 -0
  136. package/dist/shared/clientOnly.js +27 -0
  137. package/dist/shared/dev-overlay/CodeView.d.ts +7 -0
  138. package/dist/shared/dev-overlay/CodeView.jsx +62 -0
  139. package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +9 -0
  140. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +226 -0
  141. package/dist/shared/dev-overlay/createStackFrame.d.ts +9 -0
  142. package/dist/shared/dev-overlay/createStackFrame.js +56 -0
  143. package/dist/shared/dev-overlay/download.d.ts +1 -0
  144. package/dist/shared/dev-overlay/download.js +6 -0
  145. package/dist/shared/dev-overlay/get-source-map.d.ts +2 -0
  146. package/dist/shared/dev-overlay/get-source-map.js +25 -0
  147. package/dist/shared/dev-overlay/icons.d.ts +28 -0
  148. package/dist/shared/dev-overlay/icons.jsx +150 -0
  149. package/dist/shared/dev-overlay/index.d.ts +5 -0
  150. package/dist/shared/dev-overlay/index.jsx +39 -0
  151. package/dist/shared/lazy.d.ts +3 -0
  152. package/dist/shared/lazy.js +42 -0
  153. package/dist/shared/serverFunction.d.ts +6 -0
  154. package/dist/shared/serverFunction.js +8 -0
  155. package/dist/utils/debounce.d.ts +4 -0
  156. package/dist/utils/debounce.js +10 -0
  157. package/env.d.ts +12 -0
  158. package/package.json +10 -5
  159. package/scripts/build.js +0 -15
  160. package/scripts/validate-imports.js +0 -316
  161. package/src/client/mount.ts +0 -1
  162. package/src/client/spa/index.tsx +0 -9
  163. package/src/config/constants.ts +0 -19
  164. package/src/config/dev-server.ts +0 -161
  165. package/src/config/env.ts +0 -105
  166. package/src/config/fs-router.ts +0 -162
  167. package/src/config/fs-routes/fs-watcher.ts +0 -66
  168. package/src/config/fs-routes/index.ts +0 -136
  169. package/src/config/fs-routes/router.ts +0 -184
  170. package/src/config/fs-routes/tree-shake.ts +0 -324
  171. package/src/config/index.ts +0 -239
  172. package/src/config/lazy.ts +0 -132
  173. package/src/config/manifest.ts +0 -120
  174. package/src/config/utils.ts +0 -5
  175. package/src/config/vite-utils.ts +0 -113
  176. package/src/directives/bubble-function-declaration.ts +0 -33
  177. package/src/directives/compile.ts +0 -54
  178. package/src/directives/generate-unique-name.ts +0 -22
  179. package/src/directives/get-descriptive-name.ts +0 -39
  180. package/src/directives/get-import-identifier.ts +0 -34
  181. package/src/directives/get-root-statement-path.ts +0 -14
  182. package/src/directives/index.ts +0 -233
  183. package/src/directives/is-statement-top-level.ts +0 -13
  184. package/src/directives/paths.ts +0 -63
  185. package/src/directives/plugin.ts +0 -389
  186. package/src/directives/remove-unused-variables.ts +0 -70
  187. package/src/directives/xxhash32.ts +0 -214
  188. package/src/env.d.ts +0 -17
  189. package/src/fns/client.ts +0 -141
  190. package/src/fns/handler.spec.ts +0 -85
  191. package/src/fns/handler.ts +0 -287
  192. package/src/fns/registration.ts +0 -19
  193. package/src/fns/serialization.ts +0 -250
  194. package/src/fns/server.ts +0 -46
  195. package/src/fns/shared.ts +0 -116
  196. package/src/http/index.ts +0 -216
  197. package/src/internal.d.ts +0 -14
  198. package/src/middleware/index.ts +0 -92
  199. package/src/router.tsx +0 -37
  200. package/src/server/StartServer.tsx +0 -58
  201. package/src/server/assets/index.ts +0 -70
  202. package/src/server/assets/render.tsx +0 -46
  203. package/src/server/collect-styles.ts +0 -70
  204. package/src/server/fetchEvent.spec.ts +0 -85
  205. package/src/server/fetchEvent.ts +0 -36
  206. package/src/server/handler.ts +0 -261
  207. package/src/server/manifest/client-manifest.ts +0 -8
  208. package/src/server/manifest/dev-client-manifest.ts +0 -21
  209. package/src/server/manifest/dev-ssr-manifest.ts +0 -23
  210. package/src/server/manifest/prod-client-manifest.ts +0 -21
  211. package/src/server/manifest/prod-ssr-manifest.ts +0 -109
  212. package/src/server/manifest/ssr-manifest.ts +0 -10
  213. package/src/server/routes.ts +0 -126
  214. package/src/server/spa/StartServer.tsx +0 -42
  215. package/src/server/spa/handler.ts +0 -29
  216. package/src/server/types.ts +0 -82
  217. package/src/server/util.ts +0 -12
  218. package/src/shared/ErrorBoundary.tsx +0 -52
  219. package/src/shared/GET.ts +0 -8
  220. package/src/shared/HttpHeader.tsx +0 -42
  221. package/src/shared/HttpStatusCode.ts +0 -27
  222. package/src/shared/clientOnly.ts +0 -44
  223. package/src/shared/dev-overlay/CodeView.tsx +0 -90
  224. package/src/shared/dev-overlay/DevOverlayDialog.tsx +0 -316
  225. package/src/shared/dev-overlay/createStackFrame.ts +0 -74
  226. package/src/shared/dev-overlay/download.ts +0 -6
  227. package/src/shared/dev-overlay/env.d.ts +0 -4
  228. package/src/shared/dev-overlay/get-source-map.ts +0 -33
  229. package/src/shared/dev-overlay/icons.tsx +0 -456
  230. package/src/shared/dev-overlay/index.tsx +0 -63
  231. package/src/shared/lazy.ts +0 -52
  232. package/src/shared/serverFunction.ts +0 -10
  233. package/src/utils/debounce.ts +0 -10
  234. package/src/virtual.d.ts +0 -27
  235. package/tsconfig.json +0 -24
  236. package/vitest.config.ts +0 -9
  237. /package/{src/client/index.tsx → dist/client/index.d.ts} +0 -0
  238. /package/{src → dist}/shared/dev-overlay/styles.css +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @solidjs/start
2
2
 
3
+ ## 2.0.0-beta.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 8af6304: Support for Vite 8.1 Experimental Bundled Dev Mode
8
+ - 9d91484: fix: don't crash when a server function throws an error whose message contains non-latin1 characters.
9
+ - 068b64c: Return a cancellation-safe web `ReadableStream` for streaming SSR in development. Returning Solid's
10
+ raw stream only rendered on Node; Bun and Deno coerced it to `[object Object]`.
11
+
12
+ ## 2.0.0-beta.9
13
+
14
+ ### Minor Changes
15
+
16
+ - f3e84ec: Add support for `server-only` and `client-only` modules
17
+
18
+ ### Patch Changes
19
+
20
+ - a8a2328: fix: mark `@solidjs/start/http` and `@solidjs/start/middleware` as `server-only` so importing them from client-reachable code fails loudly at dev/build time, instead of silently shipping them to the browser where they crashed hydration and broke unrelated actions/forms with no diagnostic (#2068)
21
+
22
+ ## 2.0.0-beta.8
23
+
24
+ ### Patch Changes
25
+
26
+ - ecc02be: fix: resolve server functions in dev when their route was reached through client-side navigation before its module was evaluated on the server
27
+ - 85b24b2: Use per-environment Vite plugin hook APIs for forward compatibility with Vite 9.
28
+
29
+ ## 2.0.0-beta.7
30
+
31
+ ### Patch Changes
32
+
33
+ - d2f0621: Support JavaScript projects whose app and client/server entries use `.jsx`.
34
+
35
+ ## 2.0.0-beta.6
36
+
37
+ ### Patch Changes
38
+
39
+ - 25769f2: Fix Vite preview for non-HTML responses and projects whose server build uses an `.mjs`
40
+ entry.
41
+
42
+ ## 2.0.0-beta.5
43
+
44
+ ### Patch Changes
45
+
46
+ - eb73dd5: Use `oxc-parser` to analyze filesystem route exports.
47
+
48
+ ## 2.0.0-beta.4
49
+
50
+ ### Patch Changes
51
+
52
+ - 21fdb2c: Update `h3` to `2.0.1-rc.25`.
53
+
54
+ ## 2.0.0-beta.3
55
+
56
+ ### Patch Changes
57
+
58
+ - 12dc2d3: Bundle `h3` and `cookie-es` into server builds to avoid resolving incompatible hoisted versions
59
+
60
+ ## 2.0.0-beta.2
61
+
62
+ ### Patch Changes
63
+
64
+ - 3e961e0: Require Vite 8
65
+ - 11907a2: Fix published package missing `dist/`: pnpm 11 respects `.gitignore` when packing a package without a `files` field, so `2.0.0-beta.1` was published without its build output. Add an explicit `files` field.
66
+
3
67
  ## 2.0.0-beta.1
4
68
 
5
69
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ import type { JSX } from "solid-js";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
5
+ */
6
+ export declare function StartClient(): JSX.Element;
7
+ export declare function StartClientTanstack(): JSX.Element;
@@ -1,34 +1,26 @@
1
1
  // @refresh skip
2
2
  import App from "solid-start:app";
3
- import type { JSX } from "solid-js";
4
- import { ErrorBoundary } from "../shared/ErrorBoundary.tsx";
5
-
6
- function Dummy(props: { children: JSX.Element }) {
7
- return props.children;
3
+ import { ErrorBoundary } from "../shared/ErrorBoundary.jsx";
4
+ function Dummy(props) {
5
+ return props.children;
8
6
  }
9
-
10
7
  /**
11
8
  *
12
9
  * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
13
10
  */
14
11
  export function StartClient() {
15
- return (
16
- <Dummy>
12
+ return (<Dummy>
17
13
  <Dummy>
18
14
  <ErrorBoundary>
19
15
  <App />
20
16
  </ErrorBoundary>
21
17
  </Dummy>
22
- </Dummy>
23
- );
18
+ </Dummy>);
24
19
  }
25
-
26
20
  export function StartClientTanstack() {
27
- return (
28
- <Dummy>
21
+ return (<Dummy>
29
22
  <ErrorBoundary>
30
23
  <App />
31
24
  </ErrorBoundary>
32
- </Dummy>
33
- );
25
+ </Dummy>);
34
26
  }
@@ -0,0 +1,2 @@
1
+ export { mount } from "./mount.js";
2
+ export { StartClient, StartClientTanstack } from "./StartClient.jsx";
@@ -0,0 +1 @@
1
+ export { hydrate as mount } from "solid-js/web";
@@ -0,0 +1 @@
1
+ export { hydrate as mount } from "solid-js/web";
@@ -0,0 +1,4 @@
1
+ import type { JSX } from "solid-js";
2
+ import { type MountableElement } from "solid-js/web";
3
+ export declare function mount(fn: () => JSX.Element, el: MountableElement): void;
4
+ export { StartClient } from "../StartClient.tsx";
@@ -0,0 +1,5 @@
1
+ import { render } from "solid-js/web";
2
+ export function mount(fn, el) {
3
+ render(fn, el);
4
+ }
5
+ export { StartClient } from "../StartClient.jsx";
@@ -0,0 +1,14 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Supports `server-only` and `client-only` marker modules (#2162): importing
4
+ * `server-only` from a client module (or `client-only` from a server module)
5
+ * fails at resolve time; in the allowed environment the marker resolves to an
6
+ * empty module.
7
+ *
8
+ * Start's own server-only entry points (`@solidjs/start/http`,
9
+ * `@solidjs/start/middleware`) import `server-only` themselves, so pulling
10
+ * them into the client bundle fails loudly instead of shipping server code to
11
+ * the browser, where it crashed hydration and broke unrelated actions/forms
12
+ * with no diagnostic (https://github.com/solidjs/solid-start/issues/2068).
13
+ */
14
+ export declare function boundaryModules(): Plugin;
@@ -0,0 +1,41 @@
1
+ const VIRTUAL_ID = "\0solid-start:boundary-modules:id";
2
+ /**
3
+ * Supports `server-only` and `client-only` marker modules (#2162): importing
4
+ * `server-only` from a client module (or `client-only` from a server module)
5
+ * fails at resolve time; in the allowed environment the marker resolves to an
6
+ * empty module.
7
+ *
8
+ * Start's own server-only entry points (`@solidjs/start/http`,
9
+ * `@solidjs/start/middleware`) import `server-only` themselves, so pulling
10
+ * them into the client bundle fails loudly instead of shipping server code to
11
+ * the browser, where it crashed hydration and broke unrelated actions/forms
12
+ * with no diagnostic (https://github.com/solidjs/solid-start/issues/2068).
13
+ */
14
+ export function boundaryModules() {
15
+ return {
16
+ name: "solid-start:boundary-modules",
17
+ enforce: "pre",
18
+ resolveId(id, importer, { ssr }) {
19
+ if (id === "server-only") {
20
+ if (!ssr)
21
+ this.error(`Attempt to import 'server-only' in a client module: ${importer}. ` +
22
+ `Code that uses this module must run only on the server: mark it with ` +
23
+ `"use server", or make sure it is only imported by server code.`);
24
+ }
25
+ else if (id === "client-only") {
26
+ if (ssr)
27
+ this.error(`Attempt to import 'client-only' in a server module: ${importer}. ` +
28
+ `Code that uses this module must run only in the browser: make sure it ` +
29
+ `is only imported by client code (e.g. wrap components with clientOnly()).`);
30
+ }
31
+ else {
32
+ return null;
33
+ }
34
+ return VIRTUAL_ID;
35
+ },
36
+ load(id) {
37
+ if (id === VIRTUAL_ID)
38
+ return "export {}";
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,16 @@
1
+ export declare const DEFAULT_EXTENSIONS: string[];
2
+ export declare const CLIENT_BASE_PATH = "_build";
3
+ export declare const VIRTUAL_MODULES: {
4
+ readonly clientViteManifest: "solid-start:client-vite-manifest";
5
+ readonly getClientManifest: "solid-start:get-client-manifest";
6
+ readonly getManifest: "solid-start:get-manifest";
7
+ readonly middleware: "solid-start:middleware";
8
+ readonly serverFnManifest: "solid-start:server-fn-manifest";
9
+ readonly clientEntry: "solid-start:client-entry";
10
+ readonly serverEntry: "solid-start:server-entry";
11
+ readonly app: "solid-start:app";
12
+ };
13
+ export declare const VITE_ENVIRONMENTS: {
14
+ client: "client";
15
+ server: "ssr";
16
+ };
@@ -0,0 +1,16 @@
1
+ export const DEFAULT_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
2
+ export const CLIENT_BASE_PATH = "_build";
3
+ export const VIRTUAL_MODULES = {
4
+ clientViteManifest: "solid-start:client-vite-manifest",
5
+ getClientManifest: "solid-start:get-client-manifest",
6
+ getManifest: "solid-start:get-manifest",
7
+ middleware: "solid-start:middleware",
8
+ serverFnManifest: "solid-start:server-fn-manifest",
9
+ clientEntry: "solid-start:client-entry",
10
+ serverEntry: "solid-start:server-entry",
11
+ app: "solid-start:app",
12
+ };
13
+ export const VITE_ENVIRONMENTS = {
14
+ client: "client",
15
+ server: "ssr",
16
+ };
@@ -0,0 +1,4 @@
1
+ import { type PluginOption } from "vite";
2
+ export declare function devServer(serverEntryPath: string): Array<PluginOption>;
3
+ export declare function resolvePreviewServerEntry(root: string): string;
4
+ export declare function isHtmlResponse(response: Response): boolean;
@@ -0,0 +1,146 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { existsSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { pathToFileURL } from "node:url";
12
+ import { NodeRequest, sendNodeResponse } from "srvx/node";
13
+ import { isRunnableDevEnvironment, } from "vite";
14
+ import { VITE_ENVIRONMENTS } from "./constants.js";
15
+ export function devServer(serverEntryPath) {
16
+ return [
17
+ {
18
+ name: "solid-start-dev-server",
19
+ configurePreviewServer(server) {
20
+ const serverEntryUrl = pathToFileURL(resolvePreviewServerEntry(server.config.root)).href;
21
+ return () => {
22
+ server.middlewares.use(async (req, res) => {
23
+ const webReq = new NodeRequest({ req, res });
24
+ const def = await import(__rewriteRelativeImportExtension(serverEntryUrl, true));
25
+ const webRes = await def.default.fetch(webReq);
26
+ if (isHtmlResponse(webRes)) {
27
+ res.setHeader("content-encoding", "identity");
28
+ }
29
+ sendNodeResponse(res, webRes);
30
+ });
31
+ };
32
+ },
33
+ configureServer(viteDevServer) {
34
+ globalThis.VITE_DEV_SERVER = viteDevServer;
35
+ return async () => {
36
+ if (viteDevServer.config.server.middlewareMode)
37
+ return;
38
+ const serverEnv = viteDevServer.environments[VITE_ENVIRONMENTS.server];
39
+ if (!serverEnv)
40
+ throw new Error("Server environment not found");
41
+ if (
42
+ // do not check via `isFetchableDevEnvironment` since nitro does implement the `FetchableDevEnvironment` interface but not via inheritance (which this helper checks)
43
+ "dispatchFetch" in serverEnv)
44
+ return;
45
+ // another plugin is controlling the dev server
46
+ if (!isRunnableDevEnvironment(serverEnv)) {
47
+ return;
48
+ }
49
+ globalThis.USING_SOLID_START_DEV_SERVER = true;
50
+ removeHtmlMiddlewares(viteDevServer);
51
+ viteDevServer.middlewares.use(async (req, res) => {
52
+ if (req.originalUrl) {
53
+ req.url = req.originalUrl;
54
+ }
55
+ const webReq = new NodeRequest({ req, res });
56
+ try {
57
+ const serverEntry = await serverEnv.runner.import(serverEntryPath);
58
+ const webRes = await serverEntry.default.fetch(webReq);
59
+ return sendNodeResponse(res, webRes);
60
+ }
61
+ catch (e) {
62
+ console.error(e);
63
+ viteDevServer.ssrFixStacktrace(e);
64
+ if (webReq.headers.get("content-type")?.includes("application/json")) {
65
+ return sendNodeResponse(res, Response.json({
66
+ status: 500,
67
+ error: "Internal Server Error",
68
+ message: "An unexpected error occurred. Please try again later.",
69
+ timestamp: new Date().toISOString(),
70
+ }, {
71
+ status: 500,
72
+ headers: {
73
+ "Content-Type": "application/json",
74
+ },
75
+ }));
76
+ }
77
+ return sendNodeResponse(res, new Response(`
78
+ <!DOCTYPE html>
79
+ <html lang="en">
80
+ <head>
81
+ <meta charset="UTF-8" />
82
+ <title>Error</title>
83
+ <script type="module">
84
+ import { ErrorOverlay } from '/@vite/client'
85
+ document.body.appendChild(new ErrorOverlay(${JSON.stringify(prepareError(req, e)).replace(/</g, "\\u003c")}))
86
+ </script>
87
+ </head>
88
+ <body>
89
+ </body>
90
+ </html>
91
+ `, {
92
+ status: 500,
93
+ headers: { "Content-Type": "text/html" },
94
+ }));
95
+ }
96
+ });
97
+ };
98
+ },
99
+ },
100
+ ];
101
+ }
102
+ export function resolvePreviewServerEntry(root) {
103
+ const serverDirectory = join(root, "dist/server");
104
+ const serverEntry = ["js", "mjs"]
105
+ .map(extension => join(serverDirectory, `entry-server.${extension}`))
106
+ .find(existsSync);
107
+ if (!serverEntry) {
108
+ throw new Error(`Could not find the SolidStart server entry in ${serverDirectory}`);
109
+ }
110
+ return serverEntry;
111
+ }
112
+ export function isHtmlResponse(response) {
113
+ return response.headers.get("content-type")?.startsWith("text/html") ?? false;
114
+ }
115
+ /**
116
+ * Removes Vite internal middleware
117
+ *
118
+ * @param server
119
+ */
120
+ function removeHtmlMiddlewares(server) {
121
+ const html_middlewares = [
122
+ "viteIndexHtmlMiddleware",
123
+ "vite404Middleware",
124
+ "viteSpaFallbackMiddleware",
125
+ ];
126
+ for (let i = server.middlewares.stack.length - 1; i > 0; i--) {
127
+ if (html_middlewares.includes(
128
+ // @ts-expect-error
129
+ server.middlewares.stack[i].handle.name)) {
130
+ server.middlewares.stack.splice(i, 1);
131
+ }
132
+ }
133
+ }
134
+ /**
135
+ * Formats error for SSR message in error overlay
136
+ * @param req
137
+ * @param error
138
+ * @returns
139
+ */
140
+ function prepareError(req, error) {
141
+ const e = error;
142
+ return {
143
+ message: `An error occured while server rendering ${req.url}:\n\n\t${typeof e === "string" ? e : e.message} `,
144
+ stack: typeof e === "string" ? "" : e.stack,
145
+ };
146
+ }
@@ -0,0 +1,19 @@
1
+ import { type Plugin } from "vite";
2
+ declare const LOADERS: {
3
+ node: string;
4
+ "cloudflare-workers": string;
5
+ "netlify-edge": string;
6
+ };
7
+ export interface EnvPluginOptions {
8
+ server?: {
9
+ runtime?: keyof typeof LOADERS | (string & {});
10
+ load?: (mode: string) => Record<string, string>;
11
+ prefix?: string;
12
+ };
13
+ client?: {
14
+ load?: (mode: string) => Record<string, string>;
15
+ prefix?: string;
16
+ };
17
+ }
18
+ export declare function envPlugin(options?: EnvPluginOptions): Plugin;
19
+ export {};
@@ -0,0 +1,85 @@
1
+ import { loadEnv } from "vite";
2
+ import { parseIdQuery } from "./utils.js";
3
+ const LOADERS = {
4
+ node: `export default key => process.env[key];`,
5
+ "cloudflare-workers": `import { env } from 'cloudflare:workers';export default key => env[key];`,
6
+ "netlify-edge": `export default key => Netlify.env.get(key);`,
7
+ };
8
+ const SERVER_ENV = "env:server";
9
+ const CLIENT_ENV = "env:client";
10
+ const SERVER_RUNTIME_ENV = `${SERVER_ENV}/runtime`;
11
+ const SERVER_RUNTIME_LOADER = `${SERVER_RUNTIME_ENV}/loader`;
12
+ const DEFAULT_SERVER_PREFIX = "SERVER_";
13
+ const DEFAULT_CLIENT_PREFIX = "CLIENT_";
14
+ const SERVER_ONLY_MODULE = `throw new Error('Attempt to load server-only environment variables in client runtime.');`;
15
+ const SERVER_RUNTIME_CODE = `import load from '${SERVER_RUNTIME_LOADER}';
16
+
17
+ export default new Proxy({}, {
18
+ get(_, key) {
19
+ return load(key);
20
+ },
21
+ })`;
22
+ function convertObjectToModule(object) {
23
+ let result = "";
24
+ for (const key in object) {
25
+ result += `export const ${key} = ${JSON.stringify(object[key])};`;
26
+ }
27
+ return result;
28
+ }
29
+ export function envPlugin(options) {
30
+ const currentOptions = options ?? {};
31
+ let env;
32
+ const serverPrefix = currentOptions.server?.prefix ?? DEFAULT_SERVER_PREFIX;
33
+ const clientPrefix = currentOptions.client?.prefix ?? DEFAULT_CLIENT_PREFIX;
34
+ const runtime = options?.server?.runtime ?? "node";
35
+ const runtimeCode = runtime in LOADERS ? LOADERS[runtime] : runtime;
36
+ return {
37
+ name: "solid-start:env",
38
+ enforce: "pre",
39
+ configResolved(config) {
40
+ env = config.mode !== "production" ? "development" : "production";
41
+ },
42
+ resolveId(id) {
43
+ const { filename } = parseIdQuery(id);
44
+ if (filename === SERVER_ENV ||
45
+ filename === CLIENT_ENV ||
46
+ filename === SERVER_RUNTIME_ENV ||
47
+ filename === SERVER_RUNTIME_LOADER) {
48
+ return id;
49
+ }
50
+ return undefined;
51
+ },
52
+ load(id) {
53
+ const { filename } = parseIdQuery(id);
54
+ const isServer = this.environment.config.consumer === "server";
55
+ if (filename === SERVER_ENV) {
56
+ if (!isServer) {
57
+ return SERVER_ONLY_MODULE;
58
+ }
59
+ const vars = currentOptions.server?.load
60
+ ? currentOptions.server.load(env)
61
+ : loadEnv(env, '.', serverPrefix);
62
+ return convertObjectToModule(vars);
63
+ }
64
+ if (filename === CLIENT_ENV) {
65
+ const vars = currentOptions.client?.load
66
+ ? currentOptions.client.load(env)
67
+ : loadEnv(env, '.', clientPrefix);
68
+ return convertObjectToModule(vars);
69
+ }
70
+ if (filename === SERVER_RUNTIME_LOADER) {
71
+ if (!isServer) {
72
+ return SERVER_ONLY_MODULE;
73
+ }
74
+ return runtimeCode;
75
+ }
76
+ if (filename === SERVER_RUNTIME_ENV) {
77
+ if (!isServer) {
78
+ return SERVER_ONLY_MODULE;
79
+ }
80
+ return SERVER_RUNTIME_CODE;
81
+ }
82
+ return undefined;
83
+ },
84
+ };
85
+ }
@@ -0,0 +1,37 @@
1
+ import { BaseFileSystemRouter, type FileSystemRouterConfig } from "./fs-routes/router.ts";
2
+ export declare class SolidStartClientFileRouter extends BaseFileSystemRouter {
3
+ toPath(src: string): string;
4
+ toRoute(src: string): {
5
+ page: boolean;
6
+ $component: {
7
+ src: string;
8
+ pick: string[];
9
+ };
10
+ $$route: {
11
+ src: string;
12
+ pick: string[];
13
+ } | undefined;
14
+ path: string;
15
+ } | undefined;
16
+ }
17
+ export declare class SolidStartServerFileRouter extends BaseFileSystemRouter {
18
+ config: FileSystemRouterConfig & {
19
+ dataOnly?: boolean;
20
+ };
21
+ constructor(config: FileSystemRouterConfig & {
22
+ dataOnly?: boolean;
23
+ });
24
+ toPath(src: string): string;
25
+ toRoute(src: string): {
26
+ page: boolean;
27
+ $component: {
28
+ src: string;
29
+ pick: string[];
30
+ } | undefined;
31
+ $$route: {
32
+ src: string;
33
+ pick: string[];
34
+ } | undefined;
35
+ path: string;
36
+ } | undefined;
37
+ }