diff --git a/packages/start-plugin-core/src/constants.ts b/packages/start-plugin-core/src/constants.ts index 088c1ad044b..4252d2f0662 100644 --- a/packages/start-plugin-core/src/constants.ts +++ b/packages/start-plugin-core/src/constants.ts @@ -18,3 +18,5 @@ export const ENTRY_POINTS = { start: '#tanstack-start-entry', router: '#tanstack-router-entry', } as const + +export const TRANSFORM_ID_REGEX = [/\.[cm]?tsx?$/, /\.[cm]?jsx?$/] diff --git a/packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts b/packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts index 68884d695bf..25771328ddc 100644 --- a/packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts +++ b/packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts @@ -1,4 +1,4 @@ -import { VITE_ENVIRONMENT_NAMES } from '../constants' +import { TRANSFORM_ID_REGEX, VITE_ENVIRONMENT_NAMES } from '../constants' import { ServerFnCompiler } from './compiler' import type { LookupConfig, LookupKind } from './compiler' import type { CompileStartFrameworkOptions } from '../start-compiler-plugin/compilers' @@ -81,6 +81,7 @@ export function createServerFnPlugin( filter: { id: { exclude: new RegExp(`${SERVER_FN_LOOKUP}$`), + include: TRANSFORM_ID_REGEX, }, code: { // TODO apply this plugin with a different filter per environment so that .createMiddleware() calls are not scanned in server env diff --git a/packages/start-plugin-core/src/start-compiler-plugin/plugin.ts b/packages/start-plugin-core/src/start-compiler-plugin/plugin.ts index f2dd1893e74..c1f2893c94c 100644 --- a/packages/start-plugin-core/src/start-compiler-plugin/plugin.ts +++ b/packages/start-plugin-core/src/start-compiler-plugin/plugin.ts @@ -6,7 +6,7 @@ import { VIRTUAL_MODULES } from '@tanstack/start-server-core' import { normalizePath } from 'vite' import path from 'pathe' import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils' -import { VITE_ENVIRONMENT_NAMES } from '../constants' +import { TRANSFORM_ID_REGEX, VITE_ENVIRONMENT_NAMES } from '../constants' import { compileStartOutputFactory } from './compilers' import { transformFuncs } from './constants' import type { ViteEnvironmentNames } from '../constants' @@ -54,6 +54,7 @@ export function startCompilerPlugin( filter: { code: tokenRegex, id: { + include: TRANSFORM_ID_REGEX, exclude: [ VIRTUAL_MODULES.serverFnManifest, // N.B. the following files either just re-export or provide the runtime implementation of those functions