@solidjs/start 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +28 -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/dev-server.js +10 -0
- 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 +10 -11
- package/dist/config/fs-routes/tree-shake.js +12 -21
- package/dist/config/index.js +42 -42
- package/dist/config/lazy.js +42 -12
- package/dist/config/manifest.js +4 -3
- package/dist/config/vite-utils.d.ts +5 -0
- package/dist/config/vite-utils.js +7 -3
- package/dist/http/index.d.ts +1 -4
- package/dist/http/index.js +3 -5
- package/dist/index.d.ts +0 -1
- package/dist/middleware/index.d.ts +5 -2
- package/dist/middleware/index.js +6 -1
- package/dist/router.jsx +2 -2
- package/dist/server/StartServer.jsx +2 -0
- package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
- package/dist/server/assets/PatchVirtualDevStyles.jsx +28 -0
- package/dist/server/assets/index.js +1 -1
- package/dist/server/assets/render.jsx +2 -2
- package/dist/server/collect-styles.js +9 -21
- package/dist/server/fetchEvent.spec.js +1 -1
- package/dist/server/handler.js +30 -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/server/spa/StartServer.jsx +2 -0
- 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 +107 -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 +12 -13
- package/src/config/fs-routes/tree-shake.ts +342 -363
- package/src/config/index.ts +42 -43
- package/src/config/lazy.ts +47 -16
- package/src/config/manifest.ts +8 -7
- package/src/config/vite-utils.ts +9 -9
- 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 +42 -49
- package/src/router.tsx +4 -3
- package/src/server/StartServer.tsx +3 -7
- package/src/server/assets/PatchVirtualDevStyles.tsx +31 -0
- package/src/server/assets/index.ts +1 -1
- package/src/server/assets/render.tsx +6 -2
- package/src/server/collect-styles.ts +49 -73
- package/src/server/fetchEvent.spec.ts +71 -75
- package/src/server/fetchEvent.ts +17 -17
- package/src/server/handler.ts +138 -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/StartServer.tsx +2 -0
- 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/src/config/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { globSync } from "node:fs";
|
|
4
|
-
import { extname, isAbsolute, join
|
|
4
|
+
import { extname, isAbsolute, join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { type PluginOption } from "vite";
|
|
6
|
+
import { normalizePath, type PluginOption } from "vite";
|
|
7
7
|
import solid, { type Options as SolidOptions } from "vite-plugin-solid";
|
|
8
8
|
|
|
9
9
|
import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.ts";
|
|
@@ -33,10 +33,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
33
33
|
ssr: true,
|
|
34
34
|
devOverlay: true,
|
|
35
35
|
experimental: {
|
|
36
|
-
islands: false
|
|
36
|
+
islands: false,
|
|
37
37
|
},
|
|
38
38
|
solid: {},
|
|
39
|
-
extensions: []
|
|
39
|
+
extensions: [],
|
|
40
40
|
});
|
|
41
41
|
const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
|
|
42
42
|
const routeDir = join(start.appRoot, start.routeDir);
|
|
@@ -48,7 +48,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
48
48
|
const entryExtension = extname(appEntryPath);
|
|
49
49
|
const handlers = {
|
|
50
50
|
client: `${start.appRoot}/entry-client${entryExtension}`,
|
|
51
|
-
server: `${start.appRoot}/entry-server${entryExtension}
|
|
51
|
+
server: `${start.appRoot}/entry-server${entryExtension}`,
|
|
52
52
|
};
|
|
53
53
|
return [
|
|
54
54
|
{
|
|
@@ -56,13 +56,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
56
56
|
enforce: "pre",
|
|
57
57
|
configEnvironment(name) {
|
|
58
58
|
return {
|
|
59
|
-
define: {
|
|
60
|
-
"import.meta.env.SSR": JSON.stringify(name === VITE_ENVIRONMENTS.server)
|
|
61
|
-
},
|
|
62
59
|
resolve: {
|
|
63
60
|
// remove when https://github.com/solidjs/vite-plugin-solid/pull/228 is released
|
|
64
|
-
externalConditions: ["solid", "node"]
|
|
65
|
-
}
|
|
61
|
+
externalConditions: ["solid", "node"],
|
|
62
|
+
},
|
|
66
63
|
};
|
|
67
64
|
},
|
|
68
65
|
async config(_, env) {
|
|
@@ -93,9 +90,9 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
93
90
|
rollupOptions: {
|
|
94
91
|
input: clientInput,
|
|
95
92
|
treeshake: true,
|
|
96
|
-
preserveEntrySignatures: "exports-only"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
93
|
+
preserveEntrySignatures: "exports-only",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
99
96
|
},
|
|
100
97
|
[VITE_ENVIRONMENTS.server]: {
|
|
101
98
|
consumer: "server",
|
|
@@ -105,14 +102,14 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
105
102
|
manifest: true,
|
|
106
103
|
copyPublicDir: false,
|
|
107
104
|
rollupOptions: {
|
|
108
|
-
input: "~/entry-server.tsx"
|
|
105
|
+
input: "~/entry-server.tsx",
|
|
109
106
|
},
|
|
110
107
|
outDir: "dist/server",
|
|
111
108
|
commonjsOptions: {
|
|
112
|
-
include: [/node_modules/]
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
109
|
+
include: [/node_modules/],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
116
113
|
},
|
|
117
114
|
resolve: {
|
|
118
115
|
alias: {
|
|
@@ -121,17 +118,19 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
121
118
|
...(!start.ssr
|
|
122
119
|
? {
|
|
123
120
|
"@solidjs/start/server": "@solidjs/start/server/spa",
|
|
124
|
-
"@solidjs/start/client": "@solidjs/start/client/spa"
|
|
121
|
+
"@solidjs/start/client": "@solidjs/start/client/spa",
|
|
125
122
|
}
|
|
126
|
-
: {})
|
|
127
|
-
}
|
|
123
|
+
: {}),
|
|
124
|
+
},
|
|
128
125
|
},
|
|
129
126
|
define: {
|
|
130
127
|
"import.meta.env.MANIFEST": `globalThis.MANIFEST`,
|
|
131
128
|
"import.meta.env.START_SSR": JSON.stringify(start.ssr),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"import.meta.env.
|
|
129
|
+
// Use JSON.stringify so backslashes on Windows are escaped and
|
|
130
|
+
// esbuild receives a valid JS string literal for the define value
|
|
131
|
+
"import.meta.env.START_APP_ENTRY": JSON.stringify(appEntryPath),
|
|
132
|
+
"import.meta.env.START_CLIENT_ENTRY": JSON.stringify(handlers.client),
|
|
133
|
+
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
|
|
135
134
|
},
|
|
136
135
|
builder: {
|
|
137
136
|
sharedPlugins: true,
|
|
@@ -144,24 +143,24 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
144
143
|
|
|
145
144
|
if (!client.isBuilt) await builder.build(client);
|
|
146
145
|
if (!server.isBuilt) await builder.build(server);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
146
|
+
},
|
|
147
|
+
},
|
|
149
148
|
};
|
|
150
|
-
}
|
|
149
|
+
},
|
|
151
150
|
},
|
|
152
151
|
manifest(start),
|
|
153
152
|
fsRoutes({
|
|
154
153
|
routers: {
|
|
155
154
|
client: new SolidStartClientFileRouter({
|
|
156
155
|
dir: absolute(routeDir, root),
|
|
157
|
-
extensions
|
|
156
|
+
extensions,
|
|
158
157
|
}),
|
|
159
158
|
ssr: new SolidStartServerFileRouter({
|
|
160
159
|
dir: absolute(routeDir, root),
|
|
161
160
|
extensions,
|
|
162
|
-
dataOnly: !start.ssr
|
|
163
|
-
})
|
|
164
|
-
}
|
|
161
|
+
dataOnly: !start.ssr,
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
165
164
|
}),
|
|
166
165
|
lazy(),
|
|
167
166
|
// Must be placed after fsRoutes, as treeShake will remove the
|
|
@@ -176,29 +175,29 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
176
175
|
envConsumer: "client",
|
|
177
176
|
envName: VITE_ENVIRONMENTS.client,
|
|
178
177
|
getRuntimeCode: () =>
|
|
179
|
-
`import { createServerReference } from "${
|
|
178
|
+
`import { createServerReference } from "${normalizePath(
|
|
180
179
|
fileURLToPath(new URL("../server/server-runtime", import.meta.url))
|
|
181
180
|
)}"`,
|
|
182
|
-
replacer: opts => `createServerReference('${opts.functionId}')
|
|
181
|
+
replacer: opts => `createServerReference('${opts.functionId}')`,
|
|
183
182
|
},
|
|
184
183
|
{
|
|
185
184
|
envConsumer: "server",
|
|
186
185
|
envName: VITE_ENVIRONMENTS.server,
|
|
187
186
|
getRuntimeCode: () =>
|
|
188
|
-
`import { createServerReference } from '${
|
|
187
|
+
`import { createServerReference } from '${normalizePath(
|
|
189
188
|
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
|
|
190
189
|
)}'`,
|
|
191
|
-
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')
|
|
192
|
-
}
|
|
190
|
+
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
|
|
191
|
+
},
|
|
193
192
|
],
|
|
194
193
|
provider: {
|
|
195
194
|
envName: VITE_ENVIRONMENTS.server,
|
|
196
195
|
getRuntimeCode: () =>
|
|
197
|
-
`import { createServerReference } from '${
|
|
196
|
+
`import { createServerReference } from '${normalizePath(
|
|
198
197
|
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
|
|
199
198
|
)}'`,
|
|
200
|
-
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')
|
|
201
|
-
}
|
|
199
|
+
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
|
|
200
|
+
},
|
|
202
201
|
}),
|
|
203
202
|
{
|
|
204
203
|
name: "solid-start:virtual-modules",
|
|
@@ -217,20 +216,20 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
|
|
|
217
216
|
if (query.size > 0) id += `?${query.toString()}`;
|
|
218
217
|
return id;
|
|
219
218
|
}
|
|
220
|
-
}
|
|
219
|
+
},
|
|
221
220
|
},
|
|
222
221
|
{
|
|
223
222
|
name: "solid-start:capture-client-bundle",
|
|
224
223
|
enforce: "post",
|
|
225
224
|
generateBundle(_options, bundle) {
|
|
226
225
|
globalThis.START_CLIENT_BUNDLE = bundle;
|
|
227
|
-
}
|
|
226
|
+
},
|
|
228
227
|
},
|
|
229
228
|
devServer(),
|
|
230
229
|
solid({
|
|
231
230
|
...start.solid,
|
|
232
231
|
ssr: true,
|
|
233
|
-
extensions: extensions.map(ext => `.${ext}`)
|
|
234
|
-
})
|
|
232
|
+
extensions: extensions.map(ext => `.${ext}`),
|
|
233
|
+
}),
|
|
235
234
|
];
|
|
236
235
|
}
|
package/src/config/lazy.ts
CHANGED
|
@@ -13,12 +13,12 @@ const idTransform = (id: string): PluginItem => {
|
|
|
13
13
|
path.node.body.unshift(
|
|
14
14
|
t.exportNamedDeclaration(
|
|
15
15
|
t.variableDeclaration("const", [
|
|
16
|
-
t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id))
|
|
17
|
-
])
|
|
18
|
-
)
|
|
16
|
+
t.variableDeclarator(t.identifier("id$$"), t.stringLiteral(id)),
|
|
17
|
+
]),
|
|
18
|
+
),
|
|
19
19
|
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -34,13 +34,13 @@ const importTransform = (): PluginItem => {
|
|
|
34
34
|
path.insertAfter(
|
|
35
35
|
t.importDeclaration(
|
|
36
36
|
[t.importSpecifier(t.identifier("lazy"), t.identifier("lazy"))],
|
|
37
|
-
t.stringLiteral("@solidjs/start/server")
|
|
38
|
-
)
|
|
37
|
+
t.stringLiteral("@solidjs/start/server"),
|
|
38
|
+
),
|
|
39
39
|
);
|
|
40
|
-
}
|
|
40
|
+
},
|
|
41
41
|
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -48,13 +48,43 @@ const fileEndingRegex = /(ts|js)x(\?.*)?$/;
|
|
|
48
48
|
|
|
49
49
|
const lazy = (): PluginOption => {
|
|
50
50
|
const cwd = process.cwd().replaceAll(osSep, sep);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Maps module ids to their client-specific shared chunk names.
|
|
54
|
+
* Modules in shared chunks need to find their assets via the chunk name, instead of their module id.
|
|
55
|
+
*
|
|
56
|
+
* Vite includes assets of such modules in the manifest via the chunk name:
|
|
57
|
+
* https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L179
|
|
58
|
+
* https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L319
|
|
59
|
+
*
|
|
60
|
+
* Rollup occassionally creates shared chunks automatically,
|
|
61
|
+
* but they can also be manually created by the user via:
|
|
62
|
+
* https://rollupjs.org/configuration-options/#output-manualchunks
|
|
63
|
+
*
|
|
64
|
+
* More infos on Rollup's logic:
|
|
65
|
+
* https://github.com/rollup/rollup/issues/3772#issuecomment-689955168
|
|
66
|
+
*/
|
|
67
|
+
const sharedChunkNames: Record<string, string> = {};
|
|
68
|
+
|
|
51
69
|
return {
|
|
52
70
|
name: "solid-lazy-css",
|
|
53
71
|
enforce: "pre",
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
generateBundle(_, bundle) {
|
|
73
|
+
if (this.environment.name !== VITE_ENVIRONMENTS.client) return;
|
|
74
|
+
|
|
75
|
+
for (const chunk of Object.values(bundle)) {
|
|
76
|
+
if (chunk.type !== "chunk" || !chunk.isDynamicEntry || chunk.facadeModuleId) continue;
|
|
77
|
+
|
|
78
|
+
// Has to follow Vites implementation:
|
|
79
|
+
// https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L179
|
|
80
|
+
const chunkName = `_${basename(chunk.fileName)}`;
|
|
81
|
+
for (const id of chunk.moduleIds) {
|
|
82
|
+
sharedChunkNames[id] = chunkName;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
56
85
|
},
|
|
57
86
|
async transform(src, id) {
|
|
87
|
+
if (this.environment.name !== VITE_ENVIRONMENTS.server) return;
|
|
58
88
|
if (!id.match(fileEndingRegex)) return;
|
|
59
89
|
|
|
60
90
|
// The transformed files either import "lazy" or css files
|
|
@@ -66,7 +96,8 @@ const lazy = (): PluginOption => {
|
|
|
66
96
|
const hasDefaultExport = src.indexOf("export default") !== -1;
|
|
67
97
|
if (hasDefaultExport) {
|
|
68
98
|
const localId = relative(cwd, id);
|
|
69
|
-
|
|
99
|
+
const chunkName = sharedChunkNames[id];
|
|
100
|
+
plugins.push(idTransform(chunkName ?? localId));
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
const hasLazy = src.indexOf("lazy(") !== -1;
|
|
@@ -79,21 +110,21 @@ const lazy = (): PluginOption => {
|
|
|
79
110
|
const transformed = await babel.transformAsync(src, {
|
|
80
111
|
plugins,
|
|
81
112
|
parserOpts: {
|
|
82
|
-
plugins: ["jsx", "typescript"]
|
|
113
|
+
plugins: ["jsx", "typescript"],
|
|
83
114
|
},
|
|
84
115
|
filename: basename(id),
|
|
85
116
|
ast: false,
|
|
86
117
|
sourceMaps: true,
|
|
87
118
|
configFile: false,
|
|
88
119
|
babelrc: false,
|
|
89
|
-
sourceFileName: id
|
|
120
|
+
sourceFileName: id,
|
|
90
121
|
});
|
|
91
122
|
|
|
92
123
|
if (!transformed?.code) return;
|
|
93
124
|
|
|
94
125
|
const { code, map } = transformed;
|
|
95
126
|
return { code, map };
|
|
96
|
-
}
|
|
127
|
+
},
|
|
97
128
|
};
|
|
98
129
|
};
|
|
99
130
|
|
package/src/config/manifest.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type PluginOption, type ViteDevServer } from "vite";
|
|
|
3
3
|
import { findStylesInModuleGraph } from "../server/collect-styles.ts";
|
|
4
4
|
import { VIRTUAL_MODULES } from "./constants.ts";
|
|
5
5
|
import { type SolidStartOptions } from "./index.ts";
|
|
6
|
+
import { wrapId } from "./vite-utils.ts";
|
|
6
7
|
|
|
7
8
|
export function manifest(start: SolidStartOptions): PluginOption {
|
|
8
9
|
let devServer: ViteDevServer = undefined!;
|
|
@@ -17,7 +18,7 @@ export function manifest(start: SolidStartOptions): PluginOption {
|
|
|
17
18
|
return `\0${VIRTUAL_MODULES.clientViteManifest}`;
|
|
18
19
|
if (id === VIRTUAL_MODULES.getClientManifest)
|
|
19
20
|
return this.resolve(
|
|
20
|
-
new URL("../server/manifest/client-manifest", import.meta.url).pathname
|
|
21
|
+
new URL("../server/manifest/client-manifest", import.meta.url).pathname,
|
|
21
22
|
);
|
|
22
23
|
if (id === VIRTUAL_MODULES.getManifest) {
|
|
23
24
|
return this.environment.config.consumer === "client"
|
|
@@ -36,11 +37,11 @@ export function manifest(start: SolidStartOptions): PluginOption {
|
|
|
36
37
|
clientViteManifest = {};
|
|
37
38
|
} else {
|
|
38
39
|
const entry = Object.values(globalThis.START_CLIENT_BUNDLE).find(
|
|
39
|
-
v => "isEntry" in v && v.isEntry
|
|
40
|
+
v => "isEntry" in v && v.isEntry,
|
|
40
41
|
);
|
|
41
42
|
if (!entry) throw new Error("No client entry found");
|
|
42
43
|
clientViteManifest = JSON.parse(
|
|
43
|
-
(globalThis.START_CLIENT_BUNDLE[".vite/manifest.json"] as any).source
|
|
44
|
+
(globalThis.START_CLIENT_BUNDLE[".vite/manifest.json"] as any).source,
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
return `export const clientViteManifest = ${JSON.stringify(clientViteManifest)};`;
|
|
@@ -69,16 +70,16 @@ export function manifest(start: SolidStartOptions): PluginOption {
|
|
|
69
70
|
tag: "style",
|
|
70
71
|
attrs: {
|
|
71
72
|
type: "text/css",
|
|
72
|
-
"data-vite-dev-id": "${key}",
|
|
73
|
+
"data-vite-dev-id": "${wrapId(key)}",
|
|
73
74
|
"data-vite-ref": "0",
|
|
74
75
|
},
|
|
75
|
-
children: () => import("${value}?inline").then(mod => mod.default),
|
|
76
|
-
}
|
|
76
|
+
children: () => import("${wrapId(value)}?inline").then(mod => mod.default),
|
|
77
|
+
}`,
|
|
77
78
|
);
|
|
78
79
|
|
|
79
80
|
return `export default [${cssAssets.join(",")}]`;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
}
|
|
83
|
+
},
|
|
83
84
|
};
|
|
84
85
|
}
|
package/src/config/vite-utils.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const FS_PREFIX = `/@fs/`;
|
|
|
12
12
|
export const VALID_ID_PREFIX = `/@id/`;
|
|
13
13
|
|
|
14
14
|
export const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
15
|
+
const NULL_BYTE_REGEX = /^\0/;
|
|
15
16
|
|
|
16
17
|
export function normalizeResolvedIdToUrl(
|
|
17
18
|
environment: DevEnvironment,
|
|
@@ -52,10 +53,13 @@ export function normalizeResolvedIdToUrl(
|
|
|
52
53
|
return url;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Inspired by:
|
|
58
|
+
* https://github.com/withastro/astro/blob/fddde5fad81007795eb263c7fd0cea096b8e2cba/packages/astro/src/core/util.ts#L115
|
|
59
|
+
* https://github.com/vitejs/vite/blob/130e7181a55c524383c63bbfb1749d0ff7185cad/packages/vite/src/shared/utils.ts#L11
|
|
60
|
+
*/
|
|
55
61
|
export function wrapId(id: string): string {
|
|
56
|
-
return id.
|
|
57
|
-
? id
|
|
58
|
-
: VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
62
|
+
return id.replace(NULL_BYTE_REGEX, `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}`);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export function unwrapId(id: string): string {
|
|
@@ -64,10 +68,7 @@ export function unwrapId(id: string): string {
|
|
|
64
68
|
: id;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
export function normalizeViteImportAnalysisUrl(
|
|
68
|
-
environment: DevEnvironment,
|
|
69
|
-
id: string,
|
|
70
|
-
): string {
|
|
71
|
+
export function normalizeViteImportAnalysisUrl(environment: DevEnvironment, id: string): string {
|
|
71
72
|
let url = normalizeResolvedIdToUrl(environment, id, { id });
|
|
72
73
|
|
|
73
74
|
// https://github.com/vitejs/vite/blob/c18ce868c4d70873406e9f7d1b2d0a03264d2168/packages/vite/src/node/plugins/importAnalysis.ts#L416
|
|
@@ -101,8 +102,7 @@ export function slash(p: string): string {
|
|
|
101
102
|
return p.replace(windowsSlashRE, "/");
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
const isWindows =
|
|
105
|
-
typeof process !== "undefined" && process.platform === "win32";
|
|
105
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
106
106
|
|
|
107
107
|
export function injectQuery(url: string, queryToInject: string): string {
|
|
108
108
|
const { file, postfix } = splitFileAndPostfix(url);
|
package/src/env.d.ts
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
// This file
|
|
2
|
-
// Thus cannot contain any top-level imports
|
|
3
|
-
// <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
6
|
-
|
|
7
|
-
declare namespace App {
|
|
8
|
-
export interface RequestEventLocals {
|
|
9
|
-
[key: string | symbol]: any;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
// This file contains global type definitions that are internal to SolidStart and are not exported
|
|
12
2
|
|
|
13
3
|
declare module "solidstart:server-fn-manifest" {
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
type ServerFn = (...args: Array<any>) => Promise<any>;
|
|
5
|
+
export function getServerFnById(id: string): Promise<ServerFn>;
|
|
16
6
|
}
|
|
17
7
|
|
|
18
|
-
interface ImportMetaEnv
|
|
19
|
-
extends Record<`VITE_${string}`, any>,
|
|
20
|
-
SolidStartMetaEnv {
|
|
21
|
-
BASE_URL: string;
|
|
22
|
-
MODE: string;
|
|
23
|
-
DEV: boolean;
|
|
24
|
-
PROD: boolean;
|
|
25
|
-
SSR: boolean;
|
|
26
|
-
}
|
|
8
|
+
interface ImportMetaEnv extends SolidStartMetaEnv {}
|
|
27
9
|
|
|
28
10
|
interface SolidStartMetaEnv {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
START_SSR: boolean;
|
|
12
|
+
START_APP_ENTRY: string;
|
|
13
|
+
START_CLIENT_ENTRY: string;
|
|
14
|
+
START_ISLANDS: boolean;
|
|
15
|
+
// START_DEV_OVERLAY: boolean;
|
|
16
|
+
// SERVER_BASE_URL: string;
|
|
35
17
|
}
|