@solidjs/start 2.0.0-alpha.3 → 2.0.0-beta.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 (163) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +6 -5
  3. package/src/config/constants.ts +2 -2
  4. package/src/config/dev-server.ts +5 -1
  5. package/src/config/fs-routes/fs-watcher.ts +36 -40
  6. package/src/config/fs-routes/router.ts +27 -11
  7. package/src/config/fs-routes/tree-shake.ts +1 -48
  8. package/src/config/index.ts +12 -10
  9. package/src/config/lazy.ts +1 -0
  10. package/src/config/manifest.ts +8 -3
  11. package/src/directives/index.ts +1 -0
  12. package/src/directives/remove-unused-variables.ts +18 -3
  13. package/src/server/handler.ts +1 -1
  14. package/src/utils/debounce.ts +10 -0
  15. package/dist/client/StartClient.d.ts +0 -7
  16. package/dist/client/StartClient.jsx +0 -26
  17. package/dist/client/index.d.ts +0 -2
  18. package/dist/client/index.jsx +0 -2
  19. package/dist/client/mount.d.ts +0 -1
  20. package/dist/client/mount.js +0 -1
  21. package/dist/client/spa/index.d.ts +0 -4
  22. package/dist/client/spa/index.jsx +0 -5
  23. package/dist/config/constants.d.ts +0 -16
  24. package/dist/config/constants.js +0 -16
  25. package/dist/config/dev-server.d.ts +0 -2
  26. package/dist/config/dev-server.js +0 -126
  27. package/dist/config/env.d.ts +0 -19
  28. package/dist/config/env.js +0 -81
  29. package/dist/config/fs-router.d.ts +0 -37
  30. package/dist/config/fs-router.js +0 -141
  31. package/dist/config/fs-routes/fs-watcher.d.ts +0 -3
  32. package/dist/config/fs-routes/fs-watcher.js +0 -43
  33. package/dist/config/fs-routes/index.d.ts +0 -7
  34. package/dist/config/fs-routes/index.js +0 -107
  35. package/dist/config/fs-routes/router.d.ts +0 -37
  36. package/dist/config/fs-routes/router.js +0 -135
  37. package/dist/config/fs-routes/tree-shake.d.ts +0 -2
  38. package/dist/config/fs-routes/tree-shake.js +0 -348
  39. package/dist/config/index.d.ts +0 -25
  40. package/dist/config/index.js +0 -215
  41. package/dist/config/lazy.d.ts +0 -3
  42. package/dist/config/lazy.js +0 -112
  43. package/dist/config/manifest.d.ts +0 -3
  44. package/dist/config/manifest.js +0 -108
  45. package/dist/config/utils.d.ts +0 -4
  46. package/dist/config/utils.js +0 -6
  47. package/dist/config/vite-utils.d.ts +0 -21
  48. package/dist/config/vite-utils.js +0 -85
  49. package/dist/directives/bubble-function-declaration.d.ts +0 -3
  50. package/dist/directives/bubble-function-declaration.js +0 -23
  51. package/dist/directives/compile.d.ts +0 -9
  52. package/dist/directives/compile.js +0 -40
  53. package/dist/directives/generate-unique-name.d.ts +0 -3
  54. package/dist/directives/generate-unique-name.js +0 -16
  55. package/dist/directives/get-descriptive-name.d.ts +0 -2
  56. package/dist/directives/get-descriptive-name.js +0 -37
  57. package/dist/directives/get-import-identifier.d.ts +0 -4
  58. package/dist/directives/get-import-identifier.js +0 -19
  59. package/dist/directives/get-root-statement-path.d.ts +0 -2
  60. package/dist/directives/get-root-statement-path.js +0 -12
  61. package/dist/directives/index.d.ts +0 -14
  62. package/dist/directives/index.js +0 -169
  63. package/dist/directives/is-statement-top-level.d.ts +0 -3
  64. package/dist/directives/is-statement-top-level.js +0 -9
  65. package/dist/directives/paths.d.ts +0 -9
  66. package/dist/directives/paths.js +0 -36
  67. package/dist/directives/plugin.d.ts +0 -21
  68. package/dist/directives/plugin.js +0 -302
  69. package/dist/directives/remove-unused-variables.d.ts +0 -3
  70. package/dist/directives/remove-unused-variables.js +0 -53
  71. package/dist/directives/types.d.ts +0 -10
  72. package/dist/directives/types.js +0 -1
  73. package/dist/directives/xxhash32.d.ts +0 -6
  74. package/dist/directives/xxhash32.js +0 -193
  75. package/dist/fns/client.d.ts +0 -3
  76. package/dist/fns/client.js +0 -106
  77. package/dist/fns/handler.d.ts +0 -5
  78. package/dist/fns/handler.js +0 -269
  79. package/dist/fns/registration.d.ts +0 -2
  80. package/dist/fns/registration.js +0 -12
  81. package/dist/fns/serialization.d.ts +0 -6
  82. package/dist/fns/serialization.js +0 -208
  83. package/dist/fns/server.d.ts +0 -7
  84. package/dist/fns/server.js +0 -38
  85. package/dist/fns/shared.d.ts +0 -17
  86. package/dist/fns/shared.js +0 -105
  87. package/dist/http/index.d.ts +0 -81
  88. package/dist/http/index.js +0 -129
  89. package/dist/index.d.ts +0 -5
  90. package/dist/index.jsx +0 -6
  91. package/dist/middleware/index.d.ts +0 -38
  92. package/dist/middleware/index.js +0 -59
  93. package/dist/router.d.ts +0 -6
  94. package/dist/router.jsx +0 -29
  95. package/dist/server/StartServer.d.ts +0 -9
  96. package/dist/server/StartServer.jsx +0 -34
  97. package/dist/server/assets/PatchVirtualDevStyles.d.ts +0 -4
  98. package/dist/server/assets/PatchVirtualDevStyles.jsx +0 -28
  99. package/dist/server/assets/index.d.ts +0 -2
  100. package/dist/server/assets/index.js +0 -52
  101. package/dist/server/assets/render.d.ts +0 -19
  102. package/dist/server/assets/render.jsx +0 -14
  103. package/dist/server/collect-styles.d.ts +0 -3
  104. package/dist/server/collect-styles.js +0 -57
  105. package/dist/server/fetchEvent.d.ts +0 -7
  106. package/dist/server/fetchEvent.js +0 -26
  107. package/dist/server/handler.d.ts +0 -64
  108. package/dist/server/handler.js +0 -222
  109. package/dist/server/index.d.ts +0 -9
  110. package/dist/server/index.jsx +0 -14
  111. package/dist/server/manifest/client-manifest.d.ts +0 -9
  112. package/dist/server/manifest/client-manifest.js +0 -6
  113. package/dist/server/manifest/dev-client-manifest.d.ts +0 -4
  114. package/dist/server/manifest/dev-client-manifest.js +0 -24
  115. package/dist/server/manifest/dev-ssr-manifest.d.ts +0 -5
  116. package/dist/server/manifest/dev-ssr-manifest.js +0 -23
  117. package/dist/server/manifest/prod-client-manifest.d.ts +0 -5
  118. package/dist/server/manifest/prod-client-manifest.js +0 -26
  119. package/dist/server/manifest/prod-ssr-manifest.d.ts +0 -6
  120. package/dist/server/manifest/prod-ssr-manifest.js +0 -85
  121. package/dist/server/manifest/ssr-manifest.d.ts +0 -4
  122. package/dist/server/manifest/ssr-manifest.js +0 -6
  123. package/dist/server/routes.d.ts +0 -23
  124. package/dist/server/routes.js +0 -74
  125. package/dist/server/spa/StartServer.d.ts +0 -9
  126. package/dist/server/spa/StartServer.jsx +0 -25
  127. package/dist/server/spa/handler.d.ts +0 -36
  128. package/dist/server/spa/handler.js +0 -20
  129. package/dist/server/spa/index.d.ts +0 -4
  130. package/dist/server/spa/index.jsx +0 -5
  131. package/dist/server/types.d.ts +0 -75
  132. package/dist/server/types.js +0 -1
  133. package/dist/server/util.d.ts +0 -2
  134. package/dist/server/util.js +0 -8
  135. package/dist/shared/ErrorBoundary.d.ts +0 -3
  136. package/dist/shared/ErrorBoundary.jsx +0 -36
  137. package/dist/shared/GET.d.ts +0 -5
  138. package/dist/shared/GET.js +0 -8
  139. package/dist/shared/HttpHeader.d.ts +0 -10
  140. package/dist/shared/HttpHeader.jsx +0 -38
  141. package/dist/shared/HttpStatusCode.d.ts +0 -9
  142. package/dist/shared/HttpStatusCode.js +0 -18
  143. package/dist/shared/clientOnly.d.ts +0 -12
  144. package/dist/shared/clientOnly.js +0 -27
  145. package/dist/shared/dev-overlay/CodeView.d.ts +0 -7
  146. package/dist/shared/dev-overlay/CodeView.jsx +0 -62
  147. package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +0 -9
  148. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +0 -226
  149. package/dist/shared/dev-overlay/createStackFrame.d.ts +0 -9
  150. package/dist/shared/dev-overlay/createStackFrame.js +0 -56
  151. package/dist/shared/dev-overlay/download.d.ts +0 -1
  152. package/dist/shared/dev-overlay/download.js +0 -6
  153. package/dist/shared/dev-overlay/get-source-map.d.ts +0 -2
  154. package/dist/shared/dev-overlay/get-source-map.js +0 -25
  155. package/dist/shared/dev-overlay/icons.d.ts +0 -28
  156. package/dist/shared/dev-overlay/icons.jsx +0 -150
  157. package/dist/shared/dev-overlay/index.d.ts +0 -5
  158. package/dist/shared/dev-overlay/index.jsx +0 -39
  159. package/dist/shared/dev-overlay/styles.css +0 -292
  160. package/dist/shared/lazy.d.ts +0 -3
  161. package/dist/shared/lazy.js +0 -42
  162. package/dist/shared/serverFunction.d.ts +0 -6
  163. package/dist/shared/serverFunction.js +0 -8
@@ -1,135 +0,0 @@
1
- import { init, parse } from "es-module-lexer";
2
- import esbuild from "esbuild";
3
- import fg from "fast-glob";
4
- import fs from "node:fs";
5
- import micromatch from "micromatch";
6
- import { posix } from "node:path";
7
- import { pathToRegexp } from "path-to-regexp";
8
- import { normalizePath } from "vite";
9
- export { pathToRegexp };
10
- export const glob = (path) => fg.sync(path, { absolute: true });
11
- export function cleanPath(src, config) {
12
- return src
13
- .slice(config.dir.length)
14
- .replace(new RegExp(`\.(${(config.extensions ?? []).join("|")})$`), "");
15
- }
16
- export function analyzeModule(src) {
17
- return parse(esbuild.transformSync(fs.readFileSync(src, "utf-8"), {
18
- jsx: "transform",
19
- format: "esm",
20
- loader: "tsx",
21
- }).code, src);
22
- }
23
- export class BaseFileSystemRouter extends EventTarget {
24
- routes;
25
- config;
26
- /**
27
- *
28
- * @param {} config
29
- */
30
- constructor(config) {
31
- super();
32
- this.routes = [];
33
- this.config = config;
34
- }
35
- glob() {
36
- return (posix.join(fg.convertPathToPattern(this.config.dir), "**/*") +
37
- `.{${this.config.extensions.join(",")}}`);
38
- }
39
- async buildRoutes() {
40
- await init;
41
- for (var src of glob(this.glob())) {
42
- await this.addRoute(src);
43
- }
44
- return this.routes;
45
- }
46
- isRoute(src) {
47
- return Boolean(micromatch(src, this.glob())?.length);
48
- }
49
- toPath(src) {
50
- throw new Error("Not implemented");
51
- }
52
- toRoute(src) {
53
- let path = this.toPath(src);
54
- if (path === undefined)
55
- return;
56
- const [_, exports] = analyzeModule(src);
57
- if (!exports.find(e => e.n === "default")) {
58
- console.warn("No default export", src);
59
- }
60
- return {
61
- $component: {
62
- src: src,
63
- pick: ["default", "$css"],
64
- },
65
- path,
66
- // filePath: src
67
- };
68
- }
69
- /**
70
- * To be attached by vite plugin to the vite dev server
71
- */
72
- update = undefined;
73
- _addRoute(route) {
74
- this.routes = this.routes.filter(r => r.path !== route.path);
75
- this.routes.push(route);
76
- }
77
- async addRoute(src) {
78
- src = normalizePath(src);
79
- if (this.isRoute(src)) {
80
- try {
81
- const route = this.toRoute(src);
82
- if (route) {
83
- this._addRoute(route);
84
- this.reload(route.path);
85
- }
86
- }
87
- catch (e) {
88
- console.error(e);
89
- }
90
- }
91
- }
92
- reload(route) {
93
- this.dispatchEvent(new Event("reload", {
94
- // @ts-ignore
95
- detail: {
96
- route,
97
- },
98
- }));
99
- }
100
- async updateRoute(src) {
101
- src = normalizePath(src);
102
- if (this.isRoute(src)) {
103
- try {
104
- const route = this.toRoute(src);
105
- if (route) {
106
- this._addRoute(route);
107
- this.reload(route.path);
108
- }
109
- }
110
- catch (e) {
111
- console.error(e);
112
- }
113
- // this.update?.();
114
- }
115
- }
116
- removeRoute(src) {
117
- src = normalizePath(src);
118
- if (this.isRoute(src)) {
119
- const path = this.toPath(src);
120
- if (path === undefined) {
121
- return;
122
- }
123
- this.routes = this.routes.filter(r => r.path !== path);
124
- this.dispatchEvent(new Event("reload", {}));
125
- }
126
- }
127
- buildRoutesPromise;
128
- async getRoutes() {
129
- if (!this.buildRoutesPromise) {
130
- this.buildRoutesPromise = this.buildRoutes();
131
- }
132
- await this.buildRoutesPromise;
133
- return this.routes;
134
- }
135
- }
@@ -1,2 +0,0 @@
1
- import type { Plugin } from "vite";
2
- export declare function treeShake(): Plugin;
@@ -1,348 +0,0 @@
1
- // All credit for this work goes to the amazing Next.js team.
2
- // https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/plugins/next-ssg-transform.ts
3
- // This is adapted to work with routeData functions. It can be run in two modes, one which preserves the routeData and the Component in the same file, and one which creates a
4
- import { basename } from "pathe";
5
- function treeShakeTransform({ types: t }) {
6
- function getIdentifier(path) {
7
- const parentPath = path.parentPath;
8
- if (parentPath.type === "VariableDeclarator") {
9
- const pp = parentPath;
10
- const name = pp.get("id");
11
- return name.node.type === "Identifier" ? name : null;
12
- }
13
- if (parentPath.type === "AssignmentExpression") {
14
- const pp = parentPath;
15
- const name = pp.get("left");
16
- return name.node.type === "Identifier" ? name : null;
17
- }
18
- if (path.node.type === "ArrowFunctionExpression") {
19
- return null;
20
- }
21
- return path.node.id && path.node.id.type === "Identifier" ? path.get("id") : null;
22
- }
23
- function isIdentifierReferenced(ident) {
24
- const b = ident.scope.getBinding(ident.node.name);
25
- if (b?.referenced) {
26
- if (b.path.type === "FunctionDeclaration") {
27
- return !b.constantViolations
28
- .concat(b.referencePaths)
29
- .every(ref => ref.findParent(p => p === b.path));
30
- }
31
- return true;
32
- }
33
- return false;
34
- }
35
- function markFunction(path, state) {
36
- const ident = getIdentifier(path);
37
- if (ident && ident.node && isIdentifierReferenced(ident)) {
38
- state.refs.add(ident);
39
- }
40
- }
41
- function markImport(path, state) {
42
- const local = path.get("local");
43
- if (isIdentifierReferenced(local)) {
44
- state.refs.add(local);
45
- }
46
- }
47
- return {
48
- visitor: {
49
- Program: {
50
- enter(path, state) {
51
- state.refs = new Set();
52
- state.done = false;
53
- path.traverse({
54
- VariableDeclarator(variablePath, variableState) {
55
- if (variablePath.node.id.type === "Identifier") {
56
- const local = variablePath.get("id");
57
- if (isIdentifierReferenced(local)) {
58
- variableState.refs.add(local);
59
- }
60
- }
61
- else if (variablePath.node.id.type === "ObjectPattern") {
62
- const pattern = variablePath.get("id");
63
- const properties = pattern.get("properties");
64
- properties.forEach(p => {
65
- const local = p.get(p.node.type === "ObjectProperty"
66
- ? "value"
67
- : p.node.type === "RestElement"
68
- ? "argument"
69
- : (() => {
70
- throw new Error("invariant");
71
- })());
72
- if (isIdentifierReferenced(local)) {
73
- variableState.refs.add(local);
74
- }
75
- });
76
- }
77
- else if (variablePath.node.id.type === "ArrayPattern") {
78
- const pattern = variablePath.get("id");
79
- const elements = pattern.get("elements");
80
- elements.forEach(e => {
81
- let local;
82
- if (e.node && e.node.type === "Identifier") {
83
- local = e;
84
- }
85
- else if (e.node && e.node.type === "RestElement") {
86
- local = e.get("argument");
87
- }
88
- else {
89
- return;
90
- }
91
- if (isIdentifierReferenced(local)) {
92
- variableState.refs.add(local);
93
- }
94
- });
95
- }
96
- },
97
- ExportDefaultDeclaration(exportNamedPath) {
98
- // if opts.keep is true, we don't remove the routeData export
99
- if (state.opts.pick && !state.opts.pick.includes("default")) {
100
- exportNamedPath.remove();
101
- }
102
- },
103
- ExportNamedDeclaration(exportNamedPath) {
104
- // if opts.keep is false, we don't remove the routeData export
105
- if (!state.opts.pick) {
106
- return;
107
- }
108
- const specifiers = exportNamedPath.get("specifiers");
109
- if (specifiers.length) {
110
- specifiers.forEach(s => {
111
- if (t.isIdentifier(s.node.exported)
112
- ? s.node.exported.name
113
- : state.opts.pick.includes(s.node.exported.value)) {
114
- s.remove();
115
- }
116
- });
117
- if (exportNamedPath.node.specifiers.length < 1) {
118
- exportNamedPath.remove();
119
- }
120
- return;
121
- }
122
- const decl = exportNamedPath.get("declaration");
123
- if (decl == null || decl.node == null) {
124
- return;
125
- }
126
- switch (decl.node.type) {
127
- case "FunctionDeclaration": {
128
- const name = decl.node.id?.name;
129
- if (name && state.opts.pick && !state.opts.pick.includes(name)) {
130
- exportNamedPath.remove();
131
- }
132
- break;
133
- }
134
- case "VariableDeclaration": {
135
- const inner = decl.get("declarations");
136
- inner.forEach(d => {
137
- if (d.node.id.type !== "Identifier") {
138
- return;
139
- }
140
- const name = d.node.id.name;
141
- if (state.opts.pick && !state.opts.pick.includes(name)) {
142
- d.remove();
143
- }
144
- });
145
- break;
146
- }
147
- default: {
148
- break;
149
- }
150
- }
151
- },
152
- FunctionDeclaration: markFunction,
153
- FunctionExpression: markFunction,
154
- ArrowFunctionExpression: markFunction,
155
- ImportSpecifier: markImport,
156
- ImportDefaultSpecifier: markImport,
157
- ImportNamespaceSpecifier: markImport,
158
- ImportDeclaration: (path, state) => {
159
- if (path.node.source.value.endsWith(".css") &&
160
- state.opts.pick &&
161
- !state.opts.pick.includes("$css")) {
162
- path.remove();
163
- }
164
- },
165
- }, state);
166
- const refs = state.refs;
167
- let count = 0;
168
- const sweepFunction = (sweepPath) => {
169
- const ident = getIdentifier(sweepPath);
170
- if (ident && ident.node && refs.has(ident) && !isIdentifierReferenced(ident)) {
171
- ++count;
172
- if (t.isAssignmentExpression(sweepPath.parentPath) ||
173
- t.isVariableDeclarator(sweepPath.parentPath)) {
174
- sweepPath.parentPath.remove();
175
- }
176
- else {
177
- sweepPath.remove();
178
- }
179
- }
180
- };
181
- function sweepImport(sweepPath) {
182
- const local = sweepPath.get("local");
183
- if (refs.has(local) && !isIdentifierReferenced(local)) {
184
- ++count;
185
- sweepPath.remove();
186
- if (sweepPath.parent.specifiers.length === 0) {
187
- sweepPath.parentPath.remove();
188
- }
189
- }
190
- }
191
- do {
192
- path.scope.crawl();
193
- count = 0;
194
- path.traverse({
195
- VariableDeclarator(variablePath) {
196
- if (variablePath.node.id.type === "Identifier") {
197
- const local = variablePath.get("id");
198
- if (refs.has(local) && !isIdentifierReferenced(local)) {
199
- ++count;
200
- variablePath.remove();
201
- }
202
- }
203
- else if (variablePath.node.id.type === "ObjectPattern") {
204
- const pattern = variablePath.get("id");
205
- const beforeCount = count;
206
- const properties = pattern.get("properties");
207
- properties.forEach(p => {
208
- const local = p.get(p.node.type === "ObjectProperty"
209
- ? "value"
210
- : p.node.type === "RestElement"
211
- ? "argument"
212
- : (() => {
213
- throw new Error("invariant");
214
- })());
215
- if (refs.has(local) && !isIdentifierReferenced(local)) {
216
- ++count;
217
- p.remove();
218
- }
219
- });
220
- if (beforeCount !== count && pattern.get("properties").length < 1) {
221
- variablePath.remove();
222
- }
223
- }
224
- else if (variablePath.node.id.type === "ArrayPattern") {
225
- const pattern = variablePath.get("id");
226
- const beforeCount = count;
227
- const elements = pattern.get("elements");
228
- elements.forEach(e => {
229
- let local;
230
- if (e.node && e.node.type === "Identifier") {
231
- local = e;
232
- }
233
- else if (e.node && e.node.type === "RestElement") {
234
- local = e.get("argument");
235
- }
236
- else {
237
- return;
238
- }
239
- if (refs.has(local) && !isIdentifierReferenced(local)) {
240
- ++count;
241
- e.remove();
242
- }
243
- });
244
- if (beforeCount !== count && pattern.get("elements").length < 1) {
245
- variablePath.remove();
246
- }
247
- }
248
- },
249
- FunctionDeclaration: sweepFunction,
250
- FunctionExpression: sweepFunction,
251
- ArrowFunctionExpression: sweepFunction,
252
- ImportSpecifier: sweepImport,
253
- ImportDefaultSpecifier: sweepImport,
254
- ImportNamespaceSpecifier: sweepImport,
255
- });
256
- } while (count);
257
- },
258
- },
259
- },
260
- };
261
- }
262
- export function treeShake() {
263
- let config;
264
- const cache = {};
265
- let server;
266
- async function transform(id, code) {
267
- const [path, queryString] = id.split("?");
268
- const query = new URLSearchParams(queryString);
269
- if (query.has("pick")) {
270
- const babel = await import("@babel/core");
271
- const transformed = await babel.transformAsync(code, {
272
- plugins: [[treeShakeTransform, { pick: query.getAll("pick") }]],
273
- parserOpts: {
274
- plugins: ["jsx", "typescript"],
275
- },
276
- filename: basename(id),
277
- ast: false,
278
- sourceMaps: true,
279
- configFile: false,
280
- babelrc: false,
281
- sourceFileName: id,
282
- });
283
- return transformed;
284
- }
285
- }
286
- return {
287
- name: "tree-shake",
288
- enforce: "pre",
289
- configResolved(resolvedConfig) {
290
- config = resolvedConfig;
291
- },
292
- configureServer(s) {
293
- server = s;
294
- },
295
- async handleHotUpdate(ctx) {
296
- if (cache[ctx.file]) {
297
- const mods = [];
298
- const newCode = await ctx.read();
299
- for (const [id, code] of Object.entries(cache[ctx.file])) {
300
- const transformed = await transform(id, newCode);
301
- if (!transformed)
302
- continue;
303
- const { code: transformedCode } = transformed;
304
- if (transformedCode !== code) {
305
- const mod = server.moduleGraph.getModuleById(id);
306
- if (mod)
307
- mods.push(mod);
308
- }
309
- cache[ctx.file] ??= {};
310
- cache[ctx.file][id] = transformedCode;
311
- // server.moduleGraph.setModuleSource(id, code);
312
- }
313
- return mods;
314
- }
315
- // const mods = [];
316
- // [...server.moduleGraph.urlToModuleMap.entries()].forEach(([url, m]) => {
317
- // if (m.file === ctx.file && m.id.includes("pick=")) {
318
- // if (!m.id.includes("pick=loader")) {
319
- // mods.push(m);
320
- // }
321
- // }
322
- // });
323
- // return mods;
324
- // // this.router.updateRoute(ctx.path);
325
- // }
326
- },
327
- async transform(code, id) {
328
- const [path, queryString] = id.split("?");
329
- if (!path)
330
- return;
331
- const query = new URLSearchParams(queryString);
332
- const ext = path.split(".").pop();
333
- if (!ext)
334
- return;
335
- if (query.has("pick") && ["js", "jsx", "ts", "tsx"].includes(ext)) {
336
- const transformed = await transform(id, code);
337
- if (!transformed?.code)
338
- return;
339
- cache[path] ??= {};
340
- cache[path][id] = transformed.code;
341
- return {
342
- code: transformed.code,
343
- map: transformed.map,
344
- };
345
- }
346
- },
347
- };
348
- }
@@ -1,25 +0,0 @@
1
- import type { PluginOption } from "vite";
2
- import { type Options as SolidOptions } from "vite-plugin-solid";
3
- import { type ServerFunctionsOptions } from "../directives/index.ts";
4
- import { type EnvPluginOptions } from "./env.ts";
5
- export interface SolidStartOptions {
6
- solid?: Partial<SolidOptions>;
7
- ssr?: boolean;
8
- routeDir?: string;
9
- extensions?: string[];
10
- middleware?: string;
11
- serialization?: {
12
- /**
13
- * The serialization mode to use for server functions/actions.
14
- * The "js" mode uses a custom binary format that is more efficient than JSON, but requires a custom deserializer (with `eval()`) on the client.
15
- * A strong CSP should block `eval()` executions, which would prevent the "js" mode from working.
16
- * The "json" mode uses JSON for serialization, which is less efficient but can be deserialized with `JSON.parse` on the client.
17
- *
18
- * @default "json"
19
- */
20
- mode?: "js" | "json";
21
- };
22
- env?: EnvPluginOptions;
23
- serverFunctions?: Pick<ServerFunctionsOptions, "filter">;
24
- }
25
- export declare function solidStart(options?: SolidStartOptions): Array<PluginOption>;