@solidjs/start 0.4.0-alpha.7 → 0.4.0-alpha.9

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.
@@ -0,0 +1,14 @@
1
+ import { InlineConfig } from "vite";
2
+
3
+ type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
4
+ start?: {
5
+ ssr?: boolean | "async",
6
+ extensions?: string[],
7
+ server?: any,
8
+ appRoot?: string,
9
+ middleware?: string,
10
+ //islands?: boolean TODO: Get PROD bugs working probably missing release
11
+ }
12
+ }
13
+
14
+ export declare function defineConfig(baseConfig: SolidStartInlineConfig)
package/config/index.js CHANGED
@@ -43,10 +43,11 @@ export function defineConfig(baseConfig = {}) {
43
43
  appRoot: "./src",
44
44
  ssr: true,
45
45
  islands: false,
46
+ solid: {}
46
47
  });
47
48
  let server = start.server;
48
49
  if (!start.ssr) {
49
- server = { ...server, prerender: { routes: ["/"] } };
50
+ server = { ...server, prerender: { routes: ["/"] } };
50
51
  }
51
52
 
52
53
  return createApp({
@@ -79,7 +80,7 @@ export function defineConfig(baseConfig = {}) {
79
80
  runtime: normalize(fileURLToPath(new URL("./server-fns-runtime.jsx", import.meta.url)))
80
81
  }),
81
82
  start.islands ? serverComponents.server() : null,
82
- solid({ ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
83
+ solid({ ...start.solid, ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
83
84
  config("app-server", {
84
85
  resolve: {
85
86
  alias: {
@@ -89,13 +90,15 @@ export function defineConfig(baseConfig = {}) {
89
90
  ? {
90
91
  "@solidjs/start/server": "@solidjs/start/server/spa"
91
92
  }
92
- : {})
93
+ : {}),
94
+ ...userConfig.resolve?.alias
93
95
  }
94
96
  },
95
97
  define: {
96
98
  "import.meta.env.START_ISLANDS": JSON.stringify(start.islands),
97
99
  "import.meta.env.SSR": JSON.stringify(true),
98
- "import.meta.env.START_SSR": JSON.stringify(start.ssr)
100
+ "import.meta.env.START_SSR": JSON.stringify(start.ssr),
101
+ ...userConfig.define
99
102
  }
100
103
  })
101
104
  ]
@@ -118,7 +121,7 @@ export function defineConfig(baseConfig = {}) {
118
121
  runtime: normalize(fileURLToPath(new URL("./server-runtime.jsx", import.meta.url)))
119
122
  }),
120
123
  start.islands ? serverComponents.client() : null,
121
- solid({ ssr: start.ssr, extensions: extensions.map(ext => `.${ext}`) }),
124
+ solid({ ...start.solid, ssr: start.ssr, extensions: extensions.map(ext => `.${ext}`) }),
122
125
  config("app-client", {
123
126
  resolve: {
124
127
  alias: {
@@ -133,13 +136,15 @@ export function defineConfig(baseConfig = {}) {
133
136
  ? {
134
137
  "@solidjs/start/client": "@solidjs/start/client/spa"
135
138
  }
136
- : {})
139
+ : {}),
140
+ ...userConfig.resolve?.alias
137
141
  }
138
142
  },
139
143
  define: {
140
144
  "import.meta.env.START_ISLANDS": JSON.stringify(start.islands),
141
145
  "import.meta.env.SSR": JSON.stringify(false),
142
- "import.meta.env.START_SSR": JSON.stringify(start.ssr)
146
+ "import.meta.env.START_SSR": JSON.stringify(start.ssr),
147
+ ...userConfig.define
143
148
  }
144
149
  })
145
150
  ],
@@ -152,7 +157,7 @@ export function defineConfig(baseConfig = {}) {
152
157
  plugins: () => [
153
158
  config("user", userConfig),
154
159
  ...plugins,
155
- solid({ ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
160
+ solid({ ...start.solid, ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
156
161
  config("app-server", {
157
162
  resolve: {
158
163
  alias: {
@@ -162,13 +167,15 @@ export function defineConfig(baseConfig = {}) {
162
167
  ? {
163
168
  "@solidjs/start/server": "@solidjs/start/server/spa"
164
169
  }
165
- : {})
170
+ : {}),
171
+ ...userConfig.resolve?.alias
166
172
  }
167
173
  },
168
174
  define: {
169
175
  "import.meta.env.START_ISLANDS": JSON.stringify(start.islands),
170
176
  "import.meta.env.SSR": JSON.stringify(true),
171
- "import.meta.env.START_SSR": JSON.stringify(start.ssr)
177
+ "import.meta.env.START_SSR": JSON.stringify(start.ssr),
178
+ ...userConfig.define
172
179
  }
173
180
  })
174
181
  ],
@@ -10,7 +10,9 @@ export function createServerReference(fn, id, name) {
10
10
  }
11
11
  },
12
12
  apply(target, thisArg, args) {
13
- const evt = cloneEvent(getRequestEvent());
13
+ const ogEvt = getRequestEvent();
14
+ if (!ogEvt) throw new Error("Cannot call server function outside of a request");
15
+ const evt = cloneEvent(ogEvt);
14
16
  evt.serverOnly = true;
15
17
  return provideRequestEvent(evt, () => {
16
18
  return fn.apply(thisArg, args);
@@ -69,7 +69,7 @@ async function fetchServerFunction(base, id, args) {
69
69
  const instance = `server-fn:${INSTANCE++}`;
70
70
  const response = await (args.length === 1 && args[0] instanceof FormData
71
71
  ? createRequest(base, id, instance, args[0])
72
- : createRequest(base, id, instance, JSON.stringify(await toJSONAsync(args)), "application/json"));
72
+ : createRequest(base, id, instance, JSON.stringify(await Promise.resolve(toJSONAsync(args))), "application/json"));
73
73
 
74
74
  if (response.headers.get("Location")) throw response;
75
75
  if (response.headers.get("X-Revalidate")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "0.4.0-alpha.7",
3
+ "version": "0.4.0-alpha.9",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "publishConfig": {
@@ -21,7 +21,7 @@ export function StartServer(props: { document: Component<DocumentComponentProps>
21
21
  let assets = [];
22
22
  Promise.resolve().then(async () => {
23
23
  let current = context.routes;
24
- if (context.routerMatches[0]) {
24
+ if (context.routerMatches && context.routerMatches[0]) {
25
25
  for (let i = 0; i < context.routerMatches[0].length; i++) {
26
26
  const match = context.routerMatches[0][i];
27
27
  if (match.metadata && match.metadata.filesystem) {
@@ -41,7 +41,7 @@ export function StartServer(props: { document: Component<DocumentComponentProps>
41
41
  );
42
42
  });
43
43
 
44
- useAssets(() => assets.map(m => renderAsset(m)));
44
+ useAssets(() => assets.length ? assets.map(m => renderAsset(m)) : undefined);
45
45
 
46
46
  return (
47
47
  <NoHydration>
@@ -46,6 +46,7 @@ export function createHandler(
46
46
  }
47
47
 
48
48
  // render stream
49
+ const doAsync = import.meta.env.START_SSR === "async";
49
50
  const context = await createPageEvent(event);
50
51
  let cloned = { ...options };
51
52
  if (cloned.onCompleteAll) {
@@ -66,6 +67,7 @@ export function createHandler(
66
67
  if (context.response && context.response.headers.get("Location")) {
67
68
  return sendRedirect(event, context.response.headers.get("Location"));
68
69
  }
70
+ if (doAsync) return stream;
69
71
  // fix cloudflare streaming
70
72
  const { writable, readable } = new TransformStream();
71
73
  stream.pipeTo(writable);