@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
@@ -0,0 +1,39 @@
1
+ // @refresh skip
2
+ import { createEffect, createSignal, ErrorBoundary, onCleanup, resetErrorBoundaries, Show, } from "solid-js";
3
+ import clientOnly from "../clientOnly.js";
4
+ import { HttpStatusCode } from "../HttpStatusCode.js";
5
+ const DevOverlayDialog = import.meta.env.PROD
6
+ ? () => <></>
7
+ : clientOnly(() => import("./DevOverlayDialog"), { lazy: true });
8
+ export function DevOverlay(props) {
9
+ const [errors, setErrors] = createSignal([]);
10
+ function resetError() {
11
+ setErrors([]);
12
+ resetErrorBoundaries();
13
+ }
14
+ function pushError(error) {
15
+ console.error(error);
16
+ setErrors(current => [error, ...current]);
17
+ }
18
+ createEffect(() => {
19
+ const onErrorEvent = (error) => {
20
+ pushError(error.error ?? error);
21
+ };
22
+ window.addEventListener("error", onErrorEvent);
23
+ onCleanup(() => {
24
+ window.removeEventListener("error", onErrorEvent);
25
+ });
26
+ });
27
+ return (<>
28
+ <ErrorBoundary fallback={error => {
29
+ pushError(error);
30
+ return <HttpStatusCode code={500}/>;
31
+ }}>
32
+ {props.children}
33
+ </ErrorBoundary>
34
+ <Show when={errors().length}>
35
+ <HttpStatusCode code={500}/>
36
+ <DevOverlayDialog errors={errors()} resetError={resetError}/>
37
+ </Show>
38
+ </>);
39
+ }
@@ -0,0 +1,3 @@
1
+ import { lazy as solidLazy } from "solid-js";
2
+ declare const lazy: typeof solidLazy;
3
+ export default lazy;
@@ -0,0 +1,42 @@
1
+ import { lazy as solidLazy } from "solid-js";
2
+ import { getRequestEvent, isServer } from "solid-js/web";
3
+ import { getManifest } from "solid-start:get-manifest";
4
+ import { useAssets } from "../server/assets/index.js";
5
+ const assetsById = {};
6
+ const getAssets = async (id) => {
7
+ if (assetsById[id])
8
+ return assetsById[id];
9
+ const manifest = getManifest(import.meta.env.SSR && import.meta.env.DEV ? "ssr" : "client");
10
+ const assets = await manifest.getAssets(id);
11
+ if (import.meta.env.PROD)
12
+ assetsById[id] = assets;
13
+ return assets;
14
+ };
15
+ const withAssets = function (fn) {
16
+ const wrapper = async () => {
17
+ const mod = await fn();
18
+ // This id$$ export is generated by the lazy vite plugin
19
+ const id = mod.id$$;
20
+ if (!id)
21
+ return mod;
22
+ if (!mod.default) {
23
+ console.error(`Module ${id} does not export default`);
24
+ return { default: () => [] };
25
+ }
26
+ const assets = await getAssets(id);
27
+ if (!assets.length)
28
+ return mod;
29
+ return {
30
+ default: (props) => {
31
+ const { nonce } = getRequestEvent();
32
+ useAssets(assets, nonce);
33
+ return mod.default(props);
34
+ },
35
+ };
36
+ };
37
+ return wrapper;
38
+ };
39
+ const lazy = !isServer
40
+ ? solidLazy
41
+ : (fn) => solidLazy(withAssets(fn));
42
+ export default lazy;
@@ -0,0 +1,6 @@
1
+ import type { ServerFunctionMeta } from "../server/types.ts";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get-server-function-meta
5
+ */
6
+ export declare function getServerFunctionMeta(): ServerFunctionMeta | undefined;
@@ -0,0 +1,8 @@
1
+ import { getRequestEvent } from "solid-js/web";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get-server-function-meta
5
+ */
6
+ export function getServerFunctionMeta() {
7
+ return getRequestEvent()?.locals.serverFunctionMeta;
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a debounced function that delays the invocation of a function
3
+ */
4
+ export declare const debounce: <T extends (...args: any[]) => void>(cb: T, debounceMs: number) => (...args: Parameters<T>) => void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Creates a debounced function that delays the invocation of a function
3
+ */
4
+ export const debounce = (cb, debounceMs) => {
5
+ let timeout;
6
+ return (...args) => {
7
+ clearTimeout(timeout);
8
+ timeout = setTimeout(() => cb(...args), debounceMs);
9
+ };
10
+ };
package/env.d.ts CHANGED
@@ -7,3 +7,15 @@ declare namespace App {
7
7
  [key: string | symbol]: any;
8
8
  }
9
9
  }
10
+
11
+ /**
12
+ * Import `server-only` to ensure this module is never bundled for the client.
13
+ * Importing it in a client module will throw a build error.
14
+ */
15
+ declare module "server-only" {}
16
+
17
+ /**
18
+ * Import `client-only` to ensure this module is never bundled for the server.
19
+ * Importing it in a server module will throw a build error.
20
+ */
21
+ declare module "client-only" {}
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.10",
4
4
  "type": "module",
5
+ "files": [
6
+ "dist",
7
+ "env.d.ts",
8
+ "CHANGELOG.md"
9
+ ],
5
10
  "repository": {
6
11
  "type": "git",
7
12
  "url": "git+https://github.com/solidjs/solid-start.git",
@@ -34,12 +39,11 @@
34
39
  "cookie-es": "^2.0.0",
35
40
  "defu": "^6.1.4",
36
41
  "error-stack-parser": "^2.1.4",
37
- "es-module-lexer": "^2.0.0",
38
- "esbuild": "^0.27.4",
39
42
  "fast-glob": "^3.3.3",
40
- "h3": "2.0.1-rc.16",
43
+ "h3": "^2.0.1-rc.25",
41
44
  "html-to-image": "^1.11.13",
42
45
  "micromatch": "^4.0.8",
46
+ "oxc-parser": "^0.139.0",
43
47
  "path-to-regexp": "^8.3.0",
44
48
  "pathe": "^2.0.3",
45
49
  "radix3": "^1.1.2",
@@ -62,13 +66,14 @@
62
66
  "vitest": "^4.1.0"
63
67
  },
64
68
  "peerDependencies": {
65
- "vite": "^7 || ^8"
69
+ "vite": "^8 || ^9"
66
70
  },
67
71
  "scripts": {
68
72
  "build": "pnpm validate-imports && tsc && node scripts/build.js",
69
73
  "dev": "tsc --watch",
70
74
  "test": "vitest",
71
75
  "test:ci": "vitest run",
76
+ "typecheck": "tsc --noEmit",
72
77
  "typecheck:dist": "pnpm build && pnpx @arethetypeswrong/cli --pack . --profile esm-only",
73
78
  "validate-imports": "node scripts/validate-imports.js"
74
79
  }
package/scripts/build.js DELETED
@@ -1,15 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import * as path from "node:path";
3
- import glob from "fast-glob";
4
-
5
- const files = await glob("**/*.{js,css}", { cwd: `${process.cwd()}/src` });
6
-
7
- await Promise.all(
8
- files.map(file =>
9
- fs.cp(
10
- path.join(import.meta.dirname, "../src", file),
11
- path.join(import.meta.dirname, "../dist", file),
12
- { recursive: true },
13
- ),
14
- ),
15
- );
@@ -1,316 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Import Extension Validation Script for SolidStart
5
- *
6
- * This script validates that all relative imports in the src/ directory have
7
- * explicit file extensions, which is mandated by Node.js ESM (ES Modules).
8
- *
9
- * Node.js requires explicit file extensions for relative imports when using
10
- * ES modules to avoid ambiguity and improve performance. This script ensures
11
- * compliance with this requirement.
12
- *
13
- * Features:
14
- * - Scans all .ts and .tsx files in the src/ directory recursively
15
- * - Detects relative imports (starting with ./ or ../) without extensions
16
- * - Prevents .js/.jsx imports in TypeScript files (should use .ts/.tsx)
17
- * - Ignores commented code, CSS imports, and dynamic imports (handled by bundlers)
18
- * - Provides detailed error reporting with line numbers and suggestions
19
- * - Exits with appropriate status codes for CI/CD integration
20
- *
21
- * Usage:
22
- * npm run validate-imports
23
- *
24
- * Exit codes:
25
- * 0 - All relative imports have valid extensions
26
- * 1 - Found relative imports without extensions
27
- *
28
- * Valid extensions for TypeScript files: .ts, .tsx, .json
29
- * Invalid extensions for TypeScript files: .js, .jsx (use .ts/.tsx instead)
30
- *
31
- * @example
32
- * // ❌ Invalid - missing extension
33
- * import { config } from "./config/index";
34
- *
35
- * // ❌ Invalid - .js extension in TypeScript file
36
- * import { config } from "./config/index.js";
37
- *
38
- * // ✅ Valid - has .ts extension
39
- * import { config } from "./config/index.ts";
40
- *
41
- * // ✅ Valid - external package import (no extension needed)
42
- * import { something } from "external-package";
43
- */
44
-
45
- import { readFileSync, readdirSync, statSync } from "node:fs";
46
- import { join, dirname, extname } from "node:path";
47
- import { fileURLToPath } from "node:url";
48
-
49
- const __filename = fileURLToPath(import.meta.url);
50
- const __dirname = dirname(__filename);
51
-
52
- // Configuration
53
- const SRC_DIR = join(__dirname, "..", "src");
54
- const VALID_EXTENSIONS = [".ts", ".tsx", ".json"];
55
- const INVALID_EXTENSIONS = [".js", ".jsx"];
56
- const FILE_EXTENSIONS = [".ts", ".tsx"];
57
-
58
- /**
59
- * Recursively find all files with specified extensions
60
- */
61
- function findFiles(dir, extensions, files = []) {
62
- try {
63
- const entries = readdirSync(dir);
64
-
65
- for (const entry of entries) {
66
- const fullPath = join(dir, entry);
67
- const stat = statSync(fullPath);
68
-
69
- if (stat.isDirectory()) {
70
- findFiles(fullPath, extensions, files);
71
- } else if (extensions.includes(extname(entry))) {
72
- files.push(fullPath);
73
- }
74
- }
75
- } catch (error) {
76
- console.error(`Error reading directory ${dir}: ${error.message}`);
77
- }
78
-
79
- return files;
80
- }
81
-
82
- /**
83
- * Check if a path is a relative import (starts with . or ..)
84
- */
85
- function isRelativeImport(path) {
86
- return path.startsWith("./") || path.startsWith("../");
87
- }
88
-
89
- /**
90
- * Check if an import path has a valid file extension
91
- */
92
- function hasValidExtension(path) {
93
- return VALID_EXTENSIONS.some(ext => path.endsWith(ext));
94
- }
95
-
96
- /**
97
- * Check if an import path has an invalid extension for TypeScript files
98
- */
99
- function hasInvalidExtension(path) {
100
- return INVALID_EXTENSIONS.some(ext => path.endsWith(ext));
101
- }
102
-
103
- /**
104
- * Extract import/export statements from file content
105
- * Matches both import and export statements with from clauses
106
- */
107
- function extractImportExportStatements(content, filePath) {
108
- const statements = [];
109
- const lines = content.split("\n");
110
-
111
- // Regex patterns for different import/export statements
112
- const patterns = [
113
- // Standard imports: import { ... } from '...'
114
- /import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"`]([^'"`]+)['"`]/g,
115
- // Export from: export { ... } from '...'
116
- /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"`]([^'"`]+)['"`]/g,
117
- // Export default from: export { default } from '...'
118
- /export\s+\{\s*default\s*\}\s+from\s+['"`]([^'"`]+)['"`]/g,
119
- // Note: Dynamic imports are excluded as they're handled by bundlers
120
- ];
121
-
122
- lines.forEach((line, lineNumber) => {
123
- const trimmedLine = line.trim();
124
-
125
- // Skip commented lines, dynamic imports, and TypeScript type-only imports in d.ts files
126
- if (
127
- trimmedLine.startsWith("//") ||
128
- trimmedLine.startsWith("/*") ||
129
- trimmedLine.startsWith("*") ||
130
- (filePath.endsWith(".d.ts") && trimmedLine.includes("import(")) ||
131
- // Skip CSS imports as they're handled by bundlers
132
- /import\s+['"`][^'"`]*\.css['"`]/.test(trimmedLine) ||
133
- // Skip dynamic imports as they're handled by bundlers
134
- /import\s*\(\s*['"`]/.test(trimmedLine)
135
- ) {
136
- return;
137
- }
138
-
139
- patterns.forEach(pattern => {
140
- let match;
141
- // Reset regex lastIndex to avoid issues with global flag
142
- pattern.lastIndex = 0;
143
- while ((match = pattern.exec(line)) !== null) {
144
- const importPath = match[1];
145
- if (importPath) {
146
- statements.push({
147
- path: importPath,
148
- line: lineNumber + 1,
149
- fullLine: line.trim(),
150
- filePath,
151
- });
152
- }
153
- }
154
- });
155
- });
156
-
157
- return statements;
158
- }
159
-
160
- /**
161
- * Validate a single file for relative imports without extensions
162
- */
163
- function validateFile(filePath) {
164
- const errors = [];
165
-
166
- try {
167
- const content = readFileSync(filePath, "utf8");
168
- const statements = extractImportExportStatements(content, filePath);
169
-
170
- statements.forEach(statement => {
171
- if (isRelativeImport(statement.path)) {
172
- if (hasInvalidExtension(statement.path)) {
173
- errors.push({
174
- file: filePath,
175
- line: statement.line,
176
- importPath: statement.path,
177
- fullLine: statement.fullLine,
178
- type: "invalid-extension",
179
- });
180
- } else if (!hasValidExtension(statement.path)) {
181
- errors.push({
182
- file: filePath,
183
- line: statement.line,
184
- importPath: statement.path,
185
- fullLine: statement.fullLine,
186
- type: "missing-extension",
187
- });
188
- }
189
- }
190
- });
191
- } catch (error) {
192
- console.error(`Error reading file ${filePath}: ${error.message}`);
193
- }
194
-
195
- return errors;
196
- }
197
-
198
- /**
199
- * Main validation function
200
- */
201
- function validateImports() {
202
- console.log("🔍 Validating relative imports in src/ directory...\n");
203
-
204
- // Find all TypeScript/TSX files in src directory
205
- const files = findFiles(SRC_DIR, FILE_EXTENSIONS);
206
-
207
- if (files.length === 0) {
208
- console.log("⚠️ No TypeScript files found in src/ directory");
209
- process.exit(0);
210
- }
211
-
212
- console.log(`📁 Scanning ${files.length} files...\n`);
213
-
214
- let totalErrors = 0;
215
- const errorsByFile = new Map();
216
-
217
- // Validate each file
218
- files.forEach(file => {
219
- const errors = validateFile(file);
220
- if (errors.length > 0) {
221
- errorsByFile.set(file, errors);
222
- totalErrors += errors.length;
223
- }
224
- });
225
-
226
- // Report results
227
- if (totalErrors === 0) {
228
- console.log("✅ All relative imports have valid extensions!");
229
- process.exit(0);
230
- } else {
231
- const missingExtensionErrors = [];
232
- const invalidExtensionErrors = [];
233
-
234
- errorsByFile.forEach(errors => {
235
- errors.forEach(error => {
236
- if (error.type === "missing-extension") {
237
- missingExtensionErrors.push(error);
238
- } else if (error.type === "invalid-extension") {
239
- invalidExtensionErrors.push(error);
240
- }
241
- });
242
- });
243
-
244
- if (missingExtensionErrors.length > 0) {
245
- console.log(
246
- `❌ Found ${missingExtensionErrors.length} relative import(s) without extensions:\n`,
247
- );
248
-
249
- const missingByFile = new Map();
250
- missingExtensionErrors.forEach(error => {
251
- if (!missingByFile.has(error.file)) {
252
- missingByFile.set(error.file, []);
253
- }
254
- missingByFile.get(error.file).push(error);
255
- });
256
-
257
- missingByFile.forEach((errors, file) => {
258
- const relativePath = file.replace(process.cwd(), "").replace(/^\//, "");
259
- console.log(`📄 ${relativePath}:`);
260
-
261
- errors.forEach(error => {
262
- console.log(` Line ${error.line}: ${error.importPath}`);
263
- console.log(` ${error.fullLine}`);
264
- console.log(
265
- ` ${"".padStart(error.fullLine.indexOf(error.importPath), " ")}${"".padStart(error.importPath.length, "^")}`,
266
- );
267
- });
268
- console.log("");
269
- });
270
- }
271
-
272
- if (invalidExtensionErrors.length > 0) {
273
- console.log(
274
- `❌ Found ${invalidExtensionErrors.length} relative import(s) with invalid extensions:\n`,
275
- );
276
-
277
- const invalidByFile = new Map();
278
- invalidExtensionErrors.forEach(error => {
279
- if (!invalidByFile.has(error.file)) {
280
- invalidByFile.set(error.file, []);
281
- }
282
- invalidByFile.get(error.file).push(error);
283
- });
284
-
285
- invalidByFile.forEach((errors, file) => {
286
- const relativePath = file.replace(process.cwd(), "").replace(/^\//, "");
287
- console.log(`📄 ${relativePath}:`);
288
-
289
- errors.forEach(error => {
290
- console.log(` Line ${error.line}: ${error.importPath}`);
291
- console.log(` ${error.fullLine}`);
292
- console.log(
293
- ` ${"".padStart(error.fullLine.indexOf(error.importPath), " ")}${"".padStart(error.importPath.length, "^")}`,
294
- );
295
- });
296
- console.log("");
297
- });
298
- }
299
-
300
- console.log("💡 Tips:");
301
- if (missingExtensionErrors.length > 0) {
302
- console.log(' - Add file extensions to relative imports (e.g., "./file" → "./file.ts")');
303
- }
304
- if (invalidExtensionErrors.length > 0) {
305
- console.log(" - Replace .js/.jsx with .ts/.tsx in TypeScript files");
306
- }
307
- console.log(" - This is required by Node.js ESM modules");
308
- console.log(" - Valid extensions for TypeScript files: " + VALID_EXTENSIONS.join(", "));
309
- console.log(" - Invalid extensions for TypeScript files: " + INVALID_EXTENSIONS.join(", "));
310
-
311
- process.exit(1);
312
- }
313
- }
314
-
315
- // Run the validation
316
- validateImports();
@@ -1 +0,0 @@
1
- export { hydrate as mount } from "solid-js/web"
@@ -1,9 +0,0 @@
1
- // @refresh skip
2
- import type { JSX } from "solid-js";
3
- import { render, type MountableElement } from "solid-js/web";
4
-
5
- export function mount(fn: () => JSX.Element, el: MountableElement) {
6
- render(fn, el);
7
- }
8
-
9
- export { StartClient } from "../StartClient.tsx";
@@ -1,19 +0,0 @@
1
- export const DEFAULT_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
2
-
3
- export const CLIENT_BASE_PATH = "_build";
4
-
5
- export const VIRTUAL_MODULES = {
6
- clientViteManifest: "solid-start:client-vite-manifest",
7
- getClientManifest: "solid-start:get-client-manifest",
8
- getManifest: "solid-start:get-manifest",
9
- middleware: "solid-start:middleware",
10
- serverFnManifest: "solid-start:server-fn-manifest",
11
- clientEntry: "solid-start:client-entry",
12
- serverEntry: "solid-start:server-entry",
13
- app: "solid-start:app",
14
- } as const;
15
-
16
- export const VITE_ENVIRONMENTS = {
17
- client: "client" as const,
18
- server: "ssr" as const,
19
- };