Skip to content
Source
Sign inSign up
TanStack/router

test(start-plugin-core): cover whitespace-tolerant server fn filter #7281

Opencyphercodes(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7281/headopened

Showing 1 changed file with 44 additions and 0 deletions.

x
0 of 1 viewed, 1 left
44 additions and 0 deletionspackages/start-plugin-core/tests/vite-start-compiler-plugin.test.tsModified
View file
@@ -18,6 +18,25 @@
import type { Plugin } from 'vite'
import type { EnvironmentModuleNode } from 'vite'
​
+function getPerEnvironmentServerFnPlugin(type: 'client' | 'server') {
+ const name = type === 'client' ? 'client' : 'ssr'
+ const plugins = startCompilerPlugin({
+ framework: 'react',
+ providerEnvName: 'ssr',
+ environments: [{ name, type }],
+ }) as Array<Plugin>
+​
+ return plugins.find(
+ (candidate) => candidate.name === `tanstack-start-core::server-fn:${name}`,
+ )!
+}
+​
+function matchesTransformCodeFilter(plugin: Plugin, code: string) {
+ const include = (plugin.transform as any).filter.code.include as Array<RegExp>
+​
+ return include.some((pattern) => pattern.test(code))
+}
+​
describe('Vite dev server module specifiers', () => {
test('encodes app files as root-relative dev server paths', () => {
const encode = createViteDevServerFnModuleSpecifierEncoder('/repo/app')