@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.
- package/CHANGELOG.md +14 -0
- package/dist/client/mount.d.ts +1 -7
- package/dist/client/mount.js +1 -99
- package/dist/config/constants.js +2 -2
- package/dist/config/fs-router.js +10 -22
- package/dist/config/fs-routes/fs-watcher.js +4 -4
- package/dist/config/fs-routes/index.js +4 -6
- package/dist/config/fs-routes/router.js +5 -5
- package/dist/config/fs-routes/tree-shake.js +12 -21
- package/dist/config/index.js +33 -36
- package/dist/config/lazy.js +9 -9
- package/dist/config/manifest.js +1 -1
- package/dist/http/index.d.ts +1 -4
- package/dist/http/index.js +3 -5
- package/dist/index.d.ts +0 -1
- package/dist/router.jsx +2 -2
- package/dist/server/assets/index.js +1 -1
- package/dist/server/assets/render.jsx +2 -2
- package/dist/server/fetchEvent.spec.js +1 -1
- package/dist/server/handler.js +29 -15
- package/dist/server/index.d.ts +1 -0
- package/dist/server/manifest/dev-client-manifest.js +1 -1
- package/dist/server/manifest/dev-ssr-manifest.js +1 -1
- package/dist/server/manifest/prod-ssr-manifest.js +7 -12
- package/dist/server/routes.js +3 -3
- package/dist/server/server-fns-runtime.js +2 -2
- package/dist/server/server-functions-handler.js +6 -11
- package/dist/server/server-runtime.js +8 -8
- package/dist/shared/dev-overlay/CodeView.d.ts +1 -1
- package/dist/shared/dev-overlay/CodeView.jsx +23 -34
- package/dist/shared/dev-overlay/DevOverlayDialog.jsx +4 -4
- package/dist/shared/dev-overlay/get-source-map.d.ts +1 -1
- package/dist/shared/dev-overlay/get-source-map.js +5 -5
- package/dist/shared/dev-overlay/icons.d.ts +10 -10
- package/dist/shared/dev-overlay/icons.jsx +91 -91
- package/dist/shared/dev-overlay/index.jsx +1 -1
- package/dist/shared/lazy.js +4 -2
- package/env.d.ts +9 -0
- package/package.json +5 -4
- package/scripts/build.js +3 -3
- package/scripts/validate-imports.js +8 -8
- package/src/client/mount.ts +1 -114
- package/src/config/constants.ts +3 -3
- package/src/config/dev-server.ts +95 -99
- package/src/config/fs-router.ts +140 -155
- package/src/config/fs-routes/fs-watcher.ts +57 -61
- package/src/config/fs-routes/index.ts +117 -119
- package/src/config/fs-routes/router.ts +7 -7
- package/src/config/fs-routes/tree-shake.ts +342 -363
- package/src/config/index.ts +36 -39
- package/src/config/lazy.ts +13 -13
- package/src/config/manifest.ts +5 -5
- package/src/config/vite-utils.ts +2 -6
- package/src/env.d.ts +10 -28
- package/src/http/index.ts +105 -142
- package/src/index.tsx +0 -12
- package/src/internal.d.ts +1 -1
- package/src/middleware/index.ts +39 -49
- package/src/router.tsx +4 -3
- package/src/server/StartServer.tsx +1 -7
- package/src/server/assets/index.ts +1 -1
- package/src/server/assets/render.tsx +6 -2
- package/src/server/collect-styles.ts +63 -70
- package/src/server/fetchEvent.spec.ts +71 -75
- package/src/server/fetchEvent.ts +17 -17
- package/src/server/handler.ts +136 -129
- package/src/server/index.tsx +13 -0
- package/src/server/manifest/client-manifest.ts +1 -1
- package/src/server/manifest/dev-client-manifest.ts +7 -5
- package/src/server/manifest/dev-ssr-manifest.ts +8 -6
- package/src/server/manifest/prod-client-manifest.ts +7 -4
- package/src/server/manifest/prod-ssr-manifest.ts +78 -94
- package/src/server/manifest/ssr-manifest.ts +4 -2
- package/src/server/routes.ts +96 -108
- package/src/server/server-fns-runtime.ts +3 -3
- package/src/server/server-functions-handler.ts +294 -319
- package/src/server/server-runtime.ts +13 -13
- package/src/server/spa/handler.ts +12 -12
- package/src/server/types.ts +46 -46
- package/src/server/util.ts +4 -4
- package/src/shared/ErrorBoundary.tsx +1 -1
- package/src/shared/HttpHeader.tsx +20 -20
- package/src/shared/HttpStatusCode.ts +14 -14
- package/src/shared/clientOnly.ts +3 -3
- package/src/shared/dev-overlay/CodeView.tsx +43 -46
- package/src/shared/dev-overlay/DevOverlayDialog.tsx +4 -4
- package/src/shared/dev-overlay/createStackFrame.ts +59 -62
- package/src/shared/dev-overlay/env.d.ts +2 -2
- package/src/shared/dev-overlay/get-source-map.ts +5 -7
- package/src/shared/dev-overlay/icons.tsx +289 -121
- package/src/shared/dev-overlay/index.tsx +1 -1
- package/src/shared/lazy.ts +4 -3
- package/src/shared/serverFunction.ts +1 -1
- package/src/virtual.d.ts +10 -10
- package/tsconfig.json +2 -2
- package/vitest.config.ts +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @solidjs/start
|
|
2
|
+
|
|
3
|
+
## 2.0.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8256190: Rework `@solidjs/start/env`
|
|
8
|
+
- 6cbba24: Fix multiple Set-Cookie headers being lost on redirect responses
|
|
9
|
+
- d4cc548: ## Bump Seroval
|
|
10
|
+
|
|
11
|
+
- version `1.4.1`
|
|
12
|
+
|
|
13
|
+
- dd40610: Handle base url in api routes
|
|
14
|
+
- 0c8a5e2: export server types from /server
|
package/dist/client/mount.d.ts
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type MountableElement } from "solid-js/web";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Read more: https://docs.solidjs.com/solid-start/reference/client/mount
|
|
6
|
-
*/
|
|
7
|
-
export declare function mount(fn: () => JSX.Element, el: MountableElement): (() => void) | undefined;
|
|
1
|
+
export { hydrate as mount } from "solid-js/web";
|
package/dist/client/mount.js
CHANGED
|
@@ -1,99 +1 @@
|
|
|
1
|
-
|
|
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 { createStore } from "solid-js/store";
|
|
10
|
-
import { createComponent, getHydrationKey, getOwner, hydrate } from "solid-js/web";
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* Read more: https://docs.solidjs.com/solid-start/reference/client/mount
|
|
14
|
-
*/
|
|
15
|
-
export function mount(fn, el) {
|
|
16
|
-
if (import.meta.env.START_ISLANDS) {
|
|
17
|
-
const map = new WeakMap();
|
|
18
|
-
async function mountIsland(el) {
|
|
19
|
-
if (el.dataset.css) {
|
|
20
|
-
let css = JSON.parse(el.dataset.css);
|
|
21
|
-
for (let href of css) {
|
|
22
|
-
if (!document.querySelector(`link[href="${href}"]`)) {
|
|
23
|
-
let link = document.createElement("link");
|
|
24
|
-
link.rel = "stylesheet";
|
|
25
|
-
link.href = href;
|
|
26
|
-
document.head.appendChild(link);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
let mod = await import(__rewriteRelativeImportExtension(
|
|
31
|
-
/* @vite-ignore */
|
|
32
|
-
import.meta.env.MANIFEST["client"].chunks[el.dataset.id.split("#")[0]].output
|
|
33
|
-
.path, true));
|
|
34
|
-
if (!mod || !el.dataset.hk)
|
|
35
|
-
return;
|
|
36
|
-
let Component = mod[el.dataset.id.split("#")[1]];
|
|
37
|
-
let hk = el.dataset.hk;
|
|
38
|
-
// _$DEBUG("hydrating island", el.dataset.island, hk.slice(0, hk.length - 1) + `1-`, el);
|
|
39
|
-
let props = createStore({
|
|
40
|
-
...JSON.parse(el.dataset.props),
|
|
41
|
-
get children() {
|
|
42
|
-
const p = el.getElementsByTagName("solid-children");
|
|
43
|
-
getHydrationKey();
|
|
44
|
-
[...p].forEach(a => {
|
|
45
|
-
a.__$owner = getOwner();
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
map.set(el, props);
|
|
51
|
-
hydrate(() => createComponent(Component, props[0]), el, {
|
|
52
|
-
renderId: hk.slice(0, hk.length - 1) + `${1 + Number(el.dataset.offset)}-`,
|
|
53
|
-
owner: lookupOwner(el)
|
|
54
|
-
});
|
|
55
|
-
delete el.dataset.hk;
|
|
56
|
-
el.dataset.hkk = hk;
|
|
57
|
-
}
|
|
58
|
-
let queue = [];
|
|
59
|
-
let queued = false;
|
|
60
|
-
function runTaskQueue(info) {
|
|
61
|
-
while (info.timeRemaining() > 0 && queue.length) {
|
|
62
|
-
mountIsland(queue.shift());
|
|
63
|
-
}
|
|
64
|
-
if (queue.length) {
|
|
65
|
-
requestIdleCallback(runTaskQueue);
|
|
66
|
-
}
|
|
67
|
-
else
|
|
68
|
-
queued = false;
|
|
69
|
-
}
|
|
70
|
-
const hydrateIslands = () => {
|
|
71
|
-
const islands = document.querySelectorAll("solid-island[data-hk]");
|
|
72
|
-
const assets = new Set();
|
|
73
|
-
islands.forEach((el) => el.dataset.id && assets.add(el.dataset.id));
|
|
74
|
-
Promise.all([...assets].map(asset => import(
|
|
75
|
-
/* @vite-ignore */ import.meta.env.MANIFEST["client"].chunks[asset.split("#")[0]].output.path)))
|
|
76
|
-
.then(() => {
|
|
77
|
-
islands.forEach((el) => {
|
|
78
|
-
if (el.dataset.when === "idle" && "requestIdleCallback" in window) {
|
|
79
|
-
if (!queued) {
|
|
80
|
-
queued = true;
|
|
81
|
-
requestIdleCallback(runTaskQueue);
|
|
82
|
-
}
|
|
83
|
-
queue.push(el);
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
mountIsland(el);
|
|
87
|
-
});
|
|
88
|
-
})
|
|
89
|
-
.catch(e => console.error(e));
|
|
90
|
-
};
|
|
91
|
-
function lookupOwner(el) {
|
|
92
|
-
const parent = el.closest("solid-children");
|
|
93
|
-
return parent && parent.__$owner;
|
|
94
|
-
}
|
|
95
|
-
hydrateIslands();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
return hydrate(fn, el);
|
|
99
|
-
}
|
|
1
|
+
export { hydrate as mount } from "solid-js/web";
|
package/dist/config/constants.js
CHANGED
|
@@ -8,9 +8,9 @@ export const VIRTUAL_MODULES = {
|
|
|
8
8
|
serverFnManifest: "solidstart:server-fn-manifest",
|
|
9
9
|
clientEntry: "solid-start:client-entry",
|
|
10
10
|
serverEntry: "solid-start:server-entry",
|
|
11
|
-
app: "solid-start:app"
|
|
11
|
+
app: "solid-start:app",
|
|
12
12
|
};
|
|
13
13
|
export const VITE_ENVIRONMENTS = {
|
|
14
14
|
client: "client",
|
|
15
|
-
server: "ssr"
|
|
15
|
+
server: "ssr",
|
|
16
16
|
};
|
package/dist/config/fs-router.js
CHANGED
|
@@ -31,17 +31,15 @@ export class SolidStartClientFileRouter extends BaseFileSystemRouter {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
const [_, exports] = analyzeModule(src);
|
|
34
|
-
const hasDefault = !!exports.find(
|
|
35
|
-
const hasRouteConfig = !!exports.find(
|
|
34
|
+
const hasDefault = !!exports.find(e => e.n === "default");
|
|
35
|
+
const hasRouteConfig = !!exports.find(e => e.n === "route");
|
|
36
36
|
if (hasDefault) {
|
|
37
37
|
return {
|
|
38
38
|
page: true,
|
|
39
39
|
$component: {
|
|
40
40
|
src: src,
|
|
41
41
|
pick: [
|
|
42
|
-
...exports
|
|
43
|
-
.filter((e) => e.n === e.ln && e.n !== "route")
|
|
44
|
-
.map((e) => e.n),
|
|
42
|
+
...exports.filter(e => e.n === e.ln && e.n !== "route").map(e => e.n),
|
|
45
43
|
"default",
|
|
46
44
|
"$css",
|
|
47
45
|
],
|
|
@@ -58,15 +56,7 @@ export class SolidStartClientFileRouter extends BaseFileSystemRouter {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
const HTTP_METHODS = [
|
|
62
|
-
"HEAD",
|
|
63
|
-
"GET",
|
|
64
|
-
"POST",
|
|
65
|
-
"PUT",
|
|
66
|
-
"DELETE",
|
|
67
|
-
"PATCH",
|
|
68
|
-
"OPTIONS",
|
|
69
|
-
];
|
|
59
|
+
const HTTP_METHODS = ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
|
|
70
60
|
function createHTTPHandlers(src, exports) {
|
|
71
61
|
const handlers = {};
|
|
72
62
|
for (const exp of exports) {
|
|
@@ -75,7 +65,7 @@ function createHTTPHandlers(src, exports) {
|
|
|
75
65
|
src: src,
|
|
76
66
|
pick: [exp.n],
|
|
77
67
|
};
|
|
78
|
-
if (exp.n === "GET" && !exports.find(
|
|
68
|
+
if (exp.n === "GET" && !exports.find(exp => exp.n === "HEAD")) {
|
|
79
69
|
handlers.$HEAD = {
|
|
80
70
|
src: src,
|
|
81
71
|
pick: [exp.n],
|
|
@@ -119,9 +109,9 @@ export class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
|
119
109
|
};
|
|
120
110
|
}
|
|
121
111
|
const [_, exports] = analyzeModule(src);
|
|
122
|
-
const hasRouteConfig = exports.find(
|
|
123
|
-
const hasDefault = !!exports.find(
|
|
124
|
-
const hasAPIRoutes = !!exports.find(
|
|
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));
|
|
125
115
|
if (hasDefault || hasAPIRoutes) {
|
|
126
116
|
return {
|
|
127
117
|
page: hasDefault,
|
|
@@ -130,10 +120,8 @@ export class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
|
130
120
|
src: src,
|
|
131
121
|
pick: [
|
|
132
122
|
...exports
|
|
133
|
-
.filter(
|
|
134
|
-
e.n
|
|
135
|
-
!HTTP_METHODS.includes(e.n))
|
|
136
|
-
.map((e) => e.n),
|
|
123
|
+
.filter(e => e.n === e.ln && e.n !== "route" && !HTTP_METHODS.includes(e.n))
|
|
124
|
+
.map(e => e.n),
|
|
137
125
|
"default",
|
|
138
126
|
"$css",
|
|
139
127
|
],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { moduleId } from "./index.js";
|
|
2
2
|
function setupWatcher(watcher, routes) {
|
|
3
|
-
watcher.on("unlink",
|
|
4
|
-
watcher.on("add",
|
|
5
|
-
watcher.on("change",
|
|
3
|
+
watcher.on("unlink", path => routes.removeRoute(path));
|
|
4
|
+
watcher.on("add", path => routes.addRoute(path));
|
|
5
|
+
watcher.on("change", path => routes.updateRoute(path));
|
|
6
6
|
}
|
|
7
7
|
function createRoutesReloader(server, routes, environment) {
|
|
8
8
|
routes.addEventListener("reload", handleRoutesReload);
|
|
@@ -38,7 +38,7 @@ export const fileSystemWatcher = (routers) => {
|
|
|
38
38
|
const plugin = {
|
|
39
39
|
name: "fs-watcher",
|
|
40
40
|
async configureServer(server) {
|
|
41
|
-
Object.keys(routers).forEach(
|
|
41
|
+
Object.keys(routers).forEach(environment => {
|
|
42
42
|
const router = globalThis.ROUTERS[environment];
|
|
43
43
|
setupWatcher(server.watcher, router);
|
|
44
44
|
createRoutesReloader(server, router, environment);
|
|
@@ -43,10 +43,8 @@ export function fsRoutes({ routers }) {
|
|
|
43
43
|
const buildId = `${v.src}?${v.pick.map((p) => `pick=${p}`).join("&")}`;
|
|
44
44
|
return {
|
|
45
45
|
src: relative(root, buildId),
|
|
46
|
-
build: isBuild
|
|
47
|
-
|
|
48
|
-
: undefined,
|
|
49
|
-
import: `_$() => import(/* @vite-ignore */ '${buildId}')$_`
|
|
46
|
+
build: isBuild ? `_$() => import(/* @vite-ignore */ '${buildId}')$_` : undefined,
|
|
47
|
+
import: `_$() => import(/* @vite-ignore */ '${buildId}')$_`,
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
return v;
|
|
@@ -90,13 +88,13 @@ function jsCode() {
|
|
|
90
88
|
delete id["default"];
|
|
91
89
|
return Object.keys(id).length > 0
|
|
92
90
|
? `{ ${Object.keys(id)
|
|
93
|
-
.map(
|
|
91
|
+
.map(k => `${k} as ${id[k]}`)
|
|
94
92
|
.join(", ")} }`
|
|
95
93
|
: "";
|
|
96
94
|
};
|
|
97
95
|
const getImportStatements = () => {
|
|
98
96
|
return `${[...imports.keys()]
|
|
99
|
-
.map(
|
|
97
|
+
.map(i => `import ${imports.get(i).default
|
|
100
98
|
? `${imports.get(i).default}${Object.keys(imports.get(i)).length > 1 ? ", " : ""}`
|
|
101
99
|
: ""} ${getNamedExport(i)} from '${i}';`)
|
|
102
100
|
.join("\n")}`;
|
|
@@ -18,7 +18,7 @@ export function analyzeModule(src) {
|
|
|
18
18
|
return parse(esbuild.transformSync(fs.readFileSync(src, "utf-8"), {
|
|
19
19
|
jsx: "transform",
|
|
20
20
|
format: "esm",
|
|
21
|
-
loader: "tsx"
|
|
21
|
+
loader: "tsx",
|
|
22
22
|
}).code, src);
|
|
23
23
|
}
|
|
24
24
|
export class BaseFileSystemRouter extends EventTarget {
|
|
@@ -61,9 +61,9 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
61
61
|
return {
|
|
62
62
|
$component: {
|
|
63
63
|
src: src,
|
|
64
|
-
pick: ["default", "$css"]
|
|
64
|
+
pick: ["default", "$css"],
|
|
65
65
|
},
|
|
66
|
-
path
|
|
66
|
+
path,
|
|
67
67
|
// filePath: src
|
|
68
68
|
};
|
|
69
69
|
}
|
|
@@ -94,8 +94,8 @@ export class BaseFileSystemRouter extends EventTarget {
|
|
|
94
94
|
this.dispatchEvent(new Event("reload", {
|
|
95
95
|
// @ts-ignore
|
|
96
96
|
detail: {
|
|
97
|
-
route
|
|
98
|
-
}
|
|
97
|
+
route,
|
|
98
|
+
},
|
|
99
99
|
}));
|
|
100
100
|
}
|
|
101
101
|
async updateRoute(src) {
|
|
@@ -18,9 +18,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
18
18
|
if (path.node.type === "ArrowFunctionExpression") {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
return path.node.id && path.node.id.type === "Identifier"
|
|
22
|
-
? path.get("id")
|
|
23
|
-
: null;
|
|
21
|
+
return path.node.id && path.node.id.type === "Identifier" ? path.get("id") : null;
|
|
24
22
|
}
|
|
25
23
|
function isIdentifierReferenced(ident) {
|
|
26
24
|
const b = ident.scope.getBinding(ident.node.name);
|
|
@@ -28,7 +26,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
28
26
|
if (b.path.type === "FunctionDeclaration") {
|
|
29
27
|
return !b.constantViolations
|
|
30
28
|
.concat(b.referencePaths)
|
|
31
|
-
.every(
|
|
29
|
+
.every(ref => ref.findParent(p => p === b.path));
|
|
32
30
|
}
|
|
33
31
|
return true;
|
|
34
32
|
}
|
|
@@ -63,7 +61,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
63
61
|
else if (variablePath.node.id.type === "ObjectPattern") {
|
|
64
62
|
const pattern = variablePath.get("id");
|
|
65
63
|
const properties = pattern.get("properties");
|
|
66
|
-
properties.forEach(
|
|
64
|
+
properties.forEach(p => {
|
|
67
65
|
const local = p.get(p.node.type === "ObjectProperty"
|
|
68
66
|
? "value"
|
|
69
67
|
: p.node.type === "RestElement"
|
|
@@ -79,7 +77,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
79
77
|
else if (variablePath.node.id.type === "ArrayPattern") {
|
|
80
78
|
const pattern = variablePath.get("id");
|
|
81
79
|
const elements = pattern.get("elements");
|
|
82
|
-
elements.forEach(
|
|
80
|
+
elements.forEach(e => {
|
|
83
81
|
let local;
|
|
84
82
|
if (e.node && e.node.type === "Identifier") {
|
|
85
83
|
local = e;
|
|
@@ -109,7 +107,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
109
107
|
}
|
|
110
108
|
const specifiers = exportNamedPath.get("specifiers");
|
|
111
109
|
if (specifiers.length) {
|
|
112
|
-
specifiers.forEach(
|
|
110
|
+
specifiers.forEach(s => {
|
|
113
111
|
if (t.isIdentifier(s.node.exported)
|
|
114
112
|
? s.node.exported.name
|
|
115
113
|
: state.opts.pick.includes(s.node.exported.value)) {
|
|
@@ -128,16 +126,14 @@ function treeShakeTransform({ types: t }) {
|
|
|
128
126
|
switch (decl.node.type) {
|
|
129
127
|
case "FunctionDeclaration": {
|
|
130
128
|
const name = decl.node.id?.name;
|
|
131
|
-
if (name &&
|
|
132
|
-
state.opts.pick &&
|
|
133
|
-
!state.opts.pick.includes(name)) {
|
|
129
|
+
if (name && state.opts.pick && !state.opts.pick.includes(name)) {
|
|
134
130
|
exportNamedPath.remove();
|
|
135
131
|
}
|
|
136
132
|
break;
|
|
137
133
|
}
|
|
138
134
|
case "VariableDeclaration": {
|
|
139
135
|
const inner = decl.get("declarations");
|
|
140
|
-
inner.forEach(
|
|
136
|
+
inner.forEach(d => {
|
|
141
137
|
if (d.node.id.type !== "Identifier") {
|
|
142
138
|
return;
|
|
143
139
|
}
|
|
@@ -171,10 +167,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
171
167
|
let count = 0;
|
|
172
168
|
const sweepFunction = (sweepPath) => {
|
|
173
169
|
const ident = getIdentifier(sweepPath);
|
|
174
|
-
if (ident &&
|
|
175
|
-
ident.node &&
|
|
176
|
-
refs.has(ident) &&
|
|
177
|
-
!isIdentifierReferenced(ident)) {
|
|
170
|
+
if (ident && ident.node && refs.has(ident) && !isIdentifierReferenced(ident)) {
|
|
178
171
|
++count;
|
|
179
172
|
if (t.isAssignmentExpression(sweepPath.parentPath) ||
|
|
180
173
|
t.isVariableDeclarator(sweepPath.parentPath)) {
|
|
@@ -211,7 +204,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
211
204
|
const pattern = variablePath.get("id");
|
|
212
205
|
const beforeCount = count;
|
|
213
206
|
const properties = pattern.get("properties");
|
|
214
|
-
properties.forEach(
|
|
207
|
+
properties.forEach(p => {
|
|
215
208
|
const local = p.get(p.node.type === "ObjectProperty"
|
|
216
209
|
? "value"
|
|
217
210
|
: p.node.type === "RestElement"
|
|
@@ -224,8 +217,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
224
217
|
p.remove();
|
|
225
218
|
}
|
|
226
219
|
});
|
|
227
|
-
if (beforeCount !== count &&
|
|
228
|
-
pattern.get("properties").length < 1) {
|
|
220
|
+
if (beforeCount !== count && pattern.get("properties").length < 1) {
|
|
229
221
|
variablePath.remove();
|
|
230
222
|
}
|
|
231
223
|
}
|
|
@@ -233,7 +225,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
233
225
|
const pattern = variablePath.get("id");
|
|
234
226
|
const beforeCount = count;
|
|
235
227
|
const elements = pattern.get("elements");
|
|
236
|
-
elements.forEach(
|
|
228
|
+
elements.forEach(e => {
|
|
237
229
|
let local;
|
|
238
230
|
if (e.node && e.node.type === "Identifier") {
|
|
239
231
|
local = e;
|
|
@@ -249,8 +241,7 @@ function treeShakeTransform({ types: t }) {
|
|
|
249
241
|
e.remove();
|
|
250
242
|
}
|
|
251
243
|
});
|
|
252
|
-
if (beforeCount !== count &&
|
|
253
|
-
pattern.get("elements").length < 1) {
|
|
244
|
+
if (beforeCount !== count && pattern.get("elements").length < 1) {
|
|
254
245
|
variablePath.remove();
|
|
255
246
|
}
|
|
256
247
|
}
|
package/dist/config/index.js
CHANGED
|
@@ -19,10 +19,10 @@ export function solidStart(options) {
|
|
|
19
19
|
ssr: true,
|
|
20
20
|
devOverlay: true,
|
|
21
21
|
experimental: {
|
|
22
|
-
islands: false
|
|
22
|
+
islands: false,
|
|
23
23
|
},
|
|
24
24
|
solid: {},
|
|
25
|
-
extensions: []
|
|
25
|
+
extensions: [],
|
|
26
26
|
});
|
|
27
27
|
const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
|
|
28
28
|
const routeDir = join(start.appRoot, start.routeDir);
|
|
@@ -34,7 +34,7 @@ export function solidStart(options) {
|
|
|
34
34
|
const entryExtension = extname(appEntryPath);
|
|
35
35
|
const handlers = {
|
|
36
36
|
client: `${start.appRoot}/entry-client${entryExtension}`,
|
|
37
|
-
server: `${start.appRoot}/entry-server${entryExtension}
|
|
37
|
+
server: `${start.appRoot}/entry-server${entryExtension}`,
|
|
38
38
|
};
|
|
39
39
|
return [
|
|
40
40
|
{
|
|
@@ -42,13 +42,10 @@ export function solidStart(options) {
|
|
|
42
42
|
enforce: "pre",
|
|
43
43
|
configEnvironment(name) {
|
|
44
44
|
return {
|
|
45
|
-
define: {
|
|
46
|
-
"import.meta.env.SSR": JSON.stringify(name === VITE_ENVIRONMENTS.server)
|
|
47
|
-
},
|
|
48
45
|
resolve: {
|
|
49
46
|
// remove when https://github.com/solidjs/vite-plugin-solid/pull/228 is released
|
|
50
|
-
externalConditions: ["solid", "node"]
|
|
51
|
-
}
|
|
47
|
+
externalConditions: ["solid", "node"],
|
|
48
|
+
},
|
|
52
49
|
};
|
|
53
50
|
},
|
|
54
51
|
async config(_, env) {
|
|
@@ -79,9 +76,9 @@ export function solidStart(options) {
|
|
|
79
76
|
rollupOptions: {
|
|
80
77
|
input: clientInput,
|
|
81
78
|
treeshake: true,
|
|
82
|
-
preserveEntrySignatures: "exports-only"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
79
|
+
preserveEntrySignatures: "exports-only",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
85
82
|
},
|
|
86
83
|
[VITE_ENVIRONMENTS.server]: {
|
|
87
84
|
consumer: "server",
|
|
@@ -91,14 +88,14 @@ export function solidStart(options) {
|
|
|
91
88
|
manifest: true,
|
|
92
89
|
copyPublicDir: false,
|
|
93
90
|
rollupOptions: {
|
|
94
|
-
input: "~/entry-server.tsx"
|
|
91
|
+
input: "~/entry-server.tsx",
|
|
95
92
|
},
|
|
96
93
|
outDir: "dist/server",
|
|
97
94
|
commonjsOptions: {
|
|
98
|
-
include: [/node_modules/]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
95
|
+
include: [/node_modules/],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
102
99
|
},
|
|
103
100
|
resolve: {
|
|
104
101
|
alias: {
|
|
@@ -107,17 +104,17 @@ export function solidStart(options) {
|
|
|
107
104
|
...(!start.ssr
|
|
108
105
|
? {
|
|
109
106
|
"@solidjs/start/server": "@solidjs/start/server/spa",
|
|
110
|
-
"@solidjs/start/client": "@solidjs/start/client/spa"
|
|
107
|
+
"@solidjs/start/client": "@solidjs/start/client/spa",
|
|
111
108
|
}
|
|
112
|
-
: {})
|
|
113
|
-
}
|
|
109
|
+
: {}),
|
|
110
|
+
},
|
|
114
111
|
},
|
|
115
112
|
define: {
|
|
116
113
|
"import.meta.env.MANIFEST": `globalThis.MANIFEST`,
|
|
117
114
|
"import.meta.env.START_SSR": JSON.stringify(start.ssr),
|
|
118
115
|
"import.meta.env.START_APP_ENTRY": `"${appEntryPath}"`,
|
|
119
116
|
"import.meta.env.START_CLIENT_ENTRY": `"${handlers.client}"`,
|
|
120
|
-
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay)
|
|
117
|
+
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
|
|
121
118
|
},
|
|
122
119
|
builder: {
|
|
123
120
|
sharedPlugins: true,
|
|
@@ -132,24 +129,24 @@ export function solidStart(options) {
|
|
|
132
129
|
await builder.build(client);
|
|
133
130
|
if (!server.isBuilt)
|
|
134
131
|
await builder.build(server);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
132
|
+
},
|
|
133
|
+
},
|
|
137
134
|
};
|
|
138
|
-
}
|
|
135
|
+
},
|
|
139
136
|
},
|
|
140
137
|
manifest(start),
|
|
141
138
|
fsRoutes({
|
|
142
139
|
routers: {
|
|
143
140
|
client: new SolidStartClientFileRouter({
|
|
144
141
|
dir: absolute(routeDir, root),
|
|
145
|
-
extensions
|
|
142
|
+
extensions,
|
|
146
143
|
}),
|
|
147
144
|
ssr: new SolidStartServerFileRouter({
|
|
148
145
|
dir: absolute(routeDir, root),
|
|
149
146
|
extensions,
|
|
150
|
-
dataOnly: !start.ssr
|
|
151
|
-
})
|
|
152
|
-
}
|
|
147
|
+
dataOnly: !start.ssr,
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
153
150
|
}),
|
|
154
151
|
lazy(),
|
|
155
152
|
// Must be placed after fsRoutes, as treeShake will remove the
|
|
@@ -164,20 +161,20 @@ export function solidStart(options) {
|
|
|
164
161
|
envConsumer: "client",
|
|
165
162
|
envName: VITE_ENVIRONMENTS.client,
|
|
166
163
|
getRuntimeCode: () => `import { createServerReference } from "${normalize(fileURLToPath(new URL("../server/server-runtime", import.meta.url)))}"`,
|
|
167
|
-
replacer: opts => `createServerReference('${opts.functionId}')
|
|
164
|
+
replacer: opts => `createServerReference('${opts.functionId}')`,
|
|
168
165
|
},
|
|
169
166
|
{
|
|
170
167
|
envConsumer: "server",
|
|
171
168
|
envName: VITE_ENVIRONMENTS.server,
|
|
172
169
|
getRuntimeCode: () => `import { createServerReference } from '${normalize(fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)))}'`,
|
|
173
|
-
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')
|
|
174
|
-
}
|
|
170
|
+
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
|
|
171
|
+
},
|
|
175
172
|
],
|
|
176
173
|
provider: {
|
|
177
174
|
envName: VITE_ENVIRONMENTS.server,
|
|
178
175
|
getRuntimeCode: () => `import { createServerReference } from '${normalize(fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)))}'`,
|
|
179
|
-
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')
|
|
180
|
-
}
|
|
176
|
+
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
|
|
177
|
+
},
|
|
181
178
|
}),
|
|
182
179
|
{
|
|
183
180
|
name: "solid-start:virtual-modules",
|
|
@@ -198,20 +195,20 @@ export function solidStart(options) {
|
|
|
198
195
|
id += `?${query.toString()}`;
|
|
199
196
|
return id;
|
|
200
197
|
}
|
|
201
|
-
}
|
|
198
|
+
},
|
|
202
199
|
},
|
|
203
200
|
{
|
|
204
201
|
name: "solid-start:capture-client-bundle",
|
|
205
202
|
enforce: "post",
|
|
206
203
|
generateBundle(_options, bundle) {
|
|
207
204
|
globalThis.START_CLIENT_BUNDLE = bundle;
|
|
208
|
-
}
|
|
205
|
+
},
|
|
209
206
|
},
|
|
210
207
|
devServer(),
|
|
211
208
|
solid({
|
|
212
209
|
...start.solid,
|
|
213
210
|
ssr: true,
|
|
214
|
-
extensions: extensions.map(ext => `.${ext}`)
|
|
215
|
-
})
|
|
211
|
+
extensions: extensions.map(ext => `.${ext}`),
|
|
212
|
+
}),
|
|
216
213
|
];
|
|
217
214
|
}
|
package/dist/config/lazy.js
CHANGED
|
@@ -8,10 +8,10 @@ const idTransform = (id) => {
|
|
|
8
8
|
visitor: {
|
|
9
9
|
Program(path) {
|
|
10
10
|
path.node.body.unshift(t.exportNamedDeclaration(t.variableDeclaration("const", [
|
|
11
|
-
t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id))
|
|
11
|
+
t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id)),
|
|
12
12
|
])));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
const importTransform = () => {
|
|
@@ -26,10 +26,10 @@ const importTransform = () => {
|
|
|
26
26
|
return;
|
|
27
27
|
subPath.remove();
|
|
28
28
|
path.insertAfter(t.importDeclaration([t.importSpecifier(t.identifier("lazy"), t.identifier("lazy"))], t.stringLiteral("@solidjs/start/server")));
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
const fileEndingRegex = /(ts|js)x(\?.*)?$/;
|
|
@@ -63,20 +63,20 @@ const lazy = () => {
|
|
|
63
63
|
const transformed = await babel.transformAsync(src, {
|
|
64
64
|
plugins,
|
|
65
65
|
parserOpts: {
|
|
66
|
-
plugins: ["jsx", "typescript"]
|
|
66
|
+
plugins: ["jsx", "typescript"],
|
|
67
67
|
},
|
|
68
68
|
filename: basename(id),
|
|
69
69
|
ast: false,
|
|
70
70
|
sourceMaps: true,
|
|
71
71
|
configFile: false,
|
|
72
72
|
babelrc: false,
|
|
73
|
-
sourceFileName: id
|
|
73
|
+
sourceFileName: id,
|
|
74
74
|
});
|
|
75
75
|
if (!transformed?.code)
|
|
76
76
|
return;
|
|
77
77
|
const { code, map } = transformed;
|
|
78
78
|
return { code, map };
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
export default lazy;
|
package/dist/config/manifest.js
CHANGED
package/dist/http/index.d.ts
CHANGED
|
@@ -9,10 +9,7 @@ export declare function isEvent(obj: any): obj is h3.H3Event | {
|
|
|
9
9
|
};
|
|
10
10
|
type Tail<T> = T extends [any, ...infer U] ? U : never;
|
|
11
11
|
type PrependOverload<TOriginal extends (...args: Array<any>) => any, TOverload extends (...args: Array<any>) => any> = TOverload & TOriginal;
|
|
12
|
-
type WrapFunction<TFn extends (...args: Array<any>) => any> = PrependOverload<TFn, (...args: Parameters<TFn> extends [
|
|
13
|
-
h3.HTTPEvent<any> | h3.H3Event<any>,
|
|
14
|
-
...infer TArgs
|
|
15
|
-
] ? TArgs : Parameters<TFn>) => ReturnType<TFn>>;
|
|
12
|
+
type WrapFunction<TFn extends (...args: Array<any>) => any> = PrependOverload<TFn, (...args: Parameters<TFn> extends [h3.HTTPEvent<any> | h3.H3Event<any>, ...infer TArgs] ? TArgs : Parameters<TFn>) => ReturnType<TFn>>;
|
|
16
13
|
type WrappedReadBody = <T, TEventInput = InferEventInput<"body", H3Event, T>>(...args: Tail<Parameters<typeof h3.readBody<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.readBody<T, h3.H3Event, TEventInput>>;
|
|
17
14
|
export declare const readBody: PrependOverload<typeof h3.readBody, WrappedReadBody>;
|
|
18
15
|
type WrappedGetQuery = <T, TEventInput = Exclude<InferEventInput<"query", H3Event, T>, undefined>>(...args: Tail<Parameters<typeof h3.getQuery<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getQuery<T, H3Event, TEventInput>>;
|