Skip to content
Source
Sign inSign up
TanStack/router

fix: only run middleware compiler in client env #5703

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5703/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Showing 1 changed file with 27 additions and 12 deletions.

x
0 of 1 viewed, 1 left
27 additions and 12 deletionspackages/start-plugin-core/src/start-compiler-plugin/compilers.tsModified
View file
@@ -23,7 +23,7 @@
framework: CompileStartFrameworkOptions,
) {
return function compileStartOutput(opts: CompileOptions): GeneratorResult {
- const identifiers: Identifiers = {
+ const identifiers: Partial<Identifiers> = {
createServerOnlyFn: {
name: 'createServerOnlyFn',
handleCallExpression: handleCreateServerOnlyFnCallExpression,
@@ -39,11 +39,16 @@
handleCallExpression: handleCreateIsomorphicFnCallExpression,
paths: [],
},
- createMiddleware: {
+ }
+​
+ // createMiddleware only performs modifications in the client environment
+ // so we can avoid executing this on the server
+ if (opts.env === 'client') {