@solidjs/start 0.4.4 → 0.4.6

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/config/index.d.ts CHANGED
@@ -11,7 +11,7 @@ type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
11
11
  * async: ssr is in async mode
12
12
  */
13
13
  ssr?: boolean | "async",
14
- solid: Options,
14
+ solid?: Options,
15
15
  extensions?: string[],
16
16
  server?: AppOptions['server'],
17
17
  appRoot?: string,
@@ -20,4 +20,4 @@ type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
20
20
  }
21
21
  }
22
22
 
23
- export declare function defineConfig(baseConfig?: SolidStartInlineConfig)
23
+ export declare function defineConfig(baseConfig?: SolidStartInlineConfig)
package/config/index.js CHANGED
@@ -79,7 +79,17 @@ export function defineConfig(baseConfig = {}) {
79
79
  extensions,
80
80
  target: "server",
81
81
  plugins: async () => [
82
- config("user", userConfig),
82
+ config("user", {
83
+ ...userConfig,
84
+ optimizeDeps: {
85
+ ...(userConfig.optimizeDeps || {}),
86
+ include: [
87
+ ...(userConfig.optimizeDeps?.include || []),
88
+ '@solidjs/start > source-map-js',
89
+ '@solidjs/start > error-stack-parser',
90
+ ],
91
+ },
92
+ }),
83
93
  ...(typeof plugins === "function" ? [...(await plugins())] : plugins),
84
94
 
85
95
  serverTransform({
@@ -121,7 +131,17 @@ export function defineConfig(baseConfig = {}) {
121
131
  extensions,
122
132
  target: "browser",
123
133
  plugins: async () => [
124
- config("user", userConfig),
134
+ config("user", {
135
+ ...userConfig,
136
+ optimizeDeps: {
137
+ ...(userConfig.optimizeDeps || {}),
138
+ include: [
139
+ ...(userConfig.optimizeDeps?.include || []),
140
+ '@solidjs/start > source-map-js',
141
+ '@solidjs/start > error-stack-parser',
142
+ ],
143
+ },
144
+ }),
125
145
  ...(typeof plugins === "function" ? [...(await plugins())] : plugins),
126
146
  serverFunctions.client({
127
147
  runtime: normalize(fileURLToPath(new URL("./server-runtime.jsx", import.meta.url)))
@@ -150,6 +170,7 @@ export function defineConfig(baseConfig = {}) {
150
170
  "import.meta.env.START_ISLANDS": JSON.stringify(start.islands),
151
171
  "import.meta.env.SSR": JSON.stringify(false),
152
172
  "import.meta.env.START_SSR": JSON.stringify(start.ssr),
173
+ "import.meta.env.SERVER_BASE_URL": JSON.stringify(server?.baseURL ?? ""),
153
174
  ...userConfig.define
154
175
  }
155
176
  })
@@ -161,7 +182,17 @@ export function defineConfig(baseConfig = {}) {
161
182
  runtime: normalize(fileURLToPath(new URL("./server-fns-runtime.jsx", import.meta.url))),
162
183
  // routes: solidStartServerFsRouter({ dir: `${start.appRoot}/routes`, extensions }),
163
184
  plugins: async () => [
164
- config("user", userConfig),
185
+ config("user", {
186
+ ...userConfig,
187
+ optimizeDeps: {
188
+ ...(userConfig.optimizeDeps || {}),
189
+ include: [
190
+ ...(userConfig.optimizeDeps?.include || []),
191
+ '@solidjs/start > source-map-js',
192
+ '@solidjs/start > error-stack-parser',
193
+ ],
194
+ },
195
+ }),
165
196
  ...(typeof plugins === "function" ? [...(await plugins())] : plugins),
166
197
 
167
198
  solid({ ...start.solid, ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
@@ -3,10 +3,11 @@ import { provideRequestEvent } from "solid-js/web/storage";
3
3
  import { cloneEvent } from "../server/middleware";
4
4
 
5
5
  export function createServerReference(fn, id, name) {
6
+ const baseURL = import.meta.env.SERVER_BASE_URL;
6
7
  return new Proxy(fn, {
7
8
  get(target, prop, receiver) {
8
9
  if (prop === "url") {
9
- return `/_server?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
10
+ return `${baseURL}/_server?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
10
11
  }
11
12
  },
12
13
  apply(target, thisArg, args) {
@@ -120,14 +120,15 @@ async function fetchServerFunction(base, id, args) {
120
120
  }
121
121
 
122
122
  export function createServerReference(fn, id, name) {
123
+ const baseURL = import.meta.env.SERVER_BASE_URL;
123
124
  return new Proxy(fn, {
124
125
  get(target, prop, receiver) {
125
126
  if (prop === "url") {
126
- return `/_server?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
127
+ return `${baseURL}/_server?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
127
128
  }
128
129
  },
129
130
  apply(target, thisArg, args) {
130
- return fetchServerFunction("/_server", `${id}#${name}`, args);
131
+ return fetchServerFunction(`${baseURL}/_server`, `${id}#${name}`, args);
131
132
  }
132
133
  });
133
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "publishConfig": {
@@ -38,7 +38,7 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "solid-js": "^1.8.8",
41
+ "solid-js": "^1.8.10",
42
42
  "vinxi": "0.1.1"
43
43
  },
44
44
  "dependencies": {
@@ -15,24 +15,40 @@ import type { DocumentComponentProps } from "./types";
15
15
 
16
16
  const docType = ssr("<!DOCTYPE html>");
17
17
 
18
+ function matchRoute(matches, routes, matched = []) {
19
+ for (let i = 0; i < routes.length; i++) {
20
+ const segment = routes[i];
21
+ if (segment.path !== matches[0].path) continue;
22
+ let next = [...matched, segment];
23
+ if (segment.children) {
24
+ const nextMatches = matches.slice(1);
25
+ if (nextMatches.length === 0) continue;
26
+ next = matchRoute(nextMatches, segment.children, next);
27
+ if (!next) continue;
28
+ }
29
+ return next;
30
+ }
31
+ }
32
+
18
33
  export function StartServer(props: { document: Component<DocumentComponentProps> }) {
19
34
  const context = getRequestEvent() as any;
20
35
 
21
36
  let assets = [];
22
37
  Promise.resolve().then(async () => {
23
- let current = context.routes;
24
38
  if (context.routerMatches && context.routerMatches[0]) {
25
- for (let i = 0; i < context.routerMatches[0].length; i++) {
26
- const match = context.routerMatches[0][i];
27
- if (match.metadata && match.metadata.filesystem) {
28
- const segment = current.find(r => r.path === match.path);
39
+ const matches = [...context.routerMatches[0]];
40
+ while (matches.length && (!matches[0].metadata || !matches[0].metadata.filesystem))
41
+ matches.shift();
42
+ const matched = matches.length && matchRoute(matches, context.routes);
43
+ if (matched) {
44
+ for (let i = 0; i < matched.length; i++) {
45
+ const segment = matched[i];
29
46
  const part = import.meta.env.MANIFEST[import.meta.env.START_ISLANDS ? "ssr" : "client"]
30
47
  .inputs[segment["$component"].src];
31
48
  const asset = await part.assets();
32
49
  assets.push.apply(assets, asset);
33
- current = segment.children;
34
50
  }
35
- }
51
+ } else console.warn("No route matched for preloading js assets");
36
52
  }
37
53
  // dedupe assets
38
54
  assets = [...new Map(assets.map(item => [item.attrs.key, item])).values()].filter(asset =>
@@ -2,6 +2,7 @@ import {
2
2
  defineMiddleware,
3
3
  EventHandlerRequest,
4
4
  getRequestIP,
5
+ getRequestURL,
5
6
  H3Event,
6
7
  sendWebResponse,
7
8
  toWebRequest
@@ -18,9 +19,14 @@ const eventTraps = {
18
19
  };
19
20
 
20
21
  export function createFetchEvent(event: H3Event<EventHandlerRequest>): FetchEvent {
22
+ event.web ||
23
+ (event.web = {
24
+ url: getRequestURL(event),
25
+ request: toWebRequest(event)
26
+ });
21
27
  return new Proxy(
22
28
  {
23
- request: toWebRequest(event),
29
+ request: event.web.request,
24
30
  clientAddress: getRequestIP(event),
25
31
  locals: {},
26
32
  // @ts-ignore
@@ -27,6 +27,8 @@
27
27
  margin-bottom: 2rem;
28
28
  z-index: 10;
29
29
  gap: 0.5rem;
30
+ color: rgb(17 24 39);
31
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
30
32
  }
31
33
 
32
34
  .dev-overlay-navbar {
@@ -87,7 +89,6 @@
87
89
  }
88
90
 
89
91
  .dev-overlay-page-counter {
90
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
91
92
  font-size: 0.875rem;
92
93
  line-height: 1.25rem;
93
94
  font-weight: 600;
@@ -120,7 +121,6 @@
120
121
  border-radius: 9999px;
121
122
  background-color: rgb(249 250 251);
122
123
  padding: 0.25rem 0.5rem;
123
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
124
124
  font-size: 0.875rem;
125
125
  line-height: 1.25rem;
126
126
  font-weight: 600;
@@ -146,7 +146,6 @@
146
146
  }
147
147
 
148
148
  .dev-overlay-error-info {
149
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
150
149
  display: flex;
151
150
  flex-direction: column;
152
151
  gap: 0.25rem;
@@ -208,7 +207,6 @@
208
207
  }
209
208
 
210
209
  .dev-overlay-stack-frame-function {
211
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
212
210
  font-weight: 700;
213
211
  }
214
212
 
@@ -245,7 +243,6 @@
245
243
  .dev-overlay-stack-frames-code-source {
246
244
  font-size: 0.875rem;
247
245
  line-height: 1.25rem;
248
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
249
246
  color: rgb(249 250 251);
250
247
  }
251
248