@solidjs/start 2.0.0-beta.0 → 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 +7 -0
- package/package.json +5 -4
- package/src/config/dev-server.ts +5 -1
- 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 -53
- 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 -42
- package/dist/config/fs-routes/router.js +0 -148
- package/dist/config/fs-routes/tree-shake.d.ts +0 -2
- package/dist/config/fs-routes/tree-shake.js +0 -305
- package/dist/config/index.d.ts +0 -25
- package/dist/config/index.js +0 -217
- package/dist/config/lazy.d.ts +0 -3
- package/dist/config/lazy.js +0 -114
- package/dist/config/manifest.d.ts +0 -3
- package/dist/config/manifest.js +0 -109
- 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 -170
- 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 -66
- 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/dist/utils/debounce.d.ts +0 -4
- package/dist/utils/debounce.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## 2.0.0-beta.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,17 +48,17 @@
|
|
|
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": {
|
|
@@ -69,6 +69,7 @@
|
|
|
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/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,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: "client";
|
|
15
|
-
server: "ssr";
|
|
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
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
import { NodeRequest, sendNodeResponse } from "srvx/node";
|
|
10
|
-
import { isRunnableDevEnvironment, } from "vite";
|
|
11
|
-
import { VITE_ENVIRONMENTS } from "./constants.js";
|
|
12
|
-
export function devServer() {
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
name: "solid-start-dev-server",
|
|
16
|
-
configurePreviewServer(server) {
|
|
17
|
-
return () => {
|
|
18
|
-
server.middlewares.use(async (req, res) => {
|
|
19
|
-
res.setHeader("content-encoding", "identity");
|
|
20
|
-
const webReq = new NodeRequest({ req, res });
|
|
21
|
-
const def = await import(__rewriteRelativeImportExtension(process.cwd() + "/dist/server/entry-server.js", true));
|
|
22
|
-
sendNodeResponse(res, await def.default.fetch(webReq));
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
configureServer(viteDevServer) {
|
|
27
|
-
globalThis.VITE_DEV_SERVER = viteDevServer;
|
|
28
|
-
return async () => {
|
|
29
|
-
if (viteDevServer.config.server.middlewareMode)
|
|
30
|
-
return;
|
|
31
|
-
const serverEnv = viteDevServer.environments[VITE_ENVIRONMENTS.server];
|
|
32
|
-
if (!serverEnv)
|
|
33
|
-
throw new Error("Server environment not found");
|
|
34
|
-
if (
|
|
35
|
-
// do not check via `isFetchableDevEnvironment` since nitro does implement the `FetchableDevEnvironment` interface but not via inheritance (which this helper checks)
|
|
36
|
-
"dispatchFetch" in serverEnv)
|
|
37
|
-
return;
|
|
38
|
-
// another plugin is controlling the dev server
|
|
39
|
-
if (!isRunnableDevEnvironment(serverEnv)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
globalThis.USING_SOLID_START_DEV_SERVER = true;
|
|
43
|
-
removeHtmlMiddlewares(viteDevServer);
|
|
44
|
-
viteDevServer.middlewares.use(async (req, res) => {
|
|
45
|
-
if (req.originalUrl) {
|
|
46
|
-
req.url = req.originalUrl;
|
|
47
|
-
}
|
|
48
|
-
const webReq = new NodeRequest({ req, res });
|
|
49
|
-
try {
|
|
50
|
-
const serverEntry = await serverEnv.runner.import("./src/entry-server.tsx");
|
|
51
|
-
const webRes = await serverEntry.default.fetch(webReq);
|
|
52
|
-
return sendNodeResponse(res, webRes);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
console.error(e);
|
|
56
|
-
viteDevServer.ssrFixStacktrace(e);
|
|
57
|
-
if (webReq.headers.get("content-type")?.includes("application/json")) {
|
|
58
|
-
return sendNodeResponse(res, Response.json({
|
|
59
|
-
status: 500,
|
|
60
|
-
error: "Internal Server Error",
|
|
61
|
-
message: "An unexpected error occurred. Please try again later.",
|
|
62
|
-
timestamp: new Date().toISOString(),
|
|
63
|
-
}, {
|
|
64
|
-
status: 500,
|
|
65
|
-
headers: {
|
|
66
|
-
"Content-Type": "application/json",
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
return sendNodeResponse(res, new Response(`
|
|
71
|
-
<!DOCTYPE html>
|
|
72
|
-
<html lang="en">
|
|
73
|
-
<head>
|
|
74
|
-
<meta charset="UTF-8" />
|
|
75
|
-
<title>Error</title>
|
|
76
|
-
<script type="module">
|
|
77
|
-
import { ErrorOverlay } from '/@vite/client'
|
|
78
|
-
document.body.appendChild(new ErrorOverlay(${JSON.stringify(prepareError(req, e)).replace(/</g, "\\u003c")}))
|
|
79
|
-
</script>
|
|
80
|
-
</head>
|
|
81
|
-
<body>
|
|
82
|
-
</body>
|
|
83
|
-
</html>
|
|
84
|
-
`, {
|
|
85
|
-
status: 500,
|
|
86
|
-
headers: { "Content-Type": "text/html" },
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Removes Vite internal middleware
|
|
97
|
-
*
|
|
98
|
-
* @param server
|
|
99
|
-
*/
|
|
100
|
-
function removeHtmlMiddlewares(server) {
|
|
101
|
-
const html_middlewares = [
|
|
102
|
-
"viteIndexHtmlMiddleware",
|
|
103
|
-
"vite404Middleware",
|
|
104
|
-
"viteSpaFallbackMiddleware",
|
|
105
|
-
];
|
|
106
|
-
for (let i = server.middlewares.stack.length - 1; i > 0; i--) {
|
|
107
|
-
if (html_middlewares.includes(
|
|
108
|
-
// @ts-expect-error
|
|
109
|
-
server.middlewares.stack[i].handle.name)) {
|
|
110
|
-
server.middlewares.stack.splice(i, 1);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Formats error for SSR message in error overlay
|
|
116
|
-
* @param req
|
|
117
|
-
* @param error
|
|
118
|
-
* @returns
|
|
119
|
-
*/
|
|
120
|
-
function prepareError(req, error) {
|
|
121
|
-
const e = error;
|
|
122
|
-
return {
|
|
123
|
-
message: `An error occured while server rendering ${req.url}:\n\n\t${typeof e === "string" ? e : e.message} `,
|
|
124
|
-
stack: typeof e === "string" ? "" : e.stack,
|
|
125
|
-
};
|
|
126
|
-
}
|
package/dist/config/env.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from "vite";
|
|
2
|
-
declare const LOADERS: {
|
|
3
|
-
node: string;
|
|
4
|
-
"cloudflare-workers": string;
|
|
5
|
-
"netlify-edge": string;
|
|
6
|
-
};
|
|
7
|
-
export interface EnvPluginOptions {
|
|
8
|
-
server?: {
|
|
9
|
-
runtime?: keyof typeof LOADERS | (string & {});
|
|
10
|
-
load?: (mode: string) => Record<string, string>;
|
|
11
|
-
prefix?: string;
|
|
12
|
-
};
|
|
13
|
-
client?: {
|
|
14
|
-
load?: (mode: string) => Record<string, string>;
|
|
15
|
-
prefix?: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare function envPlugin(options?: EnvPluginOptions): Plugin;
|
|
19
|
-
export {};
|
package/dist/config/env.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { loadEnv } from "vite";
|
|
2
|
-
const LOADERS = {
|
|
3
|
-
node: `export default key => process.env[key];`,
|
|
4
|
-
"cloudflare-workers": `import { env } from 'cloudflare:workers';export default key => env[key];`,
|
|
5
|
-
"netlify-edge": `export default key => Netlify.env.get(key);`,
|
|
6
|
-
};
|
|
7
|
-
const SERVER_ENV = "env:server";
|
|
8
|
-
const CLIENT_ENV = "env:client";
|
|
9
|
-
const SERVER_RUNTIME_ENV = `${SERVER_ENV}/runtime`;
|
|
10
|
-
const SERVER_RUNTIME_LOADER = `${SERVER_RUNTIME_ENV}/loader`;
|
|
11
|
-
const DEFAULT_SERVER_PREFIX = "SERVER_";
|
|
12
|
-
const DEFAULT_CLIENT_PREFIX = "CLIENT_";
|
|
13
|
-
const SERVER_ONLY_MODULE = `throw new Error('Attempt to load server-only environment variables in client runtime.');`;
|
|
14
|
-
const SERVER_RUNTIME_CODE = `import load from '${SERVER_RUNTIME_LOADER}';
|
|
15
|
-
|
|
16
|
-
export default new Proxy({}, {
|
|
17
|
-
get(_, key) {
|
|
18
|
-
return load(key);
|
|
19
|
-
},
|
|
20
|
-
})`;
|
|
21
|
-
function convertObjectToModule(object) {
|
|
22
|
-
let result = "";
|
|
23
|
-
for (const key in object) {
|
|
24
|
-
result += `export const ${key} = ${JSON.stringify(object[key])};`;
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
export function envPlugin(options) {
|
|
29
|
-
const currentOptions = options ?? {};
|
|
30
|
-
let env;
|
|
31
|
-
const serverPrefix = currentOptions.server?.prefix ?? DEFAULT_SERVER_PREFIX;
|
|
32
|
-
const clientPrefix = currentOptions.client?.prefix ?? DEFAULT_CLIENT_PREFIX;
|
|
33
|
-
const runtime = options?.server?.runtime ?? "node";
|
|
34
|
-
const runtimeCode = runtime in LOADERS ? LOADERS[runtime] : runtime;
|
|
35
|
-
return {
|
|
36
|
-
name: "solid-start:env",
|
|
37
|
-
enforce: "pre",
|
|
38
|
-
configResolved(config) {
|
|
39
|
-
env = config.mode !== "production" ? "development" : "production";
|
|
40
|
-
},
|
|
41
|
-
resolveId(id) {
|
|
42
|
-
if (id === SERVER_ENV ||
|
|
43
|
-
id === CLIENT_ENV ||
|
|
44
|
-
id === SERVER_RUNTIME_ENV ||
|
|
45
|
-
id === SERVER_RUNTIME_LOADER) {
|
|
46
|
-
return id;
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
},
|
|
50
|
-
load(id, opts) {
|
|
51
|
-
if (id === SERVER_ENV) {
|
|
52
|
-
if (!opts?.ssr) {
|
|
53
|
-
return SERVER_ONLY_MODULE;
|
|
54
|
-
}
|
|
55
|
-
const vars = currentOptions.server?.load
|
|
56
|
-
? currentOptions.server.load(env)
|
|
57
|
-
: loadEnv(env, '.', serverPrefix);
|
|
58
|
-
return convertObjectToModule(vars);
|
|
59
|
-
}
|
|
60
|
-
if (id === CLIENT_ENV) {
|
|
61
|
-
const vars = currentOptions.client?.load
|
|
62
|
-
? currentOptions.client.load(env)
|
|
63
|
-
: loadEnv(env, '.', clientPrefix);
|
|
64
|
-
return convertObjectToModule(vars);
|
|
65
|
-
}
|
|
66
|
-
if (id === SERVER_RUNTIME_LOADER) {
|
|
67
|
-
if (!opts?.ssr) {
|
|
68
|
-
return SERVER_ONLY_MODULE;
|
|
69
|
-
}
|
|
70
|
-
return runtimeCode;
|
|
71
|
-
}
|
|
72
|
-
if (id === SERVER_RUNTIME_ENV) {
|
|
73
|
-
if (!opts?.ssr) {
|
|
74
|
-
return SERVER_ONLY_MODULE;
|
|
75
|
-
}
|
|
76
|
-
return SERVER_RUNTIME_CODE;
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { BaseFileSystemRouter, type FileSystemRouterConfig } from "./fs-routes/router.ts";
|
|
2
|
-
export declare class SolidStartClientFileRouter extends BaseFileSystemRouter {
|
|
3
|
-
toPath(src: string): string;
|
|
4
|
-
toRoute(src: string): {
|
|
5
|
-
page: boolean;
|
|
6
|
-
$component: {
|
|
7
|
-
src: string;
|
|
8
|
-
pick: string[];
|
|
9
|
-
};
|
|
10
|
-
$$route: {
|
|
11
|
-
src: string;
|
|
12
|
-
pick: string[];
|
|
13
|
-
} | undefined;
|
|
14
|
-
path: string;
|
|
15
|
-
} | undefined;
|
|
16
|
-
}
|
|
17
|
-
export declare class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
18
|
-
config: FileSystemRouterConfig & {
|
|
19
|
-
dataOnly?: boolean;
|
|
20
|
-
};
|
|
21
|
-
constructor(config: FileSystemRouterConfig & {
|
|
22
|
-
dataOnly?: boolean;
|
|
23
|
-
});
|
|
24
|
-
toPath(src: string): string;
|
|
25
|
-
toRoute(src: string): {
|
|
26
|
-
path: string;
|
|
27
|
-
page: boolean;
|
|
28
|
-
$component: {
|
|
29
|
-
src: string;
|
|
30
|
-
pick: string[];
|
|
31
|
-
} | undefined;
|
|
32
|
-
$$route: {
|
|
33
|
-
src: string;
|
|
34
|
-
pick: string[];
|
|
35
|
-
} | undefined;
|
|
36
|
-
} | undefined;
|
|
37
|
-
}
|
package/dist/config/fs-router.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { analyzeModule, BaseFileSystemRouter, cleanPath, } from "./fs-routes/router.js";
|
|
2
|
-
export class SolidStartClientFileRouter extends BaseFileSystemRouter {
|
|
3
|
-
toPath(src) {
|
|
4
|
-
const routePath = cleanPath(src, this.config)
|
|
5
|
-
// remove the initial slash
|
|
6
|
-
.slice(1)
|
|
7
|
-
.replace(/index$/, "")
|
|
8
|
-
.replace(/\[([^/]+)\]/g, (_, m) => {
|
|
9
|
-
if (m.length > 3 && m.startsWith("...")) {
|
|
10
|
-
return `*${m.slice(3)}`;
|
|
11
|
-
}
|
|
12
|
-
if (m.length > 2 && m.startsWith("[") && m.endsWith("]")) {
|
|
13
|
-
return `:${m.slice(1, -1)}?`;
|
|
14
|
-
}
|
|
15
|
-
return `:${m}`;
|
|
16
|
-
});
|
|
17
|
-
return routePath?.length > 0 ? `/${routePath}` : "/";
|
|
18
|
-
}
|
|
19
|
-
toRoute(src) {
|
|
20
|
-
const path = this.toPath(src);
|
|
21
|
-
if (src.endsWith(".md") || src.endsWith(".mdx")) {
|
|
22
|
-
return {
|
|
23
|
-
page: true,
|
|
24
|
-
$component: {
|
|
25
|
-
src: src,
|
|
26
|
-
pick: ["$css"],
|
|
27
|
-
},
|
|
28
|
-
$$route: undefined,
|
|
29
|
-
path,
|
|
30
|
-
// filePath: src
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const [_, exports] = analyzeModule(src);
|
|
34
|
-
const hasDefault = !!exports.find(e => e.n === "default");
|
|
35
|
-
const hasRouteConfig = !!exports.find(e => e.n === "route");
|
|
36
|
-
if (hasDefault) {
|
|
37
|
-
return {
|
|
38
|
-
page: true,
|
|
39
|
-
$component: {
|
|
40
|
-
src: src,
|
|
41
|
-
pick: [
|
|
42
|
-
...exports.filter(e => e.n === e.ln && e.n !== "route").map(e => e.n),
|
|
43
|
-
"default",
|
|
44
|
-
"$css",
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
$$route: hasRouteConfig
|
|
48
|
-
? {
|
|
49
|
-
src: src,
|
|
50
|
-
pick: ["route"],
|
|
51
|
-
}
|
|
52
|
-
: undefined,
|
|
53
|
-
path,
|
|
54
|
-
// filePath: src
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const HTTP_METHODS = ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
|
|
60
|
-
function createHTTPHandlers(src, exports) {
|
|
61
|
-
const handlers = {};
|
|
62
|
-
for (const exp of exports) {
|
|
63
|
-
if (HTTP_METHODS.includes(exp.n)) {
|
|
64
|
-
handlers[`$${exp.n}`] = {
|
|
65
|
-
src: src,
|
|
66
|
-
pick: [exp.n],
|
|
67
|
-
};
|
|
68
|
-
if (exp.n === "GET" && !exports.find(exp => exp.n === "HEAD")) {
|
|
69
|
-
handlers.$HEAD = {
|
|
70
|
-
src: src,
|
|
71
|
-
pick: [exp.n],
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return handlers;
|
|
77
|
-
}
|
|
78
|
-
export class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
79
|
-
constructor(config) {
|
|
80
|
-
super(config);
|
|
81
|
-
}
|
|
82
|
-
toPath(src) {
|
|
83
|
-
const routePath = cleanPath(src, this.config)
|
|
84
|
-
// remove the initial slash
|
|
85
|
-
.slice(1)
|
|
86
|
-
.replace(/index$/, "")
|
|
87
|
-
.replace(/\[([^/]+)\]/g, (_, m) => {
|
|
88
|
-
if (m.length > 3 && m.startsWith("...")) {
|
|
89
|
-
return `*${m.slice(3)}`;
|
|
90
|
-
}
|
|
91
|
-
if (m.length > 2 && m.startsWith("[") && m.endsWith("]")) {
|
|
92
|
-
return `:${m.slice(1, -1)}?`;
|
|
93
|
-
}
|
|
94
|
-
return `:${m}`;
|
|
95
|
-
});
|
|
96
|
-
return routePath?.length > 0 ? `/${routePath}` : "/";
|
|
97
|
-
}
|
|
98
|
-
toRoute(src) {
|
|
99
|
-
const path = this.toPath(src);
|
|
100
|
-
if (src.endsWith(".md") || src.endsWith(".mdx")) {
|
|
101
|
-
return {
|
|
102
|
-
page: true,
|
|
103
|
-
$component: {
|
|
104
|
-
src: src,
|
|
105
|
-
pick: ["$css"],
|
|
106
|
-
},
|
|
107
|
-
$$route: undefined,
|
|
108
|
-
path,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
const [_, exports] = analyzeModule(src);
|
|
112
|
-
const hasRouteConfig = exports.find(e => e.n === "route");
|
|
113
|
-
const hasDefault = !!exports.find(e => e.n === "default");
|
|
114
|
-
const hasAPIRoutes = !!exports.find(exp => HTTP_METHODS.includes(exp.n));
|
|
115
|
-
if (hasDefault || hasAPIRoutes) {
|
|
116
|
-
return {
|
|
117
|
-
page: hasDefault,
|
|
118
|
-
$component: !this.config.dataOnly && hasDefault
|
|
119
|
-
? {
|
|
120
|
-
src: src,
|
|
121
|
-
pick: [
|
|
122
|
-
...exports
|
|
123
|
-
.filter(e => e.n === e.ln && e.n !== "route" && !HTTP_METHODS.includes(e.n))
|
|
124
|
-
.map(e => e.n),
|
|
125
|
-
"default",
|
|
126
|
-
"$css",
|
|
127
|
-
],
|
|
128
|
-
}
|
|
129
|
-
: undefined,
|
|
130
|
-
$$route: hasRouteConfig
|
|
131
|
-
? {
|
|
132
|
-
src: src,
|
|
133
|
-
pick: ["route"],
|
|
134
|
-
}
|
|
135
|
-
: undefined,
|
|
136
|
-
...createHTTPHandlers(src, exports),
|
|
137
|
-
path,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { debounce } from "../../utils/debounce.js";
|
|
2
|
-
import { VITE_ENVIRONMENTS } from "../constants.js";
|
|
3
|
-
import { moduleId } from "./index.js";
|
|
4
|
-
function setupWatcher(watcher, routes) {
|
|
5
|
-
watcher.on("unlink", path => routes.removeRoute(path));
|
|
6
|
-
watcher.on("add", path => routes.addRoute(path));
|
|
7
|
-
watcher.on("change", path => routes.updateRoute(path));
|
|
8
|
-
}
|
|
9
|
-
function createRoutesReloader(server, routes, environment) {
|
|
10
|
-
const devEnv = server.environments[environment];
|
|
11
|
-
if (!devEnv?.moduleGraph)
|
|
12
|
-
return;
|
|
13
|
-
/**
|
|
14
|
-
* Debounce catches multiple route changes in a row
|
|
15
|
-
* Short timeout for inexpensive invalidations
|
|
16
|
-
*/
|
|
17
|
-
const invalidateModule = debounce((mod) => {
|
|
18
|
-
devEnv.moduleGraph.invalidateModule(mod);
|
|
19
|
-
}, 0);
|
|
20
|
-
/**
|
|
21
|
-
* Long debounce timeout for expensive reloads
|
|
22
|
-
*/
|
|
23
|
-
const reloadModule = debounce((mod) => {
|
|
24
|
-
devEnv.reloadModule(mod);
|
|
25
|
-
}, 200);
|
|
26
|
-
return routes.on("reload", function handleRoutesReload(evt) {
|
|
27
|
-
const mod = devEnv.moduleGraph.getModuleById(moduleId);
|
|
28
|
-
if (!mod) {
|
|
29
|
-
devEnv.hot.send({ type: "full-reload" });
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (environment === VITE_ENVIRONMENTS.client && evt.detail.type !== "update") {
|
|
33
|
-
// Client has to be reloaded when routes are added or removed
|
|
34
|
-
reloadModule(mod);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
invalidateModule(mod);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export const fileSystemWatcher = (routers) => {
|
|
42
|
-
const plugin = {
|
|
43
|
-
name: "fs-watcher",
|
|
44
|
-
async configureServer(server) {
|
|
45
|
-
for (const environment of [VITE_ENVIRONMENTS.server, VITE_ENVIRONMENTS.client]) {
|
|
46
|
-
const router = routers[environment];
|
|
47
|
-
setupWatcher(server.watcher, router);
|
|
48
|
-
createRoutesReloader(server, router, environment);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
return plugin;
|
|
53
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type PluginOption } from "vite";
|
|
2
|
-
import type { BaseFileSystemRouter } from "./router.ts";
|
|
3
|
-
export declare const moduleId = "solid-start:routes";
|
|
4
|
-
export interface FsRoutesArgs {
|
|
5
|
-
routers: Record<"client" | "ssr", BaseFileSystemRouter>;
|
|
6
|
-
}
|
|
7
|
-
export declare function fsRoutes({ routers }: FsRoutesArgs): Array<PluginOption>;
|