Skip to content

Commit 85b24b2

Browse files
authored
fix: add vite 9 forward compat (#2191)
1 parent ec54492 commit 85b24b2

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

.changeset/tame-dingos-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Use per-environment Vite plugin hook APIs for forward compatibility with Vite 9.

packages/start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@
8989
"vitest": "^4.1.0"
9090
},
9191
"peerDependencies": {
92-
"vite": "^8"
92+
"vite": "^8 || ^9"
9393
}
9494
}

packages/start/src/config/env.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export function envPlugin(options?: EnvPluginOptions): Plugin {
7171
}
7272
return undefined;
7373
},
74-
load(id, opts) {
74+
load(id) {
75+
const isServer = this.environment.config.consumer === "server";
7576
if (id === SERVER_ENV) {
76-
if (!opts?.ssr) {
77+
if (!isServer) {
7778
return SERVER_ONLY_MODULE;
7879
}
7980
const vars = currentOptions.server?.load
@@ -88,13 +89,13 @@ export function envPlugin(options?: EnvPluginOptions): Plugin {
8889
return convertObjectToModule(vars);
8990
}
9091
if (id === SERVER_RUNTIME_LOADER) {
91-
if (!opts?.ssr) {
92+
if (!isServer) {
9293
return SERVER_ONLY_MODULE;
9394
}
9495
return runtimeCode;
9596
}
9697
if (id === SERVER_RUNTIME_ENV) {
97-
if (!opts?.ssr) {
98+
if (!isServer) {
9899
return SERVER_ONLY_MODULE;
99100
}
100101
return SERVER_RUNTIME_CODE;

packages/start/src/directives/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ export function serverFunctionsPlugin(options: ServerFunctionsOptions): Plugin[]
181181
}
182182
return null;
183183
},
184-
async load(id, opts) {
185-
const mode = opts?.ssr ? "server" : "client";
184+
async load(id) {
185+
const mode = this.environment.config.consumer;
186186
if (id === options.manifest) {
187187
const current = new Debouncer(() =>
188188
[...manifest[mode]].map(entry => `import "${entry}";`).join("\n"),
@@ -197,8 +197,8 @@ export function serverFunctionsPlugin(options: ServerFunctionsOptions): Plugin[]
197197
{
198198
name: "solid-start:server-functions/compiler",
199199
enforce: 'pre',
200-
async transform(code, fileId, opts) {
201-
const mode = opts?.ssr ? "server" : "client";
200+
async transform(code, fileId) {
201+
const mode = this.environment.config.consumer;
202202
const [id] = fileId.split("?");
203203
if (!filter(id)) {
204204
return null;

0 commit comments

Comments
 (0)