@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/dist/config/index.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { defu } from "defu";
|
|
2
|
-
import { globSync } from "node:fs";
|
|
3
|
-
import { extname, isAbsolute, join } from "node:path";
|
|
4
|
-
import solid from "vite-plugin-solid";
|
|
5
|
-
import { serverFunctionsPlugin } from "../directives/index.js";
|
|
6
|
-
import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.js";
|
|
7
|
-
import { devServer } from "./dev-server.js";
|
|
8
|
-
import { envPlugin } from "./env.js";
|
|
9
|
-
import { SolidStartClientFileRouter, SolidStartServerFileRouter } from "./fs-router.js";
|
|
10
|
-
import { fsRoutes } from "./fs-routes/index.js";
|
|
11
|
-
import lazy from "./lazy.js";
|
|
12
|
-
import { manifest } from "./manifest.js";
|
|
13
|
-
import { parseIdQuery } from "./utils.js";
|
|
14
|
-
const absolute = (path, root) => path ? (isAbsolute(path) ? path : join(root, path)) : path;
|
|
15
|
-
export function solidStart(options) {
|
|
16
|
-
const start = defu(options ?? {}, {
|
|
17
|
-
appRoot: "./src",
|
|
18
|
-
routeDir: "./routes",
|
|
19
|
-
ssr: true,
|
|
20
|
-
devOverlay: true,
|
|
21
|
-
experimental: {
|
|
22
|
-
islands: false,
|
|
23
|
-
},
|
|
24
|
-
solid: {},
|
|
25
|
-
extensions: [],
|
|
26
|
-
});
|
|
27
|
-
const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
|
|
28
|
-
const routeDir = join(start.appRoot, start.routeDir);
|
|
29
|
-
const root = process.cwd();
|
|
30
|
-
const appEntryPath = globSync(join(root, start.appRoot, "app.{j,t}sx"))[0];
|
|
31
|
-
if (!appEntryPath) {
|
|
32
|
-
throw new Error(`Could not find an app jsx/tsx entry in ${start.appRoot}.`);
|
|
33
|
-
}
|
|
34
|
-
const entryExtension = extname(appEntryPath);
|
|
35
|
-
const handlers = {
|
|
36
|
-
client: `${start.appRoot}/entry-client${entryExtension}`,
|
|
37
|
-
server: `${start.appRoot}/entry-server${entryExtension}`,
|
|
38
|
-
};
|
|
39
|
-
return [
|
|
40
|
-
{
|
|
41
|
-
name: "solid-start:config",
|
|
42
|
-
enforce: "pre",
|
|
43
|
-
configEnvironment(name) {
|
|
44
|
-
return {
|
|
45
|
-
resolve: {
|
|
46
|
-
// remove when https://github.com/solidjs/vite-plugin-solid/pull/228 is released
|
|
47
|
-
externalConditions: ["solid", "node"],
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
async config(_, env) {
|
|
52
|
-
const clientInput = [handlers.client];
|
|
53
|
-
if (env.command === "build") {
|
|
54
|
-
const clientRouter = globalThis.ROUTERS.client;
|
|
55
|
-
for (const route of await clientRouter.getRoutes()) {
|
|
56
|
-
for (const [key, value] of Object.entries(route)) {
|
|
57
|
-
if (value && key.startsWith("$") && !key.startsWith("$$")) {
|
|
58
|
-
function toRouteId(route) {
|
|
59
|
-
return `${route.src}?${route.pick.map((p) => `pick=${p}`).join("&")}`;
|
|
60
|
-
}
|
|
61
|
-
clientInput.push(toRouteId(value));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
appType: "custom",
|
|
68
|
-
build: { assetsDir: "_build/assets" },
|
|
69
|
-
optimizeDeps: {
|
|
70
|
-
// Suppress TS errors from Vite 7 types when configuring Vite 8's Rolldown
|
|
71
|
-
...{
|
|
72
|
-
rolldownOptions: {
|
|
73
|
-
transform: {
|
|
74
|
-
jsx: "react",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
environments: {
|
|
80
|
-
[VITE_ENVIRONMENTS.client]: {
|
|
81
|
-
consumer: "client",
|
|
82
|
-
build: {
|
|
83
|
-
write: true,
|
|
84
|
-
manifest: true,
|
|
85
|
-
outDir: "dist/client",
|
|
86
|
-
rollupOptions: {
|
|
87
|
-
input: clientInput,
|
|
88
|
-
treeshake: true,
|
|
89
|
-
preserveEntrySignatures: "exports-only",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
[VITE_ENVIRONMENTS.server]: {
|
|
94
|
-
consumer: "server",
|
|
95
|
-
build: {
|
|
96
|
-
ssr: true,
|
|
97
|
-
write: true,
|
|
98
|
-
manifest: true,
|
|
99
|
-
copyPublicDir: false,
|
|
100
|
-
rollupOptions: {
|
|
101
|
-
input: "~/entry-server.tsx",
|
|
102
|
-
},
|
|
103
|
-
outDir: "dist/server",
|
|
104
|
-
commonjsOptions: {
|
|
105
|
-
include: [/node_modules/],
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
resolve: {
|
|
111
|
-
alias: {
|
|
112
|
-
"@solidjs/start/server/entry": handlers.server,
|
|
113
|
-
"~": join(process.cwd(), start.appRoot),
|
|
114
|
-
...(!start.ssr
|
|
115
|
-
? {
|
|
116
|
-
"@solidjs/start/server": "@solidjs/start/server/spa",
|
|
117
|
-
"@solidjs/start/client": "@solidjs/start/client/spa",
|
|
118
|
-
}
|
|
119
|
-
: {}),
|
|
120
|
-
},
|
|
121
|
-
// Depending on the package manager and dependency structure Vite externalizes @solidjs/start
|
|
122
|
-
// This makes sure that @solidjs/start goes through the Vite build process
|
|
123
|
-
noExternal: ["@solidjs/start"],
|
|
124
|
-
},
|
|
125
|
-
define: {
|
|
126
|
-
"import.meta.env.MANIFEST": `globalThis.MANIFEST`,
|
|
127
|
-
"import.meta.env.START_SSR": JSON.stringify(start.ssr),
|
|
128
|
-
// Use JSON.stringify so backslashes on Windows are escaped and
|
|
129
|
-
// esbuild receives a valid JS string literal for the define value
|
|
130
|
-
"import.meta.env.START_APP_ENTRY": JSON.stringify(appEntryPath),
|
|
131
|
-
"import.meta.env.START_CLIENT_ENTRY": JSON.stringify(handlers.client),
|
|
132
|
-
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
|
|
133
|
-
"import.meta.env.SEROVAL_MODE": JSON.stringify(start.serialization?.mode || "json"),
|
|
134
|
-
},
|
|
135
|
-
builder: {
|
|
136
|
-
sharedPlugins: true,
|
|
137
|
-
async buildApp(builder) {
|
|
138
|
-
const client = builder.environments[VITE_ENVIRONMENTS.client];
|
|
139
|
-
const server = builder.environments[VITE_ENVIRONMENTS.server];
|
|
140
|
-
if (!client)
|
|
141
|
-
throw new Error("Client environment not found");
|
|
142
|
-
if (!server)
|
|
143
|
-
throw new Error("SSR environment not found");
|
|
144
|
-
if (!client.isBuilt)
|
|
145
|
-
await builder.build(client);
|
|
146
|
-
if (!server.isBuilt)
|
|
147
|
-
await builder.build(server);
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
manifest(start),
|
|
154
|
-
fsRoutes({
|
|
155
|
-
routers: {
|
|
156
|
-
client: new SolidStartClientFileRouter({
|
|
157
|
-
dir: absolute(routeDir, root),
|
|
158
|
-
extensions,
|
|
159
|
-
}),
|
|
160
|
-
ssr: new SolidStartServerFileRouter({
|
|
161
|
-
dir: absolute(routeDir, root),
|
|
162
|
-
extensions,
|
|
163
|
-
dataOnly: !start.ssr,
|
|
164
|
-
}),
|
|
165
|
-
},
|
|
166
|
-
}),
|
|
167
|
-
lazy(),
|
|
168
|
-
envPlugin(options?.env),
|
|
169
|
-
// Must be placed after fsRoutes, as treeShake will remove the
|
|
170
|
-
// server fn exports added in by this plugin
|
|
171
|
-
serverFunctionsPlugin({
|
|
172
|
-
manifest: VIRTUAL_MODULES.serverFnManifest,
|
|
173
|
-
runtime: {
|
|
174
|
-
server: '@solidjs/start/fns/server',
|
|
175
|
-
client: '@solidjs/start/fns/client',
|
|
176
|
-
},
|
|
177
|
-
filter: options?.serverFunctions?.filter,
|
|
178
|
-
}),
|
|
179
|
-
{
|
|
180
|
-
name: "solid-start:virtual-modules",
|
|
181
|
-
async resolveId(id) {
|
|
182
|
-
const { filename, query } = parseIdQuery(id);
|
|
183
|
-
let base;
|
|
184
|
-
if (filename === VIRTUAL_MODULES.clientEntry)
|
|
185
|
-
base = handlers.client;
|
|
186
|
-
if (filename === VIRTUAL_MODULES.serverEntry)
|
|
187
|
-
base = handlers.server;
|
|
188
|
-
if (filename === VIRTUAL_MODULES.app)
|
|
189
|
-
base = appEntryPath;
|
|
190
|
-
if (base) {
|
|
191
|
-
let id = (await this.resolve(base))?.id;
|
|
192
|
-
if (!id)
|
|
193
|
-
return;
|
|
194
|
-
if (query.size > 0)
|
|
195
|
-
id += `?${query.toString()}`;
|
|
196
|
-
return id;
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
name: "solid-start:capture-client-bundle",
|
|
202
|
-
enforce: "post",
|
|
203
|
-
generateBundle(options, bundle) {
|
|
204
|
-
globalThis.START_CLIENT_BUNDLE = bundle;
|
|
205
|
-
globalThis.START_CLIENT_OUT_DIR = options.dir;
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
devServer(),
|
|
209
|
-
solid({
|
|
210
|
-
...start.solid,
|
|
211
|
-
ssr: true,
|
|
212
|
-
extensions: extensions.map(ext => `.${ext}`),
|
|
213
|
-
}),
|
|
214
|
-
];
|
|
215
|
-
}
|
package/dist/config/lazy.d.ts
DELETED
package/dist/config/lazy.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import babel from "@babel/core";
|
|
2
|
-
import * as t from "@babel/types";
|
|
3
|
-
import { sep as osSep } from "node:path";
|
|
4
|
-
import { basename, relative, sep } from "node:path/posix";
|
|
5
|
-
import { VITE_ENVIRONMENTS } from "./constants.js";
|
|
6
|
-
const idTransform = (id) => {
|
|
7
|
-
return {
|
|
8
|
-
visitor: {
|
|
9
|
-
Program(path) {
|
|
10
|
-
path.node.body.unshift(t.exportNamedDeclaration(t.variableDeclaration("const", [
|
|
11
|
-
t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id)),
|
|
12
|
-
])));
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const importTransform = () => {
|
|
18
|
-
return {
|
|
19
|
-
visitor: {
|
|
20
|
-
ImportDeclaration(path) {
|
|
21
|
-
if (path.node.source.value !== "solid-js")
|
|
22
|
-
return;
|
|
23
|
-
path.traverse({
|
|
24
|
-
ImportSpecifier(subPath) {
|
|
25
|
-
if (subPath.node.local.name !== "lazy")
|
|
26
|
-
return;
|
|
27
|
-
subPath.remove();
|
|
28
|
-
path.insertAfter(t.importDeclaration([t.importSpecifier(t.identifier("lazy"), t.identifier("lazy"))], t.stringLiteral("@solidjs/start/server")));
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
const fileEndingRegex = /(ts|js)x(\?.*)?$/;
|
|
36
|
-
const lazy = () => {
|
|
37
|
-
const cwd = process.cwd().replaceAll(osSep, sep);
|
|
38
|
-
/**
|
|
39
|
-
* Maps module ids to their client-specific shared chunk names.
|
|
40
|
-
* Modules in shared chunks need to find their assets via the chunk name, instead of their module id.
|
|
41
|
-
*
|
|
42
|
-
* Vite includes assets of such modules in the manifest via the chunk name:
|
|
43
|
-
* https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L179
|
|
44
|
-
* https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L319
|
|
45
|
-
*
|
|
46
|
-
* Rollup occassionally creates shared chunks automatically,
|
|
47
|
-
* but they can also be manually created by the user via:
|
|
48
|
-
* https://rollupjs.org/configuration-options/#output-manualchunks
|
|
49
|
-
*
|
|
50
|
-
* More infos on Rollup's logic:
|
|
51
|
-
* https://github.com/rollup/rollup/issues/3772#issuecomment-689955168
|
|
52
|
-
*/
|
|
53
|
-
const sharedChunkNames = {};
|
|
54
|
-
return {
|
|
55
|
-
name: "solid-lazy-css",
|
|
56
|
-
enforce: "pre",
|
|
57
|
-
generateBundle(_, bundle) {
|
|
58
|
-
if (this.environment.name !== VITE_ENVIRONMENTS.client)
|
|
59
|
-
return;
|
|
60
|
-
for (const chunk of Object.values(bundle)) {
|
|
61
|
-
if (chunk.type !== "chunk" || !chunk.isDynamicEntry || chunk.facadeModuleId)
|
|
62
|
-
continue;
|
|
63
|
-
// Has to follow Vites implementation:
|
|
64
|
-
// https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L179
|
|
65
|
-
const chunkName = `_${basename(chunk.fileName)}`;
|
|
66
|
-
for (const id of chunk.moduleIds) {
|
|
67
|
-
sharedChunkNames[id] = chunkName;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
async transform(src, id) {
|
|
72
|
-
if (this.environment.name !== VITE_ENVIRONMENTS.server)
|
|
73
|
-
return;
|
|
74
|
-
if (!id.match(fileEndingRegex))
|
|
75
|
-
return;
|
|
76
|
-
// The transformed files either import "lazy" or css files
|
|
77
|
-
// Therefore we skip, if the src doesn't have any import
|
|
78
|
-
if (src.indexOf("import") === -1)
|
|
79
|
-
return;
|
|
80
|
-
const plugins = [];
|
|
81
|
-
const hasDefaultExport = src.indexOf("export default") !== -1;
|
|
82
|
-
if (hasDefaultExport) {
|
|
83
|
-
const localId = relative(cwd, id);
|
|
84
|
-
const chunkName = sharedChunkNames[id];
|
|
85
|
-
plugins.push(idTransform(chunkName ?? localId));
|
|
86
|
-
}
|
|
87
|
-
const hasLazy = src.indexOf("lazy(") !== -1;
|
|
88
|
-
if (hasLazy)
|
|
89
|
-
plugins.push(importTransform());
|
|
90
|
-
if (!plugins.length) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const transformed = await babel.transformAsync(src, {
|
|
94
|
-
plugins,
|
|
95
|
-
parserOpts: {
|
|
96
|
-
plugins: ["jsx", "typescript"],
|
|
97
|
-
},
|
|
98
|
-
filename: basename(id),
|
|
99
|
-
ast: false,
|
|
100
|
-
sourceMaps: true,
|
|
101
|
-
configFile: false,
|
|
102
|
-
babelrc: false,
|
|
103
|
-
sourceFileName: id,
|
|
104
|
-
});
|
|
105
|
-
if (!transformed?.code)
|
|
106
|
-
return;
|
|
107
|
-
const { code, map } = transformed;
|
|
108
|
-
return { code, map };
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export default lazy;
|
package/dist/config/manifest.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { version as viteVersion } from "vite";
|
|
4
|
-
import { findStylesInModuleGraph } from "../server/collect-styles.js";
|
|
5
|
-
import { VIRTUAL_MODULES } from "./constants.js";
|
|
6
|
-
import { wrapId } from "./vite-utils.js";
|
|
7
|
-
export function manifest(start) {
|
|
8
|
-
let devServer = undefined;
|
|
9
|
-
return {
|
|
10
|
-
name: "solid-start:manifest-plugin",
|
|
11
|
-
enforce: "pre",
|
|
12
|
-
configureServer(server) {
|
|
13
|
-
devServer = server;
|
|
14
|
-
},
|
|
15
|
-
async resolveId(id) {
|
|
16
|
-
if (id === VIRTUAL_MODULES.clientViteManifest)
|
|
17
|
-
return `\0${VIRTUAL_MODULES.clientViteManifest}`;
|
|
18
|
-
if (id === VIRTUAL_MODULES.getClientManifest)
|
|
19
|
-
return this.resolve(new URL("../server/manifest/client-manifest", import.meta.url).pathname);
|
|
20
|
-
if (id === VIRTUAL_MODULES.getManifest) {
|
|
21
|
-
return this.environment.config.consumer === "client"
|
|
22
|
-
? this.resolve(new URL("../server/manifest/client-manifest", import.meta.url).pathname)
|
|
23
|
-
: this.resolve(new URL("../server/manifest/ssr-manifest", import.meta.url).pathname);
|
|
24
|
-
}
|
|
25
|
-
if (id === VIRTUAL_MODULES.middleware) {
|
|
26
|
-
if (start.middleware)
|
|
27
|
-
return await this.resolve(start.middleware);
|
|
28
|
-
return `\0${VIRTUAL_MODULES.middleware}`;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
async load(id) {
|
|
32
|
-
if (id === `\0${VIRTUAL_MODULES.clientViteManifest}`) {
|
|
33
|
-
let clientViteManifest;
|
|
34
|
-
if (this.environment.config.command === "serve") {
|
|
35
|
-
clientViteManifest = {};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
const entry = Object.values(globalThis.START_CLIENT_BUNDLE).find(v => "isEntry" in v && v.isEntry);
|
|
39
|
-
if (!entry)
|
|
40
|
-
throw new Error("No client entry found");
|
|
41
|
-
let rawManifest;
|
|
42
|
-
const viteMajor = parseInt(viteVersion.split('.')[0], 10);
|
|
43
|
-
const manifestKey = Object.keys(globalThis.START_CLIENT_BUNDLE).find(k => k.endsWith("manifest.json"));
|
|
44
|
-
if (manifestKey && viteMajor < 8) {
|
|
45
|
-
const manifestAsset = globalThis.START_CLIENT_BUNDLE[manifestKey];
|
|
46
|
-
rawManifest = manifestAsset.source;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
try {
|
|
50
|
-
const appRoot = start.appRoot || "./src";
|
|
51
|
-
let outDir = ".solid-start/client";
|
|
52
|
-
if (devServer?.environments?.client?.config?.build?.outDir) {
|
|
53
|
-
outDir = devServer.environments.client.config.build.outDir;
|
|
54
|
-
}
|
|
55
|
-
else if (this.environment?.config?.build?.outDir && this.environment?.config?.consumer === "client") {
|
|
56
|
-
outDir = this.environment.config.build.outDir;
|
|
57
|
-
}
|
|
58
|
-
else if (globalThis.START_CLIENT_OUT_DIR) {
|
|
59
|
-
outDir = globalThis.START_CLIENT_OUT_DIR;
|
|
60
|
-
}
|
|
61
|
-
const manifestPath = path.resolve(appRoot, "..", outDir, ".vite/manifest.json");
|
|
62
|
-
rawManifest = fs.readFileSync(manifestPath, "utf-8");
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
throw new Error(`Manifest asset not found in bundle and could not be read from disk. Keys: ${Object.keys(globalThis.START_CLIENT_BUNDLE).join(", ")}. Error: ${e}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (!rawManifest) {
|
|
69
|
-
throw new Error("Failed to extract or read raw manifest.");
|
|
70
|
-
}
|
|
71
|
-
clientViteManifest = JSON.parse(rawManifest);
|
|
72
|
-
}
|
|
73
|
-
return `export const clientViteManifest = ${JSON.stringify(clientViteManifest)};`;
|
|
74
|
-
}
|
|
75
|
-
else if (id === `\0${VIRTUAL_MODULES.middleware}`)
|
|
76
|
-
return "export default {};";
|
|
77
|
-
else if (id.startsWith("/@manifest")) {
|
|
78
|
-
if (this.environment.mode !== "dev")
|
|
79
|
-
throw new Error("@manifest queries are only allowed in dev");
|
|
80
|
-
const [urlPath, query] = id.split("?");
|
|
81
|
-
const target = id.split("/")[2];
|
|
82
|
-
const params = new URLSearchParams(query);
|
|
83
|
-
if (!urlPath || !query)
|
|
84
|
-
return;
|
|
85
|
-
if (urlPath.endsWith("assets")) {
|
|
86
|
-
const id = params.get("id");
|
|
87
|
-
if (!id) {
|
|
88
|
-
throw new Error("Missing id to get assets.");
|
|
89
|
-
}
|
|
90
|
-
// Client env does not have css dependencies in mod.transformResult
|
|
91
|
-
// Aalways use ssr env instead, to prevent hydration mismatches
|
|
92
|
-
const env = devServer.environments["ssr"];
|
|
93
|
-
const styles = await findStylesInModuleGraph(env, id);
|
|
94
|
-
const cssAssets = Object.entries(styles).map(([key, value]) => `{
|
|
95
|
-
tag: "style",
|
|
96
|
-
attrs: {
|
|
97
|
-
type: "text/css",
|
|
98
|
-
"data-vite-dev-id": "${wrapId(key)}",
|
|
99
|
-
"data-vite-ref": "0",
|
|
100
|
-
},
|
|
101
|
-
children: () => import("${wrapId(value)}?inline").then(mod => mod.default),
|
|
102
|
-
}`);
|
|
103
|
-
return `export default [${cssAssets.join(",")}]`;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
package/dist/config/utils.d.ts
DELETED
package/dist/config/utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { DevEnvironment, Rollup } from "vite";
|
|
2
|
-
export declare function cleanUrl(url: string): string;
|
|
3
|
-
export declare const FS_PREFIX = "/@fs/";
|
|
4
|
-
export declare const VALID_ID_PREFIX = "/@id/";
|
|
5
|
-
export declare const NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
6
|
-
export declare function normalizeResolvedIdToUrl(environment: DevEnvironment, url: string, resolved: Rollup.PartialResolvedId): string;
|
|
7
|
-
/**
|
|
8
|
-
* Inspired by:
|
|
9
|
-
* https://github.com/withastro/astro/blob/fddde5fad81007795eb263c7fd0cea096b8e2cba/packages/astro/src/core/util.ts#L115
|
|
10
|
-
* https://github.com/vitejs/vite/blob/130e7181a55c524383c63bbfb1749d0ff7185cad/packages/vite/src/shared/utils.ts#L11
|
|
11
|
-
*/
|
|
12
|
-
export declare function wrapId(id: string): string;
|
|
13
|
-
export declare function unwrapId(id: string): string;
|
|
14
|
-
export declare function normalizeViteImportAnalysisUrl(environment: DevEnvironment, id: string): string;
|
|
15
|
-
export declare function withTrailingSlash(path: string): string;
|
|
16
|
-
export declare function splitFileAndPostfix(path: string): {
|
|
17
|
-
file: string;
|
|
18
|
-
postfix: string;
|
|
19
|
-
};
|
|
20
|
-
export declare function slash(p: string): string;
|
|
21
|
-
export declare function injectQuery(url: string, queryToInject: string): string;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const postfixRE = /[?#].*$/;
|
|
4
|
-
export function cleanUrl(url) {
|
|
5
|
-
return url.replace(postfixRE, "");
|
|
6
|
-
}
|
|
7
|
-
export const FS_PREFIX = `/@fs/`;
|
|
8
|
-
export const VALID_ID_PREFIX = `/@id/`;
|
|
9
|
-
export const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
10
|
-
const NULL_BYTE_REGEX = /^\0/;
|
|
11
|
-
export function normalizeResolvedIdToUrl(environment, url, resolved) {
|
|
12
|
-
const root = environment.config.root;
|
|
13
|
-
const depsOptimizer = environment.depsOptimizer;
|
|
14
|
-
// normalize all imports into resolved URLs
|
|
15
|
-
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
16
|
-
if (resolved.id.startsWith(withTrailingSlash(root))) {
|
|
17
|
-
// in root: infer short absolute path from root
|
|
18
|
-
url = resolved.id.slice(root.length);
|
|
19
|
-
}
|
|
20
|
-
else if (depsOptimizer?.isOptimizedDepFile(resolved.id) ||
|
|
21
|
-
// vite-plugin-react isn't following the leading \0 virtual module convention.
|
|
22
|
-
// This is a temporary hack to avoid expensive fs checks for React apps.
|
|
23
|
-
// We'll remove this as soon we're able to fix the react plugins.
|
|
24
|
-
(resolved.id !== "/@react-refresh" &&
|
|
25
|
-
path.isAbsolute(resolved.id) &&
|
|
26
|
-
fs.existsSync(cleanUrl(resolved.id)))) {
|
|
27
|
-
// an optimized deps may not yet exists in the filesystem, or
|
|
28
|
-
// a regular file exists but is out of root: rewrite to absolute /@fs/ paths
|
|
29
|
-
url = path.posix.join(FS_PREFIX, resolved.id);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
url = resolved.id;
|
|
33
|
-
}
|
|
34
|
-
// if the resolved id is not a valid browser import specifier,
|
|
35
|
-
// prefix it to make it valid. We will strip this before feeding it
|
|
36
|
-
// back into the transform pipeline
|
|
37
|
-
if (url[0] !== "." && url[0] !== "/") {
|
|
38
|
-
url = wrapId(resolved.id);
|
|
39
|
-
}
|
|
40
|
-
return url;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Inspired by:
|
|
44
|
-
* https://github.com/withastro/astro/blob/fddde5fad81007795eb263c7fd0cea096b8e2cba/packages/astro/src/core/util.ts#L115
|
|
45
|
-
* https://github.com/vitejs/vite/blob/130e7181a55c524383c63bbfb1749d0ff7185cad/packages/vite/src/shared/utils.ts#L11
|
|
46
|
-
*/
|
|
47
|
-
export function wrapId(id) {
|
|
48
|
-
return id.replace(NULL_BYTE_REGEX, `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}`);
|
|
49
|
-
}
|
|
50
|
-
export function unwrapId(id) {
|
|
51
|
-
return id.startsWith(VALID_ID_PREFIX)
|
|
52
|
-
? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0")
|
|
53
|
-
: id;
|
|
54
|
-
}
|
|
55
|
-
export function normalizeViteImportAnalysisUrl(environment, id) {
|
|
56
|
-
let url = normalizeResolvedIdToUrl(environment, id, { id });
|
|
57
|
-
// https://github.com/vitejs/vite/blob/c18ce868c4d70873406e9f7d1b2d0a03264d2168/packages/vite/src/node/plugins/importAnalysis.ts#L416
|
|
58
|
-
if (environment.config.consumer === "client") {
|
|
59
|
-
const mod = environment.moduleGraph.getModuleById(id);
|
|
60
|
-
if (mod && mod.lastHMRTimestamp > 0) {
|
|
61
|
-
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return url;
|
|
65
|
-
}
|
|
66
|
-
export function withTrailingSlash(path) {
|
|
67
|
-
if (path[path.length - 1] !== "/") {
|
|
68
|
-
return `${path}/`;
|
|
69
|
-
}
|
|
70
|
-
return path;
|
|
71
|
-
}
|
|
72
|
-
export function splitFileAndPostfix(path) {
|
|
73
|
-
const file = cleanUrl(path);
|
|
74
|
-
return { file, postfix: path.slice(file.length) };
|
|
75
|
-
}
|
|
76
|
-
const windowsSlashRE = /\\/g;
|
|
77
|
-
export function slash(p) {
|
|
78
|
-
return p.replace(windowsSlashRE, "/");
|
|
79
|
-
}
|
|
80
|
-
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
81
|
-
export function injectQuery(url, queryToInject) {
|
|
82
|
-
const { file, postfix } = splitFileAndPostfix(url);
|
|
83
|
-
const normalizedFile = isWindows ? slash(file) : file;
|
|
84
|
-
return `${normalizedFile}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : /* hash only */ postfix}`;
|
|
85
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
export function bubbleFunctionDeclaration(path) {
|
|
3
|
-
const decl = path.node;
|
|
4
|
-
// Check if declaration is FunctionDeclaration
|
|
5
|
-
if (decl.id) {
|
|
6
|
-
const block = (path.findParent(current => current.isBlockStatement()) ||
|
|
7
|
-
path.scope.getProgramParent().path);
|
|
8
|
-
if (path.parentPath.isExportNamedDeclaration()) {
|
|
9
|
-
path.parentPath.replaceWith(t.exportNamedDeclaration(undefined, [t.exportSpecifier(decl.id, decl.id)]));
|
|
10
|
-
}
|
|
11
|
-
else if (path.parentPath.isExportDefaultDeclaration()) {
|
|
12
|
-
path.replaceWith(decl.id);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
path.remove();
|
|
16
|
-
}
|
|
17
|
-
const [tmp] = block.unshiftContainer("body", t.variableDeclaration("const", [
|
|
18
|
-
t.variableDeclarator(decl.id, t.functionExpression(decl.id, decl.params, decl.body, decl.generator, decl.async)),
|
|
19
|
-
]));
|
|
20
|
-
block.scope.registerDeclaration(tmp);
|
|
21
|
-
tmp.skip();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as babel from "@babel/core";
|
|
2
|
-
import { type StateContext } from "./plugin.ts";
|
|
3
|
-
export interface CompileResult {
|
|
4
|
-
valid: boolean;
|
|
5
|
-
code: string;
|
|
6
|
-
map: babel.BabelFileResult["map"];
|
|
7
|
-
}
|
|
8
|
-
export type CompileOptions = Omit<StateContext, "count" | "hash" | "imports" | "valid">;
|
|
9
|
-
export declare function compile(id: string, code: string, options: CompileOptions): Promise<CompileResult>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as babel from "@babel/core";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { directivesPlugin } from "./plugin.js";
|
|
4
|
-
import xxHash32 from "./xxhash32.js";
|
|
5
|
-
export async function compile(id, code, options) {
|
|
6
|
-
const context = {
|
|
7
|
-
...options,
|
|
8
|
-
valid: false,
|
|
9
|
-
hash: xxHash32(id).toString(16),
|
|
10
|
-
count: 0,
|
|
11
|
-
imports: new Map(),
|
|
12
|
-
};
|
|
13
|
-
const pluginOption = [directivesPlugin, context];
|
|
14
|
-
const plugins = [
|
|
15
|
-
"jsx",
|
|
16
|
-
];
|
|
17
|
-
if (/\.[mc]?tsx?$/i.test(id)) {
|
|
18
|
-
plugins.push("typescript");
|
|
19
|
-
}
|
|
20
|
-
const result = await babel.transformAsync(code, {
|
|
21
|
-
plugins: [pluginOption],
|
|
22
|
-
parserOpts: {
|
|
23
|
-
plugins,
|
|
24
|
-
},
|
|
25
|
-
filename: path.basename(id),
|
|
26
|
-
ast: false,
|
|
27
|
-
sourceMaps: true,
|
|
28
|
-
configFile: false,
|
|
29
|
-
babelrc: false,
|
|
30
|
-
sourceFileName: id,
|
|
31
|
-
});
|
|
32
|
-
if (result) {
|
|
33
|
-
return {
|
|
34
|
-
valid: context.valid,
|
|
35
|
-
code: result.code || "",
|
|
36
|
-
map: result.map,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
throw new Error("invariant");
|
|
40
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
export function generateUniqueName(path, name) {
|
|
3
|
-
let uid;
|
|
4
|
-
let i = 1;
|
|
5
|
-
do {
|
|
6
|
-
uid = name + "_" + i;
|
|
7
|
-
i++;
|
|
8
|
-
} while (path.scope.hasLabel(uid) ||
|
|
9
|
-
path.scope.hasBinding(uid) ||
|
|
10
|
-
path.scope.hasGlobal(uid) ||
|
|
11
|
-
path.scope.hasReference(uid));
|
|
12
|
-
const program = path.scope.getProgramParent();
|
|
13
|
-
program.references[uid] = true;
|
|
14
|
-
program.uids[uid] = true;
|
|
15
|
-
return t.identifier(uid);
|
|
16
|
-
}
|