@solidjs/start 2.0.0-alpha.1 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/config/constants.d.ts +1 -1
- package/dist/config/constants.js +1 -1
- package/dist/config/dev-server.js +18 -0
- package/dist/config/env.d.ts +19 -0
- package/dist/config/env.js +81 -0
- package/dist/config/fs-routes/fs-watcher.js +14 -20
- package/dist/config/fs-routes/index.js +2 -2
- package/dist/config/fs-routes/router.js +7 -8
- package/dist/config/index.d.ts +16 -1
- package/dist/config/index.js +30 -29
- package/dist/config/lazy.js +35 -5
- package/dist/config/manifest.js +40 -6
- package/dist/config/vite-utils.d.ts +6 -1
- package/dist/config/vite-utils.js +7 -3
- package/dist/directives/bubble-function-declaration.d.ts +3 -0
- package/dist/directives/bubble-function-declaration.js +23 -0
- package/dist/directives/compile.d.ts +9 -0
- package/dist/directives/compile.js +40 -0
- package/dist/directives/generate-unique-name.d.ts +3 -0
- package/dist/directives/generate-unique-name.js +16 -0
- package/dist/directives/get-descriptive-name.d.ts +2 -0
- package/dist/directives/get-descriptive-name.js +37 -0
- package/dist/directives/get-import-identifier.d.ts +4 -0
- package/dist/directives/get-import-identifier.js +19 -0
- package/dist/directives/get-root-statement-path.d.ts +2 -0
- package/dist/directives/get-root-statement-path.js +12 -0
- package/dist/directives/index.d.ts +14 -0
- package/dist/directives/index.js +169 -0
- package/dist/directives/is-statement-top-level.d.ts +3 -0
- package/dist/directives/is-statement-top-level.js +9 -0
- package/dist/directives/paths.d.ts +9 -0
- package/dist/directives/paths.js +36 -0
- package/dist/directives/plugin.d.ts +21 -0
- package/dist/directives/plugin.js +302 -0
- package/dist/directives/remove-unused-variables.d.ts +3 -0
- package/dist/directives/remove-unused-variables.js +53 -0
- package/dist/directives/types.d.ts +10 -0
- package/dist/directives/xxhash32.d.ts +6 -0
- package/dist/directives/xxhash32.js +193 -0
- package/dist/{server/server-runtime.d.ts → fns/client.d.ts} +1 -1
- package/dist/fns/client.js +106 -0
- package/dist/fns/handler.d.ts +5 -0
- package/dist/{server/server-functions-handler.js → fns/handler.js} +55 -96
- package/dist/fns/registration.d.ts +2 -0
- package/dist/fns/registration.js +12 -0
- package/dist/fns/serialization.d.ts +6 -0
- package/dist/fns/serialization.js +208 -0
- package/dist/fns/server.d.ts +7 -0
- package/dist/{server/server-fns-runtime.js → fns/server.js} +7 -1
- package/dist/fns/shared.d.ts +17 -0
- package/dist/fns/shared.js +105 -0
- package/dist/http/index.d.ts +1 -1
- package/dist/middleware/index.d.ts +20 -0
- package/dist/middleware/index.js +21 -1
- package/dist/server/StartServer.jsx +2 -0
- package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
- package/dist/server/assets/PatchVirtualDevStyles.jsx +28 -0
- package/dist/server/collect-styles.js +9 -21
- package/dist/server/handler.d.ts +61 -3
- package/dist/server/handler.js +18 -15
- package/dist/server/spa/StartServer.jsx +2 -0
- package/dist/server/spa/handler.d.ts +30 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/shared/dev-overlay/CodeView.jsx +4 -4
- package/dist/shared/dev-overlay/DevOverlayDialog.jsx +34 -34
- package/dist/shared/dev-overlay/index.jsx +2 -2
- package/dist/shared/dev-overlay/styles.css +40 -40
- package/package.json +27 -20
- package/src/config/constants.ts +1 -1
- package/src/config/dev-server.ts +12 -0
- package/src/config/env.ts +105 -0
- package/src/config/fs-routes/fs-watcher.ts +17 -24
- package/src/config/fs-routes/index.ts +2 -2
- package/src/config/fs-routes/router.ts +7 -8
- package/src/config/index.ts +44 -40
- package/src/config/lazy.ts +36 -5
- package/src/config/manifest.ts +40 -9
- package/src/config/vite-utils.ts +8 -4
- package/src/directives/bubble-function-declaration.ts +33 -0
- package/src/directives/compile.ts +54 -0
- package/src/directives/generate-unique-name.ts +22 -0
- package/src/directives/get-descriptive-name.ts +39 -0
- package/src/directives/get-import-identifier.ts +34 -0
- package/src/directives/get-root-statement-path.ts +14 -0
- package/src/directives/index.ts +232 -0
- package/src/directives/is-statement-top-level.ts +13 -0
- package/src/directives/paths.ts +63 -0
- package/src/directives/plugin.ts +389 -0
- package/src/directives/remove-unused-variables.ts +55 -0
- package/src/directives/types.ts +12 -0
- package/src/directives/xxhash32.ts +214 -0
- package/src/env.d.ts +1 -1
- package/src/fns/client.ts +141 -0
- package/src/fns/handler.spec.ts +85 -0
- package/src/{server/server-functions-handler.ts → fns/handler.ts} +65 -117
- package/src/fns/registration.ts +19 -0
- package/src/fns/serialization.ts +250 -0
- package/src/{server/server-fns-runtime.ts → fns/server.ts} +17 -2
- package/src/fns/shared.ts +116 -0
- package/src/middleware/index.ts +21 -1
- package/src/server/StartServer.tsx +2 -0
- package/src/server/assets/PatchVirtualDevStyles.tsx +31 -0
- package/src/server/collect-styles.ts +9 -26
- package/src/server/handler.ts +20 -16
- package/src/server/spa/StartServer.tsx +2 -0
- package/src/server/types.ts +1 -1
- package/src/shared/dev-overlay/CodeView.tsx +5 -7
- package/src/shared/dev-overlay/DevOverlayDialog.tsx +34 -34
- package/src/shared/dev-overlay/get-source-map.ts +1 -1
- package/src/shared/dev-overlay/index.tsx +4 -4
- package/src/shared/dev-overlay/styles.css +40 -40
- package/tsconfig.json +1 -0
- package/dist/server/fetchEvent.spec.js +0 -65
- package/dist/server/server-fns-runtime.d.ts +0 -1
- package/dist/server/server-functions-handler.d.ts +0 -2
- package/dist/server/server-runtime.js +0 -194
- package/src/server/server-runtime.ts +0 -240
- /package/dist/{server/fetchEvent.spec.d.ts → directives/types.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
[data-start-dev-overlay] {
|
|
2
2
|
position: fixed;
|
|
3
3
|
inset: 0px;
|
|
4
4
|
z-index: 50;
|
|
5
5
|
overflow-y: auto;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
[data-start-dev-overlay]>div {
|
|
9
9
|
position: relative;
|
|
10
10
|
display: flex;
|
|
11
11
|
align-items: center;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
min-height: 100vh;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
[data-start-dev-overlay-background] {
|
|
17
17
|
position: absolute;
|
|
18
18
|
inset: 0px;
|
|
19
19
|
background-color: rgb(17 24 39 / 0.5);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
[data-start-dev-overlay-panel] {
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
width: 75vw;
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
[data-start-dev-overlay-panel-container] {
|
|
34
34
|
margin: 2rem;
|
|
35
35
|
z-index: 10;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
[data-start-dev-overlay-navbar] {
|
|
39
39
|
display: flex;
|
|
40
40
|
flex-direction: row;
|
|
41
41
|
align-items: center;
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
gap: 0.5rem;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
[data-start-dev-overlay-pagination] {
|
|
47
47
|
display: flex;
|
|
48
48
|
flex-direction: row;
|
|
49
49
|
align-items: center;
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
padding: 0.25rem;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
[data-start-dev-overlay-button] {
|
|
58
58
|
display: flex;
|
|
59
59
|
padding: 0.125rem;
|
|
60
60
|
border-radius: 9999px;
|
|
@@ -68,44 +68,44 @@
|
|
|
68
68
|
transition-duration: 150ms;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
[data-start-dev-overlay-button]:hover {
|
|
72
72
|
background-color: rgb(229 231 235);
|
|
73
73
|
color: rgb(55 65 81);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
[data-start-dev-overlay-button]:focus {
|
|
77
77
|
outline: 2px solid transparent;
|
|
78
78
|
outline-offset: 2px
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
[data-start-dev-overlay-button]:focus-visible {
|
|
82
82
|
box-shadow: 0 0 0 calc(3px) rgb(17 24 39 / 0.75);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
[data-start-dev-overlay-button]:active {
|
|
86
86
|
background-color: rgb(243 244 246);
|
|
87
87
|
color: rgb(31 41 55);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
[data-start-dev-overlay-button]>svg {
|
|
91
91
|
height: 1.5rem;
|
|
92
92
|
width: 1.5rem;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
[data-start-dev-overlay-page-counter] {
|
|
96
96
|
font-size: 0.875rem;
|
|
97
97
|
line-height: 1.25rem;
|
|
98
98
|
font-weight: 600;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
[data-start-dev-overlay-navbar-left] {
|
|
102
102
|
display: flex;
|
|
103
103
|
flex-direction: row;
|
|
104
104
|
gap: 0.5rem;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
[data-start-dev-overlay-controls] {
|
|
109
109
|
display: flex;
|
|
110
110
|
flex-direction: row;
|
|
111
111
|
align-items: center;
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
padding: 0.25rem;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
[data-start-dev-overlay-version] {
|
|
120
120
|
display: flex;
|
|
121
121
|
flex-direction: row;
|
|
122
122
|
align-items: center;
|
|
@@ -130,17 +130,17 @@
|
|
|
130
130
|
font-weight: 600;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
[data-start-dev-overlay-version]>div {
|
|
134
134
|
height: 1.5rem;
|
|
135
135
|
width: 1.5rem;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
[data-start-dev-overlay-version]>div>svg {
|
|
139
139
|
height: 1.5rem;
|
|
140
140
|
width: 1.5rem;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
[data-start-dev-overlay-content] {
|
|
144
144
|
display: flex;
|
|
145
145
|
flex-direction: column;
|
|
146
146
|
gap: 0.75rem;
|
|
@@ -149,30 +149,30 @@
|
|
|
149
149
|
padding: 1rem;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
[data-start-dev-overlay-error-info] {
|
|
153
153
|
display: flex;
|
|
154
154
|
flex-direction: column;
|
|
155
155
|
gap: 0.25rem;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
[data-start-dev-overlay-error-info-name] {
|
|
159
159
|
font-weight: 700;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
[data-start-dev-overlay-error-info-message] {
|
|
163
163
|
font-size: 1.5rem;
|
|
164
164
|
line-height: 2rem;
|
|
165
165
|
color: rgb(239 68 68);
|
|
166
166
|
font-weight: 700;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
[data-start-dev-overlay-stack-frames-content] {
|
|
170
170
|
display: flex;
|
|
171
171
|
flex-direction: column;
|
|
172
172
|
gap: 0.75rem;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
[data-start-dev-overlay-stack-frames] {
|
|
176
176
|
flex: 1 1 0%;
|
|
177
177
|
display: flex;
|
|
178
178
|
flex-direction: column;
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
border-radius: 0.5rem;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
[data-start-dev-overlay-stack-frame] {
|
|
189
189
|
display: flex;
|
|
190
190
|
flex-direction: row;
|
|
191
191
|
align-items: center;
|
|
@@ -203,18 +203,18 @@
|
|
|
203
203
|
outline: none;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
[data-start-dev-overlay-stack-frame][tc-active],
|
|
207
|
+
[data-start-dev-overlay-stack-frame][tc-selected],
|
|
208
|
+
[data-start-dev-overlay-stack-frame]:focus {
|
|
209
209
|
background-color: rgb(219 234 254);
|
|
210
210
|
color: rgb(30 58 138);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
[data-start-dev-overlay-stack-frame-function] {
|
|
214
214
|
font-weight: 700;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
[data-start-dev-overlay-stack-frame-file] {
|
|
218
218
|
white-space: nowrap;
|
|
219
219
|
font-size: 0.75rem;
|
|
220
220
|
/* 12px */
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
/* 16px */
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
[data-start-dev-overlay-stack-frames-code] {
|
|
226
226
|
padding: 0.5rem 1rem;
|
|
227
227
|
gap: 0.25rem;
|
|
228
228
|
flex: 1 1 0%;
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
background-color: rgb(17 24 39);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
[data-start-dev-overlay-stack-frames-code-fallback] {
|
|
238
238
|
display: flex;
|
|
239
239
|
align-items: center;
|
|
240
240
|
justify-content: center;
|
|
@@ -244,13 +244,13 @@
|
|
|
244
244
|
line-height: 1.25rem;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
[data-start-dev-overlay-stack-frames-code-source] {
|
|
248
248
|
font-size: 0.875rem;
|
|
249
249
|
line-height: 1.25rem;
|
|
250
250
|
color: rgb(249 250 251);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
[data-start-dev-overlay-stack-frames-code-container] {
|
|
254
254
|
width: 100%;
|
|
255
255
|
overflow: hidden;
|
|
256
256
|
min-width: 100%;
|
|
@@ -260,13 +260,13 @@
|
|
|
260
260
|
border-top-color: rgb(249 250 251);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
[data-start-dev-overlay-code-view] {
|
|
264
264
|
overflow: auto;
|
|
265
265
|
min-width: 100%;
|
|
266
266
|
min-height: 16rem;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
[data-start-dev-overlay-code-view]>.shiki {
|
|
270
270
|
float: left;
|
|
271
271
|
min-width: 100%;
|
|
272
272
|
overflow-x: auto;
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
background-color: transparent !important;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
|
|
280
|
+
[data-start-dev-overlay-code-view]>.shiki .line::before {
|
|
281
281
|
content: counter(step);
|
|
282
282
|
counter-increment: step;
|
|
283
283
|
width: 1rem;
|
|
@@ -287,6 +287,6 @@
|
|
|
287
287
|
color: rgba(115, 138, 148, .4)
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
[data-start-dev-overlay-error-line] {
|
|
291
291
|
background-color: rgba(239, 68, 68, .4);
|
|
292
|
-
}
|
|
292
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/solidjs/solid-start.git",
|
|
8
|
+
"directory": "packages/start"
|
|
9
|
+
},
|
|
5
10
|
"exports": {
|
|
6
11
|
".": "./dist/index.jsx",
|
|
7
12
|
"./config": "./dist/config/index.js",
|
|
@@ -12,47 +17,49 @@
|
|
|
12
17
|
"./client/spa": "./dist/client/spa/index.jsx",
|
|
13
18
|
"./middleware": "./dist/middleware/index.js",
|
|
14
19
|
"./http": "./dist/http/index.js",
|
|
15
|
-
"./env": "./env.d.ts"
|
|
20
|
+
"./env": "./env.d.ts",
|
|
21
|
+
"./fns/server": "./dist/fns/server.js",
|
|
22
|
+
"./fns/client": "./dist/fns/client.js"
|
|
16
23
|
},
|
|
17
24
|
"publishConfig": {
|
|
18
25
|
"access": "public"
|
|
19
26
|
},
|
|
20
27
|
"dependencies": {
|
|
21
|
-
"@babel/core": "^7.
|
|
22
|
-
"@babel/traverse": "^7.
|
|
23
|
-
"@babel/types": "^7.
|
|
28
|
+
"@babel/core": "^7.29.0",
|
|
29
|
+
"@babel/traverse": "^7.29.0",
|
|
30
|
+
"@babel/types": "^7.29.0",
|
|
24
31
|
"@solidjs/meta": "^0.29.4",
|
|
25
|
-
"@tanstack/server-functions-plugin": "1.134.5",
|
|
26
32
|
"@types/babel__traverse": "^7.28.0",
|
|
27
|
-
"@types/micromatch": "^4.0.
|
|
33
|
+
"@types/micromatch": "^4.0.10",
|
|
28
34
|
"cookie-es": "^2.0.0",
|
|
29
35
|
"defu": "^6.1.4",
|
|
30
36
|
"error-stack-parser": "^2.1.4",
|
|
31
|
-
"es-module-lexer": "^
|
|
32
|
-
"esbuild": "^0.
|
|
37
|
+
"es-module-lexer": "^2.0.0",
|
|
38
|
+
"esbuild": "^0.27.4",
|
|
33
39
|
"fast-glob": "^3.3.3",
|
|
34
|
-
"h3": "
|
|
40
|
+
"h3": "2.0.1-rc.16",
|
|
35
41
|
"html-to-image": "^1.11.13",
|
|
36
42
|
"micromatch": "^4.0.8",
|
|
37
|
-
"path-to-regexp": "^8.
|
|
43
|
+
"path-to-regexp": "^8.3.0",
|
|
38
44
|
"pathe": "^2.0.3",
|
|
39
45
|
"radix3": "^1.1.2",
|
|
40
|
-
"seroval": "^1.4
|
|
41
|
-
"seroval-plugins": "^1.
|
|
42
|
-
"shiki": "^1.
|
|
43
|
-
"solid-js": "^1.9.
|
|
46
|
+
"seroval": "^1.5.4",
|
|
47
|
+
"seroval-plugins": "^1.5.1",
|
|
48
|
+
"shiki": "^1.29.2",
|
|
49
|
+
"solid-js": "^1.9.11",
|
|
44
50
|
"source-map-js": "^1.2.1",
|
|
45
|
-
"srvx": "^0.9
|
|
46
|
-
"terracotta": "^1.0
|
|
47
|
-
"vite-plugin-solid": "^2.11.
|
|
51
|
+
"srvx": "^0.11.9",
|
|
52
|
+
"terracotta": "^1.1.0",
|
|
53
|
+
"vite-plugin-solid": "^2.11.11"
|
|
48
54
|
},
|
|
49
55
|
"engines": {
|
|
50
56
|
"node": ">=22"
|
|
51
57
|
},
|
|
52
58
|
"devDependencies": {
|
|
53
59
|
"@types/babel__core": "^7.20.5",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
60
|
+
"@types/node": "^25.5.0",
|
|
61
|
+
"vite": "^7.3.1",
|
|
62
|
+
"vitest": "^4.1.0"
|
|
56
63
|
},
|
|
57
64
|
"peerDependencies": {
|
|
58
65
|
"vite": "^7"
|
package/src/config/constants.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const VIRTUAL_MODULES = {
|
|
|
7
7
|
getClientManifest: "solid-start:get-client-manifest",
|
|
8
8
|
getManifest: "solid-start:get-manifest",
|
|
9
9
|
middleware: "solid-start:middleware",
|
|
10
|
-
serverFnManifest: "
|
|
10
|
+
serverFnManifest: "solid-start:server-fn-manifest",
|
|
11
11
|
clientEntry: "solid-start:client-entry",
|
|
12
12
|
serverEntry: "solid-start:server-entry",
|
|
13
13
|
app: "solid-start:app",
|
package/src/config/dev-server.ts
CHANGED
|
@@ -11,6 +11,18 @@ export function devServer(): Array<PluginOption> {
|
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
13
|
name: "solid-start-dev-server",
|
|
14
|
+
configurePreviewServer(server) {
|
|
15
|
+
return () => {
|
|
16
|
+
server.middlewares.use(async (req, res) => {
|
|
17
|
+
res.setHeader("content-encoding", "identity");
|
|
18
|
+
const webReq = new NodeRequest({ req, res });
|
|
19
|
+
const def: {
|
|
20
|
+
default: { fetch: (req: Request) => Promise<Response> };
|
|
21
|
+
} = await import(process.cwd() + "/dist/server/entry-server.js");
|
|
22
|
+
sendNodeResponse(res, await def.default.fetch(webReq));
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
},
|
|
14
26
|
configureServer(viteDevServer) {
|
|
15
27
|
(globalThis as any).VITE_DEV_SERVER = viteDevServer;
|
|
16
28
|
return async () => {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { loadEnv, type Plugin } from "vite";
|
|
2
|
+
|
|
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
|
+
|
|
9
|
+
export interface EnvPluginOptions {
|
|
10
|
+
server?: {
|
|
11
|
+
runtime?: keyof typeof LOADERS | (string & {});
|
|
12
|
+
load?: (mode: string) => Record<string, string>;
|
|
13
|
+
prefix?: string;
|
|
14
|
+
};
|
|
15
|
+
client?: {
|
|
16
|
+
load?: (mode: string) => Record<string, string>;
|
|
17
|
+
prefix?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SERVER_ENV = "env:server";
|
|
22
|
+
const CLIENT_ENV = "env:client";
|
|
23
|
+
|
|
24
|
+
const SERVER_RUNTIME_ENV = `${SERVER_ENV}/runtime`;
|
|
25
|
+
|
|
26
|
+
const SERVER_RUNTIME_LOADER = `${SERVER_RUNTIME_ENV}/loader`;
|
|
27
|
+
|
|
28
|
+
const DEFAULT_SERVER_PREFIX = "SERVER_";
|
|
29
|
+
const DEFAULT_CLIENT_PREFIX = "CLIENT_";
|
|
30
|
+
|
|
31
|
+
const SERVER_ONLY_MODULE = `throw new Error('Attempt to load server-only environment variables in client runtime.');`;
|
|
32
|
+
|
|
33
|
+
const SERVER_RUNTIME_CODE = `import load from '${SERVER_RUNTIME_LOADER}';
|
|
34
|
+
|
|
35
|
+
export default new Proxy({}, {
|
|
36
|
+
get(_, key) {
|
|
37
|
+
return load(key);
|
|
38
|
+
},
|
|
39
|
+
})`;
|
|
40
|
+
|
|
41
|
+
function convertObjectToModule(object: Record<string, string>): string {
|
|
42
|
+
let result = "";
|
|
43
|
+
for (const key in object) {
|
|
44
|
+
result += `export const ${key} = ${JSON.stringify(object[key])};`;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function envPlugin(options?: EnvPluginOptions): Plugin {
|
|
50
|
+
const currentOptions = options ?? {};
|
|
51
|
+
let env: string;
|
|
52
|
+
const serverPrefix = currentOptions.server?.prefix ?? DEFAULT_SERVER_PREFIX;
|
|
53
|
+
const clientPrefix = currentOptions.client?.prefix ?? DEFAULT_CLIENT_PREFIX;
|
|
54
|
+
const runtime = options?.server?.runtime ?? "node";
|
|
55
|
+
const runtimeCode = runtime in LOADERS ? LOADERS[runtime as keyof typeof LOADERS] : runtime;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
name: "solid-start:env",
|
|
59
|
+
enforce: "pre",
|
|
60
|
+
configResolved(config) {
|
|
61
|
+
env = config.mode !== "production" ? "development" : "production";
|
|
62
|
+
},
|
|
63
|
+
resolveId(id) {
|
|
64
|
+
if (
|
|
65
|
+
id === SERVER_ENV ||
|
|
66
|
+
id === CLIENT_ENV ||
|
|
67
|
+
id === SERVER_RUNTIME_ENV ||
|
|
68
|
+
id === SERVER_RUNTIME_LOADER
|
|
69
|
+
) {
|
|
70
|
+
return id;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
},
|
|
74
|
+
load(id, opts) {
|
|
75
|
+
if (id === SERVER_ENV) {
|
|
76
|
+
if (!opts?.ssr) {
|
|
77
|
+
return SERVER_ONLY_MODULE;
|
|
78
|
+
}
|
|
79
|
+
const vars = currentOptions.server?.load
|
|
80
|
+
? currentOptions.server.load(env)
|
|
81
|
+
: loadEnv(env, '.', serverPrefix);
|
|
82
|
+
return convertObjectToModule(vars);
|
|
83
|
+
}
|
|
84
|
+
if (id === CLIENT_ENV) {
|
|
85
|
+
const vars = currentOptions.client?.load
|
|
86
|
+
? currentOptions.client.load(env)
|
|
87
|
+
: loadEnv(env, '.', clientPrefix);
|
|
88
|
+
return convertObjectToModule(vars);
|
|
89
|
+
}
|
|
90
|
+
if (id === SERVER_RUNTIME_LOADER) {
|
|
91
|
+
if (!opts?.ssr) {
|
|
92
|
+
return SERVER_ONLY_MODULE;
|
|
93
|
+
}
|
|
94
|
+
return runtimeCode;
|
|
95
|
+
}
|
|
96
|
+
if (id === SERVER_RUNTIME_ENV) {
|
|
97
|
+
if (!opts?.ssr) {
|
|
98
|
+
return SERVER_ONLY_MODULE;
|
|
99
|
+
}
|
|
100
|
+
return SERVER_RUNTIME_CODE;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
EnvironmentModuleNode,
|
|
3
3
|
FSWatcher,
|
|
4
|
-
ModuleGraph,
|
|
5
|
-
ModuleNode,
|
|
6
4
|
PluginOption,
|
|
7
5
|
ViteDevServer,
|
|
8
6
|
} from "vite";
|
|
7
|
+
import { VITE_ENVIRONMENTS } from "../constants.ts";
|
|
9
8
|
import { moduleId } from "./index.ts";
|
|
10
9
|
import type { BaseFileSystemRouter } from "./router.ts";
|
|
11
10
|
|
|
@@ -32,30 +31,24 @@ function createRoutesReloader(
|
|
|
32
31
|
return () => routes.removeEventListener("reload", handleRoutesReload);
|
|
33
32
|
|
|
34
33
|
function handleRoutesReload(): void {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
// Handle client environment HMR reload
|
|
48
|
-
const { moduleGraph }: { moduleGraph: ModuleGraph } = server;
|
|
49
|
-
const mod: ModuleNode | undefined = moduleGraph.getModuleById(moduleId);
|
|
50
|
-
if (mod) {
|
|
51
|
-
const seen = new Set<ModuleNode>();
|
|
52
|
-
moduleGraph.invalidateModule(mod, seen);
|
|
53
|
-
server.reloadModule(mod);
|
|
54
|
-
}
|
|
34
|
+
const envName =
|
|
35
|
+
environment === "ssr" ? VITE_ENVIRONMENTS.server : VITE_ENVIRONMENTS.client;
|
|
36
|
+
const devEnv = server.environments[envName];
|
|
37
|
+
if (!devEnv?.moduleGraph) return;
|
|
38
|
+
|
|
39
|
+
const mod: EnvironmentModuleNode | undefined =
|
|
40
|
+
devEnv.moduleGraph.getModuleById(moduleId);
|
|
41
|
+
if (mod) {
|
|
42
|
+
const seen = new Set<EnvironmentModuleNode>();
|
|
43
|
+
devEnv.moduleGraph.invalidateModule(mod, seen);
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
46
|
+
if (environment !== "ssr") {
|
|
47
|
+
if (mod) {
|
|
48
|
+
devEnv.reloadModule(mod);
|
|
49
|
+
} else if (devEnv.hot) {
|
|
50
|
+
devEnv.hot.send({ type: "full-reload" });
|
|
51
|
+
}
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
}
|
|
@@ -55,8 +55,8 @@ export function fsRoutes({ routers }: FsRoutesArgs): Array<PluginOption> {
|
|
|
55
55
|
const buildId = `${v.src}?${v.pick.map((p: any) => `pick=${p}`).join("&")}`;
|
|
56
56
|
return {
|
|
57
57
|
src: relative(root, buildId),
|
|
58
|
-
build: isBuild ? `_$() => import(
|
|
59
|
-
import: `_$() => import(
|
|
58
|
+
build: isBuild ? `_$() => import('${buildId}')$_` : undefined,
|
|
59
|
+
import: `_$() => import('${buildId}')$_`,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
return v;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { init } from "es-module-lexer";
|
|
2
|
-
import { parse } from "es-module-lexer";
|
|
1
|
+
import { init, parse } from "es-module-lexer";
|
|
3
2
|
import esbuild from "esbuild";
|
|
4
3
|
import fg from "fast-glob";
|
|
5
|
-
import fs from "fs";
|
|
4
|
+
import fs from "node:fs";
|
|
6
5
|
import micromatch from "micromatch";
|
|
7
|
-
import { posix } from "path";
|
|
6
|
+
import { posix } from "node:path";
|
|
8
7
|
import { pathToRegexp } from "path-to-regexp";
|
|
9
8
|
|
|
10
|
-
import {
|
|
9
|
+
import { normalizePath } from "vite";
|
|
11
10
|
|
|
12
11
|
export { pathToRegexp };
|
|
13
12
|
|
|
@@ -104,7 +103,7 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
async addRoute(src: string) {
|
|
107
|
-
src =
|
|
106
|
+
src = normalizePath(src);
|
|
108
107
|
if (this.isRoute(src)) {
|
|
109
108
|
try {
|
|
110
109
|
const route = this.toRoute(src);
|
|
@@ -130,7 +129,7 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
async updateRoute(src: string) {
|
|
133
|
-
src =
|
|
132
|
+
src = normalizePath(src);
|
|
134
133
|
if (this.isRoute(src)) {
|
|
135
134
|
try {
|
|
136
135
|
const route = this.toRoute(src);
|
|
@@ -146,7 +145,7 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
removeRoute(src: string) {
|
|
149
|
-
src =
|
|
148
|
+
src = normalizePath(src);
|
|
150
149
|
if (this.isRoute(src)) {
|
|
151
150
|
const path = this.toPath(src);
|
|
152
151
|
if (path === undefined) {
|