Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-dingos-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

Use per-environment Vite plugin hook APIs for forward compatibility with Vite 9.
2 changes: 1 addition & 1 deletion packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@
"vitest": "^4.1.0"
},
"peerDependencies": {
"vite": "^8"
"vite": "^8 || ^9"
}
}
9 changes: 5 additions & 4 deletions packages/start/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export function envPlugin(options?: EnvPluginOptions): Plugin {
}
return undefined;
},
load(id, opts) {
load(id) {
const isServer = this.environment.config.consumer === "server";
if (id === SERVER_ENV) {
if (!opts?.ssr) {
if (!isServer) {
return SERVER_ONLY_MODULE;
}
const vars = currentOptions.server?.load
Expand All @@ -88,13 +89,13 @@ export function envPlugin(options?: EnvPluginOptions): Plugin {
return convertObjectToModule(vars);
}
if (id === SERVER_RUNTIME_LOADER) {
if (!opts?.ssr) {
if (!isServer) {
return SERVER_ONLY_MODULE;
}
return runtimeCode;
}
if (id === SERVER_RUNTIME_ENV) {
if (!opts?.ssr) {
if (!isServer) {
return SERVER_ONLY_MODULE;
}
return SERVER_RUNTIME_CODE;
Expand Down
8 changes: 4 additions & 4 deletions packages/start/src/directives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export function serverFunctionsPlugin(options: ServerFunctionsOptions): Plugin[]
}
return null;
},
async load(id, opts) {
const mode = opts?.ssr ? "server" : "client";
async load(id) {
const mode = this.environment.config.consumer;
if (id === options.manifest) {
const current = new Debouncer(() =>
[...manifest[mode]].map(entry => `import "${entry}";`).join("\n"),
Expand All @@ -197,8 +197,8 @@ export function serverFunctionsPlugin(options: ServerFunctionsOptions): Plugin[]
{
name: "solid-start:server-functions/compiler",
enforce: 'pre',
async transform(code, fileId, opts) {
const mode = opts?.ssr ? "server" : "client";
async transform(code, fileId) {
const mode = this.environment.config.consumer;
const [id] = fileId.split("?");
if (!filter(id)) {
return null;
Expand Down
Loading