@@ -8,6 +8,7 @@ import path from 'pathe'
88import { VITE_ENVIRONMENT_NAMES } from '../constants'
99import { compileStartOutputFactory } from './compilers'
1010import { transformFuncs } from './constants'
11+ import type { ViteEnvironmentNames } from '../constants'
1112import type { Plugin } from 'vite'
1213import type { CompileStartFrameworkOptions } from './compilers'
1314
@@ -37,33 +38,17 @@ function resolvePackage(packageName: string): string {
3738
3839export function startCompilerPlugin (
3940 framework : CompileStartFrameworkOptions ,
40- inputOpts ?: {
41- client ?: {
42- envName ?: string
43- }
44- server ?: {
45- envName ?: string
46- }
47- } ,
4841) : Plugin {
49- const opts = {
50- client : {
51- envName : VITE_ENVIRONMENT_NAMES . client ,
52- ...inputOpts ?. client ,
53- } ,
54- server : {
55- envName : VITE_ENVIRONMENT_NAMES . server ,
56- ...inputOpts ?. server ,
57- } ,
58- }
59-
6042 const compileStartOutput = compileStartOutputFactory ( framework )
6143
6244 return {
6345 name : 'tanstack-start-core:compiler' ,
6446 enforce : 'pre' ,
6547 applyToEnvironment ( env ) {
66- return [ opts . client . envName , opts . server . envName ] . includes ( env . name )
48+ return [
49+ VITE_ENVIRONMENT_NAMES . client ,
50+ VITE_ENVIRONMENT_NAMES . server ,
51+ ] . includes ( env . name as ViteEnvironmentNames )
6752 } ,
6853 transform : {
6954 filter : {
@@ -103,9 +88,9 @@ export function startCompilerPlugin(
10388 } ,
10489 handler ( code , id ) {
10590 const env =
106- this . environment . name === opts . client . envName
91+ this . environment . name === VITE_ENVIRONMENT_NAMES . client
10792 ? 'client'
108- : this . environment . name === opts . server . envName
93+ : this . environment . name === VITE_ENVIRONMENT_NAMES . server
10994 ? 'server'
11095 : ( ( ) => {
11196 throw new Error (
0 commit comments