Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat server fn plugin #2993

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1663de6
checkpoint
tannerlinsley Dec 11, 2024
83e7a78
checkpoint
tannerlinsley Dec 12, 2024
9ac11e8
cleanup
tannerlinsley Dec 12, 2024
3582323
checkpoint
tannerlinsley Dec 12, 2024
fa7c035
client babel now works, runtime and rpc injection
tannerlinsley Dec 12, 2024
e0d8a31
fix: dont touch anything outside of the function
tannerlinsley Dec 12, 2024
44dac10
server functions now import a tsr-serverfn-split file version
tannerlinsley Dec 12, 2024
b1335a3
checkpoint
tannerlinsley Dec 18, 2024
9e2d9cc
checkpoint
tannerlinsley Dec 20, 2024
ce2ab10
fis tests
tannerlinsley Dec 20, 2024
bc98574
It's working!!!
tannerlinsley Dec 21, 2024
97af6f7
move serverFnFetcher to start client
tannerlinsley Dec 23, 2024
08c32e9
fix: no extra context, throw errors from middleware
tannerlinsley Dec 23, 2024
c73937e
docs: add custom link example for mantine (#3033)
youssefbenlemlih Dec 18, 2024
a3f6821
ci: apply automated fixes
autofix-ci[bot] Dec 18, 2024
707c188
fix(react-router): make sure full matches are passed into route funct…
schiller-manuel Dec 19, 2024
c48ab4f
release: v1.91.3
tannerlinsley Dec 19, 2024
915fbc0
docs: minor typo in code-based-routing.md (#3043)
AlexisPin Dec 19, 2024
1687da1
feat(start): create-start cli (#2920)
timoconnellaus Dec 19, 2024
f2dbdff
docs: Minor typo in middleware.md (#3042)
nanocom Dec 20, 2024
efed787
release: v1.92.0
tannerlinsley Dec 20, 2024
0310d21
refactor(react-router): expose `scrollBehavior` on the `ScrollRestora…
joshuaKnauber Dec 21, 2024
f8b04e6
release: v1.92.1
tannerlinsley Dec 21, 2024
11f2b96
fix(start): returning `null` from server functions (#3048)
alakhpc Dec 22, 2024
3a538f7
release: v1.92.2
tannerlinsley Dec 22, 2024
ce467d1
fix: allow serverFn errors to also have context (#3037)
tannerlinsley Dec 23, 2024
d4574ef
release: v1.92.3
tannerlinsley Dec 23, 2024
dd3ab7b
move directive plugin to own package
tannerlinsley Dec 24, 2024
cdd1028
Merge branch 'main' into feat-server-fn-plugin
tannerlinsley Jan 6, 2025
45b39c7
fixes, tests
tannerlinsley Jan 6, 2025
d82e9df
suggested fixes from sean
tannerlinsley Jan 7, 2025
7733c0c
fix tests
tannerlinsley Jan 7, 2025
d37a786
fix: import specifier
tannerlinsley Jan 7, 2025
497a83f
fix: dev imports
tannerlinsley Jan 7, 2025
83a1bc8
fix: simpler config, better logging, more reliable plugin coordination
tannerlinsley Jan 7, 2025
71037fb
fix: update test snapshots
tannerlinsley Jan 7, 2025
bbaf8fd
fix: non-split directives, clean up compilers, logging, and
tannerlinsley Jan 8, 2025
6eab24e
fix: production server fn builds
tannerlinsley Jan 8, 2025
dfb5248
feat(start): explicitly enable and disable route generation
SeanCassiere Jan 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.15.1
20.17.0
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ pnpm-lock.yaml
node_modules

**/test-results
**/tests/generator/file-modification/routes/(test)/*
**/tests/generator/file-modification/routes/(test)/*
/.nx/workspace-data
4 changes: 2 additions & 2 deletions examples/react/start-basic/app/routes/deferred.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { createServerFn } from '@tanstack/start'
import { Suspense, useState } from 'react'

const personServerFn = createServerFn({ method: 'GET' })
.validator((d) => d as string)
.validator((d: string) => d)
.handler(({ data: name }) => {
return { name, randomNumber: Math.floor(Math.random() * 100) }
})

const slowServerFn = createServerFn({ method: 'GET' })
.validator((d) => d as string)
.validator((d: string) => d)
.handler(async ({ data: name }) => {
await new Promise((r) => setTimeout(r, 1000))
return { name, randomNumber: Math.floor(Math.random() * 100) }
Expand Down
2 changes: 1 addition & 1 deletion examples/react/start-basic/app/utils/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type PostType = {

export const fetchPost = createServerFn({ method: 'GET' })
.middleware([logMiddleware])
.validator((d) => d as string)
.validator((d: string) => d)
.handler(async ({ data }) => {
console.info(`Fetching post with id ${data}...`)
const post = await axios
Expand Down
2 changes: 1 addition & 1 deletion examples/react/start-supabase-basic/app/utils/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type PostType = {
}

export const fetchPost = createServerFn({ method: 'GET' })
.validator((d) => d as string)
.validator((d: string) => d)
.handler(async ({ data: postId }) => {
console.info(`Fetching post with id ${postId}...`)
const post = await axios
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"@tanstack/arktype-adapter": "workspace:*",
"@tanstack/start": "workspace:*",
"@tanstack/start-vite-plugin": "workspace:*",
"@tanstack/eslint-plugin-router": "workspace:*"
"@tanstack/eslint-plugin-router": "workspace:*",
"@tanstack/server-functions-plugin": "workspace:*",
"@tanstack/directive-functions-plugin": "workspace:*"
}
}
}
5 changes: 5 additions & 0 deletions packages/directive-functions-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<img src="https://static.scarf.sh/a.png?x-pxid=d988eb79-b0fc-4a2b-8514-6a1ab932d188" />

# TanStack Directive Functions Plugin

See https://tanstack.com/router/latest/docs/framework/react/guide/file-based-routing
5 changes: 5 additions & 0 deletions packages/directive-functions-plugin/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from '../../eslint.config.js'

export default [...rootConfig]
89 changes: 89 additions & 0 deletions packages/directive-functions-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "@tanstack/directive-functions-plugin",
"version": "1.87.3",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/TanStack/router.git",
"directory": "packages/directive-functions-plugin"
},
"homepage": "https://tanstack.com/start",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
},
"keywords": [
"react",
"location",
"router",
"routing",
"async",
"async router",
"typescript"
],
"scripts": {
"clean": "rimraf ./dist && rimraf ./coverage",
"test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit",
"test:unit": "vitest",
"test:unit:dev": "vitest --watch",
"test:eslint": "eslint ./src",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js",
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js",
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js",
"test:types:ts57": "tsc",
"test:build": "publint --strict && attw --ignore-rules no-resolution --pack .",
"build": "vite build"
},
"type": "module",
"types": "dist/esm/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist",
"src"
],
"engines": {
"node": ">=12"
},
"dependencies": {
"@babel/code-frame": "7.26.2",
"@babel/core": "^7.26.0",
"@babel/generator": "^7.26.3",
"@babel/parser": "^7.26.3",
"@babel/plugin-syntax-jsx": "^7.25.9",
"@babel/plugin-syntax-typescript": "^7.25.9",
"@babel/template": "^7.25.9",
"@babel/traverse": "^7.26.4",
"@babel/types": "^7.26.3",
"@types/babel__code-frame": "^7.0.6",
"@types/babel__core": "^7.20.5",
"@types/babel__generator": "^7.6.8",
"@types/babel__template": "^7.4.4",
"@types/babel__traverse": "^7.20.6",
"@types/diff": "^6.0.0",
"babel-dead-code-elimination": "^1.0.6",
"chalk": "^5.3.0",
"dedent": "^1.5.3",
"diff": "^7.0.0",
"tiny-invariant": "^1.3.3"
}
}
Loading
Loading