@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.
- package/CHANGELOG.md +23 -0
- package/package.json +6 -5
- package/src/config/constants.ts +2 -2
- package/src/config/dev-server.ts +5 -1
- package/src/config/fs-routes/fs-watcher.ts +36 -40
- package/src/config/fs-routes/router.ts +27 -11
- package/src/config/fs-routes/tree-shake.ts +1 -48
- package/src/config/index.ts +12 -10
- package/src/config/lazy.ts +1 -0
- package/src/config/manifest.ts +8 -3
- package/src/directives/index.ts +1 -0
- package/src/directives/remove-unused-variables.ts +18 -3
- package/src/server/handler.ts +1 -1
- package/src/utils/debounce.ts +10 -0
- package/dist/client/StartClient.d.ts +0 -7
- package/dist/client/StartClient.jsx +0 -26
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.jsx +0 -2
- package/dist/client/mount.d.ts +0 -1
- package/dist/client/mount.js +0 -1
- package/dist/client/spa/index.d.ts +0 -4
- package/dist/client/spa/index.jsx +0 -5
- package/dist/config/constants.d.ts +0 -16
- package/dist/config/constants.js +0 -16
- package/dist/config/dev-server.d.ts +0 -2
- package/dist/config/dev-server.js +0 -126
- package/dist/config/env.d.ts +0 -19
- package/dist/config/env.js +0 -81
- package/dist/config/fs-router.d.ts +0 -37
- package/dist/config/fs-router.js +0 -141
- package/dist/config/fs-routes/fs-watcher.d.ts +0 -3
- package/dist/config/fs-routes/fs-watcher.js +0 -43
- package/dist/config/fs-routes/index.d.ts +0 -7
- package/dist/config/fs-routes/index.js +0 -107
- package/dist/config/fs-routes/router.d.ts +0 -37
- package/dist/config/fs-routes/router.js +0 -135
- package/dist/config/fs-routes/tree-shake.d.ts +0 -2
- package/dist/config/fs-routes/tree-shake.js +0 -348
- package/dist/config/index.d.ts +0 -25
- package/dist/config/index.js +0 -215
- package/dist/config/lazy.d.ts +0 -3
- package/dist/config/lazy.js +0 -112
- package/dist/config/manifest.d.ts +0 -3
- package/dist/config/manifest.js +0 -108
- package/dist/config/utils.d.ts +0 -4
- package/dist/config/utils.js +0 -6
- package/dist/config/vite-utils.d.ts +0 -21
- package/dist/config/vite-utils.js +0 -85
- package/dist/directives/bubble-function-declaration.d.ts +0 -3
- package/dist/directives/bubble-function-declaration.js +0 -23
- package/dist/directives/compile.d.ts +0 -9
- package/dist/directives/compile.js +0 -40
- package/dist/directives/generate-unique-name.d.ts +0 -3
- package/dist/directives/generate-unique-name.js +0 -16
- package/dist/directives/get-descriptive-name.d.ts +0 -2
- package/dist/directives/get-descriptive-name.js +0 -37
- package/dist/directives/get-import-identifier.d.ts +0 -4
- package/dist/directives/get-import-identifier.js +0 -19
- package/dist/directives/get-root-statement-path.d.ts +0 -2
- package/dist/directives/get-root-statement-path.js +0 -12
- package/dist/directives/index.d.ts +0 -14
- package/dist/directives/index.js +0 -169
- package/dist/directives/is-statement-top-level.d.ts +0 -3
- package/dist/directives/is-statement-top-level.js +0 -9
- package/dist/directives/paths.d.ts +0 -9
- package/dist/directives/paths.js +0 -36
- package/dist/directives/plugin.d.ts +0 -21
- package/dist/directives/plugin.js +0 -302
- package/dist/directives/remove-unused-variables.d.ts +0 -3
- package/dist/directives/remove-unused-variables.js +0 -53
- package/dist/directives/types.d.ts +0 -10
- package/dist/directives/types.js +0 -1
- package/dist/directives/xxhash32.d.ts +0 -6
- package/dist/directives/xxhash32.js +0 -193
- package/dist/fns/client.d.ts +0 -3
- package/dist/fns/client.js +0 -106
- package/dist/fns/handler.d.ts +0 -5
- package/dist/fns/handler.js +0 -269
- package/dist/fns/registration.d.ts +0 -2
- package/dist/fns/registration.js +0 -12
- package/dist/fns/serialization.d.ts +0 -6
- package/dist/fns/serialization.js +0 -208
- package/dist/fns/server.d.ts +0 -7
- package/dist/fns/server.js +0 -38
- package/dist/fns/shared.d.ts +0 -17
- package/dist/fns/shared.js +0 -105
- package/dist/http/index.d.ts +0 -81
- package/dist/http/index.js +0 -129
- package/dist/index.d.ts +0 -5
- package/dist/index.jsx +0 -6
- package/dist/middleware/index.d.ts +0 -38
- package/dist/middleware/index.js +0 -59
- package/dist/router.d.ts +0 -6
- package/dist/router.jsx +0 -29
- package/dist/server/StartServer.d.ts +0 -9
- package/dist/server/StartServer.jsx +0 -34
- package/dist/server/assets/PatchVirtualDevStyles.d.ts +0 -4
- package/dist/server/assets/PatchVirtualDevStyles.jsx +0 -28
- package/dist/server/assets/index.d.ts +0 -2
- package/dist/server/assets/index.js +0 -52
- package/dist/server/assets/render.d.ts +0 -19
- package/dist/server/assets/render.jsx +0 -14
- package/dist/server/collect-styles.d.ts +0 -3
- package/dist/server/collect-styles.js +0 -57
- package/dist/server/fetchEvent.d.ts +0 -7
- package/dist/server/fetchEvent.js +0 -26
- package/dist/server/handler.d.ts +0 -64
- package/dist/server/handler.js +0 -222
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.jsx +0 -14
- package/dist/server/manifest/client-manifest.d.ts +0 -9
- package/dist/server/manifest/client-manifest.js +0 -6
- package/dist/server/manifest/dev-client-manifest.d.ts +0 -4
- package/dist/server/manifest/dev-client-manifest.js +0 -24
- package/dist/server/manifest/dev-ssr-manifest.d.ts +0 -5
- package/dist/server/manifest/dev-ssr-manifest.js +0 -23
- package/dist/server/manifest/prod-client-manifest.d.ts +0 -5
- package/dist/server/manifest/prod-client-manifest.js +0 -26
- package/dist/server/manifest/prod-ssr-manifest.d.ts +0 -6
- package/dist/server/manifest/prod-ssr-manifest.js +0 -85
- package/dist/server/manifest/ssr-manifest.d.ts +0 -4
- package/dist/server/manifest/ssr-manifest.js +0 -6
- package/dist/server/routes.d.ts +0 -23
- package/dist/server/routes.js +0 -74
- package/dist/server/spa/StartServer.d.ts +0 -9
- package/dist/server/spa/StartServer.jsx +0 -25
- package/dist/server/spa/handler.d.ts +0 -36
- package/dist/server/spa/handler.js +0 -20
- package/dist/server/spa/index.d.ts +0 -4
- package/dist/server/spa/index.jsx +0 -5
- package/dist/server/types.d.ts +0 -75
- package/dist/server/types.js +0 -1
- package/dist/server/util.d.ts +0 -2
- package/dist/server/util.js +0 -8
- package/dist/shared/ErrorBoundary.d.ts +0 -3
- package/dist/shared/ErrorBoundary.jsx +0 -36
- package/dist/shared/GET.d.ts +0 -5
- package/dist/shared/GET.js +0 -8
- package/dist/shared/HttpHeader.d.ts +0 -10
- package/dist/shared/HttpHeader.jsx +0 -38
- package/dist/shared/HttpStatusCode.d.ts +0 -9
- package/dist/shared/HttpStatusCode.js +0 -18
- package/dist/shared/clientOnly.d.ts +0 -12
- package/dist/shared/clientOnly.js +0 -27
- package/dist/shared/dev-overlay/CodeView.d.ts +0 -7
- package/dist/shared/dev-overlay/CodeView.jsx +0 -62
- package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +0 -9
- package/dist/shared/dev-overlay/DevOverlayDialog.jsx +0 -226
- package/dist/shared/dev-overlay/createStackFrame.d.ts +0 -9
- package/dist/shared/dev-overlay/createStackFrame.js +0 -56
- package/dist/shared/dev-overlay/download.d.ts +0 -1
- package/dist/shared/dev-overlay/download.js +0 -6
- package/dist/shared/dev-overlay/get-source-map.d.ts +0 -2
- package/dist/shared/dev-overlay/get-source-map.js +0 -25
- package/dist/shared/dev-overlay/icons.d.ts +0 -28
- package/dist/shared/dev-overlay/icons.jsx +0 -150
- package/dist/shared/dev-overlay/index.d.ts +0 -5
- package/dist/shared/dev-overlay/index.jsx +0 -39
- package/dist/shared/dev-overlay/styles.css +0 -292
- package/dist/shared/lazy.d.ts +0 -3
- package/dist/shared/lazy.js +0 -42
- package/dist/shared/serverFunction.d.ts +0 -6
- package/dist/shared/serverFunction.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @solidjs/start
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee1193a: Update srvx to maintain response compatibility with Nitro v3.
|
|
8
|
+
- e263338: Fix `ERR_UNSUPPORTED_ESM_URL_SCHEME` when running `vite preview` on Windows
|
|
9
|
+
|
|
10
|
+
## 2.0.0-beta.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 0a9fdc3: fix cloudflare
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 0c95804: Fix URL to path conversion in manifest resolver
|
|
19
|
+
- 6011e5a: Fixed changes in route files resulting in a reload instead of hot module replace. Reloads now only are triggered when adding or removing routes.
|
|
20
|
+
- 8fb81e6: Fixed niche edge cases in the server functions dead code removal (DCE) logic:
|
|
21
|
+
- Server functions only referenced in event handlers (e.g. `onClick`) now aren't considered unused and work properly.
|
|
22
|
+
- Unused variables in server functions no longer lead to compilation errors.
|
|
23
|
+
- 8d12d6a: Fixed tailwind class changes not getting applied via HMR in filesystem routes.
|
|
24
|
+
- ec1b82b: Included Vite 8 in the peer dependency range.
|
|
25
|
+
|
|
3
26
|
## 2.0.0-alpha.3
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,27 +48,28 @@
|
|
|
48
48
|
"shiki": "^1.29.2",
|
|
49
49
|
"solid-js": "^1.9.11",
|
|
50
50
|
"source-map-js": "^1.2.1",
|
|
51
|
-
"srvx": "^0.11.
|
|
51
|
+
"srvx": "^0.11.22",
|
|
52
52
|
"terracotta": "^1.1.0",
|
|
53
53
|
"vite-plugin-solid": "^2.11.11"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=24"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/babel__core": "^7.20.5",
|
|
60
60
|
"@types/node": "^25.5.0",
|
|
61
|
-
"vite": "^
|
|
61
|
+
"vite": "^8.0.0",
|
|
62
62
|
"vitest": "^4.1.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"vite": "^7"
|
|
65
|
+
"vite": "^7 || ^8"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "pnpm validate-imports && tsc && node scripts/build.js",
|
|
69
69
|
"dev": "tsc --watch",
|
|
70
70
|
"test": "vitest",
|
|
71
71
|
"test:ci": "vitest run",
|
|
72
|
+
"typecheck:dist": "pnpm build && pnpx @arethetypeswrong/cli --pack . --profile esm-only",
|
|
72
73
|
"validate-imports": "node scripts/validate-imports.js"
|
|
73
74
|
}
|
|
74
75
|
}
|
package/src/config/constants.ts
CHANGED
package/src/config/dev-server.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
1
3
|
import { NodeRequest, sendNodeResponse } from "srvx/node";
|
|
2
4
|
import {
|
|
3
5
|
type Connect,
|
|
@@ -18,7 +20,9 @@ export function devServer(): Array<PluginOption> {
|
|
|
18
20
|
const webReq = new NodeRequest({ req, res });
|
|
19
21
|
const def: {
|
|
20
22
|
default: { fetch: (req: Request) => Promise<Response> };
|
|
21
|
-
} = await import(
|
|
23
|
+
} = await import(
|
|
24
|
+
pathToFileURL(join(process.cwd(), "dist/server/entry-server.js")).href
|
|
25
|
+
);
|
|
22
26
|
sendNodeResponse(res, await def.default.fetch(webReq));
|
|
23
27
|
});
|
|
24
28
|
};
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
FSWatcher,
|
|
4
|
-
PluginOption,
|
|
5
|
-
ViteDevServer,
|
|
6
|
-
} from "vite";
|
|
1
|
+
import type { EnvironmentModuleNode, FSWatcher, PluginOption, ViteDevServer } from "vite";
|
|
2
|
+
import { debounce } from "../../utils/debounce.ts";
|
|
7
3
|
import { VITE_ENVIRONMENTS } from "../constants.ts";
|
|
8
4
|
import { moduleId } from "./index.ts";
|
|
9
5
|
import type { BaseFileSystemRouter } from "./router.ts";
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
removeRoute(path: string): void;
|
|
13
|
-
addRoute(path: string): void;
|
|
14
|
-
updateRoute(path: string): void;
|
|
15
|
-
addEventListener(event: "reload", handler: () => void): void;
|
|
16
|
-
removeEventListener(event: "reload", handler: () => void): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function setupWatcher(watcher: FSWatcher, routes: CompiledRouter): void {
|
|
7
|
+
function setupWatcher(watcher: FSWatcher, routes: BaseFileSystemRouter): void {
|
|
20
8
|
watcher.on("unlink", path => routes.removeRoute(path));
|
|
21
9
|
watcher.on("add", path => routes.addRoute(path));
|
|
22
10
|
watcher.on("change", path => routes.updateRoute(path));
|
|
@@ -24,33 +12,41 @@ function setupWatcher(watcher: FSWatcher, routes: CompiledRouter): void {
|
|
|
24
12
|
|
|
25
13
|
function createRoutesReloader(
|
|
26
14
|
server: ViteDevServer,
|
|
27
|
-
routes:
|
|
15
|
+
routes: BaseFileSystemRouter,
|
|
28
16
|
environment: "client" | "ssr",
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
) {
|
|
18
|
+
const devEnv = server.environments[environment]!;
|
|
19
|
+
if (!devEnv?.moduleGraph) return;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Debounce catches multiple route changes in a row
|
|
23
|
+
* Short timeout for inexpensive invalidations
|
|
24
|
+
*/
|
|
25
|
+
const invalidateModule = debounce((mod: EnvironmentModuleNode) => {
|
|
26
|
+
devEnv.moduleGraph.invalidateModule(mod);
|
|
27
|
+
}, 0);
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Long debounce timeout for expensive reloads
|
|
31
|
+
*/
|
|
32
|
+
const reloadModule = debounce((mod: EnvironmentModuleNode) => {
|
|
33
|
+
devEnv.reloadModule(mod);
|
|
34
|
+
}, 200);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (mod) {
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
return routes.on("reload", function handleRoutesReload(evt): void {
|
|
37
|
+
const mod = devEnv.moduleGraph.getModuleById(moduleId)!;
|
|
38
|
+
if (!mod) {
|
|
39
|
+
devEnv.hot.send({ type: "full-reload" });
|
|
40
|
+
return;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
if (environment !== "
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
43
|
+
if (environment === VITE_ENVIRONMENTS.client && evt.detail.type !== "update") {
|
|
44
|
+
// Client has to be reloaded when routes are added or removed
|
|
45
|
+
reloadModule(mod);
|
|
46
|
+
} else {
|
|
47
|
+
invalidateModule(mod);
|
|
52
48
|
}
|
|
53
|
-
}
|
|
49
|
+
});
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
export const fileSystemWatcher = (
|
|
@@ -59,11 +55,11 @@ export const fileSystemWatcher = (
|
|
|
59
55
|
const plugin: PluginOption = {
|
|
60
56
|
name: "fs-watcher",
|
|
61
57
|
async configureServer(server: ViteDevServer) {
|
|
62
|
-
|
|
63
|
-
const router =
|
|
58
|
+
for (const environment of [VITE_ENVIRONMENTS.server, VITE_ENVIRONMENTS.client]) {
|
|
59
|
+
const router = routers[environment];
|
|
64
60
|
setupWatcher(server.watcher, router);
|
|
65
|
-
createRoutesReloader(server, router, environment
|
|
66
|
-
}
|
|
61
|
+
createRoutesReloader(server, router, environment);
|
|
62
|
+
}
|
|
67
63
|
},
|
|
68
64
|
};
|
|
69
65
|
return plugin;
|
|
@@ -32,6 +32,8 @@ export function analyzeModule(src: string) {
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
type RouterEvent = CustomEvent<{ route: string; type: "update" | "remove" | "add" }>;
|
|
36
|
+
|
|
35
37
|
export class BaseFileSystemRouter extends EventTarget {
|
|
36
38
|
routes: Route[];
|
|
37
39
|
|
|
@@ -98,8 +100,11 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
98
100
|
update = undefined;
|
|
99
101
|
|
|
100
102
|
_addRoute(route: Route) {
|
|
101
|
-
|
|
103
|
+
const idx = this.routes.findIndex(r => r.path === route.path);
|
|
104
|
+
if (idx >= 0) this.routes.splice(idx, 1);
|
|
102
105
|
this.routes.push(route);
|
|
106
|
+
|
|
107
|
+
return idx >= 0;
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
async addRoute(src: string) {
|
|
@@ -109,7 +114,7 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
109
114
|
const route = this.toRoute(src);
|
|
110
115
|
if (route) {
|
|
111
116
|
this._addRoute(route);
|
|
112
|
-
this.reload(route.path);
|
|
117
|
+
this.reload(route.path, "add");
|
|
113
118
|
}
|
|
114
119
|
} catch (e) {
|
|
115
120
|
console.error(e);
|
|
@@ -117,25 +122,27 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
reload(route: string) {
|
|
125
|
+
reload(route: string, type: "update" | "remove" | "add") {
|
|
121
126
|
this.dispatchEvent(
|
|
122
|
-
new
|
|
123
|
-
// @ts-ignore
|
|
127
|
+
new CustomEvent("reload", {
|
|
124
128
|
detail: {
|
|
125
129
|
route,
|
|
130
|
+
type,
|
|
126
131
|
},
|
|
127
132
|
}),
|
|
128
133
|
);
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
async updateRoute(
|
|
132
|
-
src = normalizePath(
|
|
136
|
+
async updateRoute(src_: string) {
|
|
137
|
+
const src = normalizePath(src_);
|
|
133
138
|
if (this.isRoute(src)) {
|
|
134
139
|
try {
|
|
135
140
|
const route = this.toRoute(src);
|
|
136
141
|
if (route) {
|
|
137
|
-
this._addRoute(route);
|
|
138
|
-
this.reload(route.path);
|
|
142
|
+
const updated = this._addRoute(route);
|
|
143
|
+
this.reload(route.path, updated ? "update" : "add");
|
|
144
|
+
} else {
|
|
145
|
+
this.removeRoute(src_);
|
|
139
146
|
}
|
|
140
147
|
} catch (e) {
|
|
141
148
|
console.error(e);
|
|
@@ -151,11 +158,20 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
151
158
|
if (path === undefined) {
|
|
152
159
|
return;
|
|
153
160
|
}
|
|
154
|
-
|
|
155
|
-
this.
|
|
161
|
+
|
|
162
|
+
const idx = this.routes.findIndex(r => r.path === path);
|
|
163
|
+
if (idx === -1) return;
|
|
164
|
+
|
|
165
|
+
this.routes.splice(idx, 1);
|
|
166
|
+
this.reload(path, "remove");
|
|
156
167
|
}
|
|
157
168
|
}
|
|
158
169
|
|
|
170
|
+
on(type: string, cb: (evt: RouterEvent) => void) {
|
|
171
|
+
this.addEventListener(type, cb as any);
|
|
172
|
+
return () => this.removeEventListener(type, cb as any);
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
buildRoutesPromise?: Promise<any[]>;
|
|
160
176
|
|
|
161
177
|
async getRoutes() {
|
|
@@ -6,7 +6,7 @@ import type * as Babel from "@babel/core";
|
|
|
6
6
|
import type { NodePath, PluginObj, PluginPass } from "@babel/core";
|
|
7
7
|
import type { Binding } from "@babel/traverse";
|
|
8
8
|
import { basename } from "pathe";
|
|
9
|
-
import type { Plugin
|
|
9
|
+
import type { Plugin } from "vite";
|
|
10
10
|
|
|
11
11
|
type State = Omit<PluginPass, "opts"> & {
|
|
12
12
|
opts: { pick: string[] };
|
|
@@ -280,10 +280,6 @@ function treeShakeTransform({ types: t }: typeof Babel): PluginObj<State> {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
export function treeShake(): Plugin {
|
|
283
|
-
let config: ResolvedConfig;
|
|
284
|
-
const cache: Record<string, any> = {};
|
|
285
|
-
let server: ViteDevServer;
|
|
286
|
-
|
|
287
283
|
async function transform(id: string, code: string) {
|
|
288
284
|
const [path, queryString] = id.split("?");
|
|
289
285
|
const query = new URLSearchParams(queryString);
|
|
@@ -308,46 +304,6 @@ export function treeShake(): Plugin {
|
|
|
308
304
|
return {
|
|
309
305
|
name: "tree-shake",
|
|
310
306
|
enforce: "pre",
|
|
311
|
-
configResolved(resolvedConfig) {
|
|
312
|
-
config = resolvedConfig;
|
|
313
|
-
},
|
|
314
|
-
configureServer(s) {
|
|
315
|
-
server = s;
|
|
316
|
-
},
|
|
317
|
-
async handleHotUpdate(ctx) {
|
|
318
|
-
if (cache[ctx.file]) {
|
|
319
|
-
const mods = [];
|
|
320
|
-
const newCode = await ctx.read();
|
|
321
|
-
for (const [id, code] of Object.entries(cache[ctx.file])) {
|
|
322
|
-
const transformed = await transform(id, newCode);
|
|
323
|
-
if (!transformed) continue;
|
|
324
|
-
|
|
325
|
-
const { code: transformedCode } = transformed;
|
|
326
|
-
|
|
327
|
-
if (transformedCode !== code) {
|
|
328
|
-
const mod = server.moduleGraph.getModuleById(id);
|
|
329
|
-
if (mod) mods.push(mod);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
cache[ctx.file] ??= {};
|
|
333
|
-
cache[ctx.file][id] = transformedCode;
|
|
334
|
-
// server.moduleGraph.setModuleSource(id, code);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return mods;
|
|
338
|
-
}
|
|
339
|
-
// const mods = [];
|
|
340
|
-
// [...server.moduleGraph.urlToModuleMap.entries()].forEach(([url, m]) => {
|
|
341
|
-
// if (m.file === ctx.file && m.id.includes("pick=")) {
|
|
342
|
-
// if (!m.id.includes("pick=loader")) {
|
|
343
|
-
// mods.push(m);
|
|
344
|
-
// }
|
|
345
|
-
// }
|
|
346
|
-
// });
|
|
347
|
-
// return mods;
|
|
348
|
-
// // this.router.updateRoute(ctx.path);
|
|
349
|
-
// }
|
|
350
|
-
},
|
|
351
307
|
async transform(code, id) {
|
|
352
308
|
const [path, queryString] = id.split("?");
|
|
353
309
|
if (!path) return;
|
|
@@ -358,9 +314,6 @@ export function treeShake(): Plugin {
|
|
|
358
314
|
const transformed = await transform(id, code);
|
|
359
315
|
if (!transformed?.code) return;
|
|
360
316
|
|
|
361
|
-
cache[path] ??= {};
|
|
362
|
-
cache[path][id] = transformed.code;
|
|
363
|
-
|
|
364
317
|
return {
|
|
365
318
|
code: transformed.code,
|
|
366
319
|
map: transformed.map,
|
package/src/config/index.ts
CHANGED
|
@@ -63,6 +63,18 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
63
63
|
server: `${start.appRoot}/entry-server${entryExtension}`,
|
|
64
64
|
};
|
|
65
65
|
return [
|
|
66
|
+
// TODO (Alexis): check if the comment below is still relevant
|
|
67
|
+
//
|
|
68
|
+
// Must be placed after fsRoutes, as treeShake will remove the
|
|
69
|
+
// server fn exports added in by this plugin
|
|
70
|
+
serverFunctionsPlugin({
|
|
71
|
+
manifest: VIRTUAL_MODULES.serverFnManifest,
|
|
72
|
+
runtime: {
|
|
73
|
+
server: '@solidjs/start/fns/server',
|
|
74
|
+
client: '@solidjs/start/fns/client',
|
|
75
|
+
},
|
|
76
|
+
filter: options?.serverFunctions?.filter,
|
|
77
|
+
}),
|
|
66
78
|
{
|
|
67
79
|
name: "solid-start:config",
|
|
68
80
|
enforce: "pre",
|
|
@@ -190,16 +202,6 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
190
202
|
}),
|
|
191
203
|
lazy(),
|
|
192
204
|
envPlugin(options?.env),
|
|
193
|
-
// Must be placed after fsRoutes, as treeShake will remove the
|
|
194
|
-
// server fn exports added in by this plugin
|
|
195
|
-
serverFunctionsPlugin({
|
|
196
|
-
manifest: VIRTUAL_MODULES.serverFnManifest,
|
|
197
|
-
runtime: {
|
|
198
|
-
server: '@solidjs/start/fns/server',
|
|
199
|
-
client: '@solidjs/start/fns/client',
|
|
200
|
-
},
|
|
201
|
-
filter: options?.serverFunctions?.filter,
|
|
202
|
-
}),
|
|
203
205
|
{
|
|
204
206
|
name: "solid-start:virtual-modules",
|
|
205
207
|
async resolveId(id) {
|
package/src/config/lazy.ts
CHANGED
|
@@ -90,6 +90,7 @@ const lazy = (): PluginOption => {
|
|
|
90
90
|
// The transformed files either import "lazy" or css files
|
|
91
91
|
// Therefore we skip, if the src doesn't have any import
|
|
92
92
|
if (src.indexOf("import") === -1) return;
|
|
93
|
+
if (id.includes("entry-server")) return;
|
|
93
94
|
|
|
94
95
|
const plugins: PluginItem[] = [];
|
|
95
96
|
|
package/src/config/manifest.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { type PluginOption, type ViteDevServer, version as viteVersion } from "vite";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
|
|
5
6
|
import { findStylesInModuleGraph } from "../server/collect-styles.ts";
|
|
6
7
|
import { VIRTUAL_MODULES } from "./constants.ts";
|
|
@@ -20,12 +21,16 @@ export function manifest(start: SolidStartOptions): PluginOption {
|
|
|
20
21
|
return `\0${VIRTUAL_MODULES.clientViteManifest}`;
|
|
21
22
|
if (id === VIRTUAL_MODULES.getClientManifest)
|
|
22
23
|
return this.resolve(
|
|
23
|
-
new URL("../server/manifest/client-manifest", import.meta.url)
|
|
24
|
+
fileURLToPath(new URL("../server/manifest/client-manifest", import.meta.url)),
|
|
24
25
|
);
|
|
25
26
|
if (id === VIRTUAL_MODULES.getManifest) {
|
|
26
27
|
return this.environment.config.consumer === "client"
|
|
27
|
-
? this.resolve(
|
|
28
|
-
|
|
28
|
+
? this.resolve(
|
|
29
|
+
fileURLToPath(new URL("../server/manifest/client-manifest", import.meta.url)),
|
|
30
|
+
)
|
|
31
|
+
: this.resolve(
|
|
32
|
+
fileURLToPath(new URL("../server/manifest/ssr-manifest", import.meta.url)),
|
|
33
|
+
);
|
|
29
34
|
}
|
|
30
35
|
if (id === VIRTUAL_MODULES.middleware) {
|
|
31
36
|
if (start.middleware) return await this.resolve(start.middleware);
|
package/src/directives/index.ts
CHANGED
|
@@ -196,6 +196,7 @@ export function serverFunctionsPlugin(options: ServerFunctionsOptions): Plugin[]
|
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
198
|
name: "solid-start:server-functions/compiler",
|
|
199
|
+
enforce: 'pre',
|
|
199
200
|
async transform(code, fileId, opts) {
|
|
200
201
|
const mode = opts?.ssr ? "server" : "client";
|
|
201
202
|
const [id] = fileId.split("?");
|
|
@@ -2,6 +2,20 @@ import type * as babel from "@babel/core";
|
|
|
2
2
|
import * as t from "@babel/types";
|
|
3
3
|
import { isPathValid } from "./paths.ts";
|
|
4
4
|
|
|
5
|
+
function isInvalidForRemoval(path: babel.NodePath) {
|
|
6
|
+
if (isPathValid(path, t.isCatchClause)) {
|
|
7
|
+
// This case is for `catch (error)` blocks
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// This one is for destructured variables
|
|
12
|
+
let target = path;
|
|
13
|
+
if (isPathValid(path, t.isVariableDeclarator)) {
|
|
14
|
+
target = path.get('id');
|
|
15
|
+
}
|
|
16
|
+
return isPathValid(target, t.isObjectPattern) || isPathValid(target, t.isArrayPattern);
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
export function removeUnusedVariables(program: babel.NodePath<t.Program>) {
|
|
6
20
|
// TODO(Alexis):
|
|
7
21
|
// This implementation is simple but slow
|
|
@@ -24,17 +38,18 @@ export function removeUnusedVariables(program: babel.NodePath<t.Program>) {
|
|
|
24
38
|
case "hoisted":
|
|
25
39
|
case "module":
|
|
26
40
|
if (binding.references === 0 && !binding.path.removed) {
|
|
27
|
-
if (isPathValid(binding.path.parentPath, t.isImportDeclaration)) {
|
|
28
41
|
const parent = binding.path.parentPath;
|
|
42
|
+
if (isPathValid(parent, t.isImportDeclaration)) {
|
|
29
43
|
if (parent.node.specifiers.length === 1) {
|
|
30
44
|
parent.remove();
|
|
31
45
|
} else {
|
|
32
46
|
binding.path.remove();
|
|
33
47
|
}
|
|
34
|
-
|
|
48
|
+
dirty = true;
|
|
49
|
+
} else if (!(isInvalidForRemoval(binding.path))) {
|
|
35
50
|
binding.path.remove();
|
|
51
|
+
dirty = true;
|
|
36
52
|
}
|
|
37
|
-
dirty = true;
|
|
38
53
|
}
|
|
39
54
|
break;
|
|
40
55
|
case "local":
|
package/src/server/handler.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import middleware from "solid-start:middleware";
|
|
2
|
-
import { defineHandler, getCookie, H3, type H3Event, redirect, setCookie } from "h3";
|
|
2
|
+
import { defineHandler, getCookie, H3, type H3Event, redirect, setCookie } from "h3/generic";
|
|
3
3
|
import { join } from "pathe";
|
|
4
4
|
import type { JSX } from "solid-js";
|
|
5
5
|
import { sharedConfig } from "solid-js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays the invocation of a function
|
|
3
|
+
*/
|
|
4
|
+
export const debounce = <T extends (...args: any[]) => void>(cb: T, debounceMs: number) => {
|
|
5
|
+
let timeout: NodeJS.Timeout | undefined;
|
|
6
|
+
return (...args: Parameters<T>) => {
|
|
7
|
+
clearTimeout(timeout);
|
|
8
|
+
timeout = setTimeout(() => cb(...args), debounceMs)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// @refresh skip
|
|
2
|
-
import App from "solid-start:app";
|
|
3
|
-
import { ErrorBoundary } from "../shared/ErrorBoundary.jsx";
|
|
4
|
-
function Dummy(props) {
|
|
5
|
-
return props.children;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
|
|
10
|
-
*/
|
|
11
|
-
export function StartClient() {
|
|
12
|
-
return (<Dummy>
|
|
13
|
-
<Dummy>
|
|
14
|
-
<ErrorBoundary>
|
|
15
|
-
<App />
|
|
16
|
-
</ErrorBoundary>
|
|
17
|
-
</Dummy>
|
|
18
|
-
</Dummy>);
|
|
19
|
-
}
|
|
20
|
-
export function StartClientTanstack() {
|
|
21
|
-
return (<Dummy>
|
|
22
|
-
<ErrorBoundary>
|
|
23
|
-
<App />
|
|
24
|
-
</ErrorBoundary>
|
|
25
|
-
</Dummy>);
|
|
26
|
-
}
|
package/dist/client/index.d.ts
DELETED
package/dist/client/index.jsx
DELETED
package/dist/client/mount.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { hydrate as mount } from "solid-js/web";
|
package/dist/client/mount.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { hydrate as mount } from "solid-js/web";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_EXTENSIONS: string[];
|
|
2
|
-
export declare const CLIENT_BASE_PATH = "_build";
|
|
3
|
-
export declare const VIRTUAL_MODULES: {
|
|
4
|
-
readonly clientViteManifest: "solid-start:client-vite-manifest";
|
|
5
|
-
readonly getClientManifest: "solid-start:get-client-manifest";
|
|
6
|
-
readonly getManifest: "solid-start:get-manifest";
|
|
7
|
-
readonly middleware: "solid-start:middleware";
|
|
8
|
-
readonly serverFnManifest: "solid-start:server-fn-manifest";
|
|
9
|
-
readonly clientEntry: "solid-start:client-entry";
|
|
10
|
-
readonly serverEntry: "solid-start:server-entry";
|
|
11
|
-
readonly app: "solid-start:app";
|
|
12
|
-
};
|
|
13
|
-
export declare const VITE_ENVIRONMENTS: {
|
|
14
|
-
client: string;
|
|
15
|
-
server: string;
|
|
16
|
-
};
|
package/dist/config/constants.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
|
|
2
|
-
export const CLIENT_BASE_PATH = "_build";
|
|
3
|
-
export const VIRTUAL_MODULES = {
|
|
4
|
-
clientViteManifest: "solid-start:client-vite-manifest",
|
|
5
|
-
getClientManifest: "solid-start:get-client-manifest",
|
|
6
|
-
getManifest: "solid-start:get-manifest",
|
|
7
|
-
middleware: "solid-start:middleware",
|
|
8
|
-
serverFnManifest: "solid-start:server-fn-manifest",
|
|
9
|
-
clientEntry: "solid-start:client-entry",
|
|
10
|
-
serverEntry: "solid-start:server-entry",
|
|
11
|
-
app: "solid-start:app",
|
|
12
|
-
};
|
|
13
|
-
export const VITE_ENVIRONMENTS = {
|
|
14
|
-
client: "client",
|
|
15
|
-
server: "ssr",
|
|
16
|
-
};
|