@solidjs/start 2.0.0-alpha.0 → 2.0.0-alpha.1

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 (96) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/client/mount.d.ts +1 -7
  3. package/dist/client/mount.js +1 -99
  4. package/dist/config/constants.js +2 -2
  5. package/dist/config/fs-router.js +10 -22
  6. package/dist/config/fs-routes/fs-watcher.js +4 -4
  7. package/dist/config/fs-routes/index.js +4 -6
  8. package/dist/config/fs-routes/router.js +5 -5
  9. package/dist/config/fs-routes/tree-shake.js +12 -21
  10. package/dist/config/index.js +33 -36
  11. package/dist/config/lazy.js +9 -9
  12. package/dist/config/manifest.js +1 -1
  13. package/dist/http/index.d.ts +1 -4
  14. package/dist/http/index.js +3 -5
  15. package/dist/index.d.ts +0 -1
  16. package/dist/router.jsx +2 -2
  17. package/dist/server/assets/index.js +1 -1
  18. package/dist/server/assets/render.jsx +2 -2
  19. package/dist/server/fetchEvent.spec.js +1 -1
  20. package/dist/server/handler.js +29 -15
  21. package/dist/server/index.d.ts +1 -0
  22. package/dist/server/manifest/dev-client-manifest.js +1 -1
  23. package/dist/server/manifest/dev-ssr-manifest.js +1 -1
  24. package/dist/server/manifest/prod-ssr-manifest.js +7 -12
  25. package/dist/server/routes.js +3 -3
  26. package/dist/server/server-fns-runtime.js +2 -2
  27. package/dist/server/server-functions-handler.js +6 -11
  28. package/dist/server/server-runtime.js +8 -8
  29. package/dist/shared/dev-overlay/CodeView.d.ts +1 -1
  30. package/dist/shared/dev-overlay/CodeView.jsx +23 -34
  31. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +4 -4
  32. package/dist/shared/dev-overlay/get-source-map.d.ts +1 -1
  33. package/dist/shared/dev-overlay/get-source-map.js +5 -5
  34. package/dist/shared/dev-overlay/icons.d.ts +10 -10
  35. package/dist/shared/dev-overlay/icons.jsx +91 -91
  36. package/dist/shared/dev-overlay/index.jsx +1 -1
  37. package/dist/shared/lazy.js +4 -2
  38. package/env.d.ts +9 -0
  39. package/package.json +5 -4
  40. package/scripts/build.js +3 -3
  41. package/scripts/validate-imports.js +8 -8
  42. package/src/client/mount.ts +1 -114
  43. package/src/config/constants.ts +3 -3
  44. package/src/config/dev-server.ts +95 -99
  45. package/src/config/fs-router.ts +140 -155
  46. package/src/config/fs-routes/fs-watcher.ts +57 -61
  47. package/src/config/fs-routes/index.ts +117 -119
  48. package/src/config/fs-routes/router.ts +7 -7
  49. package/src/config/fs-routes/tree-shake.ts +342 -363
  50. package/src/config/index.ts +36 -39
  51. package/src/config/lazy.ts +13 -13
  52. package/src/config/manifest.ts +5 -5
  53. package/src/config/vite-utils.ts +2 -6
  54. package/src/env.d.ts +10 -28
  55. package/src/http/index.ts +105 -142
  56. package/src/index.tsx +0 -12
  57. package/src/internal.d.ts +1 -1
  58. package/src/middleware/index.ts +39 -49
  59. package/src/router.tsx +4 -3
  60. package/src/server/StartServer.tsx +1 -7
  61. package/src/server/assets/index.ts +1 -1
  62. package/src/server/assets/render.tsx +6 -2
  63. package/src/server/collect-styles.ts +63 -70
  64. package/src/server/fetchEvent.spec.ts +71 -75
  65. package/src/server/fetchEvent.ts +17 -17
  66. package/src/server/handler.ts +136 -129
  67. package/src/server/index.tsx +13 -0
  68. package/src/server/manifest/client-manifest.ts +1 -1
  69. package/src/server/manifest/dev-client-manifest.ts +7 -5
  70. package/src/server/manifest/dev-ssr-manifest.ts +8 -6
  71. package/src/server/manifest/prod-client-manifest.ts +7 -4
  72. package/src/server/manifest/prod-ssr-manifest.ts +78 -94
  73. package/src/server/manifest/ssr-manifest.ts +4 -2
  74. package/src/server/routes.ts +96 -108
  75. package/src/server/server-fns-runtime.ts +3 -3
  76. package/src/server/server-functions-handler.ts +294 -319
  77. package/src/server/server-runtime.ts +13 -13
  78. package/src/server/spa/handler.ts +12 -12
  79. package/src/server/types.ts +46 -46
  80. package/src/server/util.ts +4 -4
  81. package/src/shared/ErrorBoundary.tsx +1 -1
  82. package/src/shared/HttpHeader.tsx +20 -20
  83. package/src/shared/HttpStatusCode.ts +14 -14
  84. package/src/shared/clientOnly.ts +3 -3
  85. package/src/shared/dev-overlay/CodeView.tsx +43 -46
  86. package/src/shared/dev-overlay/DevOverlayDialog.tsx +4 -4
  87. package/src/shared/dev-overlay/createStackFrame.ts +59 -62
  88. package/src/shared/dev-overlay/env.d.ts +2 -2
  89. package/src/shared/dev-overlay/get-source-map.ts +5 -7
  90. package/src/shared/dev-overlay/icons.tsx +289 -121
  91. package/src/shared/dev-overlay/index.tsx +1 -1
  92. package/src/shared/lazy.ts +4 -3
  93. package/src/shared/serverFunction.ts +1 -1
  94. package/src/virtual.d.ts +10 -10
  95. package/tsconfig.json +2 -2
  96. package/vitest.config.ts +2 -2
@@ -33,10 +33,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
33
33
  ssr: true,
34
34
  devOverlay: true,
35
35
  experimental: {
36
- islands: false
36
+ islands: false,
37
37
  },
38
38
  solid: {},
39
- extensions: []
39
+ extensions: [],
40
40
  });
41
41
  const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
42
42
  const routeDir = join(start.appRoot, start.routeDir);
@@ -48,7 +48,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
48
48
  const entryExtension = extname(appEntryPath);
49
49
  const handlers = {
50
50
  client: `${start.appRoot}/entry-client${entryExtension}`,
51
- server: `${start.appRoot}/entry-server${entryExtension}`
51
+ server: `${start.appRoot}/entry-server${entryExtension}`,
52
52
  };
53
53
  return [
54
54
  {
@@ -56,13 +56,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
56
56
  enforce: "pre",
57
57
  configEnvironment(name) {
58
58
  return {
59
- define: {
60
- "import.meta.env.SSR": JSON.stringify(name === VITE_ENVIRONMENTS.server)
61
- },
62
59
  resolve: {
63
60
  // remove when https://github.com/solidjs/vite-plugin-solid/pull/228 is released
64
- externalConditions: ["solid", "node"]
65
- }
61
+ externalConditions: ["solid", "node"],
62
+ },
66
63
  };
67
64
  },
68
65
  async config(_, env) {
@@ -93,9 +90,9 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
93
90
  rollupOptions: {
94
91
  input: clientInput,
95
92
  treeshake: true,
96
- preserveEntrySignatures: "exports-only"
97
- }
98
- }
93
+ preserveEntrySignatures: "exports-only",
94
+ },
95
+ },
99
96
  },
100
97
  [VITE_ENVIRONMENTS.server]: {
101
98
  consumer: "server",
@@ -105,14 +102,14 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
105
102
  manifest: true,
106
103
  copyPublicDir: false,
107
104
  rollupOptions: {
108
- input: "~/entry-server.tsx"
105
+ input: "~/entry-server.tsx",
109
106
  },
110
107
  outDir: "dist/server",
111
108
  commonjsOptions: {
112
- include: [/node_modules/]
113
- }
114
- }
115
- }
109
+ include: [/node_modules/],
110
+ },
111
+ },
112
+ },
116
113
  },
117
114
  resolve: {
118
115
  alias: {
@@ -121,17 +118,17 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
121
118
  ...(!start.ssr
122
119
  ? {
123
120
  "@solidjs/start/server": "@solidjs/start/server/spa",
124
- "@solidjs/start/client": "@solidjs/start/client/spa"
121
+ "@solidjs/start/client": "@solidjs/start/client/spa",
125
122
  }
126
- : {})
127
- }
123
+ : {}),
124
+ },
128
125
  },
129
126
  define: {
130
127
  "import.meta.env.MANIFEST": `globalThis.MANIFEST`,
131
128
  "import.meta.env.START_SSR": JSON.stringify(start.ssr),
132
129
  "import.meta.env.START_APP_ENTRY": `"${appEntryPath}"`,
133
130
  "import.meta.env.START_CLIENT_ENTRY": `"${handlers.client}"`,
134
- "import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay)
131
+ "import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
135
132
  },
136
133
  builder: {
137
134
  sharedPlugins: true,
@@ -144,24 +141,24 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
144
141
 
145
142
  if (!client.isBuilt) await builder.build(client);
146
143
  if (!server.isBuilt) await builder.build(server);
147
- }
148
- }
144
+ },
145
+ },
149
146
  };
150
- }
147
+ },
151
148
  },
152
149
  manifest(start),
153
150
  fsRoutes({
154
151
  routers: {
155
152
  client: new SolidStartClientFileRouter({
156
153
  dir: absolute(routeDir, root),
157
- extensions
154
+ extensions,
158
155
  }),
159
156
  ssr: new SolidStartServerFileRouter({
160
157
  dir: absolute(routeDir, root),
161
158
  extensions,
162
- dataOnly: !start.ssr
163
- })
164
- }
159
+ dataOnly: !start.ssr,
160
+ }),
161
+ },
165
162
  }),
166
163
  lazy(),
167
164
  // Must be placed after fsRoutes, as treeShake will remove the
@@ -177,28 +174,28 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
177
174
  envName: VITE_ENVIRONMENTS.client,
178
175
  getRuntimeCode: () =>
179
176
  `import { createServerReference } from "${normalize(
180
- fileURLToPath(new URL("../server/server-runtime", import.meta.url))
177
+ fileURLToPath(new URL("../server/server-runtime", import.meta.url)),
181
178
  )}"`,
182
- replacer: opts => `createServerReference('${opts.functionId}')`
179
+ replacer: opts => `createServerReference('${opts.functionId}')`,
183
180
  },
184
181
  {
185
182
  envConsumer: "server",
186
183
  envName: VITE_ENVIRONMENTS.server,
187
184
  getRuntimeCode: () =>
188
185
  `import { createServerReference } from '${normalize(
189
- fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
186
+ fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
190
187
  )}'`,
191
- replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`
192
- }
188
+ replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
189
+ },
193
190
  ],
194
191
  provider: {
195
192
  envName: VITE_ENVIRONMENTS.server,
196
193
  getRuntimeCode: () =>
197
194
  `import { createServerReference } from '${normalize(
198
- fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
195
+ fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
199
196
  )}'`,
200
- replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`
201
- }
197
+ replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
198
+ },
202
199
  }),
203
200
  {
204
201
  name: "solid-start:virtual-modules",
@@ -217,20 +214,20 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
217
214
  if (query.size > 0) id += `?${query.toString()}`;
218
215
  return id;
219
216
  }
220
- }
217
+ },
221
218
  },
222
219
  {
223
220
  name: "solid-start:capture-client-bundle",
224
221
  enforce: "post",
225
222
  generateBundle(_options, bundle) {
226
223
  globalThis.START_CLIENT_BUNDLE = bundle;
227
- }
224
+ },
228
225
  },
229
226
  devServer(),
230
227
  solid({
231
228
  ...start.solid,
232
229
  ssr: true,
233
- extensions: extensions.map(ext => `.${ext}`)
234
- })
230
+ extensions: extensions.map(ext => `.${ext}`),
231
+ }),
235
232
  ];
236
233
  }
@@ -13,12 +13,12 @@ const idTransform = (id: string): PluginItem => {
13
13
  path.node.body.unshift(
14
14
  t.exportNamedDeclaration(
15
15
  t.variableDeclaration("const", [
16
- t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id))
17
- ])
18
- )
16
+ t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id)),
17
+ ]),
18
+ ),
19
19
  );
20
- }
21
- }
20
+ },
21
+ },
22
22
  };
23
23
  };
24
24
 
@@ -34,13 +34,13 @@ const importTransform = (): PluginItem => {
34
34
  path.insertAfter(
35
35
  t.importDeclaration(
36
36
  [t.importSpecifier(t.identifier("lazy"), t.identifier("lazy"))],
37
- t.stringLiteral("@solidjs/start/server")
38
- )
37
+ t.stringLiteral("@solidjs/start/server"),
38
+ ),
39
39
  );
40
- }
40
+ },
41
41
  });
42
- }
43
- }
42
+ },
43
+ },
44
44
  };
45
45
  };
46
46
 
@@ -79,21 +79,21 @@ const lazy = (): PluginOption => {
79
79
  const transformed = await babel.transformAsync(src, {
80
80
  plugins,
81
81
  parserOpts: {
82
- plugins: ["jsx", "typescript"]
82
+ plugins: ["jsx", "typescript"],
83
83
  },
84
84
  filename: basename(id),
85
85
  ast: false,
86
86
  sourceMaps: true,
87
87
  configFile: false,
88
88
  babelrc: false,
89
- sourceFileName: id
89
+ sourceFileName: id,
90
90
  });
91
91
 
92
92
  if (!transformed?.code) return;
93
93
 
94
94
  const { code, map } = transformed;
95
95
  return { code, map };
96
- }
96
+ },
97
97
  };
98
98
  };
99
99
 
@@ -17,7 +17,7 @@ export function manifest(start: SolidStartOptions): PluginOption {
17
17
  return `\0${VIRTUAL_MODULES.clientViteManifest}`;
18
18
  if (id === VIRTUAL_MODULES.getClientManifest)
19
19
  return this.resolve(
20
- new URL("../server/manifest/client-manifest", import.meta.url).pathname
20
+ new URL("../server/manifest/client-manifest", import.meta.url).pathname,
21
21
  );
22
22
  if (id === VIRTUAL_MODULES.getManifest) {
23
23
  return this.environment.config.consumer === "client"
@@ -36,11 +36,11 @@ export function manifest(start: SolidStartOptions): PluginOption {
36
36
  clientViteManifest = {};
37
37
  } else {
38
38
  const entry = Object.values(globalThis.START_CLIENT_BUNDLE).find(
39
- v => "isEntry" in v && v.isEntry
39
+ v => "isEntry" in v && v.isEntry,
40
40
  );
41
41
  if (!entry) throw new Error("No client entry found");
42
42
  clientViteManifest = JSON.parse(
43
- (globalThis.START_CLIENT_BUNDLE[".vite/manifest.json"] as any).source
43
+ (globalThis.START_CLIENT_BUNDLE[".vite/manifest.json"] as any).source,
44
44
  );
45
45
  }
46
46
  return `export const clientViteManifest = ${JSON.stringify(clientViteManifest)};`;
@@ -73,12 +73,12 @@ export function manifest(start: SolidStartOptions): PluginOption {
73
73
  "data-vite-ref": "0",
74
74
  },
75
75
  children: () => import("${value}?inline").then(mod => mod.default),
76
- }`
76
+ }`,
77
77
  );
78
78
 
79
79
  return `export default [${cssAssets.join(",")}]`;
80
80
  }
81
81
  }
82
- }
82
+ },
83
83
  };
84
84
  }
@@ -64,10 +64,7 @@ export function unwrapId(id: string): string {
64
64
  : id;
65
65
  }
66
66
 
67
- export function normalizeViteImportAnalysisUrl(
68
- environment: DevEnvironment,
69
- id: string,
70
- ): string {
67
+ export function normalizeViteImportAnalysisUrl(environment: DevEnvironment, id: string): string {
71
68
  let url = normalizeResolvedIdToUrl(environment, id, { id });
72
69
 
73
70
  // https://github.com/vitejs/vite/blob/c18ce868c4d70873406e9f7d1b2d0a03264d2168/packages/vite/src/node/plugins/importAnalysis.ts#L416
@@ -101,8 +98,7 @@ export function slash(p: string): string {
101
98
  return p.replace(windowsSlashRE, "/");
102
99
  }
103
100
 
104
- const isWindows =
105
- typeof process !== "undefined" && process.platform === "win32";
101
+ const isWindows = typeof process !== "undefined" && process.platform === "win32";
106
102
 
107
103
  export function injectQuery(url: string, queryToInject: string): string {
108
104
  const { file, postfix } = splitFileAndPostfix(url);
package/src/env.d.ts CHANGED
@@ -1,35 +1,17 @@
1
- // This file is an augmentation to the built-in ImportMeta interface
2
- // Thus cannot contain any top-level imports
3
- // <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
4
-
5
- /* eslint-disable @typescript-eslint/consistent-type-imports */
6
-
7
- declare namespace App {
8
- export interface RequestEventLocals {
9
- [key: string | symbol]: any;
10
- }
11
- }
1
+ // This file contains global type definitions that are internal to SolidStart and are not exported
12
2
 
13
3
  declare module "solidstart:server-fn-manifest" {
14
- type ServerFn = (...args: Array<any>) => Promise<any>;
15
- export function getServerFnById(id: string): Promise<ServerFn>;
4
+ type ServerFn = (...args: Array<any>) => Promise<any>;
5
+ export function getServerFnById(id: string): Promise<ServerFn>;
16
6
  }
17
7
 
18
- interface ImportMetaEnv
19
- extends Record<`VITE_${string}`, any>,
20
- SolidStartMetaEnv {
21
- BASE_URL: string;
22
- MODE: string;
23
- DEV: boolean;
24
- PROD: boolean;
25
- SSR: boolean;
26
- }
8
+ interface ImportMetaEnv extends SolidStartMetaEnv {}
27
9
 
28
10
  interface SolidStartMetaEnv {
29
- START_SSR: boolean;
30
- START_APP_ENTRY: string;
31
- START_CLIENT_ENTRY: string;
32
- // START_ISLANDS: boolean;
33
- // START_DEV_OVERLAY: boolean;
34
- // SERVER_BASE_URL: string;
11
+ START_SSR: boolean;
12
+ START_APP_ENTRY: string;
13
+ START_CLIENT_ENTRY: string;
14
+ START_ISLANDS: boolean;
15
+ // START_DEV_OVERLAY: boolean;
16
+ // SERVER_BASE_URL: string;
35
17
  }