diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx index febb02ab2f..47d1148be2 100644 --- a/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx +++ b/e2e/react-router/basic-file-based-code-splitting/src/routes/posts.$postId.tsx @@ -10,6 +10,10 @@ export const Route = createFileRoute('/posts/$postId')({ return

Post not found

}, component: PostComponent, + codeSplitGroupings: [ + ['component'], + ['pendingComponent', 'errorComponent', 'notFoundComponent'], + ], }) export function PostErrorComponent({ error }: ErrorComponentProps) { diff --git a/e2e/react-router/basic-file-based-code-splitting/vite.config.ts b/e2e/react-router/basic-file-based-code-splitting/vite.config.ts index 3cc73e272d..8d2e2364d0 100644 --- a/e2e/react-router/basic-file-based-code-splitting/vite.config.ts +++ b/e2e/react-router/basic-file-based-code-splitting/vite.config.ts @@ -4,5 +4,21 @@ import { TanStackRouterVite } from '@tanstack/router-plugin/vite' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [TanStackRouterVite({ autoCodeSplitting: true }), react()], + plugins: [ + TanStackRouterVite({ + autoCodeSplitting: true, + codeSplittingOptions: { + splitBehavior: ({ routeId }) => { + if (routeId === '/posts') { + return [ + ['loader'], + ['component'], + ['pendingComponent', 'notFoundComponent', 'errorComponent'], + ] + } + }, + }, + }), + react(), + ], }) diff --git a/packages/react-router/src/route.ts b/packages/react-router/src/route.ts index 4f23cd8a8a..b934866c99 100644 --- a/packages/react-router/src/route.ts +++ b/packages/react-router/src/route.ts @@ -466,6 +466,15 @@ export interface UpdatableRouteOptions< meta?: AnyRouteMatch['meta'] } ssr?: boolean + codeSplitGroupings?: Array< + Array< + | 'loader' + | 'component' + | 'pendingComponent' + | 'notFoundComponent' + | 'errorComponent' + > + > } export type RouteLoaderFn< diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts index d12b6c2232..2e06d8610d 100644 --- a/packages/router-plugin/src/core/code-splitter/compilers.ts +++ b/packages/router-plugin/src/core/code-splitter/compilers.ts @@ -3,9 +3,12 @@ import babel from '@babel/core' import * as template from '@babel/template' import { deadCodeElimination } from 'babel-dead-code-elimination' import { generateFromAst, parseAst } from '@tanstack/router-utils' -import { splitPrefix } from '../constants' +import { tsrSplit } from '../constants' +import { createIdentifier } from './path-ids' import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils' +import type { CodeSplitGroupings, SplitRouteIdentNodes } from '../constants' +// eslint-disable-next-line unused-imports/no-unused-vars const debug = process.env.TSR_VITE_DEBUG type SplitModulesById = Record< @@ -26,17 +29,6 @@ interface State { splitModulesById: SplitModulesById } -function addSplitSearchParamToFilename(filename: string) { - const [bareFilename] = filename.split('?') - return `${bareFilename}?${splitPrefix}` -} - -function removeSplitSearchParamFromFilename(filename: string) { - const [bareFilename] = filename.split('?') - return bareFilename! -} - -type SplitRouteIdentNodes = 'component' | 'loader' type SplitNodeMeta = { routeIdent: SplitRouteIdentNodes splitStrategy: 'normal' | 'react-component' @@ -44,7 +36,17 @@ type SplitNodeMeta = { exporterIdent: string localExporterIdent: string } -const SPLIT_NOES_CONFIG = new Map([ +const SPLIT_NODES_CONFIG = new Map([ + [ + 'loader', + { + routeIdent: 'loader', + localImporterIdent: '$$splitLoaderImporter', // const $$splitLoaderImporter = () => import('...') + splitStrategy: 'normal', + localExporterIdent: 'SplitLoader', // const SplitLoader = ... + exporterIdent: 'loader', // export { SplitLoader as loader } + }, + ], [ 'component', { @@ -56,32 +58,74 @@ const SPLIT_NOES_CONFIG = new Map([ }, ], [ - 'loader', + 'pendingComponent', { - routeIdent: 'loader', - localImporterIdent: '$$splitLoaderImporter', // const $$splitLoaderImporter = () => import('...') - splitStrategy: 'normal', - localExporterIdent: 'SplitLoader', // const SplitLoader = ... - exporterIdent: 'loader', // export { SplitLoader as loader } + routeIdent: 'pendingComponent', + localImporterIdent: '$$splitPendingComponentImporter', // const $$splitPendingComponentImporter = () => import('...') + splitStrategy: 'react-component', + localExporterIdent: 'SplitPendingComponent', // const SplitPendingComponent = ... + exporterIdent: 'pendingComponent', // export { SplitPendingComponent as pendingComponent } + }, + ], + [ + 'errorComponent', + { + routeIdent: 'errorComponent', + localImporterIdent: '$$splitErrorComponentImporter', // const $$splitErrorComponentImporter = () => import('...') + splitStrategy: 'react-component', + localExporterIdent: 'SplitErrorComponent', // const SplitErrorComponent = ... + exporterIdent: 'errorComponent', // export { SplitErrorComponent as errorComponent } + }, + ], + [ + 'notFoundComponent', + { + routeIdent: 'notFoundComponent', + localImporterIdent: '$$splitNotFoundComponentImporter', // const $$splitNotFoundComponentImporter = () => import('...') + splitStrategy: 'react-component', + localExporterIdent: 'SplitNotFoundComponent', // const SplitNotFoundComponent = ... + exporterIdent: 'notFoundComponent', // export { SplitNotFoundComponent as notFoundComponent } }, ], ]) -const SPLIT_ROUTE_IDENT_NODES = [...SPLIT_NOES_CONFIG.keys()] as const +const KNOWN_SPLIT_ROUTE_IDENTS = [...SPLIT_NODES_CONFIG.keys()] as const + +function addSplitSearchParamToFilename( + filename: string, + grouping: Array, +) { + const [bareFilename] = filename.split('?') + + const params = new URLSearchParams() + params.append(tsrSplit, createIdentifier(grouping)) + + return `${bareFilename}?${params.toString()}` +} + +function removeSplitSearchParamFromFilename(filename: string) { + const [bareFilename] = filename.split('?') + return bareFilename! +} export function compileCodeSplitReferenceRoute( - opts: ParseAstOptions & { isProduction: boolean }, + opts: ParseAstOptions & { + runtimeEnv: 'dev' | 'prod' + codeSplitGroupings: CodeSplitGroupings + }, ): GeneratorResult { const ast = parseAst(opts) + function findIndexForSplitNode(str: string) { + return opts.codeSplitGroupings.findIndex((group) => + group.includes(str as any), + ) + } + babel.traverse(ast, { Program: { enter(programPath, programState) { const state = programState as unknown as State - // We need to extract the existing search params from the filename, if any - // and add the splitPrefix to them, then write them back to the filename - const splitUrl = addSplitSearchParamToFilename(opts.filename) - /** * If the component for the route is being imported from * another file, this is to track the path to that file @@ -91,8 +135,7 @@ export function compileCodeSplitReferenceRoute( * * `import '../shared/imported'` */ - let existingCompImportPath: string | null = null - let existingLoaderImportPath: string | null = null + const removableImportPaths = new Set([]) programPath.traverse( { @@ -124,9 +167,23 @@ export function compileCodeSplitReferenceRoute( options.properties.forEach((prop) => { if (t.isObjectProperty(prop)) { if (t.isIdentifier(prop.key)) { + // If the user has not specified a split grouping for this key + // then we should not split it + const codeSplitGroupingByKey = findIndexForSplitNode( + prop.key.name, + ) + if (codeSplitGroupingByKey === -1) { + return + } + const codeSplitGroup = [ + ...new Set( + opts.codeSplitGroupings[codeSplitGroupingByKey], + ), + ] + const key = prop.key.name // find key in nodeSplitConfig - const isNodeConfigAvailable = SPLIT_NOES_CONFIG.has( + const isNodeConfigAvailable = SPLIT_NODES_CONFIG.has( key as any, ) @@ -134,7 +191,16 @@ export function compileCodeSplitReferenceRoute( return } - const splitNodeMeta = SPLIT_NOES_CONFIG.get(key as any)! + const splitNodeMeta = SPLIT_NODES_CONFIG.get( + key as any, + )! + + // We need to extract the existing search params from the filename, if any + // and add the relevant codesplitPrefix to them, then write them back to the filename + const splitUrl = addSplitSearchParamToFilename( + opts.filename, + codeSplitGroup, + ) if (splitNodeMeta.splitStrategy === 'react-component') { const value = prop.value @@ -142,11 +208,14 @@ export function compileCodeSplitReferenceRoute( let shouldSplit = true if (t.isIdentifier(value)) { - existingCompImportPath = + const existingImportPath = getImportSpecifierAndPathFromLocalName( programPath, value.name, ).path + if (existingImportPath) { + removableImportPaths.add(existingImportPath) + } // exported identifiers should not be split // since they are already being imported @@ -206,7 +275,7 @@ export function compileCodeSplitReferenceRoute( // If the TSRDummyComponent is not defined, define it if ( - !opts.isProduction && // only in development + opts.runtimeEnv !== 'prod' && // only in development !hasImportedOrDefinedIdentifier('TSRDummyComponent') ) { programPath.pushContainer('body', [ @@ -223,11 +292,14 @@ export function compileCodeSplitReferenceRoute( let shouldSplit = true if (t.isIdentifier(value)) { - existingLoaderImportPath = + const existingImportPath = getImportSpecifierAndPathFromLocalName( programPath, value.name, ).path + if (existingImportPath) { + removableImportPaths.add(existingImportPath) + } // exported identifiers should not be split // since they are already being imported @@ -291,17 +363,11 @@ export function compileCodeSplitReferenceRoute( * from the program, by checking that the import has no * specifiers */ - if ( - (existingCompImportPath as string | null) || - (existingLoaderImportPath as string | null) - ) { + if (removableImportPaths.size > 0) { programPath.traverse({ ImportDeclaration(path) { if (path.node.specifiers.length > 0) return - if ( - path.node.source.value === existingCompImportPath || - path.node.source.value === existingLoaderImportPath - ) { + if (removableImportPaths.has(path.node.source.value)) { path.remove() } }, @@ -321,10 +387,14 @@ export function compileCodeSplitReferenceRoute( } export function compileCodeSplitVirtualRoute( - opts: ParseAstOptions, + opts: ParseAstOptions & { + splitTargets: Array + }, ): GeneratorResult { const ast = parseAst(opts) + const intendedSplitNodes = new Set(opts.splitTargets) + const knownExportedIdents = new Set() babel.traverse(ast, { @@ -338,9 +408,12 @@ export function compileCodeSplitVirtualRoute( > = { component: undefined, loader: undefined, + pendingComponent: undefined, + errorComponent: undefined, + notFoundComponent: undefined, } - // Find the node + // Find and track all the known split-able nodes programPath.traverse( { CallExpression: (path) => { @@ -366,7 +439,10 @@ export function compileCodeSplitVirtualRoute( if (t.isObjectExpression(options)) { options.properties.forEach((prop) => { if (t.isObjectProperty(prop)) { - SPLIT_ROUTE_IDENT_NODES.forEach((splitType) => { + // do not use `intendedSplitNodes` here + // since we have special considerations that need + // to be accounted for like (not splitting exported identifiers) + KNOWN_SPLIT_ROUTE_IDENTS.forEach((splitType) => { if ( !t.isIdentifier(prop.key) || prop.key.name !== splitType @@ -389,7 +465,7 @@ export function compileCodeSplitVirtualRoute( if (isExported && t.isIdentifier(value)) { removeExports(ast, value) } else { - const meta = SPLIT_NOES_CONFIG.get(splitType)! + const meta = SPLIT_NODES_CONFIG.get(splitType)! trackedNodesToSplitByType[splitType] = { node: prop.value, meta, @@ -408,7 +484,8 @@ export function compileCodeSplitVirtualRoute( state, ) - SPLIT_ROUTE_IDENT_NODES.forEach((SPLIT_TYPE) => { + // Start the transformation to only exported the intended split nodes + intendedSplitNodes.forEach((SPLIT_TYPE) => { const splitKey = trackedNodesToSplitByType[SPLIT_TYPE] if (!splitKey) { @@ -521,6 +598,18 @@ export function compileCodeSplitVirtualRoute( ), ]), ) + } else if (t.isTSAsExpression(splitNode)) { + // remove the type assertion + splitNode = splitNode.expression + programPath.pushContainer( + 'body', + t.variableDeclaration('const', [ + t.variableDeclarator( + t.identifier(splitMeta.localExporterIdent), + splitNode, + ), + ]), + ) } else { console.info('Unexpected splitNode type:', splitNode) throw new Error(`Unexpected splitNode type ☝️: ${splitNode.type}`) @@ -586,7 +675,7 @@ export function compileCodeSplitVirtualRoute( return str }, '') - const warningMessage = `These exports from "${opts.filename.replace('?' + splitPrefix, '')}" are not being code-split and will increase your bundle size: ${list}\nThese should either have their export statements removed or be imported from another file that is not a route.` + const warningMessage = `These exports from "${opts.filename}" are not being code-split and will increase your bundle size: ${list}\nThese should either have their export statements removed or be imported from another file that is not a route.` console.warn(warningMessage) // append this warning to the file using a template @@ -605,6 +694,101 @@ export function compileCodeSplitVirtualRoute( }) } +/** + * This function should read get the options from by searching for the key `codeSplitGroupings` + * on createFileRoute and return it's values if it exists, else return undefined + */ +export function detectCodeSplitGroupingsFromRoute(opts: ParseAstOptions): { + groupings: CodeSplitGroupings | undefined + routeId: string +} { + const ast = parseAst(opts) + + let routeId = '' + + let codeSplitGroupings: CodeSplitGroupings | undefined = undefined + + babel.traverse(ast, { + Program: { + enter(programPath) { + programPath.traverse({ + CallExpression(path) { + if (!t.isIdentifier(path.node.callee)) { + return + } + + if ( + !( + path.node.callee.name === 'createRoute' || + path.node.callee.name === 'createFileRoute' + ) + ) { + return + } + + if (t.isCallExpression(path.parentPath.node)) { + // Extract out the routeId + if (t.isCallExpression(path.parentPath.node.callee)) { + const callee = path.parentPath.node.callee + + if (t.isIdentifier(callee.callee)) { + const firstArg = callee.arguments[0] + if (t.isStringLiteral(firstArg)) { + routeId = firstArg.value + } + } + } + + // Extracting the codeSplitGroupings + const options = resolveIdentifier( + path, + path.parentPath.node.arguments[0], + ) + if (t.isObjectExpression(options)) { + options.properties.forEach((prop) => { + if (t.isObjectProperty(prop)) { + if (t.isIdentifier(prop.key)) { + if (prop.key.name === 'codeSplitGroupings') { + const value = prop.value + + if (t.isArrayExpression(value)) { + codeSplitGroupings = value.elements.map((group) => { + if (t.isArrayExpression(group)) { + return group.elements.map((node) => { + if (!t.isStringLiteral(node)) { + throw new Error( + 'You must provide a string literal for the codeSplitGroupings', + ) + } + + return node.value + }) as Array + } + + throw new Error( + 'You must provide arrays with codeSplitGroupings options.', + ) + }) + } else { + throw new Error( + 'You must provide an array of arrays for the codeSplitGroupings.', + ) + } + } + } + } + }) + } + } + }, + }) + }, + }, + }) + + return { groupings: codeSplitGroupings, routeId } +} + function getImportSpecifierAndPathFromLocalName( programPath: babel.NodePath, name: string, diff --git a/packages/router-plugin/src/core/code-splitter/path-ids.ts b/packages/router-plugin/src/core/code-splitter/path-ids.ts new file mode 100644 index 0000000000..037345549a --- /dev/null +++ b/packages/router-plugin/src/core/code-splitter/path-ids.ts @@ -0,0 +1,39 @@ +export function createIdentifier(strings: Array): string { + if (strings.length === 0) { + throw new Error('Cannot create an identifier from an empty array') + } + + const sortedStrings = [...strings].sort() + const combinedString = sortedStrings.join('---') // Delimiter + + // Replace unsafe characters + let safeString = combinedString.replace(/\//g, '--slash--') + safeString = safeString.replace(/\\/g, '--backslash--') + safeString = safeString.replace(/\?/g, '--question--') + safeString = safeString.replace(/%/g, '--percent--') + safeString = safeString.replace(/#/g, '--hash--') + safeString = safeString.replace(/\+/g, '--plus--') + safeString = safeString.replace(/=/g, '--equals--') + safeString = safeString.replace(/&/g, '--ampersand--') + safeString = safeString.replace(/\s/g, '_') // Replace spaces with underscores + + return safeString +} + +export function decodeIdentifier(identifier: string): Array { + if (!identifier) { + return [] + } + + let combinedString = identifier.replace(/--slash--/g, '/') + combinedString = combinedString.replace(/--backslash--/g, '\\') + combinedString = combinedString.replace(/--question--/g, '?') + combinedString = combinedString.replace(/--percent--/g, '%') + combinedString = combinedString.replace(/--hash--/g, '#') + combinedString = combinedString.replace(/--plus--/g, '+') + combinedString = combinedString.replace(/--equals--/g, '=') + combinedString = combinedString.replace(/--ampersand--/g, '&') + combinedString = combinedString.replace(/_/g, ' ') // Restore spaces + + return combinedString.split('---') +} diff --git a/packages/router-plugin/src/core/config.ts b/packages/router-plugin/src/core/config.ts index 3fccb42cc8..db83094d10 100644 --- a/packages/router-plugin/src/core/config.ts +++ b/packages/router-plugin/src/core/config.ts @@ -3,9 +3,72 @@ import { configSchema as generatorConfigSchema, getConfig as getGeneratorConfig, } from '@tanstack/router-generator' +import type { RegisteredRouter, RouteIds } from '@tanstack/react-router' +import type { CodeSplitGroupings } from './constants' + +export const splitGroupingsSchema = z + .array( + z.array( + z.union([ + z.literal('loader'), + z.literal('component'), + z.literal('pendingComponent'), + z.literal('errorComponent'), + z.literal('notFoundComponent'), + ]), + ), + { + message: + " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]", + }, + ) + .superRefine((val, ctx) => { + const flattened = val.flat() + const unique = [...new Set(flattened)] + + // Elements must be unique, + // ie. this shouldn't be allows [['component'], ['component', 'loader']] + if (unique.length !== flattened.length) { + ctx.addIssue({ + code: 'custom', + message: + " Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]." + + `\n You input was: ${JSON.stringify(val)}.`, + }) + } + }) + +export type CodeSplittingOptions = { + /** + * Use this function to programmatically control the code splitting behavior + * based on the `routeId` for each route. + * + * If you just need to change the default behavior, you can use the `defaultBehavior` option. + * @param params + */ + splitBehavior?: (params: { + routeId: RouteIds + }) => CodeSplitGroupings | undefined | void + + /** + * The default/global configuration to control your code splitting behavior per route. + * @default [['component'],['pendingComponent'],['errorComponent'],['notFoundComponent']] + */ + defaultBehavior?: CodeSplitGroupings +} + +const codeSplittingOptionsSchema = z.object({ + splitBehavior: z.function().optional(), + defaultBehavior: splitGroupingsSchema.optional(), +}) export const configSchema = generatorConfigSchema.extend({ enableRouteGeneration: z.boolean().optional(), + codeSplittingOptions: z + .custom((v) => { + return codeSplittingOptionsSchema.parse(v) + }) + .optional(), }) export const getConfig = (inlineConfig: Partial, root: string) => { diff --git a/packages/router-plugin/src/core/constants.ts b/packages/router-plugin/src/core/constants.ts index 4e63aeea77..690c079888 100644 --- a/packages/router-plugin/src/core/constants.ts +++ b/packages/router-plugin/src/core/constants.ts @@ -1 +1,18 @@ -export const splitPrefix = 'tsr-split' +export const tsrSplit = 'tsr-split' + +export const splitRouteIdentNodes = [ + 'loader', + 'component', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', +] as const +export type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number] +export type CodeSplitGroupings = Array> + +export const defaultCodeSplitGroupings: CodeSplitGroupings = [ + ['component'], + ['pendingComponent'], + ['errorComponent'], + ['notFoundComponent'], +] diff --git a/packages/router-plugin/src/core/router-code-splitter-plugin.ts b/packages/router-plugin/src/core/router-code-splitter-plugin.ts index a38dd6877c..09ee422cd9 100644 --- a/packages/router-plugin/src/core/router-code-splitter-plugin.ts +++ b/packages/router-plugin/src/core/router-code-splitter-plugin.ts @@ -1,16 +1,31 @@ -import { isAbsolute, join, normalize } from 'node:path' +/** + * It is important to familiarize yourself with how the code-splitting works in this plugin. + * https://github.com/TanStack/router/pull/3355 + */ +import { isAbsolute, join, normalize } from 'node:path' import { fileURLToPath, pathToFileURL } from 'node:url' import { logDiff } from '@tanstack/router-utils' -import { getConfig } from './config' +import { getConfig, splitGroupingsSchema } from './config' import { compileCodeSplitReferenceRoute, compileCodeSplitVirtualRoute, + detectCodeSplitGroupingsFromRoute, } from './code-splitter/compilers' -import { splitPrefix } from './constants' +import { + defaultCodeSplitGroupings, + splitRouteIdentNodes, + tsrSplit, +} from './constants' +import { decodeIdentifier } from './code-splitter/path-ids' +import type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants' import type { Config } from './config' -import type { UnpluginContextMeta, UnpluginFactory } from 'unplugin' +import type { + UnpluginContextMeta, + UnpluginFactory, + TransformResult as UnpluginTransformResult, +} from 'unplugin' const debug = process.env.TSR_VITE_DEBUG && @@ -71,31 +86,63 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< const isProduction = process.env.NODE_ENV === 'production' - const handleSplittingFile = (code: string, id: string) => { - if (debug) console.info('Splitting Route: ', id) + const getGlobalCodeSplitGroupings = () => { + return ( + userConfig.codeSplittingOptions?.defaultBehavior || + defaultCodeSplitGroupings + ) + } + const getShouldSplitFn = () => { + return userConfig.codeSplittingOptions?.splitBehavior + } + + const handleCompilingReferenceFile = ( + code: string, + id: string, + ): UnpluginTransformResult => { + if (debug) console.info('Compiling Route: ', id) - const compiledVirtualRoute = compileCodeSplitVirtualRoute({ + const fromCode = detectCodeSplitGroupingsFromRoute({ code, root: ROOT, filename: id, }) - if (debug) { - logDiff(code, compiledVirtualRoute.code) - console.log('Output:\n', compiledVirtualRoute.code) + if (fromCode.groupings) { + const res = splitGroupingsSchema.safeParse(fromCode.groupings) + if (!res.success) { + const message = res.error.errors.map((e) => e.message).join('. ') + throw new Error( + `The groupings for the route "${id}" are invalid.\n${message}`, + ) + } } - return compiledVirtualRoute - } + const userShouldSplitFn = getShouldSplitFn() - const handleCompilingFile = (code: string, id: string) => { - if (debug) console.info('Compiling Route: ', id) + const pluginSplitBehavior = userShouldSplitFn?.({ + routeId: fromCode.routeId, + }) as CodeSplitGroupings | undefined + + if (pluginSplitBehavior) { + const res = splitGroupingsSchema.safeParse(pluginSplitBehavior) + if (!res.success) { + const message = res.error.errors.map((e) => e.message).join('. ') + throw new Error( + `The groupings returned when using \`splitBehavior\` for the route "${id}" are invalid.\n${message}`, + ) + } + } + + const splitGroupings: CodeSplitGroupings = + fromCode.groupings || pluginSplitBehavior || getGlobalCodeSplitGroupings() const compiledReferenceRoute = compileCodeSplitReferenceRoute({ code, root: ROOT, filename: id, - isProduction, + runtimeEnv: isProduction ? 'prod' : 'dev', + codeSplitGroupings: splitGroupings, }) if (debug) { @@ -106,6 +153,43 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< return compiledReferenceRoute } + const handleCompilingVirtualFile = ( + code: string, + id: string, + ): UnpluginTransformResult => { + if (debug) console.info('Splitting Route: ', id) + + const [_, ...pathnameParts] = id.split('?') + + const searchParams = new URLSearchParams(pathnameParts.join('?')) + const splitValue = searchParams.get(tsrSplit) + + if (!splitValue) { + throw new Error( + `The split value for the virtual route "${id}" was not found.`, + ) + } + + const rawGrouping = decodeIdentifier(splitValue) + const grouping = [...new Set(rawGrouping)].filter((p) => + splitRouteIdentNodes.includes(p as any), + ) as Array + + const result = compileCodeSplitVirtualRoute({ + code, + root: ROOT, + filename: id, + splitTargets: grouping, + }) + + if (debug) { + logDiff(code, result.code) + console.log('Output:\n', result.code + '\n\n') + } + + return result + } + return { name: 'router-code-splitter-plugin', enforce: 'pre', @@ -119,8 +203,8 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< url.searchParams.delete('v') id = fileURLToPath(url).replace(/\\/g, '/') - if (id.includes(splitPrefix)) { - return handleSplittingFile(code, id) + if (id.includes(tsrSplit)) { + return handleCompilingVirtualFile(code, id) } else if ( fileIsInRoutesDirectory(id, userConfig.routesDirectory) && (code.includes('createRoute(') || code.includes('createFileRoute(')) @@ -135,7 +219,7 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< } } - return handleCompilingFile(code, id) + return handleCompilingReferenceFile(code, id) } return null @@ -148,7 +232,7 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< if ( fileIsInRoutesDirectory(id, userConfig.routesDirectory) || - id.includes(splitPrefix) + id.includes(tsrSplit) ) { return true } @@ -163,7 +247,7 @@ export const unpluginRouterCodeSplitterFactory: UnpluginFactory< }, }, - rspack(compiler) { + rspack(_compiler) { ROOT = process.cwd() userConfig = getConfig(options, ROOT) }, diff --git a/packages/router-plugin/tests/code-splitter.test.ts b/packages/router-plugin/tests/code-splitter.test.ts index 55c5ad476a..7f0c468c98 100644 --- a/packages/router-plugin/tests/code-splitter.test.ts +++ b/packages/router-plugin/tests/code-splitter.test.ts @@ -6,57 +6,103 @@ import { compileCodeSplitReferenceRoute, compileCodeSplitVirtualRoute, } from '../src/core/code-splitter/compilers' -import { splitPrefix } from '../src/core/constants' +import { createIdentifier } from '../src/core/code-splitter/path-ids' +import { defaultCodeSplitGroupings } from '../src/core/constants' +import type { CodeSplitGroupings } from '../src/core/constants' async function getFilenames() { return await readdir(path.resolve(__dirname, './code-splitter/test-files')) } -describe.each(['development', 'production'])( - 'code-splitter works, NODE_ENV=%s ', - async (NODE_ENV) => { - process.env.NODE_ENV = NODE_ENV - const filenames = await getFilenames() - - it.each(filenames)( - 'should handle the compiling of "%s"', - async (filename) => { - const file = await readFile( - path.resolve(__dirname, `./code-splitter/test-files/${filename}`), - ) - const code = file.toString() - - const compileResult = compileCodeSplitReferenceRoute({ - code, - root: './code-splitter/test-files', - filename, - isProduction: NODE_ENV === 'production', - }) - - await expect(compileResult.code).toMatchFileSnapshot( - `./code-splitter/snapshots/${NODE_ENV}/${filename}`, - ) - }, - ) - - it.each(filenames)( - 'should handle the splitting of "%s"', - async (filename) => { - const file = await readFile( - path.resolve(__dirname, `./code-splitter/test-files/${filename}`), - ) - const code = file.toString() - - const splitResult = compileCodeSplitVirtualRoute({ - code: code, - root: './code-splitter/test-files', - filename: `${filename}?${splitPrefix}`, - }) - - await expect(splitResult.code).toMatchFileSnapshot( - `./code-splitter/snapshots/${NODE_ENV}/${filename.replace('.tsx', '')}@split.tsx`, - ) - }, - ) +const testGroups: Array<{ name: string; groupings: CodeSplitGroupings }> = [ + { + name: '1-default', + groupings: defaultCodeSplitGroupings, }, -) + { + name: '2-components-combined-loader-separate', + groupings: [ + ['loader'], + ['component', 'pendingComponent', 'errorComponent', 'notFoundComponent'], + ], + }, + { + name: '3-all-combined-errorComponent-separate', + groupings: [ + ['loader', 'component', 'pendingComponent', 'notFoundComponent'], + ['errorComponent'], + ], + }, +] + +describe('code-splitter works', () => { + describe.each(testGroups)( + 'SPLIT_GROUP=$name', + async ({ groupings: grouping, name: groupName }) => { + const filenames = await getFilenames() + + describe.each(['development', 'production'])( + 'NODE_ENV=%s ', + (NODE_ENV) => { + process.env.NODE_ENV = NODE_ENV + + it.each(filenames)( + `should compile "reference" for "%s"`, + async (filename) => { + const file = await readFile( + path.resolve( + __dirname, + `./code-splitter/test-files/${filename}`, + ), + ) + const code = file.toString() + + const compileResult = compileCodeSplitReferenceRoute({ + code, + root: './code-splitter/test-files', + filename, + runtimeEnv: NODE_ENV === 'production' ? 'prod' : 'dev', + codeSplitGroupings: grouping, + }) + + await expect(compileResult.code).toMatchFileSnapshot( + `./code-splitter/snapshots/${groupName}/${NODE_ENV}/${filename}`, + ) + }, + ) + + it.each(filenames)( + `should compile "virtual" for "%s"`, + async (filename) => { + const file = await readFile( + path.resolve( + __dirname, + `./code-splitter/test-files/${filename}`, + ), + ) + const code = file.toString() + + for (const targets of grouping) { + const ident = createIdentifier(targets) + + const splitResult = compileCodeSplitVirtualRoute({ + code, + root: './code-splitter/test-files', + filename: `${filename}?${ident}`, + splitTargets: targets, + }) + + await expect(splitResult.code).toMatchFileSnapshot( + `./code-splitter/snapshots/${groupName}/${NODE_ENV}/${filename.replace( + '.tsx', + '', + )}@${ident}.tsx`, + ) + } + }, + ) + }, + ) + }, + ) +}) diff --git a/packages/router-plugin/tests/code-splitter/shared/imported.tsx b/packages/router-plugin/tests/code-splitter/shared/imported.tsx index 521bb54ffc..3613d31eb8 100644 --- a/packages/router-plugin/tests/code-splitter/shared/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/shared/imported.tsx @@ -4,6 +4,18 @@ export const importedComponent = () => { return
I am imported
} +export const importedErrorComponent = () => { + return
I am an error imported
+} + +export const importedNotFoundComponent = () => { + return
I am a not found imported
+} + +export const importedPendingComponent = () => { + return
I am a pending imported
+} + export const importedLoader = () => { return { randomNumber: Math.random(), diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function.tsx new file mode 100644 index 0000000000..ed12a9b49e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { fetchPosts } from '../posts'; +export const Route = createFileRoute('/posts')({ + loader: fetchPosts, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@component.tsx new file mode 100644 index 0000000000..be5c0086de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@component.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "arrow-function.tsx"; +const SplitComponent = () => { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-const@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@errorComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-const@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@errorComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-function@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@notFoundComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-function@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@notFoundComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-const@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@pendingComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-const@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/arrow-function@pendingComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese.tsx similarity index 95% rename from packages/router-plugin/tests/code-splitter/snapshots/development/chinese.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese.tsx index 470bfea7fb..9bf9da7298 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('chinese.tsx?tsr-split'); +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/chinese@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/chinese@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@errorComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@errorComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@notFoundComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@notFoundComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@pendingComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/chinese@pendingComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties.tsx new file mode 100644 index 0000000000..26de4ca825 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties.tsx @@ -0,0 +1,13 @@ +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { falseLoader } from '@modules/false-component'; +export const Route = createFileRoute('/posts')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: isEnabled ? TrueImport.loader : falseLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@component.tsx new file mode 100644 index 0000000000..aaf3410c69 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@component.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { FalseComponent } from '@modules/false-component'; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-function@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@errorComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-function@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@errorComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/conditional-properties@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component.tsx new file mode 100644 index 0000000000..500078adc8 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@component.tsx new file mode 100644 index 0000000000..446d55e26b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@component.tsx @@ -0,0 +1,6 @@ +import { memo } from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructured-react-memo-imported-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/destructuring.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/destructuring@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/destructuring@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@errorComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/destructuring.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@errorComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/destructuring@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@notFoundComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/destructuring@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@notFoundComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/destructuring@pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/function-as-parameter.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/function-as-parameter@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/function-as-parameter@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@errorComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/function-as-parameter.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@errorComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/function-as-parameter@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@notFoundComponent.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/function-as-parameter@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@notFoundComponent.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-as-parameter@pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration.tsx new file mode 100644 index 0000000000..92a3bf04dd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { fetchPosts } from '../posts'; +export const Route = createFileRoute('/posts')({ + loader: fetchPosts, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@component.tsx new file mode 100644 index 0000000000..544f6ffcbc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@component.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "function-declaration.tsx"; +const SplitComponent = function PostsComponent() { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/function-declaration@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute.tsx similarity index 93% rename from packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute.tsx index 643100983a..8a221122d7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split'); +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/importAttribute@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader.tsx new file mode 100644 index 0000000000..2617767d26 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@component.tsx new file mode 100644 index 0000000000..e9cae51951 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@component.tsx @@ -0,0 +1,3 @@ +import importedComponent from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component-destructured-loader@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component.tsx similarity index 90% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component.tsx index 0afffe7fab..968e6633d4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-default-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent.tsx new file mode 100644 index 0000000000..0701029aa3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent.tsx @@ -0,0 +1,11 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=errorComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@errorComponent.tsx new file mode 100644 index 0000000000..1d7f487fd2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@errorComponent.tsx @@ -0,0 +1,3 @@ +import { importedErrorComponent } from '../shared/imported'; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-errorComponent@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..63787a44d6 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent.tsx @@ -0,0 +1,11 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=notFoundComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..b3e0a2bdcd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@notFoundComponent.tsx @@ -0,0 +1,3 @@ +import { importedNotFoundComponent } from '../shared/imported'; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-notFoundComponent@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent.tsx new file mode 100644 index 0000000000..143fe9c5e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent.tsx @@ -0,0 +1,11 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@pendingComponent.tsx new file mode 100644 index 0000000000..08170fadcd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported-pendingComponent@pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedPendingComponent } from '../shared/imported'; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported.tsx new file mode 100644 index 0000000000..9e843466e2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@component.tsx new file mode 100644 index 0000000000..85355cf3a2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@component.tsx @@ -0,0 +1,3 @@ +import { importedComponent } from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/imported@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline.tsx similarity index 96% rename from packages/router-plugin/tests/code-splitter/snapshots/development/inline.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline.tsx index fc048e9ee8..3d4163335f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('inline.tsx?tsr-split'); +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/inline@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/inline@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@errorComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@errorComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@notFoundComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@notFoundComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@pendingComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/inline@pendingComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number.tsx new file mode 100644 index 0000000000..f95c3f5dfe --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number.tsx @@ -0,0 +1,18 @@ +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute, defer } from '@tanstack/react-router'; +import { getSponsorsForSponsorPack } from '~/server/sponsors'; +export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; +export const gradients = [`from-rose-500 to-yellow-500`, `from-yellow-500 to-teal-500`, `from-teal-500 to-violet-500`, `from-blue-500 to-pink-500`]; +export const Route = createFileRoute('/')({ + loader: () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; + }, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@component.tsx new file mode 100644 index 0000000000..76ed9ff5e0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@component.tsx @@ -0,0 +1,18 @@ +import discordImage from '~/images/discord-logo-white.svg'; +import { sample } from '~/utils/utils'; +import { textColors } from "random-number.tsx"; +import { gradients } from "random-number.tsx"; +import { Route } from "random-number.tsx"; +const SplitComponent = function Index() { + const { + randomNumber + } = Route.useLoaderData(); + const gradient = sample(gradients, randomNumber); + const textColor = sample(textColors, randomNumber); + return <> + {discordImage} + {gradient} + {textColor} + ; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/random-number@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component.tsx new file mode 100644 index 0000000000..cab16f8c71 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@component.tsx new file mode 100644 index 0000000000..dfef29c9e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@component.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component.tsx new file mode 100644 index 0000000000..0c7d4f0cbb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@component.tsx new file mode 100644 index 0000000000..5a6456643b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@component.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import { importedComponent } from '../shared/imported'; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/react-memo-imported-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component.tsx new file mode 100644 index 0000000000..0446cde9bb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component.tsx @@ -0,0 +1,25 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: importedLoader +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-export-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-const.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-const@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-function.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-function@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader.tsx similarity index 94% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-loader.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader.tsx index c6fe8d5b93..17a52407a1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split'); +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export function loaderFn() { diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-loader@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-exports-loader@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/retain-exports-loader@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure.tsx similarity index 95% rename from packages/router-plugin/tests/code-splitter/snapshots/development/useStateDestructure.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure.tsx index 7814e05ec6..d3a8cb93a1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split'); +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { startProject } from '~/projects/start'; import { createFileRoute } from '@tanstack/react-router'; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/useStateDestructure@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/useStateDestructure@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@errorComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@errorComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@notFoundComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@notFoundComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@pendingComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/development/useStateDestructure@pendingComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function.tsx new file mode 100644 index 0000000000..6b2e1dcace --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { fetchPosts } from '../posts'; +export const Route = createFileRoute('/posts')({ + loader: fetchPosts, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@component.tsx new file mode 100644 index 0000000000..be5c0086de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@component.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "arrow-function.tsx"; +const SplitComponent = () => { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/arrow-function@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese.tsx similarity index 95% rename from packages/router-plugin/tests/code-splitter/snapshots/production/chinese.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese.tsx index 19724978c2..fa348ee8d5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('chinese.tsx?tsr-split'); +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/chinese@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/chinese@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@errorComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@errorComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@notFoundComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@notFoundComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@pendingComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/chinese@pendingComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties.tsx new file mode 100644 index 0000000000..efec873519 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties.tsx @@ -0,0 +1,10 @@ +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { falseLoader } from '@modules/false-component'; +export const Route = createFileRoute('/posts')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: isEnabled ? TrueImport.loader : falseLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@component.tsx new file mode 100644 index 0000000000..aaf3410c69 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@component.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { FalseComponent } from '@modules/false-component'; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/conditional-properties@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component.tsx new file mode 100644 index 0000000000..7c7eb4d911 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@component.tsx new file mode 100644 index 0000000000..446d55e26b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@component.tsx @@ -0,0 +1,6 @@ +import { memo } from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructured-react-memo-imported-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@component.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@component.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@errorComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@errorComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@notFoundComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@notFoundComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/destructuring@pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@component.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@component.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@errorComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@errorComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@notFoundComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@notFoundComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-as-parameter@pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration.tsx new file mode 100644 index 0000000000..21900709e4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { fetchPosts } from '../posts'; +export const Route = createFileRoute('/posts')({ + loader: fetchPosts, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@component.tsx new file mode 100644 index 0000000000..544f6ffcbc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@component.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "function-declaration.tsx"; +const SplitComponent = function PostsComponent() { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/function-declaration@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute.tsx similarity index 92% rename from packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute.tsx index 514b7ccb40..d4283ffced 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split'); +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/importAttribute@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader.tsx new file mode 100644 index 0000000000..f2935c4ec6 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@component.tsx new file mode 100644 index 0000000000..e9cae51951 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@component.tsx @@ -0,0 +1,3 @@ +import importedComponent from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component-destructured-loader@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component.tsx similarity index 89% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component.tsx index d8ca2602d0..65202cff33 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-default-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent.tsx new file mode 100644 index 0000000000..a7b2f8702a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent.tsx @@ -0,0 +1,8 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=errorComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@errorComponent.tsx new file mode 100644 index 0000000000..1d7f487fd2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@errorComponent.tsx @@ -0,0 +1,3 @@ +import { importedErrorComponent } from '../shared/imported'; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-errorComponent@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..0f9a8a66b6 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent.tsx @@ -0,0 +1,8 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=notFoundComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..b3e0a2bdcd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@notFoundComponent.tsx @@ -0,0 +1,3 @@ +import { importedNotFoundComponent } from '../shared/imported'; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-notFoundComponent@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent.tsx new file mode 100644 index 0000000000..4b0c7bd790 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent.tsx @@ -0,0 +1,8 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@component.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@component.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@pendingComponent.tsx new file mode 100644 index 0000000000..08170fadcd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported-pendingComponent@pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedPendingComponent } from '../shared/imported'; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported.tsx new file mode 100644 index 0000000000..c921da7a08 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@component.tsx new file mode 100644 index 0000000000..85355cf3a2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@component.tsx @@ -0,0 +1,3 @@ +import { importedComponent } from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/imported@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline.tsx similarity index 95% rename from packages/router-plugin/tests/code-splitter/snapshots/production/inline.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline.tsx index 4f94f8bdd2..0df06d99cd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('inline.tsx?tsr-split'); +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/inline@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/inline@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@errorComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@errorComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@notFoundComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@notFoundComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@pendingComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/inline@pendingComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number.tsx new file mode 100644 index 0000000000..1d6cae8c03 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number.tsx @@ -0,0 +1,15 @@ +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute, defer } from '@tanstack/react-router'; +import { getSponsorsForSponsorPack } from '~/server/sponsors'; +export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; +export const gradients = [`from-rose-500 to-yellow-500`, `from-yellow-500 to-teal-500`, `from-teal-500 to-violet-500`, `from-blue-500 to-pink-500`]; +export const Route = createFileRoute('/')({ + loader: () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; + }, + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@component.tsx new file mode 100644 index 0000000000..76ed9ff5e0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@component.tsx @@ -0,0 +1,18 @@ +import discordImage from '~/images/discord-logo-white.svg'; +import { sample } from '~/utils/utils'; +import { textColors } from "random-number.tsx"; +import { gradients } from "random-number.tsx"; +import { Route } from "random-number.tsx"; +const SplitComponent = function Index() { + const { + randomNumber + } = Route.useLoaderData(); + const gradient = sample(gradients, randomNumber); + const textColor = sample(textColors, randomNumber); + return <> + {discordImage} + {gradient} + {textColor} + ; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/random-number@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component.tsx new file mode 100644 index 0000000000..f012eb1d88 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@component.tsx new file mode 100644 index 0000000000..dfef29c9e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@component.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component.tsx new file mode 100644 index 0000000000..6c55a9e5e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +import { importedLoader } from '../shared/imported'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: importedLoader +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@component.tsx new file mode 100644 index 0000000000..5a6456643b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@component.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import { importedComponent } from '../shared/imported'; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/react-memo-imported-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component.tsx new file mode 100644 index 0000000000..0446cde9bb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component.tsx @@ -0,0 +1,25 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: importedLoader +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-export-component@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-const.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-const@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-function.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@component.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-function@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader.tsx similarity index 93% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-loader.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader.tsx index 4ed9513983..f9000ca496 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split'); +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export function loaderFn() { diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-loader@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-exports-loader@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@notFoundComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/retain-exports-loader@pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure.tsx similarity index 94% rename from packages/router-plugin/tests/code-splitter/snapshots/production/useStateDestructure.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure.tsx index f847174b9e..2d4e7962bd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure.tsx @@ -1,4 +1,4 @@ -const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split'); +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component'); import { lazyRouteComponent } from '@tanstack/react-router'; import { startProject } from '~/projects/start'; import { createFileRoute } from '@tanstack/react-router'; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/useStateDestructure@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@component.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/useStateDestructure@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@component.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@errorComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@errorComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@notFoundComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@notFoundComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@pendingComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/1-default/production/useStateDestructure@pendingComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function.tsx similarity index 84% rename from packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function.tsx index 284e796894..a84401590d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split'); +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..be5c0086de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "arrow-function.tsx"; +const SplitComponent = () => { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@loader.tsx new file mode 100644 index 0000000000..d9ed4ea7af --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/arrow-function@loader.tsx @@ -0,0 +1,3 @@ +import { fetchPosts } from '../posts'; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese.tsx new file mode 100644 index 0000000000..6f7cce7a75 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +interface DemoProps { + title: string; +} +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..6e6df2f4eb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,22 @@ +interface DemoProps { + title: string; +} +function Demo({ + title +}: DemoProps) { + return

+ {title} +

; +} +const SplitComponent = function HomeComponent() { + return
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@loader.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/chinese@loader.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties.tsx similarity index 82% rename from packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties.tsx index 66e234f08c..a126bb6807 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split'); +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaf3410c69 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { FalseComponent } from '@modules/false-component'; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@loader.tsx new file mode 100644 index 0000000000..e10f305ddc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/conditional-properties@loader.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { falseLoader } from '@modules/false-component'; +const SplitLoader = isEnabled ? TrueImport.loader : falseLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx similarity index 77% rename from packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx index e227fe3b62..65f2bfb918 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..446d55e26b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,6 @@ +import { memo } from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-export-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component@loader.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-export-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructured-react-memo-imported-component@loader.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@loader.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/destructuring@loader.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@loader.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-as-parameter@loader.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration.tsx similarity index 82% rename from packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration.tsx index 5d8eb0f877..81124d1df4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split'); +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..544f6ffcbc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "function-declaration.tsx"; +const SplitComponent = function PostsComponent() { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@loader.tsx new file mode 100644 index 0000000000..d9ed4ea7af --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/function-declaration@loader.tsx @@ -0,0 +1,3 @@ +import { fetchPosts } from '../posts'; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute.tsx new file mode 100644 index 0000000000..b89aede427 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..f34d3c6408 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { test } from './test' with { type: 'macro' }; +const SplitComponent = () => test; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/importAttribute@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx similarity index 76% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx index 5816128ff5..9169f0b966 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e9cae51951 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import importedComponent from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-export-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader@loader.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-export-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component-destructured-loader@loader.tsx diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component.tsx new file mode 100644 index 0000000000..9b38429966 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-default-component@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent.tsx new file mode 100644 index 0000000000..108ad65fde --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent.tsx @@ -0,0 +1,11 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..a8e97d693c --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedErrorComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-errorComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..4df3a0edc2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent.tsx @@ -0,0 +1,11 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e4e3e353fd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedNotFoundComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-notFoundComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent.tsx new file mode 100644 index 0000000000..8a12860d09 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent.tsx @@ -0,0 +1,11 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaa3ecd4f9 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedPendingComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported-pendingComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported.tsx similarity index 85% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported.tsx index 1c83cbef17..b8c6e8c0ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('imported.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('imported.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..85355cf3a2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedComponent } from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/imported@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline.tsx new file mode 100644 index 0000000000..70ca28064d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +Route.addChildren([]); +export const test = 'test'; +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dd352c63ae --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import * as styles from '../style.css'; +import { TEST_DATA } from '../test.const'; +const Button = (props: { + children: any; +}) => { + return ; +}; +import { Route } from "inline.tsx"; +Route.addChildren([]); +import { test } from "inline.tsx"; +const SplitComponent = () => { + return
+ {test} +

{TEST_DATA.welcome}

+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@loader.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/inline@loader.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number.tsx similarity index 88% rename from packages/router-plugin/tests/code-splitter/snapshots/development/random-number.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number.tsx index e81ba56b5b..281e1d4a13 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('random-number.tsx?tsr-split'); +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..76ed9ff5e0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import discordImage from '~/images/discord-logo-white.svg'; +import { sample } from '~/utils/utils'; +import { textColors } from "random-number.tsx"; +import { gradients } from "random-number.tsx"; +import { Route } from "random-number.tsx"; +const SplitComponent = function Index() { + const { + randomNumber + } = Route.useLoaderData(); + const gradient = sample(gradients, randomNumber); + const textColor = sample(textColors, randomNumber); + return <> + {discordImage} + {gradient} + {textColor} + ; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@loader.tsx new file mode 100644 index 0000000000..3dff7886f7 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/random-number@loader.tsx @@ -0,0 +1,9 @@ +import { defer } from '@tanstack/react-router'; +import { getSponsorsForSponsorPack } from '~/server/sponsors'; +const SplitLoader = () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; +}; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component.tsx similarity index 82% rename from packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component.tsx index ec6e86b561..bf8ae8af25 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dfef29c9e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component.tsx similarity index 80% rename from packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component.tsx index 38e4fd6de0..5987f84c0a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..5a6456643b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import { importedComponent } from '../shared/imported'; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/react-memo-imported-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component.tsx similarity index 96% rename from packages/router-plugin/tests/code-splitter/snapshots/development/retain-export-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component.tsx index 5e41828800..fd6c6de54c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/retain-export-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component.tsx @@ -1,4 +1,4 @@ -const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute, Outlet } from '@tanstack/react-router'; import { importedComponent as ImportedComponent } from '../shared/imported'; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-export-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const.tsx new file mode 100644 index 0000000000..69e27260d4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export const loaderFn = () => { + return importedLoader(); +}; +const Layout = () => { + return
+
+ +
+ + +
; +}; +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-const@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function.tsx new file mode 100644 index 0000000000..8162228c27 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function loaderFn() { + return importedLoader(); +} +function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-function@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader.tsx new file mode 100644 index 0000000000..822135ddb1 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader.tsx @@ -0,0 +1,17 @@ +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export function loaderFn() { + return { + foo: 'bar' + }; +} +export const Route = createFileRoute('/_layout')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: loaderFn +}); +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dde7ab5b9d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,21 @@ +import { Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +const HEADER_HEIGHT = '63px'; +const SplitComponent = function Layout() { + return
+
+ +
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/retain-exports-loader@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure.tsx new file mode 100644 index 0000000000..2aa29a876a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure.tsx @@ -0,0 +1,15 @@ +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { startProject } from '~/projects/start'; +import { createFileRoute } from '@tanstack/react-router'; +import { seo } from '~/utils/seo'; +export const Route = createFileRoute('/_libraries/start/$version/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + meta: () => seo({ + title: startProject.name, + description: startProject.description + }) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..10f2c2d667 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,605 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} +const SplitComponent = function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {} +
+ Coming Soon! + {} +
+ {} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {} + + {} + + {} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {} + + {} + + {} +
+
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@loader.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/development/useStateDestructure@loader.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function.tsx similarity index 82% rename from packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function.tsx index 1b49b7ff9a..0a7cee7f7a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split'); +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..be5c0086de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "arrow-function.tsx"; +const SplitComponent = () => { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@loader.tsx new file mode 100644 index 0000000000..d9ed4ea7af --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/arrow-function@loader.tsx @@ -0,0 +1,3 @@ +import { fetchPosts } from '../posts'; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese.tsx new file mode 100644 index 0000000000..8810334727 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..6e6df2f4eb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,22 @@ +interface DemoProps { + title: string; +} +function Demo({ + title +}: DemoProps) { + return

+ {title} +

; +} +const SplitComponent = function HomeComponent() { + return
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@loader.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/chinese@loader.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties.tsx similarity index 80% rename from packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties.tsx index ae8ce80fc6..68f5556447 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split'); +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaf3410c69 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { FalseComponent } from '@modules/false-component'; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@loader.tsx new file mode 100644 index 0000000000..e10f305ddc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/conditional-properties@loader.tsx @@ -0,0 +1,5 @@ +import { isEnabled } from '@features/feature-flags'; +import TrueImport from '@modules/true-component'; +import { falseLoader } from '@modules/false-component'; +const SplitLoader = isEnabled ? TrueImport.loader : falseLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component.tsx similarity index 75% rename from packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component.tsx index 63033a97e2..265b803a90 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..446d55e26b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,6 @@ +import { memo } from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructured-react-memo-imported-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@loader.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/destructuring@loader.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@loader.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-as-parameter@loader.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration.tsx similarity index 81% rename from packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration.tsx index fa3fa3f6b3..29d3043856 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split'); +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/posts')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..544f6ffcbc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet } from '@tanstack/react-router'; +import { Route } from "function-declaration.tsx"; +const SplitComponent = function PostsComponent() { + const posts = Route.useLoaderData(); + return
+
    + {[...posts, { + id: 'i-do-not-exist', + title: 'Non-existent Post' + }]?.map(post => { + return
  • + +
    {post.title.substring(0, 20)}
    + +
  • ; + })} +
+
+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@loader.tsx new file mode 100644 index 0000000000..d9ed4ea7af --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/function-declaration@loader.tsx @@ -0,0 +1,3 @@ +import { fetchPosts } from '../posts'; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute.tsx new file mode 100644 index 0000000000..eb52fbee2e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute.tsx @@ -0,0 +1,6 @@ +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..f34d3c6408 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { test } from './test' with { type: 'macro' }; +const SplitComponent = () => test; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/importAttribute@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader.tsx similarity index 74% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader.tsx index b4f926eb1f..37cd9799d7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e9cae51951 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import importedComponent from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component-destructured-loader@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component.tsx new file mode 100644 index 0000000000..00e081670b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component.tsx @@ -0,0 +1,6 @@ +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-default-component@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent.tsx new file mode 100644 index 0000000000..ae97f66663 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent.tsx @@ -0,0 +1,8 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..a8e97d693c --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedErrorComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-errorComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..a0d6a07a7f --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent.tsx @@ -0,0 +1,8 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e4e3e353fd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedNotFoundComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-notFoundComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent.tsx new file mode 100644 index 0000000000..f8cd11e614 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent.tsx @@ -0,0 +1,8 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaa3ecd4f9 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedPendingComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported-pendingComponent@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported.tsx similarity index 84% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported.tsx index e3484305f6..96c6256f57 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('imported.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('imported.tsx?tsr-split'); +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..85355cf3a2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedComponent } from '../shared/imported'; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/imported@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline.tsx new file mode 100644 index 0000000000..c97b3c36a5 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +Route.addChildren([]); +export const test = 'test'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dd352c63ae --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import * as styles from '../style.css'; +import { TEST_DATA } from '../test.const'; +const Button = (props: { + children: any; +}) => { + return ; +}; +import { Route } from "inline.tsx"; +Route.addChildren([]); +import { test } from "inline.tsx"; +const SplitComponent = () => { + return
+ {test} +

{TEST_DATA.welcome}

+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@loader.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/inline@loader.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number.tsx similarity index 88% rename from packages/router-plugin/tests/code-splitter/snapshots/production/random-number.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number.tsx index f194be898d..48f67bc96a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number.tsx @@ -1,6 +1,6 @@ -const $$splitComponentImporter = () => import('random-number.tsx?tsr-split'); +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..76ed9ff5e0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import discordImage from '~/images/discord-logo-white.svg'; +import { sample } from '~/utils/utils'; +import { textColors } from "random-number.tsx"; +import { gradients } from "random-number.tsx"; +import { Route } from "random-number.tsx"; +const SplitComponent = function Index() { + const { + randomNumber + } = Route.useLoaderData(); + const gradient = sample(gradients, randomNumber); + const textColor = sample(textColors, randomNumber); + return <> + {discordImage} + {gradient} + {textColor} + ; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@loader.tsx new file mode 100644 index 0000000000..3dff7886f7 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/random-number@loader.tsx @@ -0,0 +1,9 @@ +import { defer } from '@tanstack/react-router'; +import { getSponsorsForSponsorPack } from '~/server/sponsors'; +const SplitLoader = () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; +}; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component.tsx similarity index 81% rename from packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component.tsx index c80202c1af..19e2d97b6f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dfef29c9e3 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +function Component() { + return
Component
; +} +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component.tsx similarity index 78% rename from packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component.tsx index fd823829bc..a52cdbad09 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component.tsx @@ -1,6 +1,6 @@ -const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split'); +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); import { lazyRouteComponent } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router'; export const Route = createFileRoute('/')({ diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..5a6456643b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import { importedComponent } from '../shared/imported'; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/react-memo-imported-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component.tsx similarity index 96% rename from packages/router-plugin/tests/code-splitter/snapshots/production/retain-export-component.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component.tsx index 5e41828800..fd6c6de54c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/retain-export-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component.tsx @@ -1,4 +1,4 @@ -const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split'); +const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=loader'); import { lazyFn } from '@tanstack/react-router'; import { createFileRoute, Outlet } from '@tanstack/react-router'; import { importedComponent as ImportedComponent } from '../shared/imported'; diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component@loader.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-export-component@loader.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const.tsx new file mode 100644 index 0000000000..69e27260d4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export const loaderFn = () => { + return importedLoader(); +}; +const Layout = () => { + return
+
+ +
+ + +
; +}; +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-const@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function.tsx new file mode 100644 index 0000000000..8162228c27 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function loaderFn() { + return importedLoader(); +} +function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-function@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader.tsx new file mode 100644 index 0000000000..9d9f580e24 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader.tsx @@ -0,0 +1,14 @@ +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export function loaderFn() { + return { + foo: 'bar' + }; +} +export const Route = createFileRoute('/_layout')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: loaderFn +}); +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dde7ab5b9d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,21 @@ +import { Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +const HEADER_HEIGHT = '63px'; +const SplitComponent = function Layout() { + return
+
+ +
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/retain-exports-loader@loader.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure.tsx new file mode 100644 index 0000000000..0e8fcc2257 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { startProject } from '~/projects/start'; +import { createFileRoute } from '@tanstack/react-router'; +import { seo } from '~/utils/seo'; +export const Route = createFileRoute('/_libraries/start/$version/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + meta: () => seo({ + title: startProject.name, + description: startProject.description + }) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..10f2c2d667 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,605 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} +const SplitComponent = function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {} +
+ Coming Soon! + {} +
+ {} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {} + + {} + + {} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {} + + {} + + {} +
+
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@loader.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/2-components-combined-loader-separate/production/useStateDestructure@loader.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function.tsx new file mode 100644 index 0000000000..e55be6765d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx similarity index 92% rename from packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx index 620b059230..7dd37cda89 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/arrow-function@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,8 @@ import { Link, Outlet } from '@tanstack/react-router'; import { fetchPosts } from '../posts'; import { Route } from "arrow-function.tsx"; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; const SplitComponent = () => { const posts = Route.useLoaderData(); return
@@ -24,6 +26,4 @@ const SplitComponent = () => {
; }; -export { SplitComponent as component }; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/arrow-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese.tsx new file mode 100644 index 0000000000..c065d14a4a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +interface DemoProps { + title: string; +} +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..6e6df2f4eb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,22 @@ +interface DemoProps { + title: string; +} +function Demo({ + title +}: DemoProps) { + return

+ {title} +

; +} +const SplitComponent = function HomeComponent() { + return
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@errorComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/chinese@errorComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties.tsx new file mode 100644 index 0000000000..279773de15 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx similarity index 81% rename from packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx index d483dd047c..857b130de7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/conditional-properties@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,7 @@ import { isEnabled } from '@features/feature-flags'; import TrueImport from '@modules/true-component'; import { FalseComponent, falseLoader } from '@modules/false-component'; -const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; -export { SplitComponent as component }; const SplitLoader = isEnabled ? TrueImport.loader : falseLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/conditional-properties@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx new file mode 100644 index 0000000000..0fe0b8418d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 74% rename from packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index 5d248932f2..b6748bb51b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/destructured-react-memo-imported-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -3,7 +3,7 @@ import { importedLoader } from '../shared/imported'; function Component() { return
Component
; } -const SplitComponent = memo(Component); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructured-react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@errorComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/destructuring@errorComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@errorComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-as-parameter@errorComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration.tsx new file mode 100644 index 0000000000..dda89e55de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx similarity index 92% rename from packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx index 7ecd525a8b..6eadf0e795 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/function-declaration@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,8 @@ import { Link, Outlet } from '@tanstack/react-router'; import { fetchPosts } from '../posts'; import { Route } from "function-declaration.tsx"; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; const SplitComponent = function PostsComponent() { const posts = Route.useLoaderData(); return
@@ -24,6 +26,4 @@ const SplitComponent = function PostsComponent() {
; }; -export { SplitComponent as component }; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/function-declaration@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute.tsx new file mode 100644 index 0000000000..d8355986bf --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..f34d3c6408 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { test } from './test' with { type: 'macro' }; +const SplitComponent = () => test; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/importAttribute@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx new file mode 100644 index 0000000000..4e0beddab5 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx similarity index 67% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx index 36b0a4fd34..7ca09fd5d7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/imported-default-component-destructured-loader@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ import importedComponent, { importedLoader } from '../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component-destructured-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component.tsx new file mode 100644 index 0000000000..b749bed2ea --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-default-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx new file mode 100644 index 0000000000..26951c2d0a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent.tsx @@ -0,0 +1,11 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=errorComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@errorComponent.tsx new file mode 100644 index 0000000000..1d7f487fd2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-errorComponent@errorComponent.tsx @@ -0,0 +1,3 @@ +import { importedErrorComponent } from '../shared/imported'; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..54565ca6f1 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent.tsx @@ -0,0 +1,11 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e4e3e353fd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedNotFoundComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-notFoundComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx new file mode 100644 index 0000000000..02997dc053 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent.tsx @@ -0,0 +1,11 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaa3ecd4f9 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedPendingComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported-pendingComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported.tsx new file mode 100644 index 0000000000..c397f9dccc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported@component---loader---notFoundComponent---pendingComponent.tsx similarity index 67% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported@component---loader---notFoundComponent---pendingComponent.tsx index 47c62497db..d7310c1c94 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/imported@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ import { importedComponent, importedLoader } from '../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/imported@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline.tsx new file mode 100644 index 0000000000..fd3669b108 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +Route.addChildren([]); +export const test = 'test'; +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dd352c63ae --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import * as styles from '../style.css'; +import { TEST_DATA } from '../test.const'; +const Button = (props: { + children: any; +}) => { + return ; +}; +import { Route } from "inline.tsx"; +Route.addChildren([]); +import { test } from "inline.tsx"; +const SplitComponent = () => { + return
+ {test} +

{TEST_DATA.welcome}

+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@errorComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/inline@errorComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number.tsx new file mode 100644 index 0000000000..9a267bfdb0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number.tsx @@ -0,0 +1,14 @@ +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; +export const gradients = [`from-rose-500 to-yellow-500`, `from-yellow-500 to-teal-500`, `from-teal-500 to-violet-500`, `from-blue-500 to-pink-500`]; +export const Route = createFileRoute('/')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/random-number@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number@component---loader---notFoundComponent---pendingComponent.tsx similarity index 91% rename from packages/router-plugin/tests/code-splitter/snapshots/production/random-number@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number@component---loader---notFoundComponent---pendingComponent.tsx index 7aaa5496f4..1faa5012de 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/random-number@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number@component---loader---notFoundComponent---pendingComponent.tsx @@ -5,6 +5,13 @@ import { sample } from '~/utils/utils'; import { textColors } from "random-number.tsx"; import { gradients } from "random-number.tsx"; import { Route } from "random-number.tsx"; +const SplitLoader = () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; +}; +export { SplitLoader as loader }; const SplitComponent = function Index() { const { randomNumber @@ -17,11 +24,4 @@ const SplitComponent = function Index() { {textColor} ; }; -export { SplitComponent as component }; -const SplitLoader = () => { - return { - randomNumber: Math.random(), - sponsorsPromise: defer(getSponsorsForSponsorPack()) - }; -}; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/random-number@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component.tsx new file mode 100644 index 0000000000..66da0c232a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 74% rename from packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx index 2ccf4684ae..8831513c0e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -3,7 +3,7 @@ import { importedLoader } from '../shared/imported'; function Component() { return
Component
; } -const SplitComponent = React.memo(Component); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx new file mode 100644 index 0000000000..8db833f30c --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component.tsx @@ -0,0 +1,12 @@ +const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 72% rename from packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index f8e62e3e2b..b979ac5fa4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-imported-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { importedLoader, importedComponent } from '../shared/imported'; -const SplitComponent = React.memo(importedComponent); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component.tsx new file mode 100644 index 0000000000..8373e85c77 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component.tsx @@ -0,0 +1,27 @@ +const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +export function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-export-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const.tsx new file mode 100644 index 0000000000..69e27260d4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export const loaderFn = () => { + return importedLoader(); +}; +const Layout = () => { + return
+
+ +
+ + +
; +}; +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-const@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function.tsx new file mode 100644 index 0000000000..8162228c27 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function loaderFn() { + return importedLoader(); +} +function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx new file mode 100644 index 0000000000..0befce3a09 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader.tsx @@ -0,0 +1,17 @@ +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export function loaderFn() { + return { + foo: 'bar' + }; +} +export const Route = createFileRoute('/_layout')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: loaderFn +}); +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dde7ab5b9d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,21 @@ +import { Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +const HEADER_HEIGHT = '63px'; +const SplitComponent = function Layout() { + return
+
+ +
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/retain-exports-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx new file mode 100644 index 0000000000..414db66c2e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure.tsx @@ -0,0 +1,15 @@ +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { startProject } from '~/projects/start'; +import { createFileRoute } from '@tanstack/react-router'; +import { seo } from '~/utils/seo'; +export const Route = createFileRoute('/_libraries/start/$version/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + meta: () => seo({ + title: startProject.name, + description: startProject.description + }) +}); +export function TSRDummyComponent() { + return null; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..10f2c2d667 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,605 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} +const SplitComponent = function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {} +
+ Coming Soon! + {} +
+ {} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {} + + {} + + {} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {} + + {} + + {} +
+
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@errorComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/development/useStateDestructure@errorComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function.tsx new file mode 100644 index 0000000000..36facc8ac7 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx similarity index 92% rename from packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx index 620b059230..7dd37cda89 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/arrow-function@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,8 @@ import { Link, Outlet } from '@tanstack/react-router'; import { fetchPosts } from '../posts'; import { Route } from "arrow-function.tsx"; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; const SplitComponent = () => { const posts = Route.useLoaderData(); return
@@ -24,6 +26,4 @@ const SplitComponent = () => {
; }; -export { SplitComponent as component }; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/arrow-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese.tsx new file mode 100644 index 0000000000..0902b78c6a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..6e6df2f4eb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,22 @@ +interface DemoProps { + title: string; +} +function Demo({ + title +}: DemoProps) { + return

+ {title} +

; +} +const SplitComponent = function HomeComponent() { + return
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@errorComponent.tsx new file mode 100644 index 0000000000..f5392fada0 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/chinese@errorComponent.tsx @@ -0,0 +1,3 @@ +interface DemoProps { + title: string; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties.tsx new file mode 100644 index 0000000000..fe3a1fa350 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx similarity index 81% rename from packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx index d483dd047c..857b130de7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/conditional-properties@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,7 @@ import { isEnabled } from '@features/feature-flags'; import TrueImport from '@modules/true-component'; import { FalseComponent, falseLoader } from '@modules/false-component'; -const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; -export { SplitComponent as component }; const SplitLoader = isEnabled ? TrueImport.loader : falseLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/conditional-properties@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component.tsx new file mode 100644 index 0000000000..1edba360e1 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('destructured-react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 74% rename from packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index 5d248932f2..b6748bb51b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/destructured-react-memo-imported-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -3,7 +3,7 @@ import { importedLoader } from '../shared/imported'; function Component() { return
Component
; } -const SplitComponent = memo(Component); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructured-react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@errorComponent.tsx new file mode 100644 index 0000000000..858c5c0e05 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/destructuring@errorComponent.tsx @@ -0,0 +1,11 @@ +import thing from 'thing'; +export function test() { + const { + foo: { + bar: { + destructured + } + } + } = thing; + return destructured; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@errorComponent.tsx new file mode 100644 index 0000000000..34b469f860 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-as-parameter@errorComponent.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +// @ts-expect-error +import { useMemo } from 'tan-react'; +const ReactUseMemoCall1 = React.useMemo(function performAction() { + return 'true'; +}, []); +console.info(ReactUseMemoCall1); +const ReactUseMemoCall2 = React.useMemo(() => { + return 'true'; +}, []); +console.info(ReactUseMemoCall2); +const UseMemoCall1 = useMemo(function performAction() { + return 'true'; +}, []); +console.info(UseMemoCall1); +const UseMemoCall2 = useMemo(() => { + return 'true'; +}, []); +console.info(UseMemoCall2); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration.tsx new file mode 100644 index 0000000000..13b2b8cc9f --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration.tsx @@ -0,0 +1,9 @@ +const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/posts')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx similarity index 92% rename from packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx index 7ecd525a8b..6eadf0e795 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/function-declaration@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,8 @@ import { Link, Outlet } from '@tanstack/react-router'; import { fetchPosts } from '../posts'; import { Route } from "function-declaration.tsx"; +const SplitLoader = fetchPosts; +export { SplitLoader as loader }; const SplitComponent = function PostsComponent() { const posts = Route.useLoaderData(); return
@@ -24,6 +26,4 @@ const SplitComponent = function PostsComponent() {
; }; -export { SplitComponent as component }; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/function-declaration@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute.tsx new file mode 100644 index 0000000000..847ad400fc --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute.tsx @@ -0,0 +1,6 @@ +const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..f34d3c6408 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { test } from './test' with { type: 'macro' }; +const SplitComponent = () => test; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/importAttribute@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader.tsx new file mode 100644 index 0000000000..a110778506 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('imported-default-component-destructured-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx similarity index 67% rename from packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx index 36b0a4fd34..7ca09fd5d7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/imported-default-component-destructured-loader@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ import importedComponent, { importedLoader } from '../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component-destructured-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component.tsx new file mode 100644 index 0000000000..bd196be036 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component.tsx @@ -0,0 +1,6 @@ +const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-default-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent.tsx new file mode 100644 index 0000000000..f58664d12a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent.tsx @@ -0,0 +1,8 @@ +const $$splitErrorComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=errorComponent'); +const $$splitComponentImporter = () => import('imported-errorComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c52d2691b4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import ImportedDefaultComponent from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@errorComponent.tsx new file mode 100644 index 0000000000..1d7f487fd2 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-errorComponent@errorComponent.tsx @@ -0,0 +1,3 @@ +import { importedErrorComponent } from '../shared/imported'; +const SplitErrorComponent = importedErrorComponent; +export { SplitErrorComponent as errorComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..3880466641 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent.tsx @@ -0,0 +1,8 @@ +const $$splitNotFoundComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-notFoundComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e4e3e353fd --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedNotFoundComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitNotFoundComponent = importedNotFoundComponent; +export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-notFoundComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent.tsx new file mode 100644 index 0000000000..939c087ebb --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent.tsx @@ -0,0 +1,8 @@ +const $$splitPendingComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..aaa3ecd4f9 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,5 @@ +import ImportedDefaultComponent, { importedPendingComponent } from '../shared/imported'; +const SplitComponent = ImportedDefaultComponent; +export { SplitComponent as component }; +const SplitPendingComponent = importedPendingComponent; +export { SplitPendingComponent as pendingComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported-pendingComponent@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported.tsx new file mode 100644 index 0000000000..0bbac9035a --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/imported@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported@component---loader---notFoundComponent---pendingComponent.tsx similarity index 67% rename from packages/router-plugin/tests/code-splitter/snapshots/production/imported@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported@component---loader---notFoundComponent---pendingComponent.tsx index 47c62497db..d7310c1c94 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/imported@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ import { importedComponent, importedLoader } from '../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = importedComponent; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/imported@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline.tsx new file mode 100644 index 0000000000..5655e25a26 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline.tsx @@ -0,0 +1,8 @@ +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); +Route.addChildren([]); +export const test = 'test'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dd352c63ae --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,18 @@ +import * as styles from '../style.css'; +import { TEST_DATA } from '../test.const'; +const Button = (props: { + children: any; +}) => { + return ; +}; +import { Route } from "inline.tsx"; +Route.addChildren([]); +import { test } from "inline.tsx"; +const SplitComponent = () => { + return
+ {test} +

{TEST_DATA.welcome}

+ +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@errorComponent.tsx new file mode 100644 index 0000000000..a9c5d2b6de --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/inline@errorComponent.tsx @@ -0,0 +1,2 @@ +import { Route } from "inline.tsx"; +Route.addChildren([]); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number.tsx new file mode 100644 index 0000000000..e2b0321f7f --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number.tsx @@ -0,0 +1,11 @@ +const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('random-number.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const textColors = [`text-rose-500`, `text-yellow-500`, `text-teal-500`, `text-blue-500`]; +export const gradients = [`from-rose-500 to-yellow-500`, `from-yellow-500 to-teal-500`, `from-teal-500 to-violet-500`, `from-blue-500 to-pink-500`]; +export const Route = createFileRoute('/')({ + loader: lazyFn($$splitLoaderImporter, 'loader'), + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/random-number@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number@component---loader---notFoundComponent---pendingComponent.tsx similarity index 91% rename from packages/router-plugin/tests/code-splitter/snapshots/development/random-number@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number@component---loader---notFoundComponent---pendingComponent.tsx index 7aaa5496f4..1faa5012de 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/random-number@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number@component---loader---notFoundComponent---pendingComponent.tsx @@ -5,6 +5,13 @@ import { sample } from '~/utils/utils'; import { textColors } from "random-number.tsx"; import { gradients } from "random-number.tsx"; import { Route } from "random-number.tsx"; +const SplitLoader = () => { + return { + randomNumber: Math.random(), + sponsorsPromise: defer(getSponsorsForSponsorPack()) + }; +}; +export { SplitLoader as loader }; const SplitComponent = function Index() { const { randomNumber @@ -17,11 +24,4 @@ const SplitComponent = function Index() { {textColor} ; }; -export { SplitComponent as component }; -const SplitLoader = () => { - return { - randomNumber: Math.random(), - sponsorsPromise: defer(getSponsorsForSponsorPack()) - }; -}; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/random-number@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component.tsx new file mode 100644 index 0000000000..1043478308 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('react-memo-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('react-memo-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 74% rename from packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx index 2ccf4684ae..8831513c0e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/development/react-memo-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -3,7 +3,7 @@ import { importedLoader } from '../shared/imported'; function Component() { return
Component
; } -const SplitComponent = React.memo(Component); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = React.memo(Component); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component.tsx new file mode 100644 index 0000000000..c3f6ce2057 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component.tsx @@ -0,0 +1,9 @@ +const $$splitLoaderImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('react-memo-imported-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export const Route = createFileRoute('/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: lazyFn($$splitLoaderImporter, 'loader') +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx similarity index 72% rename from packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component@split.tsx rename to packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index f8e62e3e2b..b979ac5fa4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/production/react-memo-imported-component@split.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { importedLoader, importedComponent } from '../shared/imported'; -const SplitComponent = React.memo(importedComponent); -export { SplitComponent as component }; const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader }; +const SplitComponent = React.memo(importedComponent); +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/react-memo-imported-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component.tsx new file mode 100644 index 0000000000..8373e85c77 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component.tsx @@ -0,0 +1,27 @@ +const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyFn } from '@tanstack/react-router'; +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +export function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: lazyFn($$splitLoaderImporter, 'loader') +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..c187fe188e --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,3 @@ +import { importedLoader } from '../shared/imported'; +const SplitLoader = importedLoader; +export { SplitLoader as loader }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-export-component@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const.tsx new file mode 100644 index 0000000000..69e27260d4 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export const loaderFn = () => { + return importedLoader(); +}; +const Layout = () => { + return
+
+ +
+ + +
; +}; +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-const@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function.tsx new file mode 100644 index 0000000000..8162228c27 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function.tsx @@ -0,0 +1,30 @@ +import { createFileRoute, Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent, importedLoader } from '../shared/imported'; +export function loaderFn() { + return importedLoader(); +} +function Layout() { + return
+
+ +
+ + +
; +} +export const Route = createFileRoute('/_layout')({ + component: Layout, + loader: loaderFn +}); +const HEADER_HEIGHT = '63px'; +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; +export default Layout; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-function@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader.tsx new file mode 100644 index 0000000000..72982be00f --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader.tsx @@ -0,0 +1,14 @@ +const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router'; +export function loaderFn() { + return { + foo: 'bar' + }; +} +export const Route = createFileRoute('/_layout')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + loader: loaderFn +}); +export const SIDEBAR_WIDTH = '150px'; +export const SIDEBAR_MINI_WIDTH = '80px'; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..dde7ab5b9d --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,21 @@ +import { Outlet } from '@tanstack/react-router'; +import { importedComponent as ImportedComponent } from '../shared/imported'; +const HEADER_HEIGHT = '63px'; +const SplitComponent = function Layout() { + return
+
+ +
+ + +
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/retain-exports-loader@errorComponent.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx new file mode 100644 index 0000000000..ba8e58205b --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure.tsx @@ -0,0 +1,12 @@ +const $$splitComponentImporter = () => import('useStateDestructure.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); +import { lazyRouteComponent } from '@tanstack/react-router'; +import { startProject } from '~/projects/start'; +import { createFileRoute } from '@tanstack/react-router'; +import { seo } from '~/utils/seo'; +export const Route = createFileRoute('/_libraries/start/$version/')({ + component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr), + meta: () => seo({ + title: startProject.name, + description: startProject.description + }) +}); \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx new file mode 100644 index 0000000000..10f2c2d667 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx @@ -0,0 +1,605 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
+
; +} +const SplitComponent = function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {} +
+ Coming Soon! + {} +
+ {} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {} + + {} + + {} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {} + + {} + + {} +
+
; +}; +export { SplitComponent as component }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@errorComponent.tsx new file mode 100644 index 0000000000..2c2aba5396 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/snapshots/3-all-combined-errorComponent-separate/production/useStateDestructure@errorComponent.tsx @@ -0,0 +1,444 @@ +import * as React from 'react'; +import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg'; +import { FaDiscord, FaGithub, FaTshirt, FaTwitter } from 'react-icons/fa'; +import { Await, Link, getRouteApi } from '@tanstack/react-router'; +import { Carbon } from '~/components/Carbon'; +import { Footer } from '~/components/Footer'; +import { TbHeartHandshake } from 'react-icons/tb'; +import SponsorPack from '~/components/SponsorPack'; +import { startProject } from '~/projects/start'; +const menu = [{ + label:
+ TanStack +
, + to: '/' +}, +// { +// label: ( +//
+// Examples +//
+// ), +// to: './docs/react/examples/basic', +// }, +// { +// label: ( +//
+// Docs +//
+// ), +// to: './docs/', +// }, +// { +// label: ( +//
+// GitHub +//
+// ), +// to: `https://github.com/${startProject.repo}`, +// }, +{ + label:
+ Discord +
, + to: 'https://tlinz.com/discord' +}, { + label:
+ Merch +
, + to: `https://cottonbureau.com/people/tanstack` +}]; +import { Route } from "useStateDestructure.tsx"; +const librariesRouteApi = getRouteApi('/_libraries'); +export default function VersionIndex() { + const { + sponsorsPromise + } = librariesRouteApi.useLoaderData(); + const { + version + } = Route.useParams(); + const [, setIsDark] = React.useState(true); + React.useEffect(() => { + setIsDark(window.matchMedia?.(`(prefers-color-scheme: dark)`).matches); + }, []); + const gradientText = `inline-block text-transparent bg-clip-text bg-gradient-to-r ${startProject.colorFrom} ${startProject.colorTo}`; + return
+
+ {menu?.map((item, i) => { + const label =
{item.label}
; + return
+ {item.to.startsWith('http') ? {label} : + {label} + } +
; + })} +
+
+
+

+ TanStack Start +

+
+ {/*
*/} +
+ Coming Soon! + {/* {version === 'latest' ? latestVersion : version} */} +
+ {/*
*/} +

+ Full-stack React framework{' '} + + powered by TanStack Router + {' '} +

+

+ Full-document SSR, Streaming, Server Functions, bundling and more, + powered by TanStack Router, Vinxi,{' '} + Nitro and Vite. Ready to deploy to + your favorite hosting provider. +

+
+
+
+ So when can I use it? +
+
+
+ TanStack Start is currently in development and is + not yet available for public use. We are working hard to bring you + the best possible experience and will be releasing more details + soon. In the meantime, you can follow along with the development + process by watching the commits on this very website! +
+
+ Yes, you heard that right!{' '} + + TanStack.com is already being built and deployed using TanStack + Start + + ! We are eating our own dog food and are excited to share the + results with you soon! +
+
+ +
+ {/*
+
+ +
+

+ Built on TanStack Router +

+

+ Writing your data fetching logic by hand is over. Tell TanStack + Query where to get your data and how fresh you need it to be and + the rest is automatic. It handles{' '} + + caching, background updates and stale data out of the box with + zero-configuration + + . +

+
+
+
+
+ +
+
+

+ Simple & Familiar +

+

+ If you know how to work with promises or async/await, then you + already know how to use TanStack Query. There's{' '} + + no global state to manage, reducers, normalization systems or + heavy configurations to understand + + . Simply pass a function that resolves your data (or throws an + error) and the rest is history. +

+
+
+
+
+ +
+
+

+ Extensible +

+

+ TanStack Query is configurable down to each observer instance of a + query with knobs and options to fit every use-case. It comes wired + up with{' '} + + dedicated devtools, infinite-loading APIs, and first class + mutation tools that make updating your data a breeze + + . Don't worry though, everything is pre-configured for success! +

+
+
+
*/} + + {/*
+
+

+ No dependencies. All the Features. +

+

+ With zero dependencies, TanStack Query is extremely lean given the + dense feature set it provides. From weekend hobbies all the way to + enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), + TanStack Query is the battle-hardened tool to help you succeed at + the speed of your creativity. +

+
+
+ {[ + 'Backend agnostic', + 'Dedicated Devtools', + 'Auto Caching', + 'Auto Refetching', + 'Window Focus Refetching', + 'Polling/Realtime Queries', + 'Parallel Queries', + 'Dependent Queries', + 'Mutations API', + 'Automatic Garbage Collection', + 'Paginated/Cursor Queries', + 'Load-More/Infinite Scroll Queries', + 'Scroll Recovery', + 'Request Cancellation', + 'Suspense Ready!', + 'Render-as-you-fetch', + 'Prefetching', + 'Variable-length Parallel Queries', + 'Offline Support', + 'SSR Support', + 'Data Selectors', + ].map((d, i) => { + return ( + + {d} + + ) + })} +
+
*/} + + {/*
+
+ Trusted in Production by +
+ +
+ {(new Array(4) as string[]) + .fill('') + .reduce( + (all) => [...all, ...all], + [ + 'Google', + 'Walmart', + 'Facebook', + 'PayPal', + 'Amazon', + 'American Express', + 'Microsoft', + 'Target', + 'Ebay', + 'Autodesk', + 'CarFAX', + 'Docusign', + 'HP', + 'MLB', + 'Volvo', + 'Ocado', + 'UPC.ch', + 'EFI.com', + 'ReactBricks', + 'Nozzle.io', + 'Uber', + ] + ) + .map((d, i) => ( + + {d} + + ))} +
+
+
*/} + +
+

+ Partners +

+
+
+ + Start You? + +
+
+ We're looking for a TanStack Start OSS Partner to go above and + beyond the call of sponsorship. Are you as invested in TanStack + Start as we are? Let's push the boundaries of Start together! +
+ + Let's chat + +
+
+
+ +
+

+ Sponsors +

+
+ } children={sponsors => { + return ; + }} /> +
+ +
+ +
+
+ +
+ + This ad helps us be happy about our invested time and not burn out and + rage-quit OSS. Yay money! 😉 + +
+ + {/*
+
+

+ Less code, fewer edge cases. +

+

+ Instead of writing reducers, caching logic, timers, retry logic, + complex async/await scripting (I could keep going...), you literally + write a tiny fraction of the code you normally would. You will be + surprised at how little code you're writing or how much code you're + deleting when you use TanStack Query. Try it out with one of the + examples below! +

+
+ {( + [ + { label: 'Angular', value: 'angular' }, + { label: 'React', value: 'react' }, + { label: 'Solid', value: 'solid' }, + { label: 'Svelte', value: 'svelte' }, + { label: 'Vue', value: 'vue' }, + ] as const + ).map((item) => ( + + ))} +
+
+
*/} + + {/* {[''].includes(framework) ? ( +
+
+ Looking for the @tanstack/{framework}-query{' '} + example? We could use your help to build the{' '} + @tanstack/{framework}-query adapter! Join the{' '} + + TanStack Discord Server + {' '} + and let's get to work! +
+
+ ) : ( +
+ +
+ )} */} + + {/*
+
+ Wow, you've come a long way! +
+
+ Only one thing left to do... +
+
+ + Read the Docs! + +
+
*/} +
; +} \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/test-files/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/test-files/imported-errorComponent.tsx new file mode 100644 index 0000000000..d05333e320 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/test-files/imported-errorComponent.tsx @@ -0,0 +1,10 @@ +import { createFileRoute } from '@tanstack/react-router' + +import ImportedDefaultComponent, { + importedErrorComponent, +} from '../shared/imported' + +export const Route = createFileRoute('/')({ + component: ImportedDefaultComponent, + errorComponent: importedErrorComponent, +}) diff --git a/packages/router-plugin/tests/code-splitter/test-files/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/test-files/imported-notFoundComponent.tsx new file mode 100644 index 0000000000..08d0cd0335 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/test-files/imported-notFoundComponent.tsx @@ -0,0 +1,10 @@ +import { createFileRoute } from '@tanstack/react-router' + +import ImportedDefaultComponent, { + importedNotFoundComponent, +} from '../shared/imported' + +export const Route = createFileRoute('/')({ + component: ImportedDefaultComponent, + notFoundComponent: importedNotFoundComponent, +}) diff --git a/packages/router-plugin/tests/code-splitter/test-files/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/test-files/imported-pendingComponent.tsx new file mode 100644 index 0000000000..42cccb0639 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter/test-files/imported-pendingComponent.tsx @@ -0,0 +1,10 @@ +import { createFileRoute } from '@tanstack/react-router' + +import ImportedDefaultComponent, { + importedPendingComponent, +} from '../shared/imported' + +export const Route = createFileRoute('/')({ + component: ImportedDefaultComponent, + pendingComponent: importedPendingComponent, +}) diff --git a/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts b/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts new file mode 100644 index 0000000000..69fec8ce11 --- /dev/null +++ b/packages/router-plugin/tests/detect-route-codesplit-groupings.test.ts @@ -0,0 +1,129 @@ +import { describe, expect, it } from 'vitest' +import { detectCodeSplitGroupingsFromRoute } from '../src/core/code-splitter/compilers' +import { defaultCodeSplitGroupings } from '../src/core/constants' +import type { CodeSplitGroupings } from '../src/core/constants' + +const successCases: Array<{ + name: string + code: string + expectedGrouping: CodeSplitGroupings | undefined + expectedRouteId: string +}> = [ + { + name: 'defaults', + code: ` +import {createFileRoute} from '@tanstack/react-router' +export const Route = createFileRoute('/posts')({ +codeSplitGroupings: [ + ['component'], + ['pendingComponent'], + ['errorComponent'], + ['notFoundComponent'] +] +}) +`, + expectedGrouping: defaultCodeSplitGroupings, + expectedRouteId: '/posts', + }, + { + name: 'loader-separate-components-combined', + code: ` +import {createFileRoute} from '@tanstack/react-router' +export const Route = createFileRoute('/posts')({ +codeSplitGroupings: [ + ['loader'], + ['component', 'pendingComponent', 'errorComponent', 'notFoundComponent'] +] +}) +`, + expectedGrouping: [ + ['loader'], + ['component', 'pendingComponent', 'errorComponent', 'notFoundComponent'], + ], + expectedRouteId: '/posts', + }, + { + name: 'limited-loader-and-component', + code: ` +import {createFileRoute} from '@tanstack/react-router' +export const Route = createFileRoute('/posts')({ +codeSplitGroupings: [ + ['loader', 'component'], + ['pendingComponent', 'errorComponent', 'notFoundComponent'] +] +}) +`, + expectedGrouping: [ + ['loader', 'component'], + ['pendingComponent', 'errorComponent', 'notFoundComponent'], + ], + expectedRouteId: '/posts', + }, + { + name: 'empty', + code: ` +import {createFileRoute} from '@tanstack/react-router' +export const Route = createFileRoute('/posts')({}) +`, + expectedGrouping: undefined, + expectedRouteId: '/posts', + }, +] + +describe('detectCodeSplitGroupingsFromRoute - success', () => { + it.each(successCases)( + 'should detect code split groupings for $name', + ({ code, expectedGrouping, expectedRouteId }) => { + const result = detectCodeSplitGroupingsFromRoute({ + code: code, + filename: 'test.ts', + root: '/src', + }) + + expect(result.groupings).toEqual(expectedGrouping) + expect(result.routeId).toEqual(expectedRouteId) + }, + ) +}) + +const failCases: Array<{ + name: string + code: string +}> = [ + { + name: 'not-nested-array', + code: ` + import {createFileRoute} from '@tanstack/react-router' + export const Route = createFileRoute('/')({ + codeSplitGroupings: [ + 'loader', + ] + }) + `, + }, + { + name: 'reference-variable', + code: ` +import {createFileRoute} from '@tanstack/react-router' +const groupings = [ + ['loader'], + ['component'], +] +export const Route = createFileRoute('/')({ +codeSplitGroupings: groupings +}) +`, + }, +] + +describe('detectCodeSplitGroupingsFromRoute - fail', () => { + it.each(failCases)('should throw error for $name', ({ code }) => { + expect(() => + detectCodeSplitGroupingsFromRoute({ + code: code, + filename: 'test.ts', + root: '/src', + }), + ).toThrowError() + }) +})