@@ -17,7 +17,7 @@ import {
1717 type Plugin ,
1818 type ViteDevServer ,
1919} from 'vite' ;
20- import { isRunnableEnvironment } from '../environment.js' ;
20+ import { getEnvironmentConsumer , isRunnableEnvironment } from '../environment.js' ;
2121import { joinBase , sendWebResponse , webRequestFromNode } from '../http.js' ;
2222import { compile , type CompileOptions } from './compile.js' ;
2323import xxHash32 from './xxhash32.js' ;
@@ -487,7 +487,7 @@ export function serverFunctions(
487487 enforce : 'pre' ,
488488 resolveId ( source , _importer , opts ) {
489489 if ( source === HANDLER_ID ) {
490- if ( ! opts ?. ssr ) {
490+ if ( getEnvironmentConsumer ( this . environment , opts ) !== 'server' ) {
491491 this . error (
492492 `${ HANDLER_ID } is server-only; import it from your server entry (SSR build).` ,
493493 ) ;
@@ -497,7 +497,7 @@ export function serverFunctions(
497497 return null ;
498498 } ,
499499 load ( id , opts ) {
500- if ( id === HANDLER_ID && opts ?. ssr ) {
500+ if ( id === HANDLER_ID && getEnvironmentConsumer ( this . environment , opts ) === 'server' ) {
501501 const externalDev =
502502 this . environment . mode === 'dev' &&
503503 ( internal . externalDevServer || ! isRunnableEnvironment ( this . environment ) ) ;
@@ -633,7 +633,7 @@ export function serverFunctions(
633633 return null ;
634634 } ,
635635 async load ( id , opts ) {
636- const mode = opts ?. ssr ? 'server' : 'client' ;
636+ const mode = getEnvironmentConsumer ( this . environment , opts ) ;
637637 if ( id === manifestId ) {
638638 if ( isBuild && mode === 'server' ) {
639639 // Merge the client build's persisted discoveries at load time,
@@ -659,7 +659,7 @@ export function serverFunctions(
659659 name : 'solid:server-functions/compiler' ,
660660 enforce : 'pre' ,
661661 async transform ( code , fileId , opts ) {
662- const mode = opts ?. ssr ? 'server' : 'client' ;
662+ const mode = getEnvironmentConsumer ( this . environment , opts ) ;
663663 const [ id ] = fileId . split ( '?' ) ;
664664 if ( ! filter ( id ) ) {
665665 return null ;
0 commit comments