Skip to content

Commit a84acc8

Browse files
less config options for startCompilerPlugin
1 parent 0732e2d commit a84acc8

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

packages/start-plugin-core/src/plugin.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ export function TanStackStartVitePluginCore(
290290
},
291291
},
292292
// N.B. TanStackStartCompilerPlugin must be before the TanStackServerFnPluginEnv
293-
startCompilerPlugin(corePluginOpts.framework, {
294-
client: { envName: VITE_ENVIRONMENT_NAMES.client },
295-
server: { envName: VITE_ENVIRONMENT_NAMES.server },
296-
}),
293+
startCompilerPlugin(corePluginOpts.framework),
297294
TanStackServerFnPluginEnv({
298295
// This is the ID that will be available to look up and import
299296
// our server function manifest and resolve its module

packages/start-plugin-core/src/start-compiler-plugin/plugin.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import path from 'pathe'
88
import { VITE_ENVIRONMENT_NAMES } from '../constants'
99
import { compileStartOutputFactory } from './compilers'
1010
import { transformFuncs } from './constants'
11+
import type { ViteEnvironmentNames } from '../constants'
1112
import type { Plugin } from 'vite'
1213
import type { CompileStartFrameworkOptions } from './compilers'
1314

@@ -37,33 +38,17 @@ function resolvePackage(packageName: string): string {
3738

3839
export 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

Comments
 (0)