From 42a7914cd5ebcb9fedd07b9bbab8f2b7a92bc579 Mon Sep 17 00:00:00 2001 From: Flo Date: Sat, 10 Oct 2026 14:09:42 +0200 Subject: [PATCH 01/79] test: format compiler output before comparing snapshots (#8658) * test: format compiler output before comparing file snapshots The router-plugin and start-plugin-core compiler snapshots record the layout choices of the code generator (object wrapping, blank lines, parentheses around JSX) along with the emitted program, so swapping the code generator rewrites most snapshot files even when the output is the same. Format the output with Prettier before comparing it: fixed options, `objectWrap: 'collapse'`, and blank lines outside template literals removed. Comments are kept. Output that does not parse is compared as is. Co-Authored-By: Claude Opus 5.5 * test: regenerate compiler snapshots with formatted output Co-Authored-By: Claude Opus 5.5 * test: format inline compiler snapshots before comparing them Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- packages/router-plugin/package.json | 1 + packages/router-plugin/tests/add-hmr.test.ts | 13 +- .../snapshots/react/arrow-function@false.tsx | 15 +- .../snapshots/react/arrow-function@true.tsx | 164 ++++++------ .../react/arrow-function@webpack-hot.tsx | 142 ++++++----- ...teFileRoute-lowercase-components@false.tsx | 23 +- ...ateFileRoute-lowercase-components@true.tsx | 182 +++++++------- ...createRootRoute-inline-component@false.tsx | 5 +- .../createRootRoute-inline-component@true.tsx | 148 +++++------ ...teRootRoute-lowercase-components@false.tsx | 5 - ...ateRootRoute-lowercase-components@true.tsx | 160 ++++++------ .../snapshots/react/createRootRoute@false.tsx | 6 +- .../snapshots/react/createRootRoute@true.tsx | 145 +++++------ ...teRootRouteWithContext-type-args@false.tsx | 3 - ...ateRootRouteWithContext-type-args@true.tsx | 150 +++++------ .../snapshots/react/destructuring@false.tsx | 2 - .../snapshots/react/destructuring@true.tsx | 2 - .../explicit-undefined-component@false.tsx | 5 +- .../explicit-undefined-component@true.tsx | 145 +++++------ .../react/function-declaration@false.tsx | 15 +- .../react/function-declaration@true.tsx | 164 ++++++------ .../snapshots/react/multi-component@false.tsx | 21 +- .../snapshots/react/multi-component@true.tsx | 181 +++++++------- .../react/string-literal-keys@false.tsx | 23 +- .../react/string-literal-keys@true.tsx | 183 +++++++------- .../snapshots/solid/arrow-function@false.tsx | 13 +- .../snapshots/solid/arrow-function@true.tsx | 112 ++++----- .../router-plugin/tests/code-splitter.test.ts | 17 +- .../react/1-default/arrow-function.tsx | 15 +- .../1-default/arrow-function@component.tsx | 44 ++-- .../arrow-function@errorComponent.tsx | 2 +- .../arrow-function@notFoundComponent.tsx | 2 +- .../react/1-default/boolean-null-literals.tsx | 14 +- .../boolean-null-literals@component.tsx | 4 +- .../snapshots/react/1-default/chinese.tsx | 16 +- .../react/1-default/chinese@component.tsx | 34 +-- .../1-default/chinese@errorComponent.tsx | 6 +- .../1-default/chinese@notFoundComponent.tsx | 6 +- .../circular-reference-arrow-function.tsx | 11 +- ...lar-reference-arrow-function@component.tsx | 24 +- .../1-default/circular-reference-function.tsx | 11 +- .../circular-reference-function@component.tsx | 20 +- .../1-default/conditional-properties.tsx | 17 +- .../conditional-properties@component.tsx | 10 +- .../destructured-export-multiple.tsx | 22 +- ...destructured-export-multiple@component.tsx | 10 +- .../1-default/destructured-export-nested.tsx | 25 +- .../destructured-export-nested@component.tsx | 10 +- .../react/1-default/destructured-export.tsx | 22 +- .../destructured-export@component.tsx | 15 +- .../destructured-export@errorComponent.tsx | 9 +- .../destructured-export@notFoundComponent.tsx | 9 +- ...ructured-react-memo-imported-component.tsx | 13 +- ...eact-memo-imported-component@component.tsx | 8 +- .../destructured-route-options-defaults.tsx | 13 +- ...tured-route-options-defaults@component.tsx | 4 +- ...ructured-route-options-defaults@shared.tsx | 29 +-- .../react/1-default/destructuring.tsx | 2 - .../1-default/destructuring@component.tsx | 14 +- .../destructuring@errorComponent.tsx | 14 +- .../destructuring@notFoundComponent.tsx | 14 +- .../react/1-default/directive-prologue.tsx | 14 +- .../directive-prologue@component.tsx | 9 +- .../explicit-undefined-component.tsx | 5 +- ...explicit-undefined-component@component.tsx | 2 +- ...cit-undefined-component@errorComponent.tsx | 2 +- ...-undefined-component@notFoundComponent.tsx | 2 +- ...-default-component-and-normal-notFound.tsx | 30 ++- ...omponent-and-normal-notFound@component.tsx | 2 +- ...ent-and-normal-notFound@errorComponent.tsx | 2 +- ...-and-normal-notFound@notFoundComponent.tsx | 6 +- .../1-default/export-default-component.tsx | 7 +- .../export-default-component@component.tsx | 2 +- ...xport-default-component@errorComponent.tsx | 2 +- ...rt-default-component@notFoundComponent.tsx | 2 +- .../react/1-default/function-as-parameter.tsx | 9 - .../function-as-parameter@component.tsx | 30 +-- .../function-as-parameter@errorComponent.tsx | 30 +-- ...unction-as-parameter@notFoundComponent.tsx | 30 +-- .../react/1-default/function-declaration.tsx | 15 +- .../function-declaration@component.tsx | 42 ++-- .../function-declaration@errorComponent.tsx | 2 +- ...function-declaration@notFoundComponent.tsx | 2 +- .../react/1-default/importAttribute.tsx | 11 +- .../1-default/importAttribute@component.tsx | 6 +- ...-default-component-destructured-loader.tsx | 13 +- ...omponent-destructured-loader@component.tsx | 6 +- .../1-default/imported-default-component.tsx | 11 +- .../imported-default-component@component.tsx | 6 +- .../1-default/imported-errorComponent.tsx | 17 +- .../imported-errorComponent@component.tsx | 6 +- ...imported-errorComponent@errorComponent.tsx | 6 +- .../1-default/imported-notFoundComponent.tsx | 17 +- .../imported-notFoundComponent@component.tsx | 6 +- ...ed-notFoundComponent@notFoundComponent.tsx | 6 +- .../1-default/imported-pendingComponent.tsx | 13 +- .../imported-pendingComponent@component.tsx | 6 +- .../snapshots/react/1-default/imported.tsx | 13 +- .../react/1-default/imported@component.tsx | 6 +- .../snapshots/react/1-default/inline.tsx | 16 +- .../react/1-default/inline@component.tsx | 34 +-- .../react/1-default/inline@errorComponent.tsx | 4 +- .../1-default/inline@notFoundComponent.tsx | 4 +- .../lowercase-function-declaration.tsx | 21 +- ...wercase-function-declaration@component.tsx | 4 +- ...se-function-declaration@errorComponent.tsx | 4 +- .../react/1-default/random-number.tsx | 67 +++-- .../1-default/random-number@component.tsx | 93 +++---- .../random-number@errorComponent.tsx | 38 +-- .../random-number@notFoundComponent.tsx | 38 +-- .../react/1-default/react-memo-component.tsx | 13 +- .../react-memo-component@component.tsx | 8 +- .../react-memo-imported-component.tsx | 13 +- ...eact-memo-imported-component@component.tsx | 8 +- .../1-default/retain-export-component.tsx | 3 - .../retain-export-component@component.tsx | 6 +- ...retain-export-component@errorComponent.tsx | 6 +- ...ain-export-component@notFoundComponent.tsx | 6 +- .../react/1-default/retain-exports-const.tsx | 5 - .../retain-exports-const@component.tsx | 4 +- .../retain-exports-const@errorComponent.tsx | 4 +- ...retain-exports-const@notFoundComponent.tsx | 4 +- .../1-default/retain-exports-destructured.tsx | 8 +- .../retain-exports-destructured@component.tsx | 4 +- .../retain-exports-destructured@shared.tsx | 15 +- .../1-default/retain-exports-function.tsx | 5 - .../retain-exports-function@component.tsx | 4 +- ...retain-exports-function@errorComponent.tsx | 4 +- ...ain-exports-function@notFoundComponent.tsx | 4 +- .../react/1-default/retain-exports-loader.tsx | 23 +- .../retain-exports-loader@component.tsx | 22 +- .../retain-exports-loader@errorComponent.tsx | 4 +- ...etain-exports-loader@notFoundComponent.tsx | 4 +- .../react/1-default/shared-class.tsx | 15 +- .../1-default/shared-class@component.tsx | 6 +- .../react/1-default/shared-class@shared.tsx | 10 +- .../1-default/shared-destructured-export.tsx | 15 +- .../shared-destructured-export@component.tsx | 6 +- .../shared-destructured-export@shared.tsx | 12 +- .../react/1-default/shared-destructured.tsx | 13 +- .../shared-destructured@component.tsx | 6 +- .../1-default/shared-destructured@shared.tsx | 12 +- .../react/1-default/shared-exported.tsx | 19 +- .../1-default/shared-exported@component.tsx | 6 +- .../1-default/shared-exported@shared.tsx | 7 +- .../react/1-default/shared-function.tsx | 19 +- .../1-default/shared-function@component.tsx | 6 +- .../1-default/shared-function@shared.tsx | 6 +- .../1-default/shared-imported-binding.tsx | 13 +- .../shared-imported-binding@component.tsx | 6 +- .../react/1-default/shared-indirect-ref.tsx | 19 +- .../shared-indirect-ref@component.tsx | 10 +- .../1-default/shared-indirect-ref@shared.tsx | 8 +- .../1-default/shared-jsx-component-ref.tsx | 13 +- .../shared-jsx-component-ref@component.tsx | 6 +- .../shared-jsx-component-ref@shared.tsx | 5 +- .../snapshots/react/1-default/shared-none.tsx | 13 +- .../react/1-default/shared-none@component.tsx | 12 +- .../1-default/shared-referencing-route.tsx | 21 +- .../shared-referencing-route@component.tsx | 14 +- .../shared-referencing-route@shared.tsx | 4 +- .../react/1-default/shared-runtime.tsx | 40 +-- .../1-default/shared-runtime@component.tsx | 39 +-- .../shared-runtime@errorComponent.tsx | 18 +- .../shared-runtime@notFoundComponent.tsx | 18 +- .../react/1-default/shared-runtime@shared.tsx | 35 +-- .../react/1-default/shared-transitive.tsx | 17 +- .../1-default/shared-transitive@component.tsx | 6 +- .../1-default/shared-transitive@shared.tsx | 9 +- .../react/1-default/shared-variable.tsx | 19 +- .../1-default/shared-variable@component.tsx | 6 +- .../1-default/shared-variable@shared.tsx | 7 +- .../1-default/shared-with-side-effect.tsx | 17 +- .../shared-with-side-effect@component.tsx | 6 +- .../shared-with-side-effect@shared.tsx | 4 +- .../react/1-default/undefined-literals.tsx | 1 - .../react/1-default/useStateDestructure.tsx | 26 +- .../useStateDestructure@component.tsx | 4 +- .../useStateDestructure@errorComponent.tsx | 4 +- .../useStateDestructure@notFoundComponent.tsx | 4 +- .../arrow-function.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 44 ++-- .../arrow-function@loader.tsx | 8 +- .../boolean-null-literals.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 4 +- .../boolean-null-literals@loader.tsx | 6 +- .../chinese.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 34 +-- .../chinese@loader.tsx | 6 +- .../circular-reference-arrow-function.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../circular-reference-function.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 20 +- .../conditional-properties.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../conditional-properties@loader.tsx | 10 +- .../destructured-export-multiple.tsx | 22 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../destructured-export-nested.tsx | 25 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../destructured-export.tsx | 22 +- ...--notFoundComponent---pendingComponent.tsx | 15 +- .../destructured-export@loader.tsx | 9 +- ...ructured-react-memo-imported-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 8 +- ...d-react-memo-imported-component@loader.tsx | 6 +- .../destructured-route-options-defaults.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 4 +- ...ructured-route-options-defaults@loader.tsx | 4 +- ...ructured-route-options-defaults@shared.tsx | 29 +-- .../destructuring.tsx | 2 - ...--notFoundComponent---pendingComponent.tsx | 14 +- .../destructuring@loader.tsx | 14 +- .../directive-prologue.tsx | 14 +- ...--notFoundComponent---pendingComponent.tsx | 9 +- .../explicit-undefined-component.tsx | 5 +- ...--notFoundComponent---pendingComponent.tsx | 2 +- .../explicit-undefined-component@loader.tsx | 2 +- ...-default-component-and-normal-notFound.tsx | 30 ++- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...t-component-and-normal-notFound@loader.tsx | 2 +- .../export-default-component.tsx | 7 +- ...--notFoundComponent---pendingComponent.tsx | 2 +- .../export-default-component@loader.tsx | 2 +- .../function-as-parameter.tsx | 9 - ...--notFoundComponent---pendingComponent.tsx | 30 +-- .../function-as-parameter@loader.tsx | 30 +-- .../function-declaration.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 42 ++-- .../function-declaration@loader.tsx | 8 +- .../importAttribute.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...-default-component-destructured-loader.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...t-component-destructured-loader@loader.tsx | 6 +- .../imported-default-component.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../imported-errorComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../imported-notFoundComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../imported-pendingComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../imported.tsx | 15 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../imported@loader.tsx | 6 +- .../inline.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 34 +-- .../inline@loader.tsx | 4 +- .../lowercase-function-declaration.tsx | 25 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../random-number.tsx | 65 +++-- ...--notFoundComponent---pendingComponent.tsx | 93 +++---- .../random-number@loader.tsx | 48 ++-- .../react-memo-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 8 +- .../react-memo-component@loader.tsx | 6 +- .../react-memo-imported-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 8 +- .../react-memo-imported-component@loader.tsx | 6 +- .../retain-export-component.tsx | 37 +-- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../retain-export-component@loader.tsx | 12 +- .../retain-exports-const.tsx | 5 - ...--notFoundComponent---pendingComponent.tsx | 4 +- .../retain-exports-const@loader.tsx | 4 +- .../retain-exports-destructured.tsx | 8 +- ...--notFoundComponent---pendingComponent.tsx | 4 +- .../retain-exports-destructured@loader.tsx | 4 +- .../retain-exports-destructured@shared.tsx | 15 +- .../retain-exports-function.tsx | 5 - ...--notFoundComponent---pendingComponent.tsx | 4 +- .../retain-exports-function@loader.tsx | 4 +- .../retain-exports-loader.tsx | 27 +- ...--notFoundComponent---pendingComponent.tsx | 22 +- .../retain-exports-loader@loader.tsx | 4 +- .../shared-class.tsx | 15 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-class@loader.tsx | 8 +- .../shared-class@shared.tsx | 10 +- .../shared-destructured-export.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-destructured-export@loader.tsx | 6 +- .../shared-destructured-export@shared.tsx | 12 +- .../shared-destructured.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-destructured@loader.tsx | 6 +- .../shared-destructured@shared.tsx | 12 +- .../shared-exported.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-exported@loader.tsx | 10 +- .../shared-exported@shared.tsx | 7 +- .../shared-function.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-function@loader.tsx | 12 +- .../shared-function@shared.tsx | 6 +- .../shared-imported-binding.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-imported-binding@loader.tsx | 6 +- .../shared-indirect-ref.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../shared-indirect-ref@loader.tsx | 12 +- .../shared-indirect-ref@shared.tsx | 8 +- .../shared-jsx-component-ref.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-jsx-component-ref@loader.tsx | 6 +- .../shared-jsx-component-ref@shared.tsx | 5 +- .../shared-none.tsx | 15 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../shared-none@loader.tsx | 6 +- .../shared-referencing-route.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 14 +- .../shared-referencing-route@loader.tsx | 16 +- .../shared-referencing-route@shared.tsx | 4 +- .../shared-runtime.tsx | 36 ++- ...--notFoundComponent---pendingComponent.tsx | 39 +-- .../shared-runtime@loader.tsx | 31 +-- .../shared-runtime@shared.tsx | 35 +-- .../shared-transitive.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-transitive@loader.tsx | 10 +- .../shared-transitive@shared.tsx | 9 +- .../shared-variable.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-variable@loader.tsx | 12 +- .../shared-variable@shared.tsx | 7 +- .../shared-with-side-effect.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../shared-with-side-effect@loader.tsx | 8 +- .../shared-with-side-effect@shared.tsx | 4 +- .../undefined-literals.tsx | 1 - .../useStateDestructure.tsx | 26 +- ...--notFoundComponent---pendingComponent.tsx | 4 +- .../useStateDestructure@loader.tsx | 4 +- .../using.tsx | 8 +- .../using@loader.tsx | 24 +- .../arrow-function.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 50 ++-- .../arrow-function@errorComponent.tsx | 2 +- .../boolean-null-literals.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../chinese.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 34 +-- .../chinese@errorComponent.tsx | 6 +- .../circular-reference-arrow-function.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../circular-reference-function.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 20 +- .../conditional-properties.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 14 +- .../destructured-export-multiple.tsx | 22 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../destructured-export-nested.tsx | 25 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../destructured-export.tsx | 22 +- ...--notFoundComponent---pendingComponent.tsx | 15 +- .../destructured-export@errorComponent.tsx | 9 +- ...ructured-react-memo-imported-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 14 +- .../destructured-route-options-defaults.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../destructuring.tsx | 2 - ...--notFoundComponent---pendingComponent.tsx | 14 +- .../destructuring@errorComponent.tsx | 14 +- .../directive-prologue.tsx | 14 +- ...--notFoundComponent---pendingComponent.tsx | 9 +- .../explicit-undefined-component.tsx | 5 +- ...--notFoundComponent---pendingComponent.tsx | 2 +- ...cit-undefined-component@errorComponent.tsx | 2 +- ...-default-component-and-normal-notFound.tsx | 30 ++- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...ent-and-normal-notFound@errorComponent.tsx | 2 +- .../export-default-component.tsx | 7 +- ...--notFoundComponent---pendingComponent.tsx | 2 +- ...xport-default-component@errorComponent.tsx | 2 +- .../function-as-parameter.tsx | 9 - ...--notFoundComponent---pendingComponent.tsx | 30 +-- .../function-as-parameter@errorComponent.tsx | 30 +-- .../function-declaration.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 48 ++-- .../function-declaration@errorComponent.tsx | 2 +- .../importAttribute.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...-default-component-destructured-loader.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../imported-default-component.tsx | 11 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- .../imported-errorComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 6 +- ...imported-errorComponent@errorComponent.tsx | 6 +- .../imported-notFoundComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../imported-pendingComponent.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../imported.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../inline.tsx | 17 +- ...--notFoundComponent---pendingComponent.tsx | 34 +-- .../inline@errorComponent.tsx | 4 +- .../lowercase-function-declaration.tsx | 25 +- ...--notFoundComponent---pendingComponent.tsx | 8 +- ...se-function-declaration@errorComponent.tsx | 4 +- .../random-number.tsx | 66 +++-- ...--notFoundComponent---pendingComponent.tsx | 103 ++++---- .../random-number@errorComponent.tsx | 38 +-- .../react-memo-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 14 +- .../react-memo-imported-component.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../retain-export-component.tsx | 37 +-- ...--notFoundComponent---pendingComponent.tsx | 12 +- ...retain-export-component@errorComponent.tsx | 6 +- .../retain-exports-const.tsx | 5 - ...--notFoundComponent---pendingComponent.tsx | 4 +- .../retain-exports-const@errorComponent.tsx | 4 +- .../retain-exports-destructured.tsx | 8 +- ...--notFoundComponent---pendingComponent.tsx | 2 +- .../retain-exports-function.tsx | 5 - ...--notFoundComponent---pendingComponent.tsx | 4 +- ...retain-exports-function@errorComponent.tsx | 4 +- .../retain-exports-loader.tsx | 27 +- ...--notFoundComponent---pendingComponent.tsx | 22 +- .../retain-exports-loader@errorComponent.tsx | 4 +- .../shared-class.tsx | 22 +- ...--notFoundComponent---pendingComponent.tsx | 18 +- .../shared-class@errorComponent.tsx | 8 +- .../shared-destructured-export.tsx | 28 +-- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../shared-destructured.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 18 +- .../shared-exported.tsx | 21 +- ...--notFoundComponent---pendingComponent.tsx | 14 +- .../shared-function.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 18 +- .../shared-imported-binding.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 10 +- .../shared-indirect-ref.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../shared-jsx-component-ref.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 11 +- .../shared-none.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 18 +- .../shared-referencing-route.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../shared-runtime.tsx | 36 ++- ...--notFoundComponent---pendingComponent.tsx | 48 ++-- .../shared-runtime@errorComponent.tsx | 18 +- .../shared-runtime@shared.tsx | 35 +-- .../shared-transitive.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 19 +- .../shared-variable.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 19 +- .../shared-with-side-effect.tsx | 18 +- ...--notFoundComponent---pendingComponent.tsx | 12 +- .../undefined-literals.tsx | 1 - .../useStateDestructure.tsx | 26 +- ...--notFoundComponent---pendingComponent.tsx | 4 +- .../useStateDestructure@errorComponent.tsx | 4 +- .../using.tsx | 9 +- ...--notFoundComponent---pendingComponent.tsx | 24 +- .../solid/1-default/arrow-function.tsx | 13 +- .../1-default/arrow-function@component.tsx | 39 +-- .../arrow-function.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 39 +-- .../arrow-function@loader.tsx | 6 +- .../arrow-function.tsx | 16 +- ...--notFoundComponent---pendingComponent.tsx | 45 ++-- .../router-plugin/tests/delete-nodes.test.ts | 5 +- .../createRootRoute-ssr-function.tsx | 1 - ...reateRootRouteWithContext-ssr-function.tsx | 1 - .../ssr-data-only.tsx | 1 - .../1-delete-nodes-undefined/ssr-false.tsx | 1 - .../createRootRoute-ssr-function.tsx | 1 - ...reateRootRouteWithContext-ssr-function.tsx | 1 - .../2-delete-nodes-empty/ssr-data-only.tsx | 1 - .../react/2-delete-nodes-empty/ssr-false.tsx | 1 - .../createRootRoute-ssr-function.tsx | 8 +- ...reateRootRouteWithContext-ssr-function.tsx | 8 +- .../3-delete-nodes-ssr/ssr-data-only.tsx | 8 +- .../react/3-delete-nodes-ssr/ssr-false.tsx | 8 +- .../react/3-delete-nodes-ssr/ssr-function.tsx | 8 +- .../ssr-data-only.tsx | 1 - .../1-delete-nodes-undefined/ssr-false.tsx | 1 - .../1-delete-nodes-undefined/ssr-function.tsx | 1 - .../2-delete-nodes-empty/ssr-data-only.tsx | 1 - .../solid/2-delete-nodes-empty/ssr-false.tsx | 1 - .../2-delete-nodes-empty/ssr-function.tsx | 1 - .../3-delete-nodes-ssr/ssr-data-only.tsx | 8 +- .../solid/3-delete-nodes-ssr/ssr-false.tsx | 8 +- .../solid/3-delete-nodes-ssr/ssr-function.tsx | 8 +- .../router-plugin/tests/format-snapshot.ts | 69 ++++++ packages/start-plugin-core/package.json | 1 + .../tests/clientOnlyJSX/clientOnlyJSX.test.ts | 7 +- .../snapshots/server/clientOnlyBasic.tsx | 10 +- .../snapshots/server/clientOnlyMultiple.tsx | 10 +- .../snapshots/server/clientOnlyNested.tsx | 10 +- .../snapshots/server/clientOnlyNoFallback.tsx | 10 +- .../snapshots/server/clientOnlyRenamed.tsx | 10 +- .../createIsomorphicFn.test.ts | 7 +- .../snapshots/client/call-at-module-level.ts | 8 +- .../client/createIsomorphicFnDestructured.tsx | 22 +- .../createIsomorphicFnDestructuredRename.tsx | 22 +- .../client/createIsomorphicFnFactory.tsx | 25 +- .../client/createIsomorphicFnInline.tsx | 40 ++- .../client/createIsomorphicFnStarImport.tsx | 22 +- .../snapshots/server/call-at-module-level.ts | 8 +- .../server/createIsomorphicFnDestructured.tsx | 22 +- .../createIsomorphicFnDestructuredRename.tsx | 22 +- .../server/createIsomorphicFnFactory.tsx | 25 +- .../server/createIsomorphicFnInline.tsx | 40 ++- .../server/createIsomorphicFnStarImport.tsx | 22 +- .../createMiddleware/createMiddleware.test.ts | 17 +- .../client/create-function-middleware.ts | 10 +- .../client/createMiddlewareDestructured.tsx | 18 +- .../createMiddlewareDestructuredRename.tsx | 18 +- .../client/createMiddlewareStarImport.tsx | 18 +- .../client/createMiddlewareValidator.tsx | 6 +- .../snapshots/client/createStart.tsx | 22 +- .../snapshots/client/middleware-factory.ts | 21 +- .../createServerFn/createServerFn.test.ts | 234 ++++++++++++------ .../client/createServerFnDestructured.tsx | 60 +++-- .../createServerFnDestructuredRename.tsx | 36 +-- .../client/createServerFnStarImport.tsx | 36 ++- .../client/createServerFnValidator.tsx | 12 +- .../snapshots/client/factory.tsx | 64 +++-- .../snapshots/client/isomorphic-fns.tsx | 81 +++--- .../createServerFnDestructured.tsx | 64 +++-- .../createServerFnDestructuredRename.tsx | 36 +-- .../createServerFnStarImport.tsx | 36 ++- .../server-caller/createServerFnValidator.tsx | 16 +- .../snapshots/server-caller/factory.tsx | 64 +++-- .../server-caller/isomorphic-fns.tsx | 83 ++++--- .../createServerFnDestructured.tsx | 204 +++++++++------ .../createServerFnDestructuredRename.tsx | 136 ++++++---- .../createServerFnStarImport.tsx | 134 ++++++---- .../createServerFnValidator.tsx | 29 +-- .../snapshots/server-provider/factory.tsx | 101 ++++---- .../server-provider/isomorphic-fns.tsx | 54 ++-- .../tests/envOnly/envOnly.test.ts | 7 +- .../snapshots/client/envOnlyDestructured.tsx | 8 +- .../client/envOnlyDestructuredRename.tsx | 8 +- .../snapshots/client/envOnlyExportedAlias.tsx | 12 +- .../snapshots/client/envOnlyFactory.tsx | 36 +-- .../snapshots/client/envOnlyStarImport.tsx | 8 +- .../snapshots/server/envOnlyDestructured.tsx | 8 +- .../server/envOnlyDestructuredRename.tsx | 8 +- .../snapshots/server/envOnlyExportedAlias.tsx | 4 +- .../snapshots/server/envOnlyFactory.tsx | 36 +-- .../snapshots/server/envOnlyStarImport.tsx | 8 +- .../tests/format-snapshot.ts | 69 ++++++ .../tests/hydrateWhen/hydrateWhen.test.ts | 26 +- .../snapshots/client/hydrateWhenBasic.tsx | 40 +-- .../snapshots/client/hydrateWhenMultiple.tsx | 44 ++-- .../snapshots/client/hydrateWhenNested.tsx | 34 ++- .../snapshots/client/hydrateWhenNever.tsx | 21 +- .../client/hydrateWhenObjectFallback.tsx | 65 +++-- .../client/hydrateWhenPrefetchState.tsx | 45 ++-- .../snapshots/client/hydrateWhenRenamed.tsx | 23 +- .../snapshots/server/hydrateWhenBasic.tsx | 29 +-- .../snapshots/server/hydrateWhenMultiple.tsx | 18 +- .../snapshots/server/hydrateWhenNested.tsx | 20 +- .../snapshots/server/hydrateWhenNever.tsx | 14 +- .../server/hydrateWhenObjectFallback.tsx | 26 +- .../server/hydrateWhenPrefetchState.tsx | 32 ++- .../snapshots/server/hydrateWhenRenamed.tsx | 16 +- .../server/hydrateWhenSplitFalse.tsx | 14 +- .../hydrateWhenNested.tsx.H0.client.tsx | 29 ++- .../virtual/hydrateWhenNested.tsx.H0.tsx | 24 +- .../virtual/hydrateWhenNested.tsx.H2.tsx | 6 +- pnpm-lock.yaml | 6 + 570 files changed, 5798 insertions(+), 5350 deletions(-) create mode 100644 packages/router-plugin/tests/format-snapshot.ts create mode 100644 packages/start-plugin-core/tests/format-snapshot.ts diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json index 9e20d6d308..da6fef091f 100644 --- a/packages/router-plugin/package.json +++ b/packages/router-plugin/package.json @@ -139,6 +139,7 @@ "react-dom": "catalog:", "@types/react": "catalog:", "@types/react-dom": "catalog:", + "prettier": "^3.9.6", "@arethetypeswrong/cli": "catalog:", "publint": "catalog:", "rimraf": "catalog:", diff --git a/packages/router-plugin/tests/add-hmr.test.ts b/packages/router-plugin/tests/add-hmr.test.ts index 98b3e61a5f..810f8e9b8d 100644 --- a/packages/router-plugin/tests/add-hmr.test.ts +++ b/packages/router-plugin/tests/add-hmr.test.ts @@ -7,6 +7,7 @@ import { defaultCodeSplitGroupings } from '../src/core/constants' import { getFrameworkHmrCompilerPlugins } from '../src/core/code-splitter/plugins/framework-plugins' import { createRouteHmrStatement } from '../src/core/hmr' import { frameworks } from './constants' +import { formatSnapshot } from './format-snapshot' function getFrameworkDir(framework: string) { const files = path.resolve(__dirname, `./add-hmr/test-files/${framework}`) @@ -37,7 +38,9 @@ describe('add-hmr works', () => { }), }) - await expect(compileResult?.code || code).toMatchFileSnapshot( + await expect( + await formatSnapshot(compileResult?.code || code, filename), + ).toMatchFileSnapshot( path.join(dirs.snapshots, filename.replace('.tsx', '@true.tsx')), ) }, @@ -58,7 +61,9 @@ describe('add-hmr works', () => { targetFramework: framework, }) - await expect(compileResult?.code || code).toMatchFileSnapshot( + await expect( + await formatSnapshot(compileResult?.code || code, filename), + ).toMatchFileSnapshot( path.join(dirs.snapshots, filename.replace('.tsx', '@false.tsx')), ) }, @@ -87,7 +92,9 @@ describe('add-hmr works', () => { }), }) - await expect(compileResult?.code || code).toMatchFileSnapshot( + await expect( + await formatSnapshot(compileResult?.code || code, filename), + ).toMatchFileSnapshot( path.join( getFrameworkDir(framework).snapshots, filename.replace('.tsx', '@webpack-hot.tsx'), diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx index 48e3768224..994c89e7b2 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx index 4f32369e8f..c771483895 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx @@ -1,109 +1,117 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' const TSRSplitComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: TSRSplitComponent -}); -const hot = import.meta.hot; + component: TSRSplitComponent, +}) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("arrow-function.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('arrow-function.tsx', ['Route']) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx index 12e47f429e..eb655d0287 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx @@ -1,87 +1,107 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' const TSRSplitComponent = (() => { - const hot = import.meta.webpackHot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.webpackHot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.webpackHot) { - (import.meta.webpackHot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.webpackHot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: TSRSplitComponent -}); + component: TSRSplitComponent, +}) if (import.meta.webpackHot) { - const hot = import.meta.webpackHot; - const hotData = hot.data ??= {}; - const routeId = hotData['tsr-route-id'] ?? Route.id ?? (Route.isRoot ? '__root__' : undefined); + const hot = import.meta.webpackHot + const hotData = (hot.data ??= {}) + const routeId = + hotData['tsr-route-id'] ?? + Route.id ?? + (Route.isRoot ? '__root__' : undefined) if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } - const existingRoute = typeof window !== 'undefined' && routeId ? window.__TSR_ROUTER__?.routesById?.[routeId] : undefined; + const existingRoute = + typeof window !== 'undefined' && routeId + ? window.__TSR_ROUTER__?.routesById?.[routeId] + : undefined if (routeId && existingRoute && existingRoute !== Route) { - (function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + ;(function handleRouteUpdate(routeId, newRoute) { + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - })(routeId, Route); + })(routeId, Route) try { - const tsrReactRefreshUtils = typeof __react_refresh_utils__ !== 'undefined' ? __react_refresh_utils__ : undefined; - const tsrEnqueueUpdate = tsrReactRefreshUtils && typeof tsrReactRefreshUtils.enqueueUpdate === 'function' ? tsrReactRefreshUtils.enqueueUpdate : undefined; + const tsrReactRefreshUtils = + typeof __react_refresh_utils__ !== 'undefined' + ? __react_refresh_utils__ + : undefined + const tsrEnqueueUpdate = + tsrReactRefreshUtils && + typeof tsrReactRefreshUtils.enqueueUpdate === 'function' + ? tsrReactRefreshUtils.enqueueUpdate + : undefined if (tsrEnqueueUpdate) { - tsrEnqueueUpdate(() => {}); + tsrEnqueueUpdate(() => {}) } } catch (_err) {} } - hot.dispose(data => { + hot.dispose((data) => { if (routeId) { - data['tsr-route-id'] = routeId; + data['tsr-route-id'] = routeId } - }); - hot.accept(); -} \ No newline at end of file + }) + hot.accept() +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx index a2983e31bd..e0b52f6ad6 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx @@ -1,12 +1,17 @@ -const $$splitComponentImporter = () => import('createFileRoute-lowercase-components.tsx?tsr-split=component'); -const $$splitErrorComponentImporter = () => import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('createFileRoute-lowercase-components.tsx?tsr-split=component') +const $$splitErrorComponentImporter = () => + import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/lowercase-components')({ pendingComponent: pendingComponent, - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) function pendingComponent() { - return
Pending
; -} \ No newline at end of file + return
Pending
+} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx index 70c428363e..bf94d5d3fd 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx @@ -1,120 +1,136 @@ -const $$splitComponentImporter = () => import('createFileRoute-lowercase-components.tsx?tsr-split=component'); -const $$splitErrorComponentImporter = () => import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('createFileRoute-lowercase-components.tsx?tsr-split=component') +const $$splitErrorComponentImporter = () => + import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:errorComponent"] ?? lazyRouteComponent($$splitErrorComponentImporter, "errorComponent"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:errorComponent'] ?? + lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:errorComponent"] = TSRSplitErrorComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = + TSRSplitErrorComponent } const TSRSplitComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } export const Route = createFileRoute('/lowercase-components')({ pendingComponent: TSRPendingComponent, errorComponent: TSRSplitErrorComponent, - component: TSRSplitComponent -}); + component: TSRSplitComponent, +}) function TSRPendingComponent() { - return
Pending
; + return
Pending
} -const hot = import.meta.hot; +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("createFileRoute-lowercase-components.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set( + 'createFileRoute-lowercase-components.tsx', + ['Route'], + ) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx index 5daf018617..7e3ad124ae 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx @@ -1,6 +1,3 @@ import * as React from 'react' import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: () =>
root hmr
, -}) +export const Route = createRootRoute({ component: () =>
root hmr
}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx index e5a473dc14..f12187ccd1 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx @@ -1,98 +1,102 @@ -import * as React from 'react'; -import { createRootRoute } from '@tanstack/react-router'; -const TSRComponent = () =>
root hmr
; -export const Route = createRootRoute({ - component: TSRComponent -}); -const hot = import.meta.hot; +import * as React from 'react' +import { createRootRoute } from '@tanstack/react-router' +const TSRComponent = () =>
root hmr
+export const Route = createRootRoute({ component: TSRComponent }) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("createRootRoute-inline-component.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set( + 'createRootRoute-inline-component.tsx', + ['Route'], + ) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx index 20c9a07798..6fac4df1f1 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx @@ -1,25 +1,20 @@ import * as React from 'react' import { createRootRoute } from '@tanstack/react-router' - export const Route = createRootRoute({ shellComponent: shellComponent, pendingComponent: pendingComponent, errorComponent: errorComponent, component: component, }) - function shellComponent({ children }: { children: React.ReactNode }) { return {children} } - function pendingComponent() { return
Pending
} - function errorComponent() { return
Error
} - function component() { return
Hello
} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx index cb5014cd35..9f8df0d43f 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx @@ -1,116 +1,118 @@ -import * as React from 'react'; -import { createRootRoute } from '@tanstack/react-router'; +import * as React from 'react' +import { createRootRoute } from '@tanstack/react-router' export const Route = createRootRoute({ shellComponent: TSRShellComponent, pendingComponent: TSRPendingComponent, errorComponent: TSRErrorComponent, - component: TSRComponent -}); -function TSRShellComponent({ - children -}: { - children: React.ReactNode; -}) { - return {children}; + component: TSRComponent, +}) +function TSRShellComponent({ children }: { children: React.ReactNode }) { + return {children} } function TSRPendingComponent() { - return
Pending
; + return
Pending
} function TSRErrorComponent() { - return
Error
; + return
Error
} function TSRComponent() { - return
Hello
; + return
Hello
} -const hot = import.meta.hot; +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("createRootRoute-lowercase-components.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set( + 'createRootRoute-lowercase-components.tsx', + ['Route'], + ) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx index e967791f8d..5c779d9876 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx @@ -1,10 +1,6 @@ import * as React from 'react' import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: RootComponent, -}) - +export const Route = createRootRoute({ component: RootComponent }) function RootComponent() { return
Hello
} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx index 7ba271c212..859380ef53 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx @@ -1,100 +1,101 @@ -import * as React from 'react'; -import { createRootRoute } from '@tanstack/react-router'; -export const Route = createRootRoute({ - component: RootComponent -}); +import * as React from 'react' +import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ component: RootComponent }) function RootComponent() { - return
Hello
; + return
Hello
} -const hot = import.meta.hot; +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("createRootRoute.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('createRootRoute.tsx', ['Route']) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx index 0feadacab5..43f27087a6 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx @@ -1,14 +1,11 @@ import * as React from 'react' import { createRootRouteWithContext } from '@tanstack/react-router' - interface MyRouterContext { auth: boolean } - export const Route = createRootRouteWithContext()({ component: RootComponent, }) - function RootComponent() { return
Hello
} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx index b66449aebf..9d942f65a2 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx @@ -1,103 +1,109 @@ -import * as React from 'react'; -import { createRootRouteWithContext } from '@tanstack/react-router'; +import * as React from 'react' +import { createRootRouteWithContext } from '@tanstack/react-router' interface MyRouterContext { - auth: boolean; + auth: boolean } export const Route = createRootRouteWithContext()({ - component: RootComponent -}); + component: RootComponent, +}) function RootComponent() { - return
Hello
; + return
Hello
} -const hot = import.meta.hot; +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("createRootRouteWithContext-type-args.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set( + 'createRootRouteWithContext-type-args.tsx', + ['Route'], + ) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx index d80f17484f..112fded569 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx @@ -1,11 +1,9 @@ import thing from 'thing' - export function test() { const { foo: { bar: { destructured }, }, } = thing - return destructured } diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx index d80f17484f..112fded569 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx @@ -1,11 +1,9 @@ import thing from 'thing' - export function test() { const { foo: { bar: { destructured }, }, } = thing - return destructured } diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx index 4fdd9d1c68..8109a89624 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx @@ -1,6 +1,3 @@ import React from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: undefined, -}) +export const Route = createFileRoute('/')({ component: undefined }) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx index fee0b2f2e6..555c8fdd6c 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx @@ -1,97 +1,100 @@ -import React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -export const Route = createFileRoute('/')({ - component: undefined -}); -const hot = import.meta.hot; +import React from 'react' +import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: undefined }) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("explicit-undefined-component.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('explicit-undefined-component.tsx', [ + 'Route', + ]) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx index 5d7e2181f5..e2b672f7b8 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('function-declaration.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx index 4a925828e2..9e27af7d69 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx @@ -1,109 +1,117 @@ -const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('function-declaration.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' const TSRSplitComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: TSRSplitComponent -}); -const hot = import.meta.hot; + component: TSRSplitComponent, +}) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("function-declaration.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('function-declaration.tsx', ['Route']) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx index 653c0c21f5..456134aadc 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx @@ -1,11 +1,16 @@ -const $$splitErrorComponentImporter = () => import('multi-component.tsx?tsr-split=errorComponent'); -const $$splitComponentImporter = () => import('multi-component.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitErrorComponentImporter = () => + import('multi-component.tsx?tsr-split=errorComponent') +const $$splitComponentImporter = () => + import('multi-component.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, component: lazyRouteComponent($$splitComponentImporter, 'component'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx index ca2a7ab2e2..1a134b88da 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx @@ -1,119 +1,132 @@ -const $$splitErrorComponentImporter = () => import('multi-component.tsx?tsr-split=errorComponent'); -const $$splitComponentImporter = () => import('multi-component.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitErrorComponentImporter = () => + import('multi-component.tsx?tsr-split=errorComponent') +const $$splitComponentImporter = () => + import('multi-component.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' const TSRSplitComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:errorComponent"] ?? lazyRouteComponent($$splitErrorComponentImporter, "errorComponent"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:errorComponent'] ?? + lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:errorComponent"] = TSRSplitErrorComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = + TSRSplitErrorComponent } export const Route = createFileRoute('/posts')({ loader: fetchPosts, component: TSRSplitComponent, - errorComponent: TSRSplitErrorComponent -}); -const hot = import.meta.hot; + errorComponent: TSRSplitErrorComponent, +}) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("multi-component.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('multi-component.tsx', ['Route']) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx index 4fc3129e14..cfb23b03d2 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx @@ -1,11 +1,16 @@ -const $$splitErrorComponentImporter = () => import('string-literal-keys.tsx?tsr-split=errorComponent'); -const $$splitComponentImporter = () => import('string-literal-keys.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitErrorComponentImporter = () => + import('string-literal-keys.tsx?tsr-split=errorComponent') +const $$splitComponentImporter = () => + import('string-literal-keys.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - 'component': lazyRouteComponent($$splitComponentImporter, 'component'), - 'errorComponent': lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx index b6f67e67b1..b3bc82d69e 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx @@ -1,119 +1,132 @@ -const $$splitErrorComponentImporter = () => import('string-literal-keys.tsx?tsr-split=errorComponent'); -const $$splitComponentImporter = () => import('string-literal-keys.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitErrorComponentImporter = () => + import('string-literal-keys.tsx?tsr-split=errorComponent') +const $$splitComponentImporter = () => + import('string-literal-keys.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' const TSRSplitComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:component'] ?? + lazyRouteComponent($$splitComponentImporter, 'component') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = + TSRSplitComponent } const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot; - const hotData = hot ? hot.data ??= {} : undefined; - return hotData?.["tsr-split-component:errorComponent"] ?? lazyRouteComponent($$splitErrorComponentImporter, "errorComponent"); -})(); + const hot = import.meta.hot + const hotData = hot ? (hot.data ??= {}) : undefined + return ( + hotData?.['tsr-split-component:errorComponent'] ?? + lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') + ) +})() if (import.meta.hot) { - (import.meta.hot.data ??= {})["tsr-split-component:errorComponent"] = TSRSplitErrorComponent; + ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = + TSRSplitErrorComponent } export const Route = createFileRoute('/posts')({ loader: fetchPosts, - 'component': TSRSplitComponent, - 'errorComponent': TSRSplitErrorComponent -}); -const hot = import.meta.hot; + component: TSRSplitComponent, + errorComponent: TSRSplitErrorComponent, +}) +const hot = import.meta.hot if (hot && typeof window !== 'undefined') { - hot.data ??= {}; - const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map(); - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports; - window.__getReactRefreshIgnoredExports = ctx => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? []; - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? []; - return [...ignoredExports, ...moduleIgnored]; - }; - return { - ignoredExportsById - }; - })(); - tsrReactRefresh.ignoredExportsById.set("string-literal-keys.tsx", ['Route']); + hot.data ??= {} + const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { + const ignoredExportsById = new Map() + const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports + window.__getReactRefreshIgnoredExports = (ctx) => { + const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] + const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] + return [...ignoredExports, ...moduleIgnored] + } + return { ignoredExportsById } + })()) + tsrReactRefresh.ignoredExportsById.set('string-literal-keys.tsx', ['Route']) } export function TSRFastRefreshAnchor() { - return null; + return null } if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"]; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [ + 'component', + 'shellComponent', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx index b09548da57..10bedc87f0 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/solid-router'; -import { createFileRoute } from '@tanstack/solid-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/solid-router' +import { createFileRoute } from '@tanstack/solid-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx index 754da5c902..05fa745c4b 100644 --- a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx +++ b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx @@ -1,80 +1,80 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/solid-router'; -import { createFileRoute } from '@tanstack/solid-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/solid-router' +import { createFileRoute } from '@tanstack/solid-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) if (import.meta.hot) { - const hot = import.meta.hot; - const hotData = hot.data ??= {}; + const hot = import.meta.hot + const hotData = (hot.data ??= {}) const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__; - const oldRoute = router.routesById[routeId]; + const router = window.__TSR_ROUTER__ + const oldRoute = router.routesById[routeId] if (!oldRoute) { - return; + return } - ; - const generatedRouteOptionKeys = new Set(["id", "path", "getParentRoute"]); - const generatedRouteOptions = {}; - generatedRouteOptionKeys.forEach(key => { + const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) + const generatedRouteOptions = {} + generatedRouteOptionKeys.forEach((key) => { if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key]; + generatedRouteOptions[key] = oldRoute.options[key] } - }); - const oldHasShellComponent = "shellComponent" in oldRoute.options; - const newHasShellComponent = "shellComponent" in newRoute.options; - const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent; - const componentKeys = []; + }) + const oldHasShellComponent = 'shellComponent' in oldRoute.options + const newHasShellComponent = 'shellComponent' in newRoute.options + const preserveComponentIdentity = + oldHasShellComponent === newHasShellComponent + const componentKeys = [] if (preserveComponentIdentity) { - componentKeys.forEach(key => { + componentKeys.forEach((key) => { if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key]; + newRoute.options[key] = oldRoute.options[key] } - }); + }) } - ; - const nextOptions = { - ...newRoute.options, - ...generatedRouteOptions - }; - oldRoute.options = nextOptions; - oldRoute.update(nextOptions); - router._replaceRouteChunk(oldRoute, newRoute.lazyFn); - router.setRoutes(router.buildRouteTree()); - syncHotRouteExport(oldRoute); - router.resolvePathCache.clear(); - void router._refreshRoute?.(); + const nextOptions = { ...newRoute.options, ...generatedRouteOptions } + oldRoute.options = nextOptions + oldRoute.update(nextOptions) + router._replaceRouteChunk(oldRoute, newRoute.lazyFn) + router.setRoutes(router.buildRouteTree()) + syncHotRouteExport(oldRoute) + router.resolvePathCache.clear() + void router._refreshRoute?.() function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options; - newRoute.parentRoute = liveRoute.parentRoute; - newRoute._path = liveRoute._path; - newRoute._id = liveRoute._id; - newRoute._fullPath = liveRoute._fullPath; - newRoute._to = liveRoute._to; + newRoute.options = liveRoute.options + newRoute.parentRoute = liveRoute.parentRoute + newRoute._path = liveRoute._path + newRoute._id = liveRoute._id + newRoute._fullPath = liveRoute._fullPath + newRoute._to = liveRoute._to } - }; - const initialRouteId = Route.id ?? hotData['tsr-route-id']; + } + const initialRouteId = Route.id ?? hotData['tsr-route-id'] if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId; + hotData['tsr-route-id'] = initialRouteId } - const existingRoute = typeof window !== 'undefined' && initialRouteId ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] : undefined; + const existingRoute = + typeof window !== 'undefined' && initialRouteId + ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] + : undefined if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route); - hotData['tsr-route-update-handled'] = Route; + handleRouteUpdate(initialRouteId, Route) + hotData['tsr-route-update-handled'] = Route } - hot.accept(newModule => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id; + const routeId = hotData['tsr-route-id'] ?? Route.id if (routeId) { - hotData['tsr-route-id'] = routeId; + hotData['tsr-route-id'] = routeId } if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled']; - return; + delete hotData['tsr-route-update-handled'] + return } - handleRouteUpdate(routeId, newModule.Route); + handleRouteUpdate(routeId, newModule.Route) } - }); -} \ No newline at end of file + }) +} diff --git a/packages/router-plugin/tests/code-splitter.test.ts b/packages/router-plugin/tests/code-splitter.test.ts index 967f102e4d..96807e4d42 100644 --- a/packages/router-plugin/tests/code-splitter.test.ts +++ b/packages/router-plugin/tests/code-splitter.test.ts @@ -22,6 +22,7 @@ import { createIdentifier } from '@tanstack/router-utils' import { defaultCodeSplitGroupings } from '../src/core/constants' import { getFrameworkHmrCompilerPlugins } from '../src/core/code-splitter/plugins/framework-plugins' import { frameworks } from './constants' +import { formatSnapshot } from './format-snapshot' import type { CodeSplitGroupings } from '../src/core/constants' function getFrameworkDir(framework: string) { @@ -87,7 +88,9 @@ describe('code-splitter works', () => { sharedBindings.size > 0 ? sharedBindings : undefined, }) - await expect(compileResult?.code || code).toMatchFileSnapshot( + await expect( + await formatSnapshot(compileResult?.code || code, filename), + ).toMatchFileSnapshot( path.join(dirs.snapshots, groupName, filename), ) }, @@ -120,9 +123,9 @@ describe('code-splitter works', () => { groupName, `${filename.replace('.tsx', '')}@${ident}.tsx`, ) - await expect(splitResult.code).toMatchFileSnapshot( - snapshotFilename, - ) + await expect( + await formatSnapshot(splitResult.code, filename), + ).toMatchFileSnapshot(snapshotFilename) } }, ) @@ -156,9 +159,9 @@ describe('code-splitter works', () => { filename: `${filename}?tsr-shared=1`, }) - await expect(sharedResult.code).toMatchFileSnapshot( - snapshotFilename, - ) + await expect( + await formatSnapshot(sharedResult.code, filename), + ).toMatchFileSnapshot(snapshotFilename) }, ) }, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function.tsx index 48e3768224..994c89e7b2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@component.tsx index 7fe3edee11..e36e48f495 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@component.tsx @@ -1,27 +1,31 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { Route } from "arrow-function.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; -}; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@errorComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@errorComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@notFoundComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/arrow-function@notFoundComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals.tsx index 771fd14f8b..5544bb15d4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals.tsx @@ -1,13 +1,11 @@ -const $$splitComponentImporter = () => import('boolean-null-literals.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/router'; - +const $$splitComponentImporter = () => + import('boolean-null-literals.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/router' // Test errorComponent with false literal export const Route = createFileRoute('/test')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), errorComponent: false, pendingComponent: null, - loader: async () => ({ - data: 'test' - }) -}); \ No newline at end of file + loader: async () => ({ data: 'test' }), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals@component.tsx index c49c9e93a3..557105b6a3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/boolean-null-literals@component.tsx @@ -1,3 +1,3 @@ // Test errorComponent with false literal -const SplitComponent = () =>
Test Component
; -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = () =>
Test Component
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese.tsx index 2ffcfaa9a2..35a6bda2b1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese.tsx @@ -1,10 +1,10 @@ -const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@component.tsx index 003ca944a1..2ac1fa54ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@component.tsx @@ -1,23 +1,27 @@ -import * as React from 'react'; +import * as React from 'react' function HomeComponent() { - return
+ return ( +
-
; +
+ ) } interface DemoProps { - title: string; + title: string } -function Demo({ - title -}: DemoProps) { - return

+function Demo({ title }: DemoProps) { + return ( +

{title} -

; + + ) } -export { HomeComponent as component }; \ No newline at end of file +export { HomeComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@errorComponent.tsx index b4de370f4e..cbcea8cc40 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@errorComponent.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from 'react' interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@notFoundComponent.tsx index b4de370f4e..cbcea8cc40 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/chinese@notFoundComponent.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from 'react' interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function.tsx index 6ec23e8d1c..d367391005 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function@component.tsx index 39ace71ebe..59c5b5eec2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-arrow-function@component.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } const App = () => { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; -}; -function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; +
+ ) } -export { App as component }; \ No newline at end of file +function OtherComponent() { + const componentName = getComponentName({ App }) + return
App component name is {componentName}
+} +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function.tsx index 202ef21eb3..f2e0c96476 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function@component.tsx index 96a753ad8a..22fbb8669f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/circular-reference-function@component.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } function App() { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; +
+ ) } function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; + const componentName = getComponentName({ App }) + return
App component name is {componentName}
} -export { App as component }; \ No newline at end of file +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties.tsx index 70385cd749..927bb2e738 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties.tsx @@ -1,10 +1,11 @@ -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'; +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'), - loader: isEnabled ? TrueImport.loader : falseLoader -}); \ No newline at end of file + loader: isEnabled ? TrueImport.loader : falseLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties@component.tsx index aaf3410c69..e460c54467 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/conditional-properties@component.tsx @@ -1,5 +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 +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 } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple.tsx index dcf67bfcb4..31c6033aae 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple.tsx @@ -1,15 +1,13 @@ -const $$splitComponentImporter = () => import('destructured-export-multiple.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-multiple.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const getConfig = () => ({ baseUrl: 'https://api.example.com', - timeout: 5000 -}); -export const { - baseUrl, - timeout -} = getConfig(); -export const [first, second] = [1, 2]; + timeout: 5000, +}) +export const { baseUrl, timeout } = getConfig() +export const [first, second] = [1, 2] export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple@component.tsx index 9441b5a689..6a15a59c0a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-multiple@component.tsx @@ -1,8 +1,10 @@ -import { baseUrl, timeout } from "destructured-export-multiple.tsx"; +import { baseUrl, timeout } from 'destructured-export-multiple.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

Timeout: {timeout}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested.tsx index 6793123b2f..5022580478 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested.tsx @@ -1,19 +1,16 @@ -const $$splitComponentImporter = () => import('destructured-export-nested.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-nested.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' const getConfig = () => ({ - api: { - baseUrl: 'https://api.example.com' - }, + api: { baseUrl: 'https://api.example.com' }, timeout: 5000, - extra: 'data' -}); + extra: 'data', +}) export const { - api: { - baseUrl - }, + api: { baseUrl }, ...rest -} = getConfig(); +} = getConfig() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested@component.tsx index 8ba46e33e1..9bc538525f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export-nested@component.tsx @@ -1,7 +1,9 @@ -import { baseUrl } from "destructured-export-nested.tsx"; +import { baseUrl } from 'destructured-export-nested.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export.tsx index 31b1bfbe8b..282110d045 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export.tsx @@ -1,17 +1,11 @@ -const $$splitComponentImporter = () => import('destructured-export.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } -export const { - getObject -} = getObjectCallback(); +export const { getObject } = getObjectCallback() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@component.tsx index f58942d5af..b0abbd2e6e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@component.tsx @@ -1,14 +1,11 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } function AboutComponent() { - return
+ return ( +

About

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@errorComponent.tsx index 45fb19eecd..024e0e620e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@errorComponent.tsx @@ -1,8 +1,3 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; -} \ No newline at end of file + return { getObject: () => ({ constA: 10, constB: 5 }) } +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@notFoundComponent.tsx index 45fb19eecd..024e0e620e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-export@notFoundComponent.tsx @@ -1,8 +1,3 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; -} \ No newline at end of file + return { getObject: () => ({ constA: 10, constB: 5 }) } +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component.tsx index ee2af1cf9b..9ae1904cf4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component.tsx @@ -1,8 +1,9 @@ -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'; +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'), - loader: importedLoader -}); \ No newline at end of file + loader: importedLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component@component.tsx index 446d55e26b..88dcdf6e48 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-react-memo-imported-component@component.tsx @@ -1,6 +1,6 @@ -import { memo } from 'react'; +import { memo } from 'react' function Component() { - return
Component
; + return
Component
} -const SplitComponent = memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults.tsx index 7c54a2c145..c789ea861e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults.tsx @@ -1,8 +1,9 @@ -import { loader } from "destructured-route-options-defaults.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('destructured-route-options-defaults.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { loader } from 'destructured-route-options-defaults.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('destructured-route-options-defaults.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/about')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader -}); \ No newline at end of file + loader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@component.tsx index c73696ff32..c26d6be33d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@component.tsx @@ -1,2 +1,2 @@ -import { MyComponent } from "destructured-route-options-defaults.tsx?tsr-shared=1"; -export { MyComponent as component }; \ No newline at end of file +import { MyComponent } from 'destructured-route-options-defaults.tsx?tsr-shared=1' +export { MyComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@shared.tsx index fdc9acef5b..a7dee6af52 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructured-route-options-defaults@shared.tsx @@ -1,22 +1,23 @@ function defaultLoader() { - return { - message: 'default' - }; + return { message: 'default' } } function DefaultComponent() { - return
Default
; + return
Default
} const createBits = () => ({ component: ActualComponent, - loader: () => ({ - message: 'hello' - }) -}); -const { - component: MyComponent = DefaultComponent, - loader = defaultLoader -} = createBits(); + loader: () => ({ message: 'hello' }), +}) +const { component: MyComponent = DefaultComponent, loader = defaultLoader } = + createBits() function ActualComponent() { - return
About
; + return
About
+} +export { + ActualComponent, + createBits, + DefaultComponent, + defaultLoader, + loader, + MyComponent, } -export { ActualComponent, createBits, DefaultComponent, defaultLoader, loader, MyComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring.tsx index d80f17484f..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring.tsx @@ -1,11 +1,9 @@ import thing from 'thing' - export function test() { const { foo: { bar: { destructured }, }, } = thing - return destructured } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@component.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@component.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@errorComponent.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@errorComponent.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@notFoundComponent.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/destructuring@notFoundComponent.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue.tsx index 68f8be0364..5a116073c1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue.tsx @@ -1,8 +1,8 @@ -'use client'; - -const $$splitComponentImporter = () => import('directive-prologue.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +'use client' +const $$splitComponentImporter = () => + import('directive-prologue.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/directive')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue@component.tsx index ce7cd5e5ee..9ee4bd8f4c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/directive-prologue@component.tsx @@ -1,6 +1,5 @@ -'use client'; - +'use client' const SplitComponent = () => { - return
directive preserved
; -}; -export { SplitComponent as component }; \ No newline at end of file + return
directive preserved
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component.tsx index 4fdd9d1c68..8109a89624 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component.tsx @@ -1,6 +1,3 @@ import React from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: undefined, -}) +export const Route = createFileRoute('/')({ component: undefined }) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@component.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@component.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@notFoundComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/explicit-undefined-component@notFoundComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound.tsx index da4daa9a3f..7154b79acd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound.tsx @@ -1,15 +1,23 @@ -console.warn("[tanstack-router] These exports from \"export-default-component-and-normal-notFound.tsx\" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitNotFoundComponentImporter = () => import('export-default-component-and-normal-notFound.tsx?tsr-split=notFoundComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import React, { useState } from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +console.warn( + '[tanstack-router] These exports from "export-default-component-and-normal-notFound.tsx" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitNotFoundComponentImporter = () => + import('export-default-component-and-normal-notFound.tsx?tsr-split=notFoundComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import React, { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/home')({ component: Home, - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) export default function Home() { - const [one, setOne] = useState('this is from a state'); - return
+ const [one, setOne] = useState('this is from a state') + return ( +

{one}

-
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@component.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@component.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@notFoundComponent.tsx index 62cd0a1036..3da924c04c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component-and-normal-notFound@notFoundComponent.tsx @@ -1,5 +1,5 @@ -import React from 'react'; +import React from 'react' function NotFoundComponent() { - return
Not Found
; + return
Not Found
} -export { NotFoundComponent as notFoundComponent }; \ No newline at end of file +export { NotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component.tsx index c5198b9e00..de2d748c91 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component.tsx @@ -1,13 +1,8 @@ import React, { useState } from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/home')({ - component: Home, -}) - +export const Route = createFileRoute('/home')({ component: Home }) export default function Home() { const [one, setOne] = useState('this is from a state') - return (

{one}

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@component.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@component.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@notFoundComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/export-default-component@notFoundComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter.tsx index 3ae9710cd5..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter.tsx @@ -1,29 +1,20 @@ import * as React from 'react' // @ts-expect-error import { useMemo } from 'tan-react' - const useUsedVar = 'i-am-unused' - 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) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@component.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@component.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@errorComponent.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@errorComponent.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@notFoundComponent.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-as-parameter@notFoundComponent.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration.tsx index 5d7e2181f5..e2b672f7b8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('function-declaration.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('function-declaration.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@component.tsx index 3476c52d54..a0ebf07dee 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@component.tsx @@ -1,27 +1,31 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { Route } from "function-declaration.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { Route } from 'function-declaration.tsx' function PostsComponent() { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; +
+ ) } -export { PostsComponent as component }; \ No newline at end of file +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@errorComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@errorComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@notFoundComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/function-declaration@notFoundComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute.tsx index df71217488..82d7bb0cad 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('importAttribute.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute@component.tsx index f34d3c6408..88abef0c00 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/importAttribute@component.tsx @@ -1,3 +1,3 @@ -import { test } from './test' with { type: 'macro' }; -const SplitComponent = () => test; -export { SplitComponent as component }; \ No newline at end of file +import { test } from './test' with { type: 'macro' } +const SplitComponent = () => test +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader.tsx index 2271ab4454..4818827c9c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader.tsx @@ -1,8 +1,9 @@ -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'; +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'), - loader: importedLoader -}); \ No newline at end of file + loader: importedLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader@component.tsx index d21b198c98..9350cda9e8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component-destructured-loader@component.tsx @@ -1,3 +1,3 @@ -import importedComponent from '../../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import importedComponent from '../../shared/imported' +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component.tsx index dcd6f3d5e0..d213c7c5af 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('imported-default-component.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component@component.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-default-component@component.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent.tsx index 898e1b3618..e3702ed63b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@component.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@component.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@errorComponent.tsx index 7a8654fb94..3f20c3e485 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-errorComponent@errorComponent.tsx @@ -1,3 +1,3 @@ -import { importedErrorComponent } from '../../shared/imported'; -const SplitErrorComponent = importedErrorComponent; -export { SplitErrorComponent as errorComponent }; \ No newline at end of file +import { importedErrorComponent } from '../../shared/imported' +const SplitErrorComponent = importedErrorComponent +export { SplitErrorComponent as errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent.tsx index 4c5c19cfcf..0a203d3cf9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); \ No newline at end of file + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@component.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@component.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@notFoundComponent.tsx index c6cfd9797f..bfe9d4e1c9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-notFoundComponent@notFoundComponent.tsx @@ -1,3 +1,3 @@ -import { importedNotFoundComponent } from '../../shared/imported'; -const SplitNotFoundComponent = importedNotFoundComponent; -export { SplitNotFoundComponent as notFoundComponent }; \ No newline at end of file +import { importedNotFoundComponent } from '../../shared/imported' +const SplitNotFoundComponent = importedNotFoundComponent +export { SplitNotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent.tsx index 17adf19f06..751e1c9a50 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('imported-pendingComponent.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -import { importedPendingComponent } from '../../shared/imported'; +const $$splitComponentImporter = () => + import('imported-pendingComponent.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +import { importedPendingComponent } from '../../shared/imported' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - pendingComponent: importedPendingComponent -}); \ No newline at end of file + pendingComponent: importedPendingComponent, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent@component.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported-pendingComponent@component.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported.tsx index e92f76cf98..6ead4fbb5e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -import { importedLoader } from '../../shared'; +const $$splitComponentImporter = () => + import('imported.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +import { importedLoader } from '../../shared' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: importedLoader -}); \ No newline at end of file + loader: importedLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported@component.tsx index 5bc9da8d43..e3c06dbe9e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/imported@component.tsx @@ -1,3 +1,3 @@ -import { importedComponent } from '../../shared'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import { importedComponent } from '../../shared' +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline.tsx index c2b4dae416..7b39974d3a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline.tsx @@ -1,9 +1,9 @@ -const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -Route.addChildren([]); -export const test = 'test'; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +Route.addChildren([]) +export const test = 'test' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@component.tsx index 58ccfb2903..d28b872634 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@component.tsx @@ -1,18 +1,18 @@ -import * as React from 'react'; -import * as styles from '../style.css'; -import { TEST_DATA } from '../test.const'; -const Button = (props: { - children: any; -}) => { - return ; -}; -import { Route } from "inline.tsx"; -import { test } from "inline.tsx"; +import * as React from 'react' +import * as styles from '../style.css' +import { TEST_DATA } from '../test.const' +const Button = (props: { children: any }) => { + return +} +import { Route } from 'inline.tsx' +import { test } from 'inline.tsx' const SplitComponent = () => { - return
- {test} -

{TEST_DATA.welcome}

- -
; -}; -export { SplitComponent as component }; \ No newline at end of file + return ( +
+ {test} +

{TEST_DATA.welcome}

+ +
+ ) +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@errorComponent.tsx index 9236af6021..23fab71edc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -import { Route } from "inline.tsx"; \ No newline at end of file +import * as React from 'react' +import { Route } from 'inline.tsx' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@notFoundComponent.tsx index 9236af6021..23fab71edc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/inline@notFoundComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -import { Route } from "inline.tsx"; \ No newline at end of file +import * as React from 'react' +import { Route } from 'inline.tsx' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration.tsx index b2f908ab45..13cb142f27 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration.tsx @@ -1,12 +1,17 @@ -const $$splitErrorComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=errorComponent'); -const $$splitComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitErrorComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=errorComponent') +const $$splitComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), pendingComponent, - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) function pendingComponent() { - return
lowercase pending function declaration
; -} \ No newline at end of file + return
lowercase pending function declaration
+} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@component.tsx index 65735a0f20..e53a2acebf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@component.tsx @@ -1,4 +1,4 @@ function component() { - return
lowercase function declaration
; + return
lowercase function declaration
} -export { component }; \ No newline at end of file +export { component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@errorComponent.tsx index acc1c0be8d..9d411c1f0f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/lowercase-function-declaration@errorComponent.tsx @@ -1,4 +1,4 @@ function errorComponent() { - return
lowercase error function declaration
; + return
lowercase error function declaration
} -export { errorComponent }; \ No newline at end of file +export { errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number.tsx index 0cb0a2e13b..c9e47e1145 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number.tsx @@ -1,32 +1,45 @@ -const $$splitComponentImporter = () => import('random-number.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { Await, Link, createFileRoute, defer } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import { getSponsorsForSponsorPack } from '~/server/sponsors'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -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`]; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; +const $$splitComponentImporter = () => + import('random-number.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { Await, Link, createFileRoute, defer } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import { getSponsorsForSponsorPack } from '~/server/sponsors' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +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`, +] +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] export const Route = createFileRoute('/')({ loader: () => { return { randomNumber: Math.random(), - sponsorsPromise: defer(getSponsorsForSponsorPack()) - }; + sponsorsPromise: defer(getSponsorsForSponsorPack()), + } }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@component.tsx index 9ed6d15184..26a9f9c142 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@component.tsx @@ -1,61 +1,48 @@ -import { Await, Link } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import discordImage from '~/images/discord-logo-white.svg'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -import { useMutation } from '~/hooks/useMutation'; -import { sample } from '~/utils/utils'; -import { textColors } from "random-number.tsx"; -import { gradients } from "random-number.tsx"; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; -import { Route } from "random-number.tsx"; -async function bytesSignupServerFn({ - email -}: { - email: string; -}) { - 'use server'; - +import { Await, Link } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import discordImage from '~/images/discord-logo-white.svg' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +import { useMutation } from '~/hooks/useMutation' +import { sample } from '~/utils/utils' +import { textColors } from 'random-number.tsx' +import { gradients } from 'random-number.tsx' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] +import { Route } from 'random-number.tsx' +async function bytesSignupServerFn({ email }: { email: string }) { + 'use server' return fetch(`https://bytes.dev/api/bytes-optin-cors`, { method: 'POST', - body: JSON.stringify({ - email, - influencer: 'tanstack' - }), - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json' - } - }); + body: JSON.stringify({ email, influencer: 'tanstack' }), + headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, + }) } function Index() { - const bytesSignupMutation = useMutation({ - fn: bytesSignupServerFn - }); - const { - sponsorsPromise, - randomNumber, - testing2 - } = Route.useLoaderData(); - const gradient = sample(gradients, randomNumber); - const textColor = sample(textColors, randomNumber); - return <> + const bytesSignupMutation = useMutation({ fn: bytesSignupServerFn }) + const { sponsorsPromise, randomNumber, testing2 } = Route.useLoaderData() + const gradient = sample(gradients, randomNumber) + const textColor = sample(textColors, randomNumber) + return ( + <> {discordImage} {gradient} {textColor} - ; + + ) } -export { Index as component }; \ No newline at end of file +export { Index as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@errorComponent.tsx index cdf4d37891..8e156eca17 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@errorComponent.tsx @@ -1,18 +1,20 @@ -import { Await, Link } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; \ No newline at end of file +import { Await, Link } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@notFoundComponent.tsx index cdf4d37891..8e156eca17 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/random-number@notFoundComponent.tsx @@ -1,18 +1,20 @@ -import { Await, Link } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; \ No newline at end of file +import { Await, Link } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component.tsx index 5fd96f8da1..229a2d0f80 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component.tsx @@ -1,8 +1,9 @@ -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'; +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'), - loader: importedLoader -}); \ No newline at end of file + loader: importedLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component@component.tsx index dfef29c9e3..6bdb537fe9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-component@component.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React from 'react' function Component() { - return
Component
; + return
Component
} -const SplitComponent = React.memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = React.memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component.tsx index 69df0886db..701826b3f6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component.tsx @@ -1,8 +1,9 @@ -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'; +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'), - loader: importedLoader -}); \ No newline at end of file + loader: importedLoader, +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component@component.tsx index 540812230e..d162a1aeaf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/react-memo-imported-component@component.tsx @@ -1,4 +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 +import React from 'react' +import { importedComponent } from '../../shared/imported' +const SplitComponent = React.memo(importedComponent) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component.tsx index 1ae234de6f..f2078a1757 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component.tsx @@ -4,7 +4,6 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export function Layout() { return (
@@ -22,12 +21,10 @@ export function Layout() {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: importedLoader, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' const SIDEBAR_MINI_WIDTH = '80px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@component.tsx index 5bb0ab5451..8fb12f0c6b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@component.tsx @@ -1,3 +1,3 @@ -import * as React from 'react'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@errorComponent.tsx index 5bb0ab5451..8fb12f0c6b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@errorComponent.tsx @@ -1,3 +1,3 @@ -import * as React from 'react'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@notFoundComponent.tsx index 5bb0ab5451..8fb12f0c6b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-export-component@notFoundComponent.tsx @@ -1,3 +1,3 @@ -import * as React from 'react'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const.tsx index f256b01a83..d674dbb799 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export const loaderFn = () => { return importedLoader() } - const Layout = () => { return (
@@ -26,15 +24,12 @@ const Layout = () => {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@component.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@component.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@notFoundComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-const@notFoundComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured.tsx index 0e3175116f..89c23305a0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured.tsx @@ -1,18 +1,12 @@ import { createFileRoute } from '@tanstack/react-router' - const createBits = () => ({ component: AboutComponentImpl, - loader: () => ({ - message: 'hello', - }), + loader: () => ({ message: 'hello' }), }) - export const { component: AboutComponent, loader } = createBits() - function AboutComponentImpl() { return
About
} - export const Route = createFileRoute('/about')({ component: AboutComponent, loader, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@component.tsx index a6d57afe77..d64b42fdcc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@component.tsx @@ -1,2 +1,2 @@ -import { AboutComponent } from "retain-exports-destructured.tsx?tsr-shared=1"; -export { AboutComponent as component }; \ No newline at end of file +import { AboutComponent } from 'retain-exports-destructured.tsx?tsr-shared=1' +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@shared.tsx index b03a4eb83a..6eff1ff083 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-destructured@shared.tsx @@ -1,14 +1,9 @@ const createBits = () => ({ component: AboutComponentImpl, - loader: () => ({ - message: 'hello' - }) -}); -const { - component: AboutComponent, - loader -} = createBits(); + loader: () => ({ message: 'hello' }), +}) +const { component: AboutComponent, loader } = createBits() function AboutComponentImpl() { - return
About
; + return
About
} -export { AboutComponent, AboutComponentImpl, createBits, loader }; \ No newline at end of file +export { AboutComponent, AboutComponentImpl, createBits, loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function.tsx index 298c388e65..83b3dd4eb5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export function loaderFn() { return importedLoader() } - function Layout() { return (
@@ -26,15 +24,12 @@ function Layout() {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@component.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@component.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@notFoundComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-function@notFoundComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader.tsx index 88cd35f704..16357edc27 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader.tsx @@ -1,16 +1,15 @@ -const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('retain-exports-loader.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export function loaderFn() { - return { - foo: 'bar' - }; + return { foo: 'bar' } } export const Route = createFileRoute('/_layout')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: loaderFn -}); -export const SIDEBAR_WIDTH = '150px'; -export const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file + loader: loaderFn, +}) +export const SIDEBAR_WIDTH = '150px' +export const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@component.tsx index 9f54ae0dc5..604be4dc69 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@component.tsx @@ -1,11 +1,10 @@ -import * as React from 'react'; -import { Outlet } from '@tanstack/react-router'; -import { importedComponent as ImportedComponent } from '../../shared/imported'; +import * as React from 'react' +import { Outlet } from '@tanstack/react-router' +import { importedComponent as ImportedComponent } from '../../shared/imported' function Layout() { - return
-
+ return ( +
+
-
; +
+ ) } -const HEADER_HEIGHT = '63px'; -const ASIDE_WIDTH = '250px'; -export { Layout as component }; \ No newline at end of file +const HEADER_HEIGHT = '63px' +const ASIDE_WIDTH = '250px' +export { Layout as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@notFoundComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/retain-exports-loader@notFoundComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class.tsx index 6e2f0229e4..19509e3bdd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class.tsx @@ -1,10 +1,11 @@ -import { store } from "shared-class.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-class.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { store } from 'shared-class.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-class.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/store')({ loader: async () => { - store.set('items', await fetch('/api')); + store.set('items', await fetch('/api')) }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@component.tsx index 6a38b10ff8..e0e187fb1d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@component.tsx @@ -1,3 +1,3 @@ -import { store } from "shared-class.tsx?tsr-shared=1"; -const SplitComponent = () =>
{store.get('items')}
; -export { SplitComponent as component }; \ No newline at end of file +import { store } from 'shared-class.tsx?tsr-shared=1' +const SplitComponent = () =>
{store.get('items')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@shared.tsx index 18c40bafb6..0abc282ecc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-class@shared.tsx @@ -1,11 +1,11 @@ class DataStore { - data = new Map(); + data = new Map() get(k: string) { - return this.data.get(k); + return this.data.get(k) } set(k: string, v: unknown) { - this.data.set(k, v); + this.data.set(k, v) } } -const store = new DataStore(); -export { DataStore, store }; \ No newline at end of file +const store = new DataStore() +export { DataStore, store } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export.tsx index 9453dbfbda..dc4d2d383f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export.tsx @@ -1,9 +1,10 @@ -import { apiUrl } from "shared-destructured-export.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-destructured-export.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { apiUrl } from 'shared-destructured-export.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-destructured-export.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/config')({ loader: async () => fetch(apiUrl), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -export { apiUrl, timeout } from "shared-destructured-export.tsx?tsr-shared=1"; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +export { apiUrl, timeout } from 'shared-destructured-export.tsx?tsr-shared=1' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@component.tsx index 16b288ac5f..8cd0f14a27 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@component.tsx @@ -1,3 +1,3 @@ -import { timeout } from "shared-destructured-export.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { timeout } from 'shared-destructured-export.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@shared.tsx index f0bfd70add..ae9324acc9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured-export@shared.tsx @@ -1,11 +1,5 @@ -const { - apiUrl, - timeout -} = getConfig(); +const { apiUrl, timeout } = getConfig() function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; + return { apiUrl: '/api', timeout: 5000 } } -export { apiUrl, getConfig, timeout }; \ No newline at end of file +export { apiUrl, getConfig, timeout } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured.tsx index 3019454516..b1d4f96065 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured.tsx @@ -1,8 +1,9 @@ -import { apiUrl } from "shared-destructured.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-destructured.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { apiUrl } from 'shared-destructured.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-destructured.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/config')({ loader: async () => fetch(apiUrl), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@component.tsx index 5c0182e61a..3d7933a573 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@component.tsx @@ -1,3 +1,3 @@ -import { timeout } from "shared-destructured.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { timeout } from 'shared-destructured.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@shared.tsx index f0bfd70add..ae9324acc9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-destructured@shared.tsx @@ -1,11 +1,5 @@ -const { - apiUrl, - timeout -} = getConfig(); +const { apiUrl, timeout } = getConfig() function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; + return { apiUrl: '/api', timeout: 5000 } } -export { apiUrl, getConfig, timeout }; \ No newline at end of file +export { apiUrl, getConfig, timeout } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported.tsx index c2eb8b1012..aa9730bec7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported.tsx @@ -1,13 +1,12 @@ -import { queryOptions } from "shared-exported.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-exported.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { queryOptions } from 'shared-exported.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-exported.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/query')({ loader: async () => { - return { - staleTime: queryOptions.staleTime - }; + return { staleTime: queryOptions.staleTime } }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -export { queryOptions } from "shared-exported.tsx?tsr-shared=1"; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +export { queryOptions } from 'shared-exported.tsx?tsr-shared=1' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@component.tsx index b020b5cadf..9fe61942dd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@component.tsx @@ -1,3 +1,3 @@ -import { queryOptions } from "shared-exported.tsx?tsr-shared=1"; -const SplitComponent = () =>
GC: {queryOptions.gcTime}
; -export { SplitComponent as component }; \ No newline at end of file +import { queryOptions } from 'shared-exported.tsx?tsr-shared=1' +const SplitComponent = () =>
GC: {queryOptions.gcTime}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@shared.tsx index a3f91b85bb..3a1ff108bb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-exported@shared.tsx @@ -1,5 +1,2 @@ -const queryOptions = { - staleTime: 5000, - gcTime: 10000 -}; -export { queryOptions }; \ No newline at end of file +const queryOptions = { staleTime: 5000, gcTime: 10000 } +export { queryOptions } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function.tsx index 7372ff4b07..d4f3d89f2d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function.tsx @@ -1,14 +1,15 @@ -import { getCached, cache } from "shared-function.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { getCached, cache } from 'shared-function.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' function setCached(key: string, val: unknown) { - cache.set(key, val); + cache.set(key, val) } export const Route = createFileRoute('/cached')({ loader: async () => { - setCached('data', await fetch('/api').then(r => r.json())); - return getCached('data'); + setCached('data', await fetch('/api').then((r) => r.json())) + return getCached('data') }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@component.tsx index 571bd9356a..1c327523af 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@component.tsx @@ -1,3 +1,3 @@ -import { getCached } from "shared-function.tsx?tsr-shared=1"; -const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
; -export { SplitComponent as component }; \ No newline at end of file +import { getCached } from 'shared-function.tsx?tsr-shared=1' +const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@shared.tsx index 27d2cf03f1..243ac23a66 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-function@shared.tsx @@ -1,5 +1,5 @@ -const cache = new Map(); +const cache = new Map() function getCached(key: string) { - return cache.get(key); + return cache.get(key) } -export { cache, getCached }; \ No newline at end of file +export { cache, getCached } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding.tsx index c3e284c081..da3387c5fd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('shared-imported-binding.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -import { sharedUtil } from '../utils'; +const $$splitComponentImporter = () => + import('shared-imported-binding.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +import { sharedUtil } from '../utils' export const Route = createFileRoute('/imported')({ loader: async () => sharedUtil('load'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding@component.tsx index 0a835ae063..e3c8a0f5d8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-imported-binding@component.tsx @@ -1,3 +1,3 @@ -import { sharedUtil } from '../utils'; -const SplitComponent = () =>
{sharedUtil('render')}
; -export { SplitComponent as component }; \ No newline at end of file +import { sharedUtil } from '../utils' +const SplitComponent = () =>
{sharedUtil('render')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref.tsx index 889dd57cf0..244f566066 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref.tsx @@ -1,13 +1,12 @@ -import { state, getCount } from "shared-indirect-ref.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-indirect-ref.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { state, getCount } from 'shared-indirect-ref.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-indirect-ref.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/shared-indirect')({ loader: () => { - state.count++; - return { - count: getCount() - }; + state.count++ + return { count: getCount() } }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@component.tsx index 62995e7fd8..64bb6ab567 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@component.tsx @@ -1,7 +1,9 @@ -import { state, getCount } from "shared-indirect-ref.tsx?tsr-shared=1"; +import { state, getCount } from 'shared-indirect-ref.tsx?tsr-shared=1' function SharedComponent() { - return
+ return ( +
{getCount()} - {state.count} -
; +
+ ) } -export { SharedComponent as component }; \ No newline at end of file +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@shared.tsx index 7e7e811ba8..b4910d2fd1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-indirect-ref@shared.tsx @@ -1,7 +1,5 @@ -const state = { - count: 0 -}; +const state = { count: 0 } function getCount() { - return state.count; + return state.count } -export { getCount, state }; \ No newline at end of file +export { getCount, state } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref.tsx index 728caca361..6b29c09f33 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref.tsx @@ -1,9 +1,10 @@ -import { shared } from "shared-jsx-component-ref.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-jsx-component-ref.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; +import { shared } from 'shared-jsx-component-ref.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-jsx-component-ref.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' // @ts-nocheck -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/jsx')({ loader: () => shared, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@component.tsx index 52ecb6d474..845e1db45c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@component.tsx @@ -1,5 +1,5 @@ -import { shared } from "shared-jsx-component-ref.tsx?tsr-shared=1"; // @ts-nocheck +import { shared } from 'shared-jsx-component-ref.tsx?tsr-shared=1' // @ts-nocheck function SharedComponent() { - return
{shared}
; + return
{shared}
} -export { SharedComponent as component }; \ No newline at end of file +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@shared.tsx index d5cc2cf990..60ae1006a1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-jsx-component-ref@shared.tsx @@ -1,4 +1,3 @@ // @ts-nocheck - -const shared = 1; -export { shared }; \ No newline at end of file +const shared = 1 +export { shared } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none.tsx index dd352bfc41..6d0ece44ba 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('shared-none.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -const loaderHelper = () => fetch('/api'); +const $$splitComponentImporter = () => + import('shared-none.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +const loaderHelper = () => fetch('/api') export const Route = createFileRoute('/clean')({ loader: async () => loaderHelper(), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none@component.tsx index 701deeedeb..1bfd4eb63f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-none@component.tsx @@ -1,5 +1,7 @@ -const ComponentHelper = () => helper; -const SplitComponent = () =>
- -
; -export { SplitComponent as component }; \ No newline at end of file +const ComponentHelper = () => helper +const SplitComponent = () => ( +
+ +
+) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route.tsx index f82ac5b900..1ac3428ebc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route.tsx @@ -1,16 +1,15 @@ -import { HEADER } from "shared-referencing-route.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-referencing-route.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { HEADER } from 'shared-referencing-route.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-referencing-route.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' function usePageTitle() { - return `${HEADER} - ${Route.fullPath}`; + return `${HEADER} - ${Route.fullPath}` } export const Route = createFileRoute('/about')({ loader: async () => { - const title = usePageTitle(); - return { - title - }; + const title = usePageTitle() + return { title } }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@component.tsx index 2cb2cdb68c..b2c4630c90 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@component.tsx @@ -1,10 +1,10 @@ -import { HEADER } from "shared-referencing-route.tsx?tsr-shared=1"; +import { HEADER } from 'shared-referencing-route.tsx?tsr-shared=1' function usePageTitle() { - return `${HEADER} - ${Route.fullPath}`; + return `${HEADER} - ${Route.fullPath}` } -import { Route } from "shared-referencing-route.tsx"; +import { Route } from 'shared-referencing-route.tsx' const SplitComponent = () => { - const title = usePageTitle(); - return
{title}
; -}; -export { SplitComponent as component }; \ No newline at end of file + const title = usePageTitle() + return
{title}
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@shared.tsx index cc2d01424c..34b9c4ca41 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-referencing-route@shared.tsx @@ -1,2 +1,2 @@ -const HEADER = 'Page'; -export { HEADER }; \ No newline at end of file +const HEADER = 'Page' +export { HEADER } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime.tsx index c230b4d37f..17d70ca9bd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime.tsx @@ -1,23 +1,25 @@ -import { state, createState, createSeed, increment } from "shared-runtime.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-runtime.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('shared-runtime:reference'); +import { + state, + createState, + createSeed, + increment, +} from 'shared-runtime.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-runtime.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('shared-runtime:reference') export const Route = createFileRoute('/shared-runtime')({ beforeLoad: () => state, loader: () => { - increment(); - return state; + increment() + return state }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@component.tsx index fbccf6c90b..5245f6d9eb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@component.tsx @@ -1,23 +1,24 @@ -import { state, createState, createSeed, Labels } from "shared-runtime.tsx?tsr-shared=1"; -const label = createComponentLabel(); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -function createComponentLabel() { - console.log('shared-runtime:component'); - return Labels.component; +import { + state, + createState, + createSeed, + Labels, +} from 'shared-runtime.tsx?tsr-shared=1' +const label = createComponentLabel() +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number } -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; +function createComponentLabel() { + console.log('shared-runtime:component') + return Labels.component +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed const SplitComponent = () => { if (state.count === 3) { - throw new Error('route source-map contract'); + throw new Error('route source-map contract') } - return `${label}:${state.count}`; -}; -export { SplitComponent as component }; \ No newline at end of file + return `${label}:${state.count}` +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@errorComponent.tsx index d890a562c9..03cacac5b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@errorComponent.tsx @@ -1,11 +1,7 @@ -import { state, createState, createSeed } from "shared-runtime.tsx?tsr-shared=1"; -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file +import { state, createState, createSeed } from 'shared-runtime.tsx?tsr-shared=1' +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@notFoundComponent.tsx index d890a562c9..03cacac5b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@notFoundComponent.tsx @@ -1,11 +1,7 @@ -import { state, createState, createSeed } from "shared-runtime.tsx?tsr-shared=1"; -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file +import { state, createState, createSeed } from 'shared-runtime.tsx?tsr-shared=1' +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@shared.tsx index 54239b6cc5..c53a7e1568 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-runtime@shared.tsx @@ -1,28 +1,13 @@ -const Count = { - Initial: 0 -}; -const Labels = { - component: 'count' -}; -const seed = createSeed(); -const { - state, - increment -} = createState(seed); +const Count = { Initial: 0 } +const Labels = { component: 'count' } +const seed = createSeed() +const { state, increment } = createState(seed) function createSeed() { - console.log('shared-runtime:seed'); - return { - count: Count.Initial, - label: Labels.component - }; + console.log('shared-runtime:seed') + return { count: Count.Initial, label: Labels.component } } -function createState(initialState: { - count: number; -}) { - console.log('shared-runtime:state'); - return { - state: initialState, - increment: () => initialState.count++ - }; +function createState(initialState: { count: number }) { + console.log('shared-runtime:state') + return { state: initialState, increment: () => initialState.count++ } } -export { Count, createSeed, createState, increment, Labels, seed, state }; \ No newline at end of file +export { Count, createSeed, createState, increment, Labels, seed, state } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive.tsx index ce5a10c47c..3860bd4688 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive.tsx @@ -1,11 +1,12 @@ -import { config } from "shared-transitive.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-transitive.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -const fetcher = (path: string) => fetch(`${config.url}${path}`); +import { config } from 'shared-transitive.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-transitive.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +const fetcher = (path: string) => fetch(`${config.url}${path}`) export const Route = createFileRoute('/api')({ loader: async () => { - return fetcher('/data'); + return fetcher('/data') }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@component.tsx index 7a3a74048e..c237a03583 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@component.tsx @@ -1,3 +1,3 @@ -import { config } from "shared-transitive.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {config.timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { config } from 'shared-transitive.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {config.timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@shared.tsx index 8bec4a1d55..ac44498714 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-transitive@shared.tsx @@ -1,6 +1,3 @@ -const BASE_URL = 'https://api.example.com'; -const config = { - url: BASE_URL, - timeout: 5000 -}; -export { BASE_URL, config }; \ No newline at end of file +const BASE_URL = 'https://api.example.com' +const config = { url: BASE_URL, timeout: 5000 } +export { BASE_URL, config } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable.tsx index c0c02cec46..f7b7b51f4d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable.tsx @@ -1,13 +1,12 @@ -import { collection } from "shared-variable.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-variable.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +import { collection } from 'shared-variable.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-variable.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/todos')({ loader: async () => { - await collection.preload(); - return { - data: 'loaded' - }; + await collection.preload() + return { data: 'loaded' } }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@component.tsx index d149922fbc..10325aa95e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@component.tsx @@ -1,3 +1,3 @@ -import { collection } from "shared-variable.tsx?tsr-shared=1"; -const SplitComponent = () =>
{collection.name}
; -export { SplitComponent as component }; \ No newline at end of file +import { collection } from 'shared-variable.tsx?tsr-shared=1' +const SplitComponent = () =>
{collection.name}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@shared.tsx index 8a0560d5b9..10421dac09 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-variable@shared.tsx @@ -1,5 +1,2 @@ -const collection = { - name: 'todos', - preload: async () => {} -}; -export { collection }; \ No newline at end of file +const collection = { name: 'todos', preload: async () => {} } +export { collection } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect.tsx index cba0c7770b..39bbc717d9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect.tsx @@ -1,11 +1,12 @@ -import { registry } from "shared-with-side-effect.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-with-side-effect.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('registry created'); +import { registry } from 'shared-with-side-effect.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-with-side-effect.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('registry created') export const Route = createFileRoute('/fx')({ loader: async () => { - registry.set('loaded', true); + registry.set('loaded', true) }, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@component.tsx index d953af00fa..3ede22c8be 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@component.tsx @@ -1,3 +1,3 @@ -import { registry } from "shared-with-side-effect.tsx?tsr-shared=1"; -const SplitComponent = () =>
{registry.size}
; -export { SplitComponent as component }; \ No newline at end of file +import { registry } from 'shared-with-side-effect.tsx?tsr-shared=1' +const SplitComponent = () =>
{registry.size}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@shared.tsx index f26c656fdd..a59298f9e0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/shared-with-side-effect@shared.tsx @@ -1,2 +1,2 @@ -const registry = new Map(); -export { registry }; \ No newline at end of file +const registry = new Map() +export { registry } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/undefined-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/undefined-literals.tsx index 0c6e4f01aa..88b0bf1ba8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/undefined-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/undefined-literals.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/undefined-test')({ component: undefined, errorComponent: undefined, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure.tsx index d0de09bf8b..b5b3ecade6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure.tsx @@ -1,5 +1,4 @@ import * as React from 'react' - import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg' import { FaBolt, @@ -21,7 +20,6 @@ import { startProject } from '~/projects/start' import { createFileRoute } from '@tanstack/react-router' import { Framework, getBranch } from '~/projects' import { seo } from '~/utils/seo' - const menu = [ { label: ( @@ -72,31 +70,22 @@ const menu = [ to: `https://cottonbureau.com/people/tanstack`, }, ] - export const Route = createFileRoute('/_libraries/start/$version/')({ component: VersionIndex, meta: () => - seo({ - title: startProject.name, - description: startProject.description, - }), + seo({ title: startProject.name, description: startProject.description }), }) - const librariesRouteApi = getRouteApi('/_libraries') - export default function VersionIndex() { const { sponsorsPromise } = librariesRouteApi.useLoaderData() const { version } = Route.useParams() const branch = getBranch(startProject, version) const [framework, setFramework] = React.useState('react') const [isDark, 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 (
{item.label}
) - return (
{item.to.startsWith('http') ? ( @@ -269,7 +257,6 @@ Check it out at https://tanstack.com/start/`,
*/} - {/*

@@ -315,7 +302,6 @@ Check it out at https://tanstack.com/start/`, })}

*/} - {/*
Trusted in Production by @@ -358,7 +344,6 @@ Check it out at https://tanstack.com/start/`,
*/} -

Partners @@ -388,16 +373,13 @@ Check it out at https://tanstack.com/start/`,

-

Sponsors

-
@@ -429,7 +410,6 @@ Check it out at https://tanstack.com/start/`, rage-quit OSS. Yay money! 😉
- {/*

@@ -468,7 +448,6 @@ Check it out at https://tanstack.com/start/`,

*/} - {/* {[''].includes(framework) ? (
@@ -503,7 +482,6 @@ Check it out at https://tanstack.com/start/`, >
)} */} - {/*
Wow, you've come a long way! diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@component.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@component.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@errorComponent.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@errorComponent.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@notFoundComponent.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/1-default/useStateDestructure@notFoundComponent.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function.tsx index ad71347222..29a53d433e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function.tsx @@ -1,10 +1,12 @@ -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=loader'); -import { lazyFn } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +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=loader') +import { lazyFn } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index 7fe3edee11..e36e48f495 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,27 +1,31 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { Route } from "arrow-function.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; -}; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@loader.tsx index cb195afdd8..1c4fc213ed 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/arrow-function@loader.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; -import { fetchPosts } from '../posts'; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +import * as React from 'react' +import { fetchPosts } from '../posts' +const SplitLoader = fetchPosts +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals.tsx index c31ee0e095..05711582b7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals.tsx @@ -1,13 +1,14 @@ -const $$splitLoaderImporter = () => import('boolean-null-literals.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('boolean-null-literals.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/router'; - +const $$splitLoaderImporter = () => + import('boolean-null-literals.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +const $$splitComponentImporter = () => + import('boolean-null-literals.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/router' // Test errorComponent with false literal export const Route = createFileRoute('/test')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), errorComponent: false, pendingComponent: null, - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@component---errorComponent---notFoundComponent---pendingComponent.tsx index c49c9e93a3..557105b6a3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ // Test errorComponent with false literal -const SplitComponent = () =>
Test Component
; -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = () =>
Test Component
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@loader.tsx index 666ed1e7ec..0e19f8cafe 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/boolean-null-literals@loader.tsx @@ -1,5 +1,3 @@ // Test errorComponent with false literal -const SplitLoader = async () => ({ - data: 'test' -}); -export { SplitLoader as loader }; \ No newline at end of file +const SplitLoader = async () => ({ data: 'test' }) +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese.tsx index 327e227da4..41db95b98c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese.tsx @@ -1,10 +1,11 @@ -const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('chinese.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx index 003ca944a1..2ac1fa54ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,23 +1,27 @@ -import * as React from 'react'; +import * as React from 'react' function HomeComponent() { - return
+ return ( +
-
; +
+ ) } interface DemoProps { - title: string; + title: string } -function Demo({ - title -}: DemoProps) { - return

+function Demo({ title }: DemoProps) { + return ( +

{title} -

; + + ) } -export { HomeComponent as component }; \ No newline at end of file +export { HomeComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@loader.tsx index b4de370f4e..cbcea8cc40 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/chinese@loader.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from 'react' interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function.tsx index ec4cff827d..38e3239ffd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-arrow-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-arrow-function.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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index 39ace71ebe..59c5b5eec2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } const App = () => { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; -}; -function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; +
+ ) } -export { App as component }; \ No newline at end of file +function OtherComponent() { + const componentName = getComponentName({ App }) + return
App component name is {componentName}
+} +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function.tsx index e4a82d1022..b3bdc6b113 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-function.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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index 96a753ad8a..22fbb8669f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/circular-reference-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } function App() { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; +
+ ) } function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; + const componentName = getComponentName({ App }) + return
App component name is {componentName}
} -export { App as component }; \ No newline at end of file +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties.tsx index c20dcdc135..e8296b890b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties.tsx @@ -1,9 +1,11 @@ -const $$splitLoaderImporter = () => import('conditional-properties.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('conditional-properties.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => + import('conditional-properties.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +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')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx index aaf3410c69..e460c54467 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +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 +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 } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@loader.tsx index e10f305ddc..e5872a344c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/conditional-properties@loader.tsx @@ -1,5 +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 +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 } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple.tsx index e411fd54d8..f9e740d637 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple.tsx @@ -1,15 +1,13 @@ -const $$splitComponentImporter = () => import('destructured-export-multiple.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-multiple.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const getConfig = () => ({ baseUrl: 'https://api.example.com', - timeout: 5000 -}); -export const { - baseUrl, - timeout -} = getConfig(); -export const [first, second] = [1, 2]; + timeout: 5000, +}) +export const { baseUrl, timeout } = getConfig() +export const [first, second] = [1, 2] export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple@component---errorComponent---notFoundComponent---pendingComponent.tsx index 9441b5a689..6a15a59c0a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-multiple@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,8 +1,10 @@ -import { baseUrl, timeout } from "destructured-export-multiple.tsx"; +import { baseUrl, timeout } from 'destructured-export-multiple.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

Timeout: {timeout}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested.tsx index 076c24b06f..f4fafce158 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested.tsx @@ -1,19 +1,16 @@ -const $$splitComponentImporter = () => import('destructured-export-nested.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-nested.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' const getConfig = () => ({ - api: { - baseUrl: 'https://api.example.com' - }, + api: { baseUrl: 'https://api.example.com' }, timeout: 5000, - extra: 'data' -}); + extra: 'data', +}) export const { - api: { - baseUrl - }, + api: { baseUrl }, ...rest -} = getConfig(); +} = getConfig() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested@component---errorComponent---notFoundComponent---pendingComponent.tsx index 8ba46e33e1..9bc538525f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export-nested@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,9 @@ -import { baseUrl } from "destructured-export-nested.tsx"; +import { baseUrl } from 'destructured-export-nested.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export.tsx index 3f79ca544b..b56d070279 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export.tsx @@ -1,17 +1,11 @@ -const $$splitComponentImporter = () => import('destructured-export.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } -export const { - getObject -} = getObjectCallback(); +export const { getObject } = getObjectCallback() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx index f58942d5af..b0abbd2e6e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,14 +1,11 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } function AboutComponent() { - return
+ return ( +

About

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@loader.tsx index 45fb19eecd..024e0e620e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-export@loader.tsx @@ -1,8 +1,3 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; -} \ No newline at end of file + return { getObject: () => ({ constA: 10, constB: 5 }) } +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component.tsx index c27220acce..e914a58628 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component.tsx @@ -1,9 +1,11 @@ -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=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index 446d55e26b..88dcdf6e48 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ -import { memo } from 'react'; +import { memo } from 'react' function Component() { - return
Component
; + return
Component
} -const SplitComponent = memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@loader.tsx index 52e811be53..8691aec6ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-react-memo-imported-component@loader.tsx @@ -1,3 +1,3 @@ -import { importedLoader } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import { importedLoader } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults.tsx index 1759b05846..bf26704b82 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults.tsx @@ -1,9 +1,11 @@ -const $$splitLoaderImporter = () => import('destructured-route-options-defaults.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('destructured-route-options-defaults.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => + import('destructured-route-options-defaults.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +const $$splitComponentImporter = () => + import('destructured-route-options-defaults.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/about')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@component---errorComponent---notFoundComponent---pendingComponent.tsx index c73696ff32..c26d6be33d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import { MyComponent } from "destructured-route-options-defaults.tsx?tsr-shared=1"; -export { MyComponent as component }; \ No newline at end of file +import { MyComponent } from 'destructured-route-options-defaults.tsx?tsr-shared=1' +export { MyComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@loader.tsx index 99d9619b91..3caedc3e55 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@loader.tsx @@ -1,2 +1,2 @@ -import { loader } from "destructured-route-options-defaults.tsx?tsr-shared=1"; -export { loader }; \ No newline at end of file +import { loader } from 'destructured-route-options-defaults.tsx?tsr-shared=1' +export { loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@shared.tsx index fdc9acef5b..a7dee6af52 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructured-route-options-defaults@shared.tsx @@ -1,22 +1,23 @@ function defaultLoader() { - return { - message: 'default' - }; + return { message: 'default' } } function DefaultComponent() { - return
Default
; + return
Default
} const createBits = () => ({ component: ActualComponent, - loader: () => ({ - message: 'hello' - }) -}); -const { - component: MyComponent = DefaultComponent, - loader = defaultLoader -} = createBits(); + loader: () => ({ message: 'hello' }), +}) +const { component: MyComponent = DefaultComponent, loader = defaultLoader } = + createBits() function ActualComponent() { - return
About
; + return
About
+} +export { + ActualComponent, + createBits, + DefaultComponent, + defaultLoader, + loader, + MyComponent, } -export { ActualComponent, createBits, DefaultComponent, defaultLoader, loader, MyComponent }; \ No newline at end of file diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring.tsx index d80f17484f..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring.tsx @@ -1,11 +1,9 @@ import thing from 'thing' - export function test() { const { foo: { bar: { destructured }, }, } = thing - return destructured } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@loader.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/destructuring@loader.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue.tsx index 12d3529331..a5bca5a02c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue.tsx @@ -1,8 +1,8 @@ -'use client'; - -const $$splitComponentImporter = () => import('directive-prologue.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +'use client' +const $$splitComponentImporter = () => + import('directive-prologue.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/directive')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue@component---errorComponent---notFoundComponent---pendingComponent.tsx index ce7cd5e5ee..9ee4bd8f4c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/directive-prologue@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,5 @@ -'use client'; - +'use client' const SplitComponent = () => { - return
directive preserved
; -}; -export { SplitComponent as component }; \ No newline at end of file + return
directive preserved
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component.tsx index 4fdd9d1c68..8109a89624 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component.tsx @@ -1,6 +1,3 @@ import React from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: undefined, -}) +export const Route = createFileRoute('/')({ component: undefined }) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@loader.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/explicit-undefined-component@loader.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound.tsx index 0ca25a7017..fc6cef74a4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound.tsx @@ -1,15 +1,23 @@ -console.warn("[tanstack-router] These exports from \"export-default-component-and-normal-notFound.tsx\" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitNotFoundComponentImporter = () => import('export-default-component-and-normal-notFound.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import React, { useState } from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +console.warn( + '[tanstack-router] These exports from "export-default-component-and-normal-notFound.tsx" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitNotFoundComponentImporter = () => + import('export-default-component-and-normal-notFound.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import React, { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/home')({ component: Home, - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) export default function Home() { - const [one, setOne] = useState('this is from a state'); - return
+ const [one, setOne] = useState('this is from a state') + return ( +

{one}

-
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@component---errorComponent---notFoundComponent---pendingComponent.tsx index 62cd0a1036..3da924c04c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import React from 'react'; +import React from 'react' function NotFoundComponent() { - return
Not Found
; + return
Not Found
} -export { NotFoundComponent as notFoundComponent }; \ No newline at end of file +export { NotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@loader.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component-and-normal-notFound@loader.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component.tsx index c5198b9e00..de2d748c91 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component.tsx @@ -1,13 +1,8 @@ import React, { useState } from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/home')({ - component: Home, -}) - +export const Route = createFileRoute('/home')({ component: Home }) export default function Home() { const [one, setOne] = useState('this is from a state') - return (

{one}

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@loader.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/export-default-component@loader.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter.tsx index 3ae9710cd5..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter.tsx @@ -1,29 +1,20 @@ import * as React from 'react' // @ts-expect-error import { useMemo } from 'tan-react' - const useUsedVar = 'i-am-unused' - 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) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@loader.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-as-parameter@loader.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration.tsx index c191f9fddd..b12490e0a5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration.tsx @@ -1,10 +1,12 @@ -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=loader'); -import { lazyFn } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +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=loader') +import { lazyFn } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx index 3476c52d54..a0ebf07dee 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,27 +1,31 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { Route } from "function-declaration.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { Route } from 'function-declaration.tsx' function PostsComponent() { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; +
+ ) } -export { PostsComponent as component }; \ No newline at end of file +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@loader.tsx index cb195afdd8..1c4fc213ed 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/function-declaration@loader.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; -import { fetchPosts } from '../posts'; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +import * as React from 'react' +import { fetchPosts } from '../posts' +const SplitLoader = fetchPosts +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute.tsx index e2aab465f5..b6b9c182dc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx index f34d3c6408..88abef0c00 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/importAttribute@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { test } from './test' with { type: 'macro' }; -const SplitComponent = () => test; -export { SplitComponent as component }; \ No newline at end of file +import { test } from './test' with { type: 'macro' } +const SplitComponent = () => test +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader.tsx index 70d5be8c3f..969129bdf2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader.tsx @@ -1,9 +1,11 @@ -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=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx index d21b198c98..9350cda9e8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import importedComponent from '../../shared/imported'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import importedComponent from '../../shared/imported' +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@loader.tsx index 52e811be53..8691aec6ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component-destructured-loader@loader.tsx @@ -1,3 +1,3 @@ -import { importedLoader } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import { importedLoader } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component.tsx index 601c1f656a..f793a41de9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component.tsx @@ -1,6 +1,7 @@ -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'; +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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-default-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent.tsx index 4df12c02de..13e87eb7f1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx index d8a0fcf9ff..b5bded20a6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-errorComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -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 +import ImportedDefaultComponent, { + importedErrorComponent, +} from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } +const SplitErrorComponent = importedErrorComponent +export { SplitErrorComponent as errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent.tsx index 716ec0ca3a..48b7f7f6bf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); \ No newline at end of file + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx index 1273c7c50d..9f904a1a19 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-notFoundComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -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 +import ImportedDefaultComponent, { + importedNotFoundComponent, +} from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } +const SplitNotFoundComponent = importedNotFoundComponent +export { SplitNotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent.tsx index 5a5aa789f7..c22e117560 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') -}); \ No newline at end of file + pendingComponent: lazyRouteComponent( + $$splitPendingComponentImporter, + 'pendingComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx index 0368000afa..d24c7b1505 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported-pendingComponent@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -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 +import ImportedDefaultComponent, { + importedPendingComponent, +} from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } +const SplitPendingComponent = importedPendingComponent +export { SplitPendingComponent as pendingComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported.tsx index dd3299b1b1..54a7733167 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported.tsx @@ -1,9 +1,10 @@ -const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('imported.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('imported.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +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('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx index 5bc9da8d43..e3c06dbe9e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { importedComponent } from '../../shared'; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import { importedComponent } from '../../shared' +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@loader.tsx index 9b91fafd91..d0418cbce3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/imported@loader.tsx @@ -1,3 +1,3 @@ -import { importedLoader } from '../../shared'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import { importedLoader } from '../../shared' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline.tsx index 960f639c0a..3c27842428 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('inline.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -Route.addChildren([]); -export const test = 'test'; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +Route.addChildren([]) +export const test = 'test' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx index 58ccfb2903..d28b872634 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,18 +1,18 @@ -import * as React from 'react'; -import * as styles from '../style.css'; -import { TEST_DATA } from '../test.const'; -const Button = (props: { - children: any; -}) => { - return ; -}; -import { Route } from "inline.tsx"; -import { test } from "inline.tsx"; +import * as React from 'react' +import * as styles from '../style.css' +import { TEST_DATA } from '../test.const' +const Button = (props: { children: any }) => { + return +} +import { Route } from 'inline.tsx' +import { test } from 'inline.tsx' const SplitComponent = () => { - return
- {test} -

{TEST_DATA.welcome}

- -
; -}; -export { SplitComponent as component }; \ No newline at end of file + return ( +
+ {test} +

{TEST_DATA.welcome}

+ +
+ ) +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@loader.tsx index 9236af6021..23fab71edc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/inline@loader.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -import { Route } from "inline.tsx"; \ No newline at end of file +import * as React from 'react' +import { Route } from 'inline.tsx' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration.tsx index 75657cb44a..79ef82a7af 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration.tsx @@ -1,10 +1,19 @@ -const $$splitErrorComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -const $$splitPendingComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -const $$splitComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitErrorComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +const $$splitPendingComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +const $$splitComponentImporter = () => + import('lowercase-function-declaration.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'), - pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + pendingComponent: lazyRouteComponent( + $$splitPendingComponentImporter, + 'pendingComponent', + ), + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx index 86876d616e..ec003091fb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/lowercase-function-declaration@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,12 +1,12 @@ function component() { - return
lowercase function declaration
; + return
lowercase function declaration
} function pendingComponent() { - return
lowercase pending function declaration
; + return
lowercase pending function declaration
} function errorComponent() { - return
lowercase error function declaration
; + return
lowercase error function declaration
} -export { component }; -export { pendingComponent }; -export { errorComponent }; \ No newline at end of file +export { component } +export { pendingComponent } +export { errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number.tsx index a345d17ae7..440e1f4253 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number.tsx @@ -1,28 +1,41 @@ -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=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { Await, Link, createFileRoute } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -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`]; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; +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=loader') +import { lazyFn } from '@tanstack/react-router' +import { Await, Link, createFileRoute } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +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`, +] +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] export const Route = createFileRoute('/')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx index 9ed6d15184..26a9f9c142 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,61 +1,48 @@ -import { Await, Link } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import discordImage from '~/images/discord-logo-white.svg'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -import { useMutation } from '~/hooks/useMutation'; -import { sample } from '~/utils/utils'; -import { textColors } from "random-number.tsx"; -import { gradients } from "random-number.tsx"; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; -import { Route } from "random-number.tsx"; -async function bytesSignupServerFn({ - email -}: { - email: string; -}) { - 'use server'; - +import { Await, Link } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import discordImage from '~/images/discord-logo-white.svg' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +import { useMutation } from '~/hooks/useMutation' +import { sample } from '~/utils/utils' +import { textColors } from 'random-number.tsx' +import { gradients } from 'random-number.tsx' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] +import { Route } from 'random-number.tsx' +async function bytesSignupServerFn({ email }: { email: string }) { + 'use server' return fetch(`https://bytes.dev/api/bytes-optin-cors`, { method: 'POST', - body: JSON.stringify({ - email, - influencer: 'tanstack' - }), - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json' - } - }); + body: JSON.stringify({ email, influencer: 'tanstack' }), + headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, + }) } function Index() { - const bytesSignupMutation = useMutation({ - fn: bytesSignupServerFn - }); - const { - sponsorsPromise, - randomNumber, - testing2 - } = Route.useLoaderData(); - const gradient = sample(gradients, randomNumber); - const textColor = sample(textColors, randomNumber); - return <> + const bytesSignupMutation = useMutation({ fn: bytesSignupServerFn }) + const { sponsorsPromise, randomNumber, testing2 } = Route.useLoaderData() + const gradient = sample(gradients, randomNumber) + const textColor = sample(textColors, randomNumber) + return ( + <> {discordImage} {gradient} {textColor} - ; + + ) } -export { Index as component }; \ No newline at end of file +export { Index as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@loader.tsx index 9f854acfb0..0e7d41451e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/random-number@loader.tsx @@ -1,26 +1,28 @@ -import { Await, Link, defer } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import { getSponsorsForSponsorPack } from '~/server/sponsors'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; +import { Await, Link, defer } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import { getSponsorsForSponsorPack } from '~/server/sponsors' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] const SplitLoader = () => { return { randomNumber: Math.random(), - sponsorsPromise: defer(getSponsorsForSponsorPack()) - }; -}; -export { SplitLoader as loader }; \ No newline at end of file + sponsorsPromise: defer(getSponsorsForSponsorPack()), + } +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component.tsx index eea3e62996..9be4f76d08 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component.tsx @@ -1,9 +1,11 @@ -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=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index dfef29c9e3..6bdb537fe9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React from 'react' function Component() { - return
Component
; + return
Component
} -const SplitComponent = React.memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitComponent = React.memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@loader.tsx index 52e811be53..8691aec6ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-component@loader.tsx @@ -1,3 +1,3 @@ -import { importedLoader } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import { importedLoader } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component.tsx index e445bcbb72..2637f8de7a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component.tsx @@ -1,9 +1,11 @@ -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=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index 540812230e..d162a1aeaf 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,4 +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 +import React from 'react' +import { importedComponent } from '../../shared/imported' +const SplitComponent = React.memo(importedComponent) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@loader.tsx index 52e811be53..8691aec6ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/react-memo-imported-component@loader.tsx @@ -1,3 +1,3 @@ -import { importedLoader } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import { importedLoader } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component.tsx index f22aa236e1..1b374dd690 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component.tsx @@ -1,14 +1,16 @@ -console.warn("[tanstack-router] These exports from \"retain-export-component.tsx\" will not be code-split and will increase your bundle size:\n- Layout\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute, Outlet } from '@tanstack/react-router'; -import { importedComponent as ImportedComponent } from '../../shared/imported'; +console.warn( + '[tanstack-router] These exports from "retain-export-component.tsx" will not be code-split and will increase your bundle size:\n- Layout\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitLoaderImporter = () => + import('retain-export-component.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute, Outlet } from '@tanstack/react-router' +import { importedComponent as ImportedComponent } from '../../shared/imported' export function Layout() { - return
-
+ return ( +
+
-
; +
+ ) } export const Route = createFileRoute('/_layout')({ component: Layout, - loader: lazyFn($$splitLoaderImporter, 'loader') -}); -const HEADER_HEIGHT = '63px'; -export const SIDEBAR_WIDTH = '150px'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) +const HEADER_HEIGHT = '63px' +export const SIDEBAR_WIDTH = '150px' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx index 5bb0ab5451..8fb12f0c6b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import * as React from 'react'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@loader.tsx index 9787e27ad7..ddeb4d1e6f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-export-component@loader.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import { importedLoader } from '../../shared/imported'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import * as React from 'react' +import { importedLoader } from '../../shared/imported' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const.tsx index f256b01a83..d674dbb799 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export const loaderFn = () => { return importedLoader() } - const Layout = () => { return (
@@ -26,15 +24,12 @@ const Layout = () => {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@loader.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-const@loader.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured.tsx index 0e3175116f..89c23305a0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured.tsx @@ -1,18 +1,12 @@ import { createFileRoute } from '@tanstack/react-router' - const createBits = () => ({ component: AboutComponentImpl, - loader: () => ({ - message: 'hello', - }), + loader: () => ({ message: 'hello' }), }) - export const { component: AboutComponent, loader } = createBits() - function AboutComponentImpl() { return
About
} - export const Route = createFileRoute('/about')({ component: AboutComponent, loader, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx index a6d57afe77..d64b42fdcc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import { AboutComponent } from "retain-exports-destructured.tsx?tsr-shared=1"; -export { AboutComponent as component }; \ No newline at end of file +import { AboutComponent } from 'retain-exports-destructured.tsx?tsr-shared=1' +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@loader.tsx index e8d771ea44..0397569b0f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@loader.tsx @@ -1,2 +1,2 @@ -import { loader } from "retain-exports-destructured.tsx?tsr-shared=1"; -export { loader }; \ No newline at end of file +import { loader } from 'retain-exports-destructured.tsx?tsr-shared=1' +export { loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@shared.tsx index b03a4eb83a..6eff1ff083 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-destructured@shared.tsx @@ -1,14 +1,9 @@ const createBits = () => ({ component: AboutComponentImpl, - loader: () => ({ - message: 'hello' - }) -}); -const { - component: AboutComponent, - loader -} = createBits(); + loader: () => ({ message: 'hello' }), +}) +const { component: AboutComponent, loader } = createBits() function AboutComponentImpl() { - return
About
; + return
About
} -export { AboutComponent, AboutComponentImpl, createBits, loader }; \ No newline at end of file +export { AboutComponent, AboutComponentImpl, createBits, loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function.tsx index 298c388e65..83b3dd4eb5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export function loaderFn() { return importedLoader() } - function Layout() { return (
@@ -26,15 +24,12 @@ function Layout() {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@loader.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-function@loader.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader.tsx index c7d5437729..ef230c47f6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader.tsx @@ -1,17 +1,18 @@ -console.warn("[tanstack-router] These exports from \"retain-exports-loader.tsx\" will not be code-split and will increase your bundle size:\n- loaderFn\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +console.warn( + '[tanstack-router] These exports from "retain-exports-loader.tsx" will not be code-split and will increase your bundle size:\n- loaderFn\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitComponentImporter = () => + import('retain-exports-loader.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export function loaderFn() { - return { - foo: 'bar' - }; + return { foo: 'bar' } } export const Route = createFileRoute('/_layout')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: loaderFn -}); -export const SIDEBAR_WIDTH = '150px'; -export const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file + loader: loaderFn, +}) +export const SIDEBAR_WIDTH = '150px' +export const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx index 9f54ae0dc5..604be4dc69 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,11 +1,10 @@ -import * as React from 'react'; -import { Outlet } from '@tanstack/react-router'; -import { importedComponent as ImportedComponent } from '../../shared/imported'; +import * as React from 'react' +import { Outlet } from '@tanstack/react-router' +import { importedComponent as ImportedComponent } from '../../shared/imported' function Layout() { - return
-
+ return ( +
+
-
; +
+ ) } -const HEADER_HEIGHT = '63px'; -const ASIDE_WIDTH = '250px'; -export { Layout as component }; \ No newline at end of file +const HEADER_HEIGHT = '63px' +const ASIDE_WIDTH = '250px' +export { Layout as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@loader.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/retain-exports-loader@loader.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class.tsx index da068daa17..96d51c8492 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('shared-class.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-class.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-class.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => import('shared-class.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/store')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@component---errorComponent---notFoundComponent---pendingComponent.tsx index 6a38b10ff8..e0e187fb1d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { store } from "shared-class.tsx?tsr-shared=1"; -const SplitComponent = () =>
{store.get('items')}
; -export { SplitComponent as component }; \ No newline at end of file +import { store } from 'shared-class.tsx?tsr-shared=1' +const SplitComponent = () =>
{store.get('items')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@loader.tsx index f91799f3c8..96dcaca4a8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@loader.tsx @@ -1,5 +1,5 @@ -import { store } from "shared-class.tsx?tsr-shared=1"; +import { store } from 'shared-class.tsx?tsr-shared=1' const SplitLoader = async () => { - store.set('items', await fetch('/api')); -}; -export { SplitLoader as loader }; \ No newline at end of file + store.set('items', await fetch('/api')) +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@shared.tsx index 18c40bafb6..0abc282ecc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-class@shared.tsx @@ -1,11 +1,11 @@ class DataStore { - data = new Map(); + data = new Map() get(k: string) { - return this.data.get(k); + return this.data.get(k) } set(k: string, v: unknown) { - this.data.set(k, v); + this.data.set(k, v) } } -const store = new DataStore(); -export { DataStore, store }; \ No newline at end of file +const store = new DataStore() +export { DataStore, store } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export.tsx index 7d0f0fcae1..080a19ff45 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-destructured-export.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-destructured-export.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-destructured-export.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-destructured-export.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/config')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -export { apiUrl, timeout } from "shared-destructured-export.tsx?tsr-shared=1"; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +export { apiUrl, timeout } from 'shared-destructured-export.tsx?tsr-shared=1' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx index 16b288ac5f..8cd0f14a27 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { timeout } from "shared-destructured-export.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { timeout } from 'shared-destructured-export.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@loader.tsx index 33d4b5aa43..d099459c6f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@loader.tsx @@ -1,3 +1,3 @@ -import { apiUrl } from "shared-destructured-export.tsx?tsr-shared=1"; -const SplitLoader = async () => fetch(apiUrl); -export { SplitLoader as loader }; \ No newline at end of file +import { apiUrl } from 'shared-destructured-export.tsx?tsr-shared=1' +const SplitLoader = async () => fetch(apiUrl) +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@shared.tsx index f0bfd70add..ae9324acc9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured-export@shared.tsx @@ -1,11 +1,5 @@ -const { - apiUrl, - timeout -} = getConfig(); +const { apiUrl, timeout } = getConfig() function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; + return { apiUrl: '/api', timeout: 5000 } } -export { apiUrl, getConfig, timeout }; \ No newline at end of file +export { apiUrl, getConfig, timeout } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured.tsx index 8185738e9d..7c46a40bb3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-destructured.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-destructured.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-destructured.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-destructured.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/config')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx index 5c0182e61a..3d7933a573 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { timeout } from "shared-destructured.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { timeout } from 'shared-destructured.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@loader.tsx index 94b0923079..53e56d748d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@loader.tsx @@ -1,3 +1,3 @@ -import { apiUrl } from "shared-destructured.tsx?tsr-shared=1"; -const SplitLoader = async () => fetch(apiUrl); -export { SplitLoader as loader }; \ No newline at end of file +import { apiUrl } from 'shared-destructured.tsx?tsr-shared=1' +const SplitLoader = async () => fetch(apiUrl) +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@shared.tsx index f0bfd70add..ae9324acc9 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-destructured@shared.tsx @@ -1,11 +1,5 @@ -const { - apiUrl, - timeout -} = getConfig(); +const { apiUrl, timeout } = getConfig() function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; + return { apiUrl: '/api', timeout: 5000 } } -export { apiUrl, getConfig, timeout }; \ No newline at end of file +export { apiUrl, getConfig, timeout } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported.tsx index ce690311b2..bf6574aaed 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-exported.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-exported.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-exported.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-exported.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/query')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -export { queryOptions } from "shared-exported.tsx?tsr-shared=1"; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +export { queryOptions } from 'shared-exported.tsx?tsr-shared=1' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@component---errorComponent---notFoundComponent---pendingComponent.tsx index b020b5cadf..9fe61942dd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { queryOptions } from "shared-exported.tsx?tsr-shared=1"; -const SplitComponent = () =>
GC: {queryOptions.gcTime}
; -export { SplitComponent as component }; \ No newline at end of file +import { queryOptions } from 'shared-exported.tsx?tsr-shared=1' +const SplitComponent = () =>
GC: {queryOptions.gcTime}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@loader.tsx index 332fa35079..4d4b8fbc5c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@loader.tsx @@ -1,7 +1,5 @@ -import { queryOptions } from "shared-exported.tsx?tsr-shared=1"; +import { queryOptions } from 'shared-exported.tsx?tsr-shared=1' const SplitLoader = async () => { - return { - staleTime: queryOptions.staleTime - }; -}; -export { SplitLoader as loader }; \ No newline at end of file + return { staleTime: queryOptions.staleTime } +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@shared.tsx index a3f91b85bb..3a1ff108bb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-exported@shared.tsx @@ -1,5 +1,2 @@ -const queryOptions = { - staleTime: 5000, - gcTime: 10000 -}; -export { queryOptions }; \ No newline at end of file +const queryOptions = { staleTime: 5000, gcTime: 10000 } +export { queryOptions } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function.tsx index b5bf41235e..ef2e5e57a3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-function.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-function.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/cached')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index 571bd9356a..1c327523af 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { getCached } from "shared-function.tsx?tsr-shared=1"; -const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
; -export { SplitComponent as component }; \ No newline at end of file +import { getCached } from 'shared-function.tsx?tsr-shared=1' +const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@loader.tsx index f5f72ab014..d8ae45caed 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@loader.tsx @@ -1,9 +1,9 @@ -import { getCached, cache } from "shared-function.tsx?tsr-shared=1"; +import { getCached, cache } from 'shared-function.tsx?tsr-shared=1' function setCached(key: string, val: unknown) { - cache.set(key, val); + cache.set(key, val) } const SplitLoader = async () => { - setCached('data', await fetch('/api').then(r => r.json())); - return getCached('data'); -}; -export { SplitLoader as loader }; \ No newline at end of file + setCached('data', await fetch('/api').then((r) => r.json())) + return getCached('data') +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@shared.tsx index 27d2cf03f1..243ac23a66 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-function@shared.tsx @@ -1,5 +1,5 @@ -const cache = new Map(); +const cache = new Map() function getCached(key: string) { - return cache.get(key); + return cache.get(key) } -export { cache, getCached }; \ No newline at end of file +export { cache, getCached } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding.tsx index d9ce6828fa..30823e2684 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-imported-binding.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-imported-binding.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-imported-binding.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-imported-binding.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/imported')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@component---errorComponent---notFoundComponent---pendingComponent.tsx index 0a835ae063..e3c8a0f5d8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { sharedUtil } from '../utils'; -const SplitComponent = () =>
{sharedUtil('render')}
; -export { SplitComponent as component }; \ No newline at end of file +import { sharedUtil } from '../utils' +const SplitComponent = () =>
{sharedUtil('render')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@loader.tsx index 1b27de9093..8b8c645837 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-imported-binding@loader.tsx @@ -1,3 +1,3 @@ -import { sharedUtil } from '../utils'; -const SplitLoader = async () => sharedUtil('load'); -export { SplitLoader as loader }; \ No newline at end of file +import { sharedUtil } from '../utils' +const SplitLoader = async () => sharedUtil('load') +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref.tsx index f4dfce52ba..17ae801b02 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-indirect-ref.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-indirect-ref.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-indirect-ref.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-indirect-ref.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/shared-indirect')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx index 62995e7fd8..64bb6ab567 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,9 @@ -import { state, getCount } from "shared-indirect-ref.tsx?tsr-shared=1"; +import { state, getCount } from 'shared-indirect-ref.tsx?tsr-shared=1' function SharedComponent() { - return
+ return ( +
{getCount()} - {state.count} -
; +
+ ) } -export { SharedComponent as component }; \ No newline at end of file +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@loader.tsx index 0625ac53f8..6b4c2c895b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@loader.tsx @@ -1,8 +1,6 @@ -import { state, getCount } from "shared-indirect-ref.tsx?tsr-shared=1"; +import { state, getCount } from 'shared-indirect-ref.tsx?tsr-shared=1' const SplitLoader = () => { - state.count++; - return { - count: getCount() - }; -}; -export { SplitLoader as loader }; \ No newline at end of file + state.count++ + return { count: getCount() } +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@shared.tsx index 7e7e811ba8..b4910d2fd1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-indirect-ref@shared.tsx @@ -1,7 +1,5 @@ -const state = { - count: 0 -}; +const state = { count: 0 } function getCount() { - return state.count; + return state.count } -export { getCount, state }; \ No newline at end of file +export { getCount, state } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref.tsx index 8ac24d49cf..fd6b2c69be 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-jsx-component-ref.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-jsx-component-ref.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-jsx-component-ref.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-jsx-component-ref.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' // @ts-nocheck -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/jsx')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx index 52ecb6d474..845e1db45c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import { shared } from "shared-jsx-component-ref.tsx?tsr-shared=1"; // @ts-nocheck +import { shared } from 'shared-jsx-component-ref.tsx?tsr-shared=1' // @ts-nocheck function SharedComponent() { - return
{shared}
; + return
{shared}
} -export { SharedComponent as component }; \ No newline at end of file +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@loader.tsx index f861dda436..348aecd923 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@loader.tsx @@ -1,3 +1,3 @@ -import { shared } from "shared-jsx-component-ref.tsx?tsr-shared=1"; // @ts-nocheck -const SplitLoader = () => shared; -export { SplitLoader as loader }; \ No newline at end of file +import { shared } from 'shared-jsx-component-ref.tsx?tsr-shared=1' // @ts-nocheck +const SplitLoader = () => shared +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@shared.tsx index d5cc2cf990..60ae1006a1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-jsx-component-ref@shared.tsx @@ -1,4 +1,3 @@ // @ts-nocheck - -const shared = 1; -export { shared }; \ No newline at end of file +const shared = 1 +export { shared } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none.tsx index 06e81042d6..5ecfa3b109 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('shared-none.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-none.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-none.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => import('shared-none.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/clean')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@component---errorComponent---notFoundComponent---pendingComponent.tsx index 701deeedeb..1bfd4eb63f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -const ComponentHelper = () => helper; -const SplitComponent = () =>
- -
; -export { SplitComponent as component }; \ No newline at end of file +const ComponentHelper = () => helper +const SplitComponent = () => ( +
+ +
+) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@loader.tsx index d0cfce36ee..0dfbec2515 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-none@loader.tsx @@ -1,3 +1,3 @@ -const loaderHelper = () => fetch('/api'); -const SplitLoader = async () => loaderHelper(); -export { SplitLoader as loader }; \ No newline at end of file +const loaderHelper = () => fetch('/api') +const SplitLoader = async () => loaderHelper() +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route.tsx index b62568c1fb..5a3509f434 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-referencing-route.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-referencing-route.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-referencing-route.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-referencing-route.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/about')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@component---errorComponent---notFoundComponent---pendingComponent.tsx index 2cb2cdb68c..b2c4630c90 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,10 +1,10 @@ -import { HEADER } from "shared-referencing-route.tsx?tsr-shared=1"; +import { HEADER } from 'shared-referencing-route.tsx?tsr-shared=1' function usePageTitle() { - return `${HEADER} - ${Route.fullPath}`; + return `${HEADER} - ${Route.fullPath}` } -import { Route } from "shared-referencing-route.tsx"; +import { Route } from 'shared-referencing-route.tsx' const SplitComponent = () => { - const title = usePageTitle(); - return
{title}
; -}; -export { SplitComponent as component }; \ No newline at end of file + const title = usePageTitle() + return
{title}
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@loader.tsx index baedd53bd7..dbf196f1b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@loader.tsx @@ -1,12 +1,10 @@ -import { HEADER } from "shared-referencing-route.tsx?tsr-shared=1"; +import { HEADER } from 'shared-referencing-route.tsx?tsr-shared=1' function usePageTitle() { - return `${HEADER} - ${Route.fullPath}`; + return `${HEADER} - ${Route.fullPath}` } -import { Route } from "shared-referencing-route.tsx"; +import { Route } from 'shared-referencing-route.tsx' const SplitLoader = async () => { - const title = usePageTitle(); - return { - title - }; -}; -export { SplitLoader as loader }; \ No newline at end of file + const title = usePageTitle() + return { title } +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@shared.tsx index cc2d01424c..34b9c4ca41 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-referencing-route@shared.tsx @@ -1,2 +1,2 @@ -const HEADER = 'Page'; -export { HEADER }; \ No newline at end of file +const HEADER = 'Page' +export { HEADER } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime.tsx index bceb12d39a..944c0b8ca8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime.tsx @@ -1,22 +1,20 @@ -import { state, createState, createSeed } from "shared-runtime.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-runtime.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-runtime.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('shared-runtime:reference'); +import { state, createState, createSeed } from 'shared-runtime.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-runtime.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-runtime.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('shared-runtime:reference') export const Route = createFileRoute('/shared-runtime')({ beforeLoad: () => state, loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@component---errorComponent---notFoundComponent---pendingComponent.tsx index fbccf6c90b..5245f6d9eb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,23 +1,24 @@ -import { state, createState, createSeed, Labels } from "shared-runtime.tsx?tsr-shared=1"; -const label = createComponentLabel(); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -function createComponentLabel() { - console.log('shared-runtime:component'); - return Labels.component; +import { + state, + createState, + createSeed, + Labels, +} from 'shared-runtime.tsx?tsr-shared=1' +const label = createComponentLabel() +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number } -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; +function createComponentLabel() { + console.log('shared-runtime:component') + return Labels.component +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed const SplitComponent = () => { if (state.count === 3) { - throw new Error('route source-map contract'); + throw new Error('route source-map contract') } - return `${label}:${state.count}`; -}; -export { SplitComponent as component }; \ No newline at end of file + return `${label}:${state.count}` +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@loader.tsx index 6c797c0226..6c0c88cab7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@loader.tsx @@ -1,16 +1,17 @@ -import { state, createState, createSeed, increment } from "shared-runtime.tsx?tsr-shared=1"; -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; +import { + state, + createState, + createSeed, + increment, +} from 'shared-runtime.tsx?tsr-shared=1' +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed const SplitLoader = () => { - increment(); - return state; -}; -export { SplitLoader as loader }; \ No newline at end of file + increment() + return state +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@shared.tsx index 54239b6cc5..c53a7e1568 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-runtime@shared.tsx @@ -1,28 +1,13 @@ -const Count = { - Initial: 0 -}; -const Labels = { - component: 'count' -}; -const seed = createSeed(); -const { - state, - increment -} = createState(seed); +const Count = { Initial: 0 } +const Labels = { component: 'count' } +const seed = createSeed() +const { state, increment } = createState(seed) function createSeed() { - console.log('shared-runtime:seed'); - return { - count: Count.Initial, - label: Labels.component - }; + console.log('shared-runtime:seed') + return { count: Count.Initial, label: Labels.component } } -function createState(initialState: { - count: number; -}) { - console.log('shared-runtime:state'); - return { - state: initialState, - increment: () => initialState.count++ - }; +function createState(initialState: { count: number }) { + console.log('shared-runtime:state') + return { state: initialState, increment: () => initialState.count++ } } -export { Count, createSeed, createState, increment, Labels, seed, state }; \ No newline at end of file +export { Count, createSeed, createState, increment, Labels, seed, state } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive.tsx index 869602e15b..aba85fd14b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-transitive.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-transitive.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-transitive.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-transitive.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/api')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@component---errorComponent---notFoundComponent---pendingComponent.tsx index 7a3a74048e..c237a03583 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { config } from "shared-transitive.tsx?tsr-shared=1"; -const SplitComponent = () =>
Timeout: {config.timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { config } from 'shared-transitive.tsx?tsr-shared=1' +const SplitComponent = () =>
Timeout: {config.timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@loader.tsx index 8472eab295..70faa4c627 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@loader.tsx @@ -1,6 +1,6 @@ -import { config } from "shared-transitive.tsx?tsr-shared=1"; -const fetcher = (path: string) => fetch(`${config.url}${path}`); +import { config } from 'shared-transitive.tsx?tsr-shared=1' +const fetcher = (path: string) => fetch(`${config.url}${path}`) const SplitLoader = async () => { - return fetcher('/data'); -}; -export { SplitLoader as loader }; \ No newline at end of file + return fetcher('/data') +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@shared.tsx index 8bec4a1d55..ac44498714 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-transitive@shared.tsx @@ -1,6 +1,3 @@ -const BASE_URL = 'https://api.example.com'; -const config = { - url: BASE_URL, - timeout: 5000 -}; -export { BASE_URL, config }; \ No newline at end of file +const BASE_URL = 'https://api.example.com' +const config = { url: BASE_URL, timeout: 5000 } +export { BASE_URL, config } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable.tsx index 42f68cce48..e06ea2b1d2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-variable.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-variable.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-variable.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-variable.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/todos')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@component---errorComponent---notFoundComponent---pendingComponent.tsx index d149922fbc..10325aa95e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { collection } from "shared-variable.tsx?tsr-shared=1"; -const SplitComponent = () =>
{collection.name}
; -export { SplitComponent as component }; \ No newline at end of file +import { collection } from 'shared-variable.tsx?tsr-shared=1' +const SplitComponent = () =>
{collection.name}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@loader.tsx index 196a8e48a4..b76d00b514 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@loader.tsx @@ -1,8 +1,6 @@ -import { collection } from "shared-variable.tsx?tsr-shared=1"; +import { collection } from 'shared-variable.tsx?tsr-shared=1' const SplitLoader = async () => { - await collection.preload(); - return { - data: 'loaded' - }; -}; -export { SplitLoader as loader }; \ No newline at end of file + await collection.preload() + return { data: 'loaded' } +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@shared.tsx index 8a0560d5b9..10421dac09 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-variable@shared.tsx @@ -1,5 +1,2 @@ -const collection = { - name: 'todos', - preload: async () => {} -}; -export { collection }; \ No newline at end of file +const collection = { name: 'todos', preload: async () => {} } +export { collection } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect.tsx index 943cdf189c..5965d04430 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-with-side-effect.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-with-side-effect.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('registry created'); +const $$splitComponentImporter = () => + import('shared-with-side-effect.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-with-side-effect.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('registry created') export const Route = createFileRoute('/fx')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@component---errorComponent---notFoundComponent---pendingComponent.tsx index d953af00fa..3ede22c8be 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { registry } from "shared-with-side-effect.tsx?tsr-shared=1"; -const SplitComponent = () =>
{registry.size}
; -export { SplitComponent as component }; \ No newline at end of file +import { registry } from 'shared-with-side-effect.tsx?tsr-shared=1' +const SplitComponent = () =>
{registry.size}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@loader.tsx index a5f06a0a05..b3b404a8ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@loader.tsx @@ -1,5 +1,5 @@ -import { registry } from "shared-with-side-effect.tsx?tsr-shared=1"; +import { registry } from 'shared-with-side-effect.tsx?tsr-shared=1' const SplitLoader = async () => { - registry.set('loaded', true); -}; -export { SplitLoader as loader }; \ No newline at end of file + registry.set('loaded', true) +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@shared.tsx index f26c656fdd..a59298f9e0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/shared-with-side-effect@shared.tsx @@ -1,2 +1,2 @@ -const registry = new Map(); -export { registry }; \ No newline at end of file +const registry = new Map() +export { registry } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/undefined-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/undefined-literals.tsx index 0c6e4f01aa..88b0bf1ba8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/undefined-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/undefined-literals.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/undefined-test')({ component: undefined, errorComponent: undefined, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure.tsx index d0de09bf8b..b5b3ecade6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure.tsx @@ -1,5 +1,4 @@ import * as React from 'react' - import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg' import { FaBolt, @@ -21,7 +20,6 @@ import { startProject } from '~/projects/start' import { createFileRoute } from '@tanstack/react-router' import { Framework, getBranch } from '~/projects' import { seo } from '~/utils/seo' - const menu = [ { label: ( @@ -72,31 +70,22 @@ const menu = [ to: `https://cottonbureau.com/people/tanstack`, }, ] - export const Route = createFileRoute('/_libraries/start/$version/')({ component: VersionIndex, meta: () => - seo({ - title: startProject.name, - description: startProject.description, - }), + seo({ title: startProject.name, description: startProject.description }), }) - const librariesRouteApi = getRouteApi('/_libraries') - export default function VersionIndex() { const { sponsorsPromise } = librariesRouteApi.useLoaderData() const { version } = Route.useParams() const branch = getBranch(startProject, version) const [framework, setFramework] = React.useState('react') const [isDark, 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 (
{item.label}
) - return (
{item.to.startsWith('http') ? ( @@ -269,7 +257,6 @@ Check it out at https://tanstack.com/start/`,
*/} - {/*

@@ -315,7 +302,6 @@ Check it out at https://tanstack.com/start/`, })}

*/} - {/*
Trusted in Production by @@ -358,7 +344,6 @@ Check it out at https://tanstack.com/start/`,
*/} -

Partners @@ -388,16 +373,13 @@ Check it out at https://tanstack.com/start/`,

-

Sponsors

-
@@ -429,7 +410,6 @@ Check it out at https://tanstack.com/start/`, rage-quit OSS. Yay money! 😉
- {/*

@@ -468,7 +448,6 @@ Check it out at https://tanstack.com/start/`,

*/} - {/* {[''].includes(framework) ? (
@@ -503,7 +482,6 @@ Check it out at https://tanstack.com/start/`, >
)} */} - {/*
Wow, you've come a long way! diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@loader.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/useStateDestructure@loader.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using.tsx index c58f0f663b..811b66a9d3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using.tsx @@ -1,5 +1,5 @@ -const $$splitLoaderImporter = () => import('using.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => import('using.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/react-router' export const Route = createFileRoute({ - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using@loader.tsx index 7e4f4fde9b..3b60e73b8d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/2-components-combined-loader-separate/using@loader.tsx @@ -1,17 +1,9 @@ const DummyPostResource = (postId: string) => ({ - postData: { - id: postId, - title: 'dummy', - body: 'dummy' - }, - [Symbol.dispose]: () => console.log('disposing!') -}); -const SplitLoader = ({ - params: { - postId - } -}) => { - using dummyPost = DummyPostResource(postId); - return dummyPost.postData; -}; -export { SplitLoader as loader }; \ No newline at end of file + postData: { id: postId, title: 'dummy', body: 'dummy' }, + [Symbol.dispose]: () => console.log('disposing!'), +}) +const SplitLoader = ({ params: { postId } }) => { + using dummyPost = DummyPostResource(postId) + return dummyPost.postData +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function.tsx index 380087d43c..19dfb7e3ba 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function.tsx @@ -1,10 +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 * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +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 * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx index 764043a59c..e2f2a1ccdb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,30 +1,34 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; -import { Route } from "arrow-function.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { fetchPosts } from '../posts' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; -}; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +const SplitLoader = fetchPosts +export { SplitLoader as loader } +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@errorComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/arrow-function@errorComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals.tsx index d3f54dd789..68fd7fc203 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals.tsx @@ -1,13 +1,14 @@ -const $$splitLoaderImporter = () => import('boolean-null-literals.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('boolean-null-literals.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/router'; - +const $$splitLoaderImporter = () => + import('boolean-null-literals.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +const $$splitComponentImporter = () => + import('boolean-null-literals.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/router' // Test errorComponent with false literal export const Route = createFileRoute('/test')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), errorComponent: false, pendingComponent: null, - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals@component---loader---notFoundComponent---pendingComponent.tsx index 40973b0328..7133d0d77e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/boolean-null-literals@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,5 @@ // Test errorComponent with false literal -const SplitLoader = async () => ({ - data: 'test' -}); -export { SplitLoader as loader }; -const SplitComponent = () =>
Test Component
; -export { SplitComponent as component }; \ No newline at end of file +const SplitLoader = async () => ({ data: 'test' }) +export { SplitLoader as loader } +const SplitComponent = () =>
Test Component
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese.tsx index d08045e238..bfe965067d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese.tsx @@ -1,10 +1,11 @@ -const $$splitComponentImporter = () => import('chinese.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('chinese.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@component---loader---notFoundComponent---pendingComponent.tsx index 003ca944a1..2ac1fa54ff 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,23 +1,27 @@ -import * as React from 'react'; +import * as React from 'react' function HomeComponent() { - return
+ return ( +
-
; +
+ ) } interface DemoProps { - title: string; + title: string } -function Demo({ - title -}: DemoProps) { - return

+function Demo({ title }: DemoProps) { + return ( +

{title} -

; + + ) } -export { HomeComponent as component }; \ No newline at end of file +export { HomeComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@errorComponent.tsx index b4de370f4e..cbcea8cc40 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/chinese@errorComponent.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from 'react' interface DemoProps { - title: string; -} \ No newline at end of file + title: string +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function.tsx index fe221be964..819a4a9bf4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-arrow-function.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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function@component---loader---notFoundComponent---pendingComponent.tsx index 39ace71ebe..59c5b5eec2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-arrow-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } const App = () => { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; -}; -function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; +
+ ) } -export { App as component }; \ No newline at end of file +function OtherComponent() { + const componentName = getComponentName({ App }) + return
App component name is {componentName}
+} +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function.tsx index 14d74d432d..d4a70c7341 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('circular-reference-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('circular-reference-function.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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function@component---loader---notFoundComponent---pendingComponent.tsx index 96a753ad8a..22fbb8669f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/circular-reference-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,19 +1,17 @@ function getComponentName(obj: Record): string { - return Object.keys(obj)[0]; + return Object.keys(obj)[0] } function App() { - const componentName = getComponentName({ - App - }); - return
+ const componentName = getComponentName({ App }) + return ( +
Component Name is {componentName} -
; +
+ ) } function OtherComponent() { - const componentName = getComponentName({ - App - }); - return
App component name is {componentName}
; + const componentName = getComponentName({ App }) + return
App component name is {componentName}
} -export { App as component }; \ No newline at end of file +export { App as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties.tsx index dfb3b09c5e..3b956ec804 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx index 857b130de7..88dcc8e930 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/conditional-properties@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/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 SplitLoader = isEnabled ? TrueImport.loader : falseLoader; -export { SplitLoader as loader }; -const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent; -export { SplitComponent as component }; \ No newline at end of file +import { isEnabled } from '@features/feature-flags' +import TrueImport from '@modules/true-component' +import { FalseComponent, falseLoader } from '@modules/false-component' +const SplitLoader = isEnabled ? TrueImport.loader : falseLoader +export { SplitLoader as loader } +const SplitComponent = isEnabled ? TrueImport.Component : FalseComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple.tsx index 8b823166e4..e3c598b0b5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple.tsx @@ -1,15 +1,13 @@ -const $$splitComponentImporter = () => import('destructured-export-multiple.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-multiple.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const getConfig = () => ({ baseUrl: 'https://api.example.com', - timeout: 5000 -}); -export const { - baseUrl, - timeout -} = getConfig(); -export const [first, second] = [1, 2]; + timeout: 5000, +}) +export const { baseUrl, timeout } = getConfig() +export const [first, second] = [1, 2] export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple@component---loader---notFoundComponent---pendingComponent.tsx index 9441b5a689..6a15a59c0a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-multiple@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,8 +1,10 @@ -import { baseUrl, timeout } from "destructured-export-multiple.tsx"; +import { baseUrl, timeout } from 'destructured-export-multiple.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

Timeout: {timeout}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested.tsx index 5920a891c0..f1608ec6dd 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested.tsx @@ -1,19 +1,16 @@ -const $$splitComponentImporter = () => import('destructured-export-nested.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export-nested.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' const getConfig = () => ({ - api: { - baseUrl: 'https://api.example.com' - }, + api: { baseUrl: 'https://api.example.com' }, timeout: 5000, - extra: 'data' -}); + extra: 'data', +}) export const { - api: { - baseUrl - }, + api: { baseUrl }, ...rest -} = getConfig(); +} = getConfig() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested@component---loader---notFoundComponent---pendingComponent.tsx index 8ba46e33e1..9bc538525f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export-nested@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,9 @@ -import { baseUrl } from "destructured-export-nested.tsx"; +import { baseUrl } from 'destructured-export-nested.tsx' function AboutComponent() { - return
+ return ( +

Base URL: {baseUrl}

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export.tsx index f573764824..397c6400f5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export.tsx @@ -1,17 +1,11 @@ -const $$splitComponentImporter = () => import('destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } -export const { - getObject -} = getObjectCallback(); +export const { getObject } = getObjectCallback() export const Route = createFileRoute('/about')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@component---loader---notFoundComponent---pendingComponent.tsx index f58942d5af..b0abbd2e6e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,14 +1,11 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; + return { getObject: () => ({ constA: 10, constB: 5 }) } } function AboutComponent() { - return
+ return ( +

About

-
; +
+ ) } -export { AboutComponent as component }; \ No newline at end of file +export { AboutComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@errorComponent.tsx index 45fb19eecd..024e0e620e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-export@errorComponent.tsx @@ -1,8 +1,3 @@ export function getObjectCallback() { - return { - getObject: () => ({ - constA: 10, - constB: 5 - }) - }; -} \ No newline at end of file + return { getObject: () => ({ constA: 10, constB: 5 }) } +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component.tsx index 1776055cc2..b8053fff9e 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index 931bed75b4..66f97a20d0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,9 +1,9 @@ -import { memo } from 'react'; -import { importedLoader } from '../../shared/imported'; +import { memo } from 'react' +import { importedLoader } from '../../shared/imported' function Component() { - return
Component
; + return
Component
} -const SplitLoader = importedLoader; -export { SplitLoader as loader }; -const SplitComponent = memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitLoader = importedLoader +export { SplitLoader as loader } +const SplitComponent = memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults.tsx index 6cac408c56..636e017a64 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults.tsx @@ -1,9 +1,11 @@ -const $$splitLoaderImporter = () => import('destructured-route-options-defaults.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -const $$splitComponentImporter = () => import('destructured-route-options-defaults.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => + import('destructured-route-options-defaults.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +const $$splitComponentImporter = () => + import('destructured-route-options-defaults.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/about')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults@component---loader---notFoundComponent---pendingComponent.tsx index 2f8ef91c49..ae1cd17853 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructured-route-options-defaults@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,23 +1,17 @@ function defaultLoader() { - return { - message: 'default' - }; + return { message: 'default' } } function DefaultComponent() { - return
Default
; + return
Default
} const createBits = () => ({ component: ActualComponent, - loader: () => ({ - message: 'hello' - }) -}); -const { - component: MyComponent = DefaultComponent, - loader = defaultLoader -} = createBits(); + loader: () => ({ message: 'hello' }), +}) +const { component: MyComponent = DefaultComponent, loader = defaultLoader } = + createBits() function ActualComponent() { - return
About
; + return
About
} -export { loader }; -export { MyComponent as component }; \ No newline at end of file +export { loader } +export { MyComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring.tsx index d80f17484f..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring.tsx @@ -1,11 +1,9 @@ import thing from 'thing' - export function test() { const { foo: { bar: { destructured }, }, } = thing - return destructured } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@component---loader---notFoundComponent---pendingComponent.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@errorComponent.tsx index 858c5c0e05..112fded569 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/destructuring@errorComponent.tsx @@ -1,11 +1,9 @@ -import thing from 'thing'; +import thing from 'thing' export function test() { const { foo: { - bar: { - destructured - } - } - } = thing; - return destructured; -} \ No newline at end of file + bar: { destructured }, + }, + } = thing + return destructured +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue.tsx index 178bec9bf7..b807ba9283 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue.tsx @@ -1,8 +1,8 @@ -'use client'; - -const $$splitComponentImporter = () => import('directive-prologue.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +'use client' +const $$splitComponentImporter = () => + import('directive-prologue.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/directive')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue@component---loader---notFoundComponent---pendingComponent.tsx index ce7cd5e5ee..9ee4bd8f4c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/directive-prologue@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,5 @@ -'use client'; - +'use client' const SplitComponent = () => { - return
directive preserved
; -}; -export { SplitComponent as component }; \ No newline at end of file + return
directive preserved
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component.tsx index 4fdd9d1c68..8109a89624 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component.tsx @@ -1,6 +1,3 @@ import React from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: undefined, -}) +export const Route = createFileRoute('/')({ component: undefined }) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@component---loader---notFoundComponent---pendingComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/explicit-undefined-component@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound.tsx index a3e020c559..534529220a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound.tsx @@ -1,15 +1,23 @@ -console.warn("[tanstack-router] These exports from \"export-default-component-and-normal-notFound.tsx\" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitNotFoundComponentImporter = () => import('export-default-component-and-normal-notFound.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import React, { useState } from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +console.warn( + '[tanstack-router] These exports from "export-default-component-and-normal-notFound.tsx" will not be code-split and will increase your bundle size:\n- Home\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitNotFoundComponentImporter = () => + import('export-default-component-and-normal-notFound.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import React, { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/home')({ component: Home, - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) export default function Home() { - const [one, setOne] = useState('this is from a state'); - return
+ const [one, setOne] = useState('this is from a state') + return ( +

{one}

-
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@component---loader---notFoundComponent---pendingComponent.tsx index 62cd0a1036..3da924c04c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import React from 'react'; +import React from 'react' function NotFoundComponent() { - return
Not Found
; + return
Not Found
} -export { NotFoundComponent as notFoundComponent }; \ No newline at end of file +export { NotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component-and-normal-notFound@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component.tsx index c5198b9e00..de2d748c91 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component.tsx @@ -1,13 +1,8 @@ import React, { useState } from 'react' import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/home')({ - component: Home, -}) - +export const Route = createFileRoute('/home')({ component: Home }) export default function Home() { const [one, setOne] = useState('this is from a state') - return (

{one}

diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@component---loader---notFoundComponent---pendingComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@errorComponent.tsx index b01f5e7863..b45dfaa8f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/export-default-component@errorComponent.tsx @@ -1 +1 @@ -import React from 'react'; \ No newline at end of file +import React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter.tsx index 3ae9710cd5..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter.tsx @@ -1,29 +1,20 @@ import * as React from 'react' // @ts-expect-error import { useMemo } from 'tan-react' - const useUsedVar = 'i-am-unused' - 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) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@errorComponent.tsx index 23e2cd0f03..817b89d69a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-as-parameter@errorComponent.tsx @@ -1,20 +1,20 @@ -import * as React from 'react'; +import * as React from 'react' // @ts-expect-error -import { useMemo } from 'tan-react'; -const useUsedVar = 'i-am-unused'; +import { useMemo } from 'tan-react' +const useUsedVar = 'i-am-unused' const ReactUseMemoCall1 = React.useMemo(function performAction() { - return 'true'; -}, []); -console.info(ReactUseMemoCall1); + return 'true' +}, []) +console.info(ReactUseMemoCall1) const ReactUseMemoCall2 = React.useMemo(() => { - return 'true'; -}, []); -console.info(ReactUseMemoCall2); + return 'true' +}, []) +console.info(ReactUseMemoCall2) const UseMemoCall1 = useMemo(function performAction() { - return 'true'; -}, []); -console.info(UseMemoCall1); + return 'true' +}, []) +console.info(UseMemoCall1) const UseMemoCall2 = useMemo(() => { - return 'true'; -}, []); -console.info(UseMemoCall2); \ No newline at end of file + return 'true' +}, []) +console.info(UseMemoCall2) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration.tsx index 6076420598..bdef68ad2d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration.tsx @@ -1,10 +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 * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +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 * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx index d453767c20..5289c0c3c4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,30 +1,34 @@ -import * as React from 'react'; -import { Link, Outlet } from '@tanstack/react-router'; -import { fetchPosts } from '../posts'; -import { Route } from "function-declaration.tsx"; +import * as React from 'react' +import { Link, Outlet } from '@tanstack/react-router' +import { fetchPosts } from '../posts' +import { Route } from 'function-declaration.tsx' function PostsComponent() { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {[...posts, { - id: 'i-do-not-exist', - title: 'Non-existent Post' - }]?.map(post => { - return
  • - + {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( + (post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - })} + + ) + }, + )}

-
; +
+ ) } -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; -export { PostsComponent as component }; \ No newline at end of file +const SplitLoader = fetchPosts +export { SplitLoader as loader } +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@errorComponent.tsx index 5f67a6fff1..371dc65868 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/function-declaration@errorComponent.tsx @@ -1 +1 @@ -import * as React from 'react'; \ No newline at end of file +import * as React from 'react' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute.tsx index cec0324adf..f336e2ff0f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute.tsx @@ -1,6 +1,7 @@ -const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx index f34d3c6408..88abef0c00 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/importAttribute@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import { test } from './test' with { type: 'macro' }; -const SplitComponent = () => test; -export { SplitComponent as component }; \ No newline at end of file +import { test } from './test' with { type: 'macro' } +const SplitComponent = () => test +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader.tsx index d79c8e0f32..d7c5699549 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx index d4fc40141e..b7ed94da4a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component-destructured-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import importedComponent, { importedLoader } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import importedComponent, { importedLoader } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component.tsx index c165f65262..81ec753301 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component.tsx @@ -1,6 +1,7 @@ -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'; +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') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-default-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent.tsx index 4152c9af17..e2179478b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx index 31ccf07c52..d356227040 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,3 +1,3 @@ -import ImportedDefaultComponent from '../../shared/imported'; -const SplitComponent = ImportedDefaultComponent; -export { SplitComponent as component }; \ No newline at end of file +import ImportedDefaultComponent from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@errorComponent.tsx index 7a8654fb94..3f20c3e485 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-errorComponent@errorComponent.tsx @@ -1,3 +1,3 @@ -import { importedErrorComponent } from '../../shared/imported'; -const SplitErrorComponent = importedErrorComponent; -export { SplitErrorComponent as errorComponent }; \ No newline at end of file +import { importedErrorComponent } from '../../shared/imported' +const SplitErrorComponent = importedErrorComponent +export { SplitErrorComponent as errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent.tsx index 584c829f37..31812e1e44 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - notFoundComponent: lazyRouteComponent($$splitNotFoundComponentImporter, 'notFoundComponent') -}); \ No newline at end of file + notFoundComponent: lazyRouteComponent( + $$splitNotFoundComponentImporter, + 'notFoundComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx index 1273c7c50d..9f904a1a19 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-notFoundComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -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 +import ImportedDefaultComponent, { + importedNotFoundComponent, +} from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } +const SplitNotFoundComponent = importedNotFoundComponent +export { SplitNotFoundComponent as notFoundComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent.tsx index 1be3f8071b..0996abeb6c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent.tsx @@ -1,8 +1,13 @@ -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'; +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'), - pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent') -}); \ No newline at end of file + pendingComponent: lazyRouteComponent( + $$splitPendingComponentImporter, + 'pendingComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx index 0368000afa..d24c7b1505 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported-pendingComponent@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,7 @@ -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 +import ImportedDefaultComponent, { + importedPendingComponent, +} from '../../shared/imported' +const SplitComponent = ImportedDefaultComponent +export { SplitComponent as component } +const SplitPendingComponent = importedPendingComponent +export { SplitPendingComponent as pendingComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported.tsx index 14356133d6..75c54f18ad 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported@component---loader---notFoundComponent---pendingComponent.tsx index ecc588688b..1c4d3e909b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/imported@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import { importedComponent, importedLoader } from '../../shared'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; -const SplitComponent = importedComponent; -export { SplitComponent as component }; \ No newline at end of file +import { importedComponent, importedLoader } from '../../shared' +const SplitLoader = importedLoader +export { SplitLoader as loader } +const SplitComponent = importedComponent +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline.tsx index 3e2ea1f1c2..fbc7185a17 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline.tsx @@ -1,9 +1,10 @@ -const $$splitComponentImporter = () => import('inline.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('inline.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -Route.addChildren([]); -export const test = 'test'; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +Route.addChildren([]) +export const test = 'test' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@component---loader---notFoundComponent---pendingComponent.tsx index 58ccfb2903..d28b872634 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,18 +1,18 @@ -import * as React from 'react'; -import * as styles from '../style.css'; -import { TEST_DATA } from '../test.const'; -const Button = (props: { - children: any; -}) => { - return ; -}; -import { Route } from "inline.tsx"; -import { test } from "inline.tsx"; +import * as React from 'react' +import * as styles from '../style.css' +import { TEST_DATA } from '../test.const' +const Button = (props: { children: any }) => { + return +} +import { Route } from 'inline.tsx' +import { test } from 'inline.tsx' const SplitComponent = () => { - return
- {test} -

{TEST_DATA.welcome}

- -
; -}; -export { SplitComponent as component }; \ No newline at end of file + return ( +
+ {test} +

{TEST_DATA.welcome}

+ +
+ ) +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@errorComponent.tsx index 9236af6021..23fab71edc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/inline@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -import { Route } from "inline.tsx"; \ No newline at end of file +import * as React from 'react' +import { Route } from 'inline.tsx' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration.tsx index 574c6d4c2b..55c51e878b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration.tsx @@ -1,10 +1,19 @@ -const $$splitErrorComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=errorComponent'); -const $$splitPendingComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -const $$splitComponentImporter = () => import('lowercase-function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitErrorComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=errorComponent') +const $$splitPendingComponentImporter = () => + import('lowercase-function-declaration.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +const $$splitComponentImporter = () => + import('lowercase-function-declaration.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'), - pendingComponent: lazyRouteComponent($$splitPendingComponentImporter, 'pendingComponent'), - errorComponent: lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') -}); \ No newline at end of file + pendingComponent: lazyRouteComponent( + $$splitPendingComponentImporter, + 'pendingComponent', + ), + errorComponent: lazyRouteComponent( + $$splitErrorComponentImporter, + 'errorComponent', + ), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@component---loader---notFoundComponent---pendingComponent.tsx index 382621ea9a..3b432397b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,8 +1,8 @@ function component() { - return
lowercase function declaration
; + return
lowercase function declaration
} function pendingComponent() { - return
lowercase pending function declaration
; + return
lowercase pending function declaration
} -export { component }; -export { pendingComponent }; \ No newline at end of file +export { component } +export { pendingComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@errorComponent.tsx index acc1c0be8d..9d411c1f0f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/lowercase-function-declaration@errorComponent.tsx @@ -1,4 +1,4 @@ function errorComponent() { - return
lowercase error function declaration
; + return
lowercase error function declaration
} -export { errorComponent }; \ No newline at end of file +export { errorComponent } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number.tsx index 5b4cfaaa9b..602ff5c117 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number.tsx @@ -1,28 +1,42 @@ -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 { Await, Link, createFileRoute } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -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`]; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; +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 { Await, Link, createFileRoute } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +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`, +] +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] export const Route = createFileRoute('/')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@component---loader---notFoundComponent---pendingComponent.tsx index c133e05d9e..37649d8606 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,69 +1,56 @@ -import { Await, Link, defer } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import { getSponsorsForSponsorPack } from '~/server/sponsors'; -import discordImage from '~/images/discord-logo-white.svg'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -import { useMutation } from '~/hooks/useMutation'; -import { sample } from '~/utils/utils'; -import { textColors } from "random-number.tsx"; -import { gradients } from "random-number.tsx"; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; -import { Route } from "random-number.tsx"; -async function bytesSignupServerFn({ - email -}: { - email: string; -}) { - 'use server'; - +import { Await, Link, defer } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import { getSponsorsForSponsorPack } from '~/server/sponsors' +import discordImage from '~/images/discord-logo-white.svg' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +import { useMutation } from '~/hooks/useMutation' +import { sample } from '~/utils/utils' +import { textColors } from 'random-number.tsx' +import { gradients } from 'random-number.tsx' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] +import { Route } from 'random-number.tsx' +async function bytesSignupServerFn({ email }: { email: string }) { + 'use server' return fetch(`https://bytes.dev/api/bytes-optin-cors`, { method: 'POST', - body: JSON.stringify({ - email, - influencer: 'tanstack' - }), - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json' - } - }); + body: JSON.stringify({ email, influencer: 'tanstack' }), + headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, + }) } function Index() { - const bytesSignupMutation = useMutation({ - fn: bytesSignupServerFn - }); - const { - sponsorsPromise, - randomNumber, - testing2 - } = Route.useLoaderData(); - const gradient = sample(gradients, randomNumber); - const textColor = sample(textColors, randomNumber); - return <> + const bytesSignupMutation = useMutation({ fn: bytesSignupServerFn }) + const { sponsorsPromise, randomNumber, testing2 } = Route.useLoaderData() + const gradient = sample(gradients, randomNumber) + const textColor = sample(textColors, randomNumber) + return ( + <> {discordImage} {gradient} {textColor} - ; + + ) } const SplitLoader = () => { return { randomNumber: Math.random(), - sponsorsPromise: defer(getSponsorsForSponsorPack()) - }; -}; -export { SplitLoader as loader }; -export { Index as component }; \ No newline at end of file + sponsorsPromise: defer(getSponsorsForSponsorPack()), + } +} +export { SplitLoader as loader } +export { Index as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@errorComponent.tsx index cdf4d37891..8e156eca17 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/random-number@errorComponent.tsx @@ -1,18 +1,20 @@ -import { Await, Link } from '@tanstack/react-router'; -import { Carbon } from '~/components/Carbon'; -import { twMerge } from 'tailwind-merge'; -import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa'; -import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg'; -import { Footer } from '~/components/Footer'; -import SponsorPack from '~/components/SponsorPack'; -import { LogoColor } from '~/components/LogoColor'; -import agGridImage from '~/images/ag-grid.png'; -import nozzleImage from '~/images/nozzle.png'; -import bytesImage from '~/images/bytes.svg'; -import bytesUidotdevImage from '~/images/bytes-uidotdev.png'; -const courses = [{ - name: 'The Official TanStack React Query Course', - cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, - href: 'https://query.gg/?s=tanstack', - description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.` -}]; \ No newline at end of file +import { Await, Link } from '@tanstack/react-router' +import { Carbon } from '~/components/Carbon' +import { twMerge } from 'tailwind-merge' +import { FaDiscord, FaGithub, FaTshirt } from 'react-icons/fa' +import { CgMusicSpeaker, CgSpinner } from 'react-icons/cg' +import { Footer } from '~/components/Footer' +import SponsorPack from '~/components/SponsorPack' +import { LogoColor } from '~/components/LogoColor' +import agGridImage from '~/images/ag-grid.png' +import nozzleImage from '~/images/nozzle.png' +import bytesImage from '~/images/bytes.svg' +import bytesUidotdevImage from '~/images/bytes-uidotdev.png' +const courses = [ + { + name: 'The Official TanStack React Query Course', + cardStyles: `border-t-4 border-red-500 hover:(border-green-500)`, + href: 'https://query.gg/?s=tanstack', + description: `Learn how to build enterprise quality apps with TanStack's React Query the easy way with our brand new course.`, + }, +] diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component.tsx index 568c8dc323..9f605effce 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx index 70d8b0eb42..7c2c8e17de 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import { importedLoader } from '../../shared/imported'; +import React from 'react' +import { importedLoader } from '../../shared/imported' function Component() { - return
Component
; + return
Component
} -const SplitLoader = importedLoader; -export { SplitLoader as loader }; -const SplitComponent = React.memo(Component); -export { SplitComponent as component }; \ No newline at end of file +const SplitLoader = importedLoader +export { SplitLoader as loader } +const SplitComponent = React.memo(Component) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component.tsx index 233eca72a0..7e9467be1b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component.tsx @@ -1,9 +1,11 @@ -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'; +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'), - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx index d2671013ef..83e6e4b28c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/react-memo-imported-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ -import React from 'react'; -import { importedLoader, importedComponent } from '../../shared/imported'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; -const SplitComponent = React.memo(importedComponent); -export { SplitComponent as component }; \ No newline at end of file +import React from 'react' +import { importedLoader, importedComponent } from '../../shared/imported' +const SplitLoader = importedLoader +export { SplitLoader as loader } +const SplitComponent = React.memo(importedComponent) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component.tsx index 1b00751ae6..4f14db0832 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component.tsx @@ -1,14 +1,16 @@ -console.warn("[tanstack-router] These exports from \"retain-export-component.tsx\" will not be code-split and will increase your bundle size:\n- Layout\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitLoaderImporter = () => import('retain-export-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute, Outlet } from '@tanstack/react-router'; -import { importedComponent as ImportedComponent } from '../../shared/imported'; +console.warn( + '[tanstack-router] These exports from "retain-export-component.tsx" will not be code-split and will increase your bundle size:\n- Layout\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitLoaderImporter = () => + import('retain-export-component.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute, Outlet } from '@tanstack/react-router' +import { importedComponent as ImportedComponent } from '../../shared/imported' export function Layout() { - return
-
+ return ( +
+
-
; +
+ ) } export const Route = createFileRoute('/_layout')({ component: Layout, - loader: lazyFn($$splitLoaderImporter, 'loader') -}); -const HEADER_HEIGHT = '63px'; -export const SIDEBAR_WIDTH = '150px'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) +const HEADER_HEIGHT = '63px' +export const SIDEBAR_WIDTH = '150px' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx index 9787e27ad7..ddeb4d1e6f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import { importedLoader } from '../../shared/imported'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; -const SplitLoader = importedLoader; -export { SplitLoader as loader }; \ No newline at end of file +import * as React from 'react' +import { importedLoader } from '../../shared/imported' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' +const SplitLoader = importedLoader +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@errorComponent.tsx index 5bb0ab5451..8fb12f0c6b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-export-component@errorComponent.tsx @@ -1,3 +1,3 @@ -import * as React from 'react'; -const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const.tsx index f256b01a83..d674dbb799 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export const loaderFn = () => { return importedLoader() } - const Layout = () => { return (
@@ -26,15 +24,12 @@ const Layout = () => {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-const@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured.tsx index 0e3175116f..89c23305a0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured.tsx @@ -1,18 +1,12 @@ import { createFileRoute } from '@tanstack/react-router' - const createBits = () => ({ component: AboutComponentImpl, - loader: () => ({ - message: 'hello', - }), + loader: () => ({ message: 'hello' }), }) - export const { component: AboutComponent, loader } = createBits() - function AboutComponentImpl() { return
About
} - export const Route = createFileRoute('/about')({ component: AboutComponent, loader, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured@component---loader---notFoundComponent---pendingComponent.tsx index 43108700f5..c3ddde13a8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-destructured@component---loader---notFoundComponent---pendingComponent.tsx @@ -1 +1 @@ -export { SplitLoader as loader }; \ No newline at end of file +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function.tsx index 298c388e65..83b3dd4eb5 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function.tsx @@ -4,11 +4,9 @@ import { importedComponent as ImportedComponent, importedLoader, } from '../../shared/imported' - export function loaderFn() { return importedLoader() } - function Layout() { return (
@@ -26,15 +24,12 @@ function Layout() {
) } - export const Route = createFileRoute('/_layout')({ component: Layout, loader: loaderFn, }) - const HEADER_HEIGHT = '63px' export const SIDEBAR_WIDTH = '150px' export const SIDEBAR_MINI_WIDTH = '80px' const ASIDE_WIDTH = '250px' - export default Layout diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-function@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader.tsx index b36cbc6be2..e805842e0c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader.tsx @@ -1,17 +1,18 @@ -console.warn("[tanstack-router] These exports from \"retain-exports-loader.tsx\" will not be code-split and will increase your bundle size:\n- loaderFn\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file."); -const $$splitComponentImporter = () => import('retain-exports-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -import * as React from 'react'; -import { createFileRoute } from '@tanstack/react-router'; +console.warn( + '[tanstack-router] These exports from "retain-exports-loader.tsx" will not be code-split and will increase your bundle size:\n- loaderFn\nFor the best optimization, these items should either have their export statements removed, or be imported from another location that is not a route file.', +) +const $$splitComponentImporter = () => + import('retain-exports-loader.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' export function loaderFn() { - return { - foo: 'bar' - }; + return { foo: 'bar' } } export const Route = createFileRoute('/_layout')({ component: lazyRouteComponent($$splitComponentImporter, 'component'), - loader: loaderFn -}); -export const SIDEBAR_WIDTH = '150px'; -export const SIDEBAR_MINI_WIDTH = '80px'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file + loader: loaderFn, +}) +export const SIDEBAR_WIDTH = '150px' +export const SIDEBAR_MINI_WIDTH = '80px' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx index 9f54ae0dc5..604be4dc69 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,11 +1,10 @@ -import * as React from 'react'; -import { Outlet } from '@tanstack/react-router'; -import { importedComponent as ImportedComponent } from '../../shared/imported'; +import * as React from 'react' +import { Outlet } from '@tanstack/react-router' +import { importedComponent as ImportedComponent } from '../../shared/imported' function Layout() { - return
-
+ return ( +
+
-
; +
+ ) } -const HEADER_HEIGHT = '63px'; -const ASIDE_WIDTH = '250px'; -export { Layout as component }; \ No newline at end of file +const HEADER_HEIGHT = '63px' +const ASIDE_WIDTH = '250px' +export { Layout as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@errorComponent.tsx index 168ba78680..0e0123f1ab 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/retain-exports-loader@errorComponent.tsx @@ -1,2 +1,2 @@ -import * as React from 'react'; -const ASIDE_WIDTH = '250px'; \ No newline at end of file +import * as React from 'react' +const ASIDE_WIDTH = '250px' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class.tsx index 48afc3f070..c9bffc92ba 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class.tsx @@ -1,18 +1,20 @@ -const $$splitComponentImporter = () => import('shared-class.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-class.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-class.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-class.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' class DataStore { - data = new Map(); + data = new Map() get(k: string) { - return this.data.get(k); + return this.data.get(k) } set(k: string, v: unknown) { - this.data.set(k, v); + this.data.set(k, v) } } export const Route = createFileRoute('/store')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@component---loader---notFoundComponent---pendingComponent.tsx index 10675b99ed..39593e61e0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,16 +1,16 @@ class DataStore { - data = new Map(); + data = new Map() get(k: string) { - return this.data.get(k); + return this.data.get(k) } set(k: string, v: unknown) { - this.data.set(k, v); + this.data.set(k, v) } } -const store = new DataStore(); +const store = new DataStore() const SplitLoader = async () => { - store.set('items', await fetch('/api')); -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
{store.get('items')}
; -export { SplitComponent as component }; \ No newline at end of file + store.set('items', await fetch('/api')) +} +export { SplitLoader as loader } +const SplitComponent = () =>
{store.get('items')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@errorComponent.tsx index 0a50638c6a..31a1763b5d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-class@errorComponent.tsx @@ -1,9 +1,9 @@ class DataStore { - data = new Map(); + data = new Map() get(k: string) { - return this.data.get(k); + return this.data.get(k) } set(k: string, v: unknown) { - this.data.set(k, v); + this.data.set(k, v) } -} \ No newline at end of file +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export.tsx index 73f1b54389..6b770a1cf2 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export.tsx @@ -1,19 +1,15 @@ -const $$splitComponentImporter = () => import('shared-destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -export const { - apiUrl, - timeout -} = getConfig(); +const $$splitComponentImporter = () => + import('shared-destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-destructured-export.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +export const { apiUrl, timeout } = getConfig() export const Route = createFileRoute('/config')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; -} \ No newline at end of file + return { apiUrl: '/api', timeout: 5000 } +} diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export@component---loader---notFoundComponent---pendingComponent.tsx index d48accf910..68114df748 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured-export@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import { apiUrl, timeout } from "shared-destructured-export.tsx"; -const SplitLoader = async () => fetch(apiUrl); -export { SplitLoader as loader }; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +import { apiUrl, timeout } from 'shared-destructured-export.tsx' +const SplitLoader = async () => fetch(apiUrl) +export { SplitLoader as loader } +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured.tsx index fbc4272c3e..78bf0b8ceb 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-destructured.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-destructured.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-destructured.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-destructured.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/config')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured@component---loader---notFoundComponent---pendingComponent.tsx index e92f7dd7f8..a5c9439324 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-destructured@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,14 +1,8 @@ -const { - apiUrl, - timeout -} = getConfig(); +const { apiUrl, timeout } = getConfig() function getConfig() { - return { - apiUrl: '/api', - timeout: 5000 - }; + return { apiUrl: '/api', timeout: 5000 } } -const SplitLoader = async () => fetch(apiUrl); -export { SplitLoader as loader }; -const SplitComponent = () =>
Timeout: {timeout}
; -export { SplitComponent as component }; \ No newline at end of file +const SplitLoader = async () => fetch(apiUrl) +export { SplitLoader as loader } +const SplitComponent = () =>
Timeout: {timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported.tsx index 76a5d29dc3..887f52978d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported.tsx @@ -1,13 +1,12 @@ -const $$splitComponentImporter = () => import('shared-exported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-exported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -export const queryOptions = { - staleTime: 5000, - gcTime: 10000 -}; +const $$splitComponentImporter = () => + import('shared-exported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-exported.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +export const queryOptions = { staleTime: 5000, gcTime: 10000 } export const Route = createFileRoute('/query')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported@component---loader---notFoundComponent---pendingComponent.tsx index f77f81cbdb..f2a32be2bc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-exported@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,9 +1,7 @@ -import { queryOptions } from "shared-exported.tsx"; +import { queryOptions } from 'shared-exported.tsx' const SplitLoader = async () => { - return { - staleTime: queryOptions.staleTime - }; -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
GC: {queryOptions.gcTime}
; -export { SplitComponent as component }; \ No newline at end of file + return { staleTime: queryOptions.staleTime } +} +export { SplitLoader as loader } +const SplitComponent = () =>
GC: {queryOptions.gcTime}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function.tsx index 8a921d9640..b964d09962 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/cached')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function@component---loader---notFoundComponent---pendingComponent.tsx index cfe519f47a..0f4a23b3fe 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,14 +1,14 @@ -const cache = new Map(); +const cache = new Map() function getCached(key: string) { - return cache.get(key); + return cache.get(key) } function setCached(key: string, val: unknown) { - cache.set(key, val); + cache.set(key, val) } const SplitLoader = async () => { - setCached('data', await fetch('/api').then(r => r.json())); - return getCached('data'); -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
; -export { SplitComponent as component }; \ No newline at end of file + setCached('data', await fetch('/api').then((r) => r.json())) + return getCached('data') +} +export { SplitLoader as loader } +const SplitComponent = () =>
{JSON.stringify(getCached('data'))}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding.tsx index feb46cd789..71082ac702 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-imported-binding.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-imported-binding.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-imported-binding.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-imported-binding.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/imported')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding@component---loader---notFoundComponent---pendingComponent.tsx index 409e8d4023..7718cec94c 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-imported-binding@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,5 +1,5 @@ -import { sharedUtil } from '../utils'; -const SplitLoader = async () => sharedUtil('load'); -export { SplitLoader as loader }; -const SplitComponent = () =>
{sharedUtil('render')}
; -export { SplitComponent as component }; \ No newline at end of file +import { sharedUtil } from '../utils' +const SplitLoader = async () => sharedUtil('load') +export { SplitLoader as loader } +const SplitComponent = () =>
{sharedUtil('render')}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref.tsx index 4275e17e58..913fae8432 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-indirect-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-indirect-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-indirect-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-indirect-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/shared-indirect')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref@component---loader---notFoundComponent---pendingComponent.tsx index 090f3b5c73..90815572f7 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-indirect-ref@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,19 +1,17 @@ -const state = { - count: 0 -}; +const state = { count: 0 } function getCount() { - return state.count; + return state.count } function SharedComponent() { - return
+ return ( +
{getCount()} - {state.count} -
; +
+ ) } const SplitLoader = () => { - state.count++; - return { - count: getCount() - }; -}; -export { SplitLoader as loader }; -export { SharedComponent as component }; \ No newline at end of file + state.count++ + return { count: getCount() } +} +export { SplitLoader as loader } +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref.tsx index 130c7ce120..7d5cff0d5f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-jsx-component-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-jsx-component-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-jsx-component-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-jsx-component-ref.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' // @ts-nocheck -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/jsx')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref@component---loader---notFoundComponent---pendingComponent.tsx index c5fd18664e..82b634246f 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-jsx-component-ref@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,9 +1,8 @@ // @ts-nocheck - -const shared = 1; +const shared = 1 function SharedComponent() { - return
{shared}
; + return
{shared}
} -const SplitLoader = () => shared; -export { SplitLoader as loader }; -export { SharedComponent as component }; \ No newline at end of file +const SplitLoader = () => shared +export { SplitLoader as loader } +export { SharedComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none.tsx index eac0f9ab0a..1dd8f7bb0a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-none.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-none.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-none.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-none.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/clean')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none@component---loader---notFoundComponent---pendingComponent.tsx index f9f52ba6be..9f1d1a5ca1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-none@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,8 +1,10 @@ -const loaderHelper = () => fetch('/api'); -const ComponentHelper = () => helper; -const SplitLoader = async () => loaderHelper(); -export { SplitLoader as loader }; -const SplitComponent = () =>
- -
; -export { SplitComponent as component }; \ No newline at end of file +const loaderHelper = () => fetch('/api') +const ComponentHelper = () => helper +const SplitLoader = async () => loaderHelper() +export { SplitLoader as loader } +const SplitComponent = () => ( +
+ +
+) +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route.tsx index 9aebb45a95..f51ed0c13a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-referencing-route.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-referencing-route.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-referencing-route.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-referencing-route.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/about')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route@component---loader---notFoundComponent---pendingComponent.tsx index 9bcd130ea8..da98398ae1 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-referencing-route@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,17 +1,15 @@ -const HEADER = 'Page'; +const HEADER = 'Page' function usePageTitle() { - return `${HEADER} - ${Route.fullPath}`; + return `${HEADER} - ${Route.fullPath}` } -import { Route } from "shared-referencing-route.tsx"; +import { Route } from 'shared-referencing-route.tsx' const SplitLoader = async () => { - const title = usePageTitle(); - return { - title - }; -}; -export { SplitLoader as loader }; + const title = usePageTitle() + return { title } +} +export { SplitLoader as loader } const SplitComponent = () => { - const title = usePageTitle(); - return
{title}
; -}; -export { SplitComponent as component }; \ No newline at end of file + const title = usePageTitle() + return
{title}
+} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime.tsx index d88eff9d9b..fdc18fa37b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime.tsx @@ -1,22 +1,20 @@ -import { state, createState, createSeed } from "shared-runtime.tsx?tsr-shared=1"; -const $$splitComponentImporter = () => import('shared-runtime.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-runtime.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('shared-runtime:reference'); +import { state, createState, createSeed } from 'shared-runtime.tsx?tsr-shared=1' +const $$splitComponentImporter = () => + import('shared-runtime.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-runtime.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('shared-runtime:reference') export const Route = createFileRoute('/shared-runtime')({ beforeLoad: () => state, loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@component---loader---notFoundComponent---pendingComponent.tsx index 0af87c21c5..053cf24d5a 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,28 +1,30 @@ -import { state, createState, createSeed, Labels, increment } from "shared-runtime.tsx?tsr-shared=1"; -const label = createComponentLabel(); -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -function createComponentLabel() { - console.log('shared-runtime:component'); - return Labels.component; +import { + state, + createState, + createSeed, + Labels, + increment, +} from 'shared-runtime.tsx?tsr-shared=1' +const label = createComponentLabel() +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number } -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; +function createComponentLabel() { + console.log('shared-runtime:component') + return Labels.component +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed const SplitLoader = () => { - increment(); - return state; -}; -export { SplitLoader as loader }; + increment() + return state +} +export { SplitLoader as loader } const SplitComponent = () => { if (state.count === 3) { - throw new Error('route source-map contract'); + throw new Error('route source-map contract') } - return `${label}:${state.count}`; -}; -export { SplitComponent as component }; \ No newline at end of file + return `${label}:${state.count}` +} +export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@errorComponent.tsx index d890a562c9..03cacac5b3 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@errorComponent.tsx @@ -1,11 +1,7 @@ -import { state, createState, createSeed } from "shared-runtime.tsx?tsr-shared=1"; -function createState(initialState: { - count: number; -}): { - state: { - count: number; - }; - increment: () => number; -}; -export { state as firstState, state as secondState, state as 'odd-name' }; -export default createSeed; \ No newline at end of file +import { state, createState, createSeed } from 'shared-runtime.tsx?tsr-shared=1' +function createState(initialState: { count: number }): { + state: { count: number } + increment: () => number +} +export { state as firstState, state as secondState, state as 'odd-name' } +export default createSeed diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@shared.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@shared.tsx index 54239b6cc5..c53a7e1568 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@shared.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-runtime@shared.tsx @@ -1,28 +1,13 @@ -const Count = { - Initial: 0 -}; -const Labels = { - component: 'count' -}; -const seed = createSeed(); -const { - state, - increment -} = createState(seed); +const Count = { Initial: 0 } +const Labels = { component: 'count' } +const seed = createSeed() +const { state, increment } = createState(seed) function createSeed() { - console.log('shared-runtime:seed'); - return { - count: Count.Initial, - label: Labels.component - }; + console.log('shared-runtime:seed') + return { count: Count.Initial, label: Labels.component } } -function createState(initialState: { - count: number; -}) { - console.log('shared-runtime:state'); - return { - state: initialState, - increment: () => initialState.count++ - }; +function createState(initialState: { count: number }) { + console.log('shared-runtime:state') + return { state: initialState, increment: () => initialState.count++ } } -export { Count, createSeed, createState, increment, Labels, seed, state }; \ No newline at end of file +export { Count, createSeed, createState, increment, Labels, seed, state } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive.tsx index 67b0631b8e..552cd657e0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-transitive.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-transitive.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-transitive.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-transitive.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/api')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive@component---loader---notFoundComponent---pendingComponent.tsx index 662d7fd7aa..c67ed3c691 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-transitive@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,12 +1,9 @@ -const BASE_URL = 'https://api.example.com'; -const config = { - url: BASE_URL, - timeout: 5000 -}; -const fetcher = (path: string) => fetch(`${config.url}${path}`); +const BASE_URL = 'https://api.example.com' +const config = { url: BASE_URL, timeout: 5000 } +const fetcher = (path: string) => fetch(`${config.url}${path}`) const SplitLoader = async () => { - return fetcher('/data'); -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
Timeout: {config.timeout}
; -export { SplitComponent as component }; \ No newline at end of file + return fetcher('/data') +} +export { SplitLoader as loader } +const SplitComponent = () =>
Timeout: {config.timeout}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable.tsx index 48cdad100e..191b12aa33 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('shared-variable.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-variable.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; +const $$splitComponentImporter = () => + import('shared-variable.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-variable.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/todos')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable@component---loader---notFoundComponent---pendingComponent.tsx index daca782a6f..e96ced1955 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-variable@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,13 +1,8 @@ -const collection = { - name: 'todos', - preload: async () => {} -}; +const collection = { name: 'todos', preload: async () => {} } const SplitLoader = async () => { - await collection.preload(); - return { - data: 'loaded' - }; -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
{collection.name}
; -export { SplitComponent as component }; \ No newline at end of file + await collection.preload() + return { data: 'loaded' } +} +export { SplitLoader as loader } +const SplitComponent = () =>
{collection.name}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect.tsx index c322746737..5f68cb275d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect.tsx @@ -1,10 +1,12 @@ -const $$splitComponentImporter = () => import('shared-with-side-effect.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/react-router'; -const $$splitLoaderImporter = () => import('shared-with-side-effect.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; -import { createFileRoute } from '@tanstack/react-router'; -console.log('registry created'); +const $$splitComponentImporter = () => + import('shared-with-side-effect.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/react-router' +const $$splitLoaderImporter = () => + import('shared-with-side-effect.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' +console.log('registry created') export const Route = createFileRoute('/fx')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect@component---loader---notFoundComponent---pendingComponent.tsx index 6c77f8b857..542779a26b 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/shared-with-side-effect@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,7 +1,7 @@ -const registry = new Map(); +const registry = new Map() const SplitLoader = async () => { - registry.set('loaded', true); -}; -export { SplitLoader as loader }; -const SplitComponent = () =>
{registry.size}
; -export { SplitComponent as component }; \ No newline at end of file + registry.set('loaded', true) +} +export { SplitLoader as loader } +const SplitComponent = () =>
{registry.size}
+export { SplitComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/undefined-literals.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/undefined-literals.tsx index 0c6e4f01aa..88b0bf1ba8 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/undefined-literals.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/undefined-literals.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/undefined-test')({ component: undefined, errorComponent: undefined, diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure.tsx index d0de09bf8b..b5b3ecade6 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure.tsx @@ -1,5 +1,4 @@ import * as React from 'react' - import { CgCornerUpLeft, CgSpinner } from 'react-icons/cg' import { FaBolt, @@ -21,7 +20,6 @@ import { startProject } from '~/projects/start' import { createFileRoute } from '@tanstack/react-router' import { Framework, getBranch } from '~/projects' import { seo } from '~/utils/seo' - const menu = [ { label: ( @@ -72,31 +70,22 @@ const menu = [ to: `https://cottonbureau.com/people/tanstack`, }, ] - export const Route = createFileRoute('/_libraries/start/$version/')({ component: VersionIndex, meta: () => - seo({ - title: startProject.name, - description: startProject.description, - }), + seo({ title: startProject.name, description: startProject.description }), }) - const librariesRouteApi = getRouteApi('/_libraries') - export default function VersionIndex() { const { sponsorsPromise } = librariesRouteApi.useLoaderData() const { version } = Route.useParams() const branch = getBranch(startProject, version) const [framework, setFramework] = React.useState('react') const [isDark, 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 (
{item.label}
) - return (
{item.to.startsWith('http') ? ( @@ -269,7 +257,6 @@ Check it out at https://tanstack.com/start/`,
*/} - {/*

@@ -315,7 +302,6 @@ Check it out at https://tanstack.com/start/`, })}

*/} - {/*
Trusted in Production by @@ -358,7 +344,6 @@ Check it out at https://tanstack.com/start/`,
*/} -

Partners @@ -388,16 +373,13 @@ Check it out at https://tanstack.com/start/`,

-

Sponsors

-
@@ -429,7 +410,6 @@ Check it out at https://tanstack.com/start/`, rage-quit OSS. Yay money! 😉
- {/*

@@ -468,7 +448,6 @@ Check it out at https://tanstack.com/start/`,

*/} - {/* {[''].includes(framework) ? (
@@ -503,7 +482,6 @@ Check it out at https://tanstack.com/start/`, >
)} */} - {/*
Wow, you've come a long way! diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@errorComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@errorComponent.tsx index 97b5481cf5..5cc3099643 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@errorComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/useStateDestructure@errorComponent.tsx @@ -1,2 +1,2 @@ -import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa'; -import { VscPreview, VscWand } from 'react-icons/vsc'; \ No newline at end of file +import { FaBolt, FaBook, FaCheckCircle, FaCogs } from 'react-icons/fa' +import { VscPreview, VscWand } from 'react-icons/vsc' diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using.tsx index 140f394f60..22ad515362 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using.tsx @@ -1,5 +1,6 @@ -const $$splitLoaderImporter = () => import('using.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/react-router'; +const $$splitLoaderImporter = () => + import('using.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/react-router' export const Route = createFileRoute({ - loader: lazyFn($$splitLoaderImporter, 'loader') -}); \ No newline at end of file + loader: lazyFn($$splitLoaderImporter, 'loader'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using@component---loader---notFoundComponent---pendingComponent.tsx index 7e4f4fde9b..3b60e73b8d 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/react/3-all-combined-errorComponent-separate/using@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,17 +1,9 @@ const DummyPostResource = (postId: string) => ({ - postData: { - id: postId, - title: 'dummy', - body: 'dummy' - }, - [Symbol.dispose]: () => console.log('disposing!') -}); -const SplitLoader = ({ - params: { - postId - } -}) => { - using dummyPost = DummyPostResource(postId); - return dummyPost.postData; -}; -export { SplitLoader as loader }; \ No newline at end of file + postData: { id: postId, title: 'dummy', body: 'dummy' }, + [Symbol.dispose]: () => console.log('disposing!'), +}) +const SplitLoader = ({ params: { postId } }) => { + using dummyPost = DummyPostResource(postId) + return dummyPost.postData +} +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function.tsx index b09548da57..10bedc87f0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function.tsx @@ -1,8 +1,9 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component'); -import { lazyRouteComponent } from '@tanstack/solid-router'; -import { createFileRoute } from '@tanstack/solid-router'; -import { fetchPosts } from '../posts'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component') +import { lazyRouteComponent } from '@tanstack/solid-router' +import { createFileRoute } from '@tanstack/solid-router' +import { fetchPosts } from '../posts' export const Route = createFileRoute('/posts')({ loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function@component.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function@component.tsx index fe44a34fe1..c84e6f25d4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function@component.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/1-default/arrow-function@component.tsx @@ -1,26 +1,31 @@ -import * as Solid from 'solid-js'; -import { Link, Outlet } from '@tanstack/solid-router'; -import { Route } from "arrow-function.tsx"; +import * as Solid from 'solid-js' +import { Link, Outlet } from '@tanstack/solid-router' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {post => { - return
  • - + {(post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - }} + + ) + }}

-
; -}; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function.tsx index 61c77d73bd..6842e20964 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/solid-router'; -const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=loader'); -import { lazyFn } from '@tanstack/solid-router'; -import { createFileRoute } from '@tanstack/solid-router'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component---errorComponent---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/solid-router' +const $$splitLoaderImporter = () => + import('arrow-function.tsx?tsr-split=loader') +import { lazyFn } from '@tanstack/solid-router' +import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx index fe44a34fe1..c84e6f25d4 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@component---errorComponent---notFoundComponent---pendingComponent.tsx @@ -1,26 +1,31 @@ -import * as Solid from 'solid-js'; -import { Link, Outlet } from '@tanstack/solid-router'; -import { Route } from "arrow-function.tsx"; +import * as Solid from 'solid-js' +import { Link, Outlet } from '@tanstack/solid-router' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {post => { - return
  • - + {(post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - }} + + ) + }}

-
; -}; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@loader.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@loader.tsx index d9ed4ea7af..888abc8593 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@loader.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/2-components-combined-loader-separate/arrow-function@loader.tsx @@ -1,3 +1,3 @@ -import { fetchPosts } from '../posts'; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; \ No newline at end of file +import { fetchPosts } from '../posts' +const SplitLoader = fetchPosts +export { SplitLoader as loader } diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function.tsx index a872f13d33..2b7b2caefc 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function.tsx @@ -1,9 +1,11 @@ -const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyRouteComponent } from '@tanstack/solid-router'; -const $$splitLoaderImporter = () => import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent'); -import { lazyFn } from '@tanstack/solid-router'; -import { createFileRoute } from '@tanstack/solid-router'; +const $$splitComponentImporter = () => + import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyRouteComponent } from '@tanstack/solid-router' +const $$splitLoaderImporter = () => + import('arrow-function.tsx?tsr-split=component---loader---notFoundComponent---pendingComponent') +import { lazyFn } from '@tanstack/solid-router' +import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/posts')({ loader: lazyFn($$splitLoaderImporter, 'loader'), - component: lazyRouteComponent($$splitComponentImporter, 'component') -}); \ No newline at end of file + component: lazyRouteComponent($$splitComponentImporter, 'component'), +}) diff --git a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx index 2ea36d2e03..7fdf2dd9d0 100644 --- a/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx +++ b/packages/router-plugin/tests/code-splitter/snapshots/solid/3-all-combined-errorComponent-separate/arrow-function@component---loader---notFoundComponent---pendingComponent.tsx @@ -1,29 +1,34 @@ -import * as Solid from 'solid-js'; -import { Link, Outlet } from '@tanstack/solid-router'; -import { fetchPosts } from '../posts'; -import { Route } from "arrow-function.tsx"; +import * as Solid from 'solid-js' +import { Link, Outlet } from '@tanstack/solid-router' +import { fetchPosts } from '../posts' +import { Route } from 'arrow-function.tsx' const PostsComponent = () => { - const posts = Route.useLoaderData(); - return
+ const posts = Route.useLoaderData() + return ( +
    - {post => { - return
  • - + {(post) => { + return ( +
  • +
    {post.title.substring(0, 20)}
    -
  • ; - }} + + ) + }}

-
; -}; -const SplitLoader = fetchPosts; -export { SplitLoader as loader }; -export { PostsComponent as component }; \ No newline at end of file +
+ ) +} +const SplitLoader = fetchPosts +export { SplitLoader as loader } +export { PostsComponent as component } diff --git a/packages/router-plugin/tests/delete-nodes.test.ts b/packages/router-plugin/tests/delete-nodes.test.ts index 6bb1d3dc6d..d9b37ce54a 100644 --- a/packages/router-plugin/tests/delete-nodes.test.ts +++ b/packages/router-plugin/tests/delete-nodes.test.ts @@ -4,6 +4,7 @@ import { describe, expect, it } from 'vitest' import { compileCodeSplitReferenceRoute } from '../src/core/code-splitter/compilers' import { frameworks } from './constants' +import { formatSnapshot } from './format-snapshot' import type { DeletableNodes } from '../src/core/config' function getFrameworkDir(framework: string) { @@ -57,7 +58,9 @@ describe('code-splitter delete nodes', () => { targetFramework: framework, }) - await expect(compileResult?.code || code).toMatchFileSnapshot( + await expect( + await formatSnapshot(compileResult?.code || code, filename), + ).toMatchFileSnapshot( path.join(dirs.snapshots, groupName, filename), ) }, diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRoute-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRoute-ssr-function.tsx index 512e597528..9ddd962b9c 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRoute-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRoute-ssr-function.tsx @@ -1,6 +1,5 @@ import { createRootRoute } from '@tanstack/react-router' import crypto from 'node:crypto' - export const Route = createRootRoute({ ssr: () => { if (crypto.randomInt(0, 2) === 0) { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRouteWithContext-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRouteWithContext-ssr-function.tsx index 9a2cac49b3..97521cd051 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRouteWithContext-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/createRootRouteWithContext-ssr-function.tsx @@ -1,6 +1,5 @@ import { createRootRouteWithContext } from '@tanstack/react-router' import crypto from 'node:crypto' - export const Route = createRootRouteWithContext<{}>()({ ssr: () => { if (crypto.randomInt(0, 2) === 0) { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-data-only.tsx index c489be3266..9ab5a1eb7f 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-data-only.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/')({ ssr: 'data-only', component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-false.tsx index d2409de686..daeb982324 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/1-delete-nodes-undefined/ssr-false.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/')({ ssr: false, component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRoute-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRoute-ssr-function.tsx index 512e597528..9ddd962b9c 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRoute-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRoute-ssr-function.tsx @@ -1,6 +1,5 @@ import { createRootRoute } from '@tanstack/react-router' import crypto from 'node:crypto' - export const Route = createRootRoute({ ssr: () => { if (crypto.randomInt(0, 2) === 0) { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRouteWithContext-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRouteWithContext-ssr-function.tsx index 9a2cac49b3..97521cd051 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRouteWithContext-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/createRootRouteWithContext-ssr-function.tsx @@ -1,6 +1,5 @@ import { createRootRouteWithContext } from '@tanstack/react-router' import crypto from 'node:crypto' - export const Route = createRootRouteWithContext<{}>()({ ssr: () => { if (crypto.randomInt(0, 2) === 0) { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-data-only.tsx index c489be3266..9ab5a1eb7f 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-data-only.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/')({ ssr: 'data-only', component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-false.tsx index d2409de686..daeb982324 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/2-delete-nodes-empty/ssr-false.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/react-router' - export const Route = createFileRoute('/')({ ssr: false, component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRoute-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRoute-ssr-function.tsx index a442b9ad2f..74e60e59e1 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRoute-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRoute-ssr-function.tsx @@ -1,6 +1,6 @@ -import { createRootRoute } from '@tanstack/react-router'; +import { createRootRoute } from '@tanstack/react-router' export const Route = createRootRoute({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRouteWithContext-ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRouteWithContext-ssr-function.tsx index 75c818b072..9c4e69445c 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRouteWithContext-ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/createRootRouteWithContext-ssr-function.tsx @@ -1,6 +1,6 @@ -import { createRootRouteWithContext } from '@tanstack/react-router'; +import { createRootRouteWithContext } from '@tanstack/react-router' export const Route = createRootRouteWithContext<{}>()({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-data-only.tsx index cd2371ae2e..fd9a7cd090 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-data-only.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-false.tsx index cd2371ae2e..fd9a7cd090 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-false.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-function.tsx index cd2371ae2e..fd9a7cd090 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/react/3-delete-nodes-ssr/ssr-function.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-data-only.tsx index e6a51d19ea..50cdfdeb49 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-data-only.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: 'data-only', component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-false.tsx index 31eda25da3..178109f8d7 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-false.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: false, component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-function.tsx index a111e03c8d..d16a74bb7a 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/1-delete-nodes-undefined/ssr-function.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: () => { if (typeof window === 'undefined') { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-data-only.tsx index e6a51d19ea..50cdfdeb49 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-data-only.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: 'data-only', component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-false.tsx index 31eda25da3..178109f8d7 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-false.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: false, component: () => { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-function.tsx index a111e03c8d..d16a74bb7a 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/2-delete-nodes-empty/ssr-function.tsx @@ -1,5 +1,4 @@ import { createFileRoute } from '@tanstack/solid-router' - export const Route = createFileRoute('/')({ ssr: () => { if (typeof window === 'undefined') { diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-data-only.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-data-only.tsx index 77e05f3b12..7ed1de7be5 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-data-only.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-data-only.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router'; +import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-false.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-false.tsx index 77e05f3b12..7ed1de7be5 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-false.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-false.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router'; +import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-function.tsx b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-function.tsx index 77e05f3b12..7ed1de7be5 100644 --- a/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-function.tsx +++ b/packages/router-plugin/tests/delete-nodes/snapshots/solid/3-delete-nodes-ssr/ssr-function.tsx @@ -1,6 +1,6 @@ -import { createFileRoute } from '@tanstack/solid-router'; +import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/')({ component: () => { - return
hello world
; - } -}); \ No newline at end of file + return
hello world
+ }, +}) diff --git a/packages/router-plugin/tests/format-snapshot.ts b/packages/router-plugin/tests/format-snapshot.ts new file mode 100644 index 0000000000..d152094bea --- /dev/null +++ b/packages/router-plugin/tests/format-snapshot.ts @@ -0,0 +1,69 @@ +import { format } from 'prettier' +import { parsers } from 'prettier/plugins/typescript' +import type { ParserOptions } from 'prettier' + +/** + * Formats compiler output before it is compared with a file snapshot, so that + * snapshots record the emitted program instead of the layout choices of the + * code generator (object wrapping, blank lines, parentheses around JSX, ...). + * + * Comments are kept: they are part of the output. Output that does not parse + * is returned unchanged. + */ +export async function formatSnapshot(code: string, filepath: string) { + try { + return await format(await removeBlankLines(code, filepath), { + filepath, + parser: 'typescript', + semi: false, + singleQuote: true, + trailingComma: 'all', + // Do not keep an object expanded because the generator printed it + // over several lines. + objectWrap: 'collapse', + }) + } catch { + return code + } +} + +/** + * Prettier keeps single blank lines from its input. Outside template literals, + * line breaks are not significant, so blank lines can be dropped. + */ +async function removeBlankLines(code: string, filepath: string) { + const parser = parsers.typescript + const ast = await parser.parse(code, { filepath } as ParserOptions) + const templateRanges: Array<[number, number]> = [] + const visit = (node: unknown): void => { + if (Array.isArray(node)) { + node.forEach(visit) + return + } + if (!node || typeof node !== 'object') { + return + } + if ((node as { type?: unknown }).type === 'TemplateElement') { + templateRanges.push([parser.locStart(node), parser.locEnd(node)]) + } + for (const [key, value] of Object.entries(node)) { + if (key !== 'loc' && key !== 'range') { + visit(value) + } + } + } + visit(ast) + + const lines: Array = [] + let lineStart = 0 + for (const line of code.split('\n')) { + const isInTemplate = templateRanges.some( + ([start, end]) => start < lineStart && lineStart < end, + ) + if (line.trim() !== '' || isInTemplate) { + lines.push(line) + } + lineStart += line.length + 1 + } + return lines.join('\n') +} diff --git a/packages/start-plugin-core/package.json b/packages/start-plugin-core/package.json index 6ab02f91e5..677fb18013 100644 --- a/packages/start-plugin-core/package.json +++ b/packages/start-plugin-core/package.json @@ -113,6 +113,7 @@ "@types/babel__core": "^7.20.5", "@types/node": ">=20", "@types/picomatch": "^4.0.2", + "prettier": "^3.9.6", "vite": "*", "@tanstack/vite-config": "catalog:", "vitest": "catalog:", diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts index 4f645d73db..fa48668a38 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts +++ b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts @@ -6,6 +6,7 @@ import { detectKindsInCode, StartCompiler, } from '../../src/start-compiler/compiler' +import { formatSnapshot } from '../format-snapshot' // Default test options for StartCompiler function getDefaultTestOptions(env: 'client' | 'server') { @@ -72,9 +73,9 @@ describe('ClientOnlyJSX compiles correctly', async () => { }) if (compiledResult) { - await expect(compiledResult.code).toMatchFileSnapshot( - `./snapshots/server/${filename}`, - ) + await expect( + await formatSnapshot(compiledResult.code, filename), + ).toMatchFileSnapshot(`./snapshots/server/${filename}`) } else { // No transformation - for files where ClientOnly is not from TanStack await expect('no-transform').toMatchFileSnapshot( diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx index 82195ff739..96de7844f6 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx +++ b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx @@ -1,6 +1,8 @@ -import { ClientOnly } from '@tanstack/react-router'; +import { ClientOnly } from '@tanstack/react-router' export function MyComponent() { - return
+ return ( +
Loading...
} /> -
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx index f437f41b05..6b95090d3f 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx +++ b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx @@ -1,8 +1,10 @@ -import { ClientOnly } from '@tanstack/react-router'; +import { ClientOnly } from '@tanstack/react-router' export function MyComponent() { - return
+ return ( +
Loading video...} />

Some server content

Loading audio...} /> -
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx index 9d48d6577d..f3d5d3b526 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx +++ b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx @@ -1,6 +1,8 @@ -import { ClientOnly } from '@tanstack/react-router'; +import { ClientOnly } from '@tanstack/react-router' export function MyComponent() { - return
+ return ( +
Outer loading
} /> -
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx index 9224aeb1cf..40551a6dad 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx +++ b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx @@ -1,6 +1,8 @@ -import { ClientOnly } from '@tanstack/react-router'; +import { ClientOnly } from '@tanstack/react-router' export function MyComponent() { - return
+ return ( +
-
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx index de9e376b63..9a537448b0 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx +++ b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx @@ -1,7 +1,9 @@ // Test: ClientOnly imported with an alias should still be transformed -import { ClientOnly as CO } from '@tanstack/react-router'; +import { ClientOnly as CO } from '@tanstack/react-router' export function MyComponent() { - return
+ return ( +
Loading...
} /> -
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts index c36c117692..0b6a5aa26a 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts +++ b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts @@ -3,6 +3,7 @@ import path from 'node:path' import { describe, expect, test } from 'vitest' import { StartCompiler } from '../../src/start-compiler/compiler' +import { formatSnapshot } from '../format-snapshot' // Default test options for StartCompiler function getDefaultTestOptions(env: 'client' | 'server') { @@ -68,9 +69,9 @@ describe('createIsomorphicFn compiles correctly', async () => { id: filename, }) - await expect(compiledResult!.code).toMatchFileSnapshot( - `./snapshots/${env}/${filename}`, - ) + await expect( + await formatSnapshot(compiledResult!.code, filename), + ).toMatchFileSnapshot(`./snapshots/${env}/${filename}`) }, ) }) diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts index efc23cf31b..7e8ade3201 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts @@ -1,5 +1,5 @@ const getEnvironment = () => { - console.log('[CLIENT] getEnvironment called'); - return 'client'; -}; -const moduleLevel = getEnvironment(); \ No newline at end of file + console.log('[CLIENT] getEnvironment called') + return 'client' +} +const moduleLevel = getEnvironment() diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx index 956fe05f98..20fbb3d4dc 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx @@ -1,13 +1,13 @@ -import { createIsomorphicFn } from '@tanstack/react-start'; -const noImpl = createIsomorphicFn(); -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -const serverOnlyFnAbstracted = () => {}; +import { createIsomorphicFn } from '@tanstack/react-start' +const noImpl = createIsomorphicFn() +const serverOnlyFn = () => {} +const clientOnlyFn = () => 'client' +const serverThenClientFn = () => 'client' +const clientThenServerFn = () => 'client' +const serverOnlyFnAbstracted = () => {} function abstractedClientFn() { - return 'client'; + return 'client' } -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file +const clientOnlyFnAbstracted = abstractedClientFn +const serverThenClientFnAbstracted = abstractedClientFn +const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx index 5e167daeb6..d8f76d94b0 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx @@ -1,13 +1,13 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start'; -const noImpl = isomorphicFn(); -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -const serverOnlyFnAbstracted = () => {}; +import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start' +const noImpl = isomorphicFn() +const serverOnlyFn = () => {} +const clientOnlyFn = () => 'client' +const serverThenClientFn = () => 'client' +const clientThenServerFn = () => 'client' +const serverOnlyFnAbstracted = () => {} function abstractedClientFn() { - return 'client'; + return 'client' } -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file +const clientOnlyFnAbstracted = abstractedClientFn +const serverThenClientFnAbstracted = abstractedClientFn +const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx index b54ad664b1..08772a9178 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx @@ -1,27 +1,22 @@ -import { createIsomorphicFn } from '@tanstack/react-start'; - +import { createIsomorphicFn } from '@tanstack/react-start' // Isomorphic function factory - returns a createIsomorphicFn with .client() and .server() calls export function createPlatformFn(platform: string) { - return () => `client-${platform}`; + return () => `client-${platform}` } - // Arrow function factory with only server implementation export const createServerImplFn = (name: string) => { - return () => {}; -}; - + return () => {} +} // Arrow function factory with only client implementation export const createClientImplFn = (name: string) => { return () => { - console.log(`Client: ${name}`); - return `client-${name}`; - }; -}; - + console.log(`Client: ${name}`) + return `client-${name}` + } +} // Factory returning no-implementation isomorphic fn export function createNoImplFn() { - return createIsomorphicFn(); + return createIsomorphicFn() } - // Top-level isomorphic fn for comparison -export const topLevelIsomorphicFn = () => 'client'; \ No newline at end of file +export const topLevelIsomorphicFn = () => 'client' diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx index 09666623a6..28930701bd 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx @@ -1,41 +1,33 @@ // Create and immediately invoke isomorphic fn inside a function export function getPlatformValue() { - const fn = () => 'client-value'; - return fn(); + const fn = () => 'client-value' + return fn() } - // Arrow function that creates and invokes isomorphic fn export const getEnvironment = () => { - const envFn = () => 'running on client'; - return envFn(); -}; - + const envFn = () => 'running on client' + return envFn() +} // Create isomorphic fn inline without assigning to variable export function getDirectValue() { - return (() => 'direct-client')(); + return (() => 'direct-client')() } - // Multiple isomorphic fns created and used in same function export function getMultipleValues() { - const first = () => 'first-client'; - const second = () => 'second-client'; - return { - first: first(), - second: second() - }; + const first = () => 'first-client' + const second = () => 'second-client' + return { first: first(), second: second() } } - // Isomorphic fn with server-only implementation used inline export function getServerOnlyValue() { - const fn = () => {}; - return fn(); + const fn = () => {} + return fn() } - // Isomorphic fn with client-only implementation used inline export function getClientOnlyValue() { const fn = () => { - console.log('client side effect'); - return 'client-only-value'; - }; - return fn(); -} \ No newline at end of file + console.log('client side effect') + return 'client-only-value' + } + return fn() +} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx index 070f59d901..f8604d9723 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx @@ -1,13 +1,13 @@ -import * as TanStackStart from '@tanstack/react-start'; -const noImpl = TanStackStart.createIsomorphicFn(); -const serverOnlyFn = () => {}; -const clientOnlyFn = () => 'client'; -const serverThenClientFn = () => 'client'; -const clientThenServerFn = () => 'client'; -const serverOnlyFnAbstracted = () => {}; +import * as TanStackStart from '@tanstack/react-start' +const noImpl = TanStackStart.createIsomorphicFn() +const serverOnlyFn = () => {} +const clientOnlyFn = () => 'client' +const serverThenClientFn = () => 'client' +const clientThenServerFn = () => 'client' +const serverOnlyFnAbstracted = () => {} function abstractedClientFn() { - return 'client'; + return 'client' } -const clientOnlyFnAbstracted = abstractedClientFn; -const serverThenClientFnAbstracted = abstractedClientFn; -const clientThenServerFnAbstracted = abstractedClientFn; \ No newline at end of file +const clientOnlyFnAbstracted = abstractedClientFn +const serverThenClientFnAbstracted = abstractedClientFn +const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts index 2fa99b5686..66c327f562 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts @@ -1,5 +1,5 @@ const getEnvironment = () => { - console.log('[SERVER] getEnvironment called'); - return 'server'; -}; -const moduleLevel = getEnvironment(); \ No newline at end of file + console.log('[SERVER] getEnvironment called') + return 'server' +} +const moduleLevel = getEnvironment() diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx index 195cee12a6..ee54120ca1 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx @@ -1,13 +1,13 @@ -import { createIsomorphicFn } from '@tanstack/react-start'; -const noImpl = createIsomorphicFn(); -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; +import { createIsomorphicFn } from '@tanstack/react-start' +const noImpl = createIsomorphicFn() +const serverOnlyFn = () => 'server' +const clientOnlyFn = () => {} +const serverThenClientFn = () => 'server' +const clientThenServerFn = () => 'server' function abstractedServerFn() { - return 'server'; + return 'server' } -const serverOnlyFnAbstracted = abstractedServerFn; -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file +const serverOnlyFnAbstracted = abstractedServerFn +const clientOnlyFnAbstracted = () => {} +const serverThenClientFnAbstracted = abstractedServerFn +const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx index c50c274dd6..11289136e9 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx @@ -1,13 +1,13 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start'; -const noImpl = isomorphicFn(); -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; +import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start' +const noImpl = isomorphicFn() +const serverOnlyFn = () => 'server' +const clientOnlyFn = () => {} +const serverThenClientFn = () => 'server' +const clientThenServerFn = () => 'server' function abstractedServerFn() { - return 'server'; + return 'server' } -const serverOnlyFnAbstracted = abstractedServerFn; -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file +const serverOnlyFnAbstracted = abstractedServerFn +const clientOnlyFnAbstracted = () => {} +const serverThenClientFnAbstracted = abstractedServerFn +const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx index cce206bc8b..c1ec1e79f5 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx @@ -1,27 +1,22 @@ -import { createIsomorphicFn } from '@tanstack/react-start'; - +import { createIsomorphicFn } from '@tanstack/react-start' // Isomorphic function factory - returns a createIsomorphicFn with .client() and .server() calls export function createPlatformFn(platform: string) { - return () => `server-${platform}`; + return () => `server-${platform}` } - // Arrow function factory with only server implementation export const createServerImplFn = (name: string) => { return () => { - console.log(`Server: ${name}`); - return `server-${name}`; - }; -}; - + console.log(`Server: ${name}`) + return `server-${name}` + } +} // Arrow function factory with only client implementation export const createClientImplFn = (name: string) => { - return () => {}; -}; - + return () => {} +} // Factory returning no-implementation isomorphic fn export function createNoImplFn() { - return createIsomorphicFn(); + return createIsomorphicFn() } - // Top-level isomorphic fn for comparison -export const topLevelIsomorphicFn = () => 'server'; \ No newline at end of file +export const topLevelIsomorphicFn = () => 'server' diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx index 9c058dfae8..c2b0d07284 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx @@ -1,41 +1,33 @@ // Create and immediately invoke isomorphic fn inside a function export function getPlatformValue() { - const fn = () => 'server-value'; - return fn(); + const fn = () => 'server-value' + return fn() } - // Arrow function that creates and invokes isomorphic fn export const getEnvironment = () => { - const envFn = () => 'running on server'; - return envFn(); -}; - + const envFn = () => 'running on server' + return envFn() +} // Create isomorphic fn inline without assigning to variable export function getDirectValue() { - return (() => 'direct-server')(); + return (() => 'direct-server')() } - // Multiple isomorphic fns created and used in same function export function getMultipleValues() { - const first = () => 'first-server'; - const second = () => 'second-server'; - return { - first: first(), - second: second() - }; + const first = () => 'first-server' + const second = () => 'second-server' + return { first: first(), second: second() } } - // Isomorphic fn with server-only implementation used inline export function getServerOnlyValue() { const fn = () => { - console.log('server side effect'); - return 'server-only-value'; - }; - return fn(); + console.log('server side effect') + return 'server-only-value' + } + return fn() } - // Isomorphic fn with client-only implementation used inline export function getClientOnlyValue() { - const fn = () => {}; - return fn(); -} \ No newline at end of file + const fn = () => {} + return fn() +} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx index 65e4fc18b1..6a1c429167 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx +++ b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx @@ -1,13 +1,13 @@ -import * as TanStackStart from '@tanstack/react-start'; -const noImpl = TanStackStart.createIsomorphicFn(); -const serverOnlyFn = () => 'server'; -const clientOnlyFn = () => {}; -const serverThenClientFn = () => 'server'; -const clientThenServerFn = () => 'server'; +import * as TanStackStart from '@tanstack/react-start' +const noImpl = TanStackStart.createIsomorphicFn() +const serverOnlyFn = () => 'server' +const clientOnlyFn = () => {} +const serverThenClientFn = () => 'server' +const clientThenServerFn = () => 'server' function abstractedServerFn() { - return 'server'; + return 'server' } -const serverOnlyFnAbstracted = abstractedServerFn; -const clientOnlyFnAbstracted = () => {}; -const serverThenClientFnAbstracted = abstractedServerFn; -const clientThenServerFnAbstracted = abstractedServerFn; \ No newline at end of file +const serverOnlyFnAbstracted = abstractedServerFn +const clientOnlyFnAbstracted = () => {} +const serverThenClientFnAbstracted = abstractedServerFn +const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts index 4747cfc848..e4690737ac 100644 --- a/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts +++ b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts @@ -2,6 +2,7 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test, vi } from 'vitest' import { StartCompiler } from '../../src/start-compiler/compiler' +import { formatSnapshot } from '../format-snapshot' // Default test options for StartCompiler function getDefaultTestOptions(env: 'client' | 'server') { @@ -69,9 +70,9 @@ describe('createMiddleware compiles correctly', async () => { test(`should compile for ${filename} client`, async () => { const result = await compile({ env: 'client', code, id: filename }) - await expect(result!.code).toMatchFileSnapshot( - `./snapshots/client/${filename}`, - ) + await expect( + await formatSnapshot(result!.code, filename), + ).toMatchFileSnapshot(`./snapshots/client/${filename}`) }) }) @@ -90,11 +91,11 @@ describe('createMiddleware compiles correctly', async () => { id: 'test.ts', }) - expect(result!.code).toMatchInlineSnapshot(` - "import { createMiddleware } from '@tanstack/react-start'; - const myMiddleware = createMiddleware({ - type: 'function' - });" + expect(await formatSnapshot(result!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createMiddleware } from '@tanstack/react-start' + const myMiddleware = createMiddleware({ type: 'function' }) + " `) }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts index b37e25e498..73d5910eef 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts @@ -1,6 +1,4 @@ -import { createMiddleware } from '@tanstack/react-start'; -export const fnMw = createMiddleware({ - type: 'function' -}).client(() => { - console.log('client'); -}); \ No newline at end of file +import { createMiddleware } from '@tanstack/react-start' +export const fnMw = createMiddleware({ type: 'function' }).client(() => { + console.log('client') +}) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx index b5cf588a1f..c3497f072b 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx @@ -1,13 +1,5 @@ -import { createMiddleware } from '@tanstack/react-start'; -export const withUseServer = createMiddleware({ - id: 'test' -}); -export const withoutUseServer = createMiddleware({ - id: 'test' -}); -export const withVariable = createMiddleware({ - id: 'test' -}); -export const withZodValidator = createMiddleware({ - id: 'test' -}); \ No newline at end of file +import { createMiddleware } from '@tanstack/react-start' +export const withUseServer = createMiddleware({ id: 'test' }) +export const withoutUseServer = createMiddleware({ id: 'test' }) +export const withVariable = createMiddleware({ id: 'test' }) +export const withZodValidator = createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx index ee06179703..70d3921bda 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx @@ -1,13 +1,5 @@ -import { createMiddleware as middlewareFn } from '@tanstack/react-start'; -export const withUseServer = middlewareFn({ - id: 'test' -}); -export const withoutUseServer = middlewareFn({ - id: 'test' -}); -export const withVariable = middlewareFn({ - id: 'test' -}); -export const withZodValidator = middlewareFn({ - id: 'test' -}); \ No newline at end of file +import { createMiddleware as middlewareFn } from '@tanstack/react-start' +export const withUseServer = middlewareFn({ id: 'test' }) +export const withoutUseServer = middlewareFn({ id: 'test' }) +export const withVariable = middlewareFn({ id: 'test' }) +export const withZodValidator = middlewareFn({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx index 6f2f40a2a3..f997f40fe0 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx @@ -1,13 +1,5 @@ -import * as TanStackStart from '@tanstack/react-start'; -export const withUseServer = TanStackStart.createMiddleware({ - id: 'test' -}); -export const withoutUseServer = TanStackStart.createMiddleware({ - id: 'test' -}); -export const withVariable = TanStackStart.createMiddleware({ - id: 'test' -}); -export const withZodValidator = TanStackStart.createMiddleware({ - id: 'test' -}); \ No newline at end of file +import * as TanStackStart from '@tanstack/react-start' +export const withUseServer = TanStackStart.createMiddleware({ id: 'test' }) +export const withoutUseServer = TanStackStart.createMiddleware({ id: 'test' }) +export const withVariable = TanStackStart.createMiddleware({ id: 'test' }) +export const withZodValidator = TanStackStart.createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx index 3b1beac2c0..773e990702 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx @@ -1,4 +1,2 @@ -import { createMiddleware } from '@tanstack/react-start'; -export const withUseServer = createMiddleware({ - id: 'test' -}); \ No newline at end of file +import { createMiddleware } from '@tanstack/react-start' +export const withUseServer = createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx index 8c3a7fc205..b2bde33436 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx @@ -1,13 +1,9 @@ -import { createStart } from '@tanstack/react-start'; -export const startInstance = createStart(() => {}); -export const serverFnMw = startInstance.createMiddleware({ - type: 'function' -}).client(({ - next -}) => { - console.log('client mw'); - return next(); -}); -export const requestMw = startInstance.createMiddleware({ - type: 'request' -}); \ No newline at end of file +import { createStart } from '@tanstack/react-start' +export const startInstance = createStart(() => {}) +export const serverFnMw = startInstance + .createMiddleware({ type: 'function' }) + .client(({ next }) => { + console.log('client mw') + return next() + }) +export const requestMw = startInstance.createMiddleware({ type: 'request' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts index 6845bd0ef5..0e51f2f369 100644 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts +++ b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts @@ -1,20 +1,11 @@ -import { createMiddleware } from '@tanstack/react-start'; - +import { createMiddleware } from '@tanstack/react-start' // Middleware factory function - returns a middleware with .server() call export function createPublicRateLimitMiddleware(keySuffix) { - return createMiddleware({ - type: 'function' - }); + return createMiddleware({ type: 'function' }) } - // Arrow function factory -export const createAuthMiddleware = requiredRole => { - return createMiddleware({ - type: 'function' - }); -}; - +export const createAuthMiddleware = (requiredRole) => { + return createMiddleware({ type: 'function' }) +} // Top-level middleware for comparison -export const topLevelMiddleware = createMiddleware({ - id: 'topLevel' -}); \ No newline at end of file +export const topLevelMiddleware = createMiddleware({ id: 'topLevel' }) diff --git a/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts index f5236d8443..a0ba9c4ba6 100644 --- a/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts @@ -2,6 +2,7 @@ import { readFile, readdir } from 'node:fs/promises' import path from 'node:path' import { describe, expect, test, vi } from 'vitest' import { StartCompiler } from '../../src/start-compiler/compiler' +import { formatSnapshot } from '../format-snapshot' // Default test options for StartCompiler function getDefaultTestOptions(env: 'client' | 'server') { @@ -91,9 +92,9 @@ describe('createServerFn compiles correctly', async () => { : env.isProviderFile ? 'server-provider' : 'server-caller' - await expect(result!.code).toMatchFileSnapshot( - `./snapshots/${folder}/${filename}`, - ) + await expect( + await formatSnapshot(result!.code, filename), + ).toMatchFileSnapshot(`./snapshots/${folder}/${filename}`) }) }) @@ -111,11 +112,17 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResultClient!.code).toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc'; - import { createServerFn } from '@tanstack/react-start'; - const myServerFn = createServerFn().handler(createClientRpc(\"2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b\"));" - `) + expect(await formatSnapshot(compiledResultClient!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createClientRpc } from '@tanstack/react-start/client-rpc' + import { createServerFn } from '@tanstack/react-start' + const myServerFn = createServerFn().handler( + createClientRpc( + '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', + ), + ) + " + `) }) // Editors count \n, \r\n, a lone \r, U+2028 and U+2029 as line @@ -206,34 +213,54 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResultClient!.code).toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc'; - import { createServerFn } from '@tanstack/react-start'; - const myServerFn = createServerFn().handler(createClientRpc("2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b"));" - `) + expect(await formatSnapshot(compiledResultClient!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createClientRpc } from '@tanstack/react-start/client-rpc' + import { createServerFn } from '@tanstack/react-start' + const myServerFn = createServerFn().handler( + createClientRpc( + '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', + ), + ) + " + `) // Server caller: no second argument (implementation from extracted chunk) - expect(compiledResultServerCaller!.code).toMatchInlineSnapshot(` - "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; - import { createServerFn } from '@tanstack/react-start'; - const myServerFn = createServerFn().handler(createSsrRpc("2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b"));" - `) + expect(await formatSnapshot(compiledResultServerCaller!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' + import { createServerFn } from '@tanstack/react-start' + const myServerFn = createServerFn().handler( + createSsrRpc( + '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', + ), + ) + " + `) // Server provider: has second argument (this is the implementation file) - expect(compiledResultServerProvider!.code).toMatchInlineSnapshot(` - "import { createServerRpc } from '@tanstack/react-start/server-rpc'; - import { createServerFn } from '@tanstack/react-start'; - const myFunc = () => { - return 'hello from the server'; - }; - const myServerFn_createServerFn_handler = createServerRpc({ - id: "2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b", - name: "myServerFn", - filename: "src/test.ts" - }, opts => myServerFn.__executeServer(opts)); - const myServerFn = createServerFn().handler(myServerFn_createServerFn_handler, myFunc); - export { myServerFn_createServerFn_handler };" - `) + expect(await formatSnapshot(compiledResultServerProvider!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createServerRpc } from '@tanstack/react-start/server-rpc' + import { createServerFn } from '@tanstack/react-start' + const myFunc = () => { + return 'hello from the server' + } + const myServerFn_createServerFn_handler = createServerRpc( + { + id: '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', + name: 'myServerFn', + filename: 'src/test.ts', + }, + (opts) => myServerFn.__executeServer(opts), + ) + const myServerFn = createServerFn().handler( + myServerFn_createServerFn_handler, + myFunc, + ) + export { myServerFn_createServerFn_handler } + " + `) }) test('should remove imports used only as caller handler identifiers', async () => { @@ -251,11 +278,17 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResult!.code).toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc'; - import { createServerFn } from '@tanstack/react-start'; - export const getUsersFn = createServerFn().handler(createClientRpc(\"a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100\"));" - `) + expect(await formatSnapshot(compiledResult!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createClientRpc } from '@tanstack/react-start/client-rpc' + import { createServerFn } from '@tanstack/react-start' + export const getUsersFn = createServerFn().handler( + createClientRpc( + 'a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100', + ), + ) + " + `) }) test('should not remove handler identifier bindings that are still referenced', async () => { @@ -274,13 +307,19 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResult!.code).toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc'; - import { createServerFn } from '@tanstack/react-start'; - import { getUsers } from './server'; - export const getUsersFn = createServerFn().handler(createClientRpc(\"a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100\")); - console.log(getUsers);" - `) + expect(await formatSnapshot(compiledResult!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createClientRpc } from '@tanstack/react-start/client-rpc' + import { createServerFn } from '@tanstack/react-start' + import { getUsers } from './server' + export const getUsersFn = createServerFn().handler( + createClientRpc( + 'a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100', + ), + ) + console.log(getUsers) + " + `) }) test('should compile server functions wrapped in TypeScript as expressions', async () => { @@ -341,12 +380,22 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResult!.code).toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc'; - import { createServerFn } from '@tanstack/react-start'; - export const exportedFn = createServerFn().handler(createClientRpc("c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864")); - const nonExportedFn = createServerFn().handler(createClientRpc("f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2"));" - `) + expect(await formatSnapshot(compiledResult!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createClientRpc } from '@tanstack/react-start/client-rpc' + import { createServerFn } from '@tanstack/react-start' + export const exportedFn = createServerFn().handler( + createClientRpc( + 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', + ), + ) + const nonExportedFn = createServerFn().handler( + createClientRpc( + 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', + ), + ) + " + `) // Server caller (route file) - no second argument const compiledResultServerCaller = await compile({ @@ -356,12 +405,22 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResultServerCaller!.code).toMatchInlineSnapshot(` - "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; - import { createServerFn } from '@tanstack/react-start'; - export const exportedFn = createServerFn().handler(createSsrRpc("c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864")); - const nonExportedFn = createServerFn().handler(createSsrRpc("f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2"));" - `) + expect(await formatSnapshot(compiledResultServerCaller!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' + import { createServerFn } from '@tanstack/react-start' + export const exportedFn = createServerFn().handler( + createSsrRpc( + 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', + ), + ) + const nonExportedFn = createServerFn().handler( + createSsrRpc( + 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', + ), + ) + " + `) // Server provider (extracted file) - has second argument const compiledResultServerProvider = await compile({ @@ -371,29 +430,46 @@ describe('createServerFn compiles correctly', async () => { mode: 'build', }) - expect(compiledResultServerProvider!.code).toMatchInlineSnapshot(` - "import { createServerRpc } from '@tanstack/react-start/server-rpc'; - import { createServerFn } from '@tanstack/react-start'; - const exportedVar = 'exported'; - const exportedFn_createServerFn_handler = createServerRpc({ - id: "c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864", - name: "exportedFn", - filename: "src/test.ts" - }, opts => exportedFn.__executeServer(opts)); - const exportedFn = createServerFn().handler(exportedFn_createServerFn_handler, async () => { - return exportedVar; - }); - const nonExportedVar = 'non-exported'; - const nonExportedFn_createServerFn_handler = createServerRpc({ - id: "f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2", - name: "nonExportedFn", - filename: "src/test.ts" - }, opts => nonExportedFn.__executeServer(opts)); - const nonExportedFn = createServerFn().handler(nonExportedFn_createServerFn_handler, async () => { - return nonExportedVar; - }); - export { exportedFn_createServerFn_handler, nonExportedFn_createServerFn_handler };" - `) + expect(await formatSnapshot(compiledResultServerProvider!.code, 'test.ts')) + .toMatchInlineSnapshot(` + "import { createServerRpc } from '@tanstack/react-start/server-rpc' + import { createServerFn } from '@tanstack/react-start' + const exportedVar = 'exported' + const exportedFn_createServerFn_handler = createServerRpc( + { + id: 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', + name: 'exportedFn', + filename: 'src/test.ts', + }, + (opts) => exportedFn.__executeServer(opts), + ) + const exportedFn = createServerFn().handler( + exportedFn_createServerFn_handler, + async () => { + return exportedVar + }, + ) + const nonExportedVar = 'non-exported' + const nonExportedFn_createServerFn_handler = createServerRpc( + { + id: 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', + name: 'nonExportedFn', + filename: 'src/test.ts', + }, + (opts) => nonExportedFn.__executeServer(opts), + ) + const nonExportedFn = createServerFn().handler( + nonExportedFn_createServerFn_handler, + async () => { + return nonExportedVar + }, + ) + export { + exportedFn_createServerFn_handler, + nonExportedFn_createServerFn_handler, + } + " + `) }) test('should use fast path for direct imports from known library (no extra resolveId calls)', async () => { diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx index 2c0e54f9c9..88e8607da2 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx @@ -1,23 +1,39 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import { createServerFn } from '@tanstack/react-start'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler(createClientRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); -export const withArrowFunction = createServerFn({ - method: 'GET' -}).handler(createClientRpc("a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793")); +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import { createServerFn } from '@tanstack/react-start' +export const withUseServer = createServerFn({ method: 'GET' }).handler( + createClientRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) +export const withArrowFunction = createServerFn({ method: 'GET' }).handler( + createClientRpc( + 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', + ), +) export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET' -}).handler(createClientRpc("dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e")); -export const withoutUseServer = createServerFn({ - method: 'GET' -}).handler(createClientRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); -export const withVariable = createServerFn({ - method: 'GET' -}).handler(createClientRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); -export const withZodValidator = createServerFn({ - method: 'GET' -}).handler(createClientRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); -export const withValidatorFn = createServerFn({ - method: 'GET' -}).handler(createClientRpc("5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44")); \ No newline at end of file + method: 'GET', +}).handler( + createClientRpc( + 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', + ), +) +export const withoutUseServer = createServerFn({ method: 'GET' }).handler( + createClientRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) +export const withVariable = createServerFn({ method: 'GET' }).handler( + createClientRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) +export const withZodValidator = createServerFn({ method: 'GET' }).handler( + createClientRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) +export const withValidatorFn = createServerFn({ method: 'GET' }).handler( + createClientRpc( + '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx index e55318337d..34e0c452b6 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx @@ -1,14 +1,22 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import { createServerFn as serverFn } from '@tanstack/react-start'; -export const withUseServer = serverFn({ - method: 'GET' -}).handler(createClientRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); -export const withoutUseServer = serverFn({ - method: 'GET' -}).handler(createClientRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); -export const withVariable = serverFn({ - method: 'GET' -}).handler(createClientRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); -export const withZodValidator = serverFn({ - method: 'GET' -}).handler(createClientRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); \ No newline at end of file +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import { createServerFn as serverFn } from '@tanstack/react-start' +export const withUseServer = serverFn({ method: 'GET' }).handler( + createClientRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) +export const withoutUseServer = serverFn({ method: 'GET' }).handler( + createClientRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) +export const withVariable = serverFn({ method: 'GET' }).handler( + createClientRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) +export const withZodValidator = serverFn({ method: 'GET' }).handler( + createClientRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx index 5b33829a38..2cea070645 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx @@ -1,14 +1,30 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import * as TanStackStart from '@tanstack/react-start'; +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import * as TanStackStart from '@tanstack/react-start' export const withUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createClientRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); + method: 'GET', +}).handler( + createClientRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createClientRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); + method: 'GET', +}).handler( + createClientRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) export const withVariable = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createClientRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); + method: 'GET', +}).handler( + createClientRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createClientRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); \ No newline at end of file + method: 'GET', +}).handler( + createClientRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx index 056535d0bc..97253672a6 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx @@ -1,5 +1,7 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import { createServerFn } from '@tanstack/react-start'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler(createClientRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); \ No newline at end of file +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import { createServerFn } from '@tanstack/react-start' +export const withUseServer = createServerFn({ method: 'GET' }).handler( + createClientRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx index 436b8ab4cb..889c1fbf4e 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx @@ -1,38 +1,34 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import { createServerFn, createMiddleware } from '@tanstack/react-start'; -const authMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - auth: 'auth' - } - }); -}); -const adminMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - admin: 'admin' - } - }); -}); -export const createAuthServerFn = createServerFn().middleware([authMiddleware]); -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]); -export const myAuthedFn = createAuthServerFn().handler(createClientRpc("3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3")); -export const deleteUserFn = createAdminServerFn().handler(createClientRpc("44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31")); +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import { createServerFn, createMiddleware } from '@tanstack/react-start' +const authMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { auth: 'auth' } }) + }, +) +const adminMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { admin: 'admin' } }) + }, +) +export const createAuthServerFn = createServerFn().middleware([authMiddleware]) +const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) +export const myAuthedFn = createAuthServerFn().handler( + createClientRpc( + '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', + ), +) +export const deleteUserFn = createAdminServerFn().handler( + createClientRpc( + '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', + ), +) function createFakeFn() { return { - handler: cb => { - return cb(); - } - }; + handler: (cb) => { + return cb() + }, + } } const x = createFakeFn().handler(() => { - return 'fakeFn'; -}); \ No newline at end of file + return 'fakeFn' +}) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx index 020d1346e4..8e09a57d37 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx @@ -1,48 +1,49 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc'; -import { createFileRoute } from '@tanstack/react-router'; -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start'; -import { useState } from 'react'; -const getEnv = createIsomorphicFn().server(() => 'server').client(() => 'client'); -const getServerEnv = createServerFn().handler(createClientRpc("6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2")); -const getEcho = createIsomorphicFn().server((input: string) => 'server received ' + input).client(input => 'client received ' + input); -const getServerEcho = createServerFn().handler(createClientRpc("ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1")); +import { createClientRpc } from '@tanstack/react-start/client-rpc' +import { createFileRoute } from '@tanstack/react-router' +import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +const getEnv = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') +const getServerEnv = createServerFn().handler( + createClientRpc( + '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', + ), +) +const getEcho = createIsomorphicFn() + .server((input: string) => 'server received ' + input) + .client((input) => 'client received ' + input) +const getServerEcho = createServerFn().handler( + createClientRpc( + 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', + ), +) export const Route = createFileRoute('/isomorphic-fns')({ component: RouteComponent, loader() { - return { - envOnLoad: getEnv() - }; - } -}); + return { envOnLoad: getEnv() } + }, +}) function RouteComponent() { - const { - envOnLoad - } = Route.useLoaderData(); - const [results, setResults] = useState>>(); + const { envOnLoad } = Route.useLoaderData() + const [results, setResults] = useState>>() async function handleClick() { - const envOnClick = getEnv(); - const echo = getEcho('hello'); - const [serverEnv, serverEcho] = await Promise.all([getServerEnv(), getServerEcho({ - data: 'hello' - })]); - setResults({ - envOnClick, - echo, - serverEnv, - serverEcho - }); + const envOnClick = getEnv() + const echo = getEcho('hello') + const [serverEnv, serverEcho] = await Promise.all([ + getServerEnv(), + getServerEcho({ data: 'hello' }), + ]) + setResults({ envOnClick, echo, serverEnv, serverEcho }) } - const { - envOnClick, - echo, - serverEnv, - serverEcho - } = results || {}; - return
+ const { envOnClick, echo, serverEnv, serverEcho } = results || {} + return ( +
- {!!results &&
+ {!!results && ( +

getEnv

@@ -62,6 +63,8 @@ function RouteComponent() { When we called the function on the client it returned:
{JSON.stringify(echo)}
-
} -
; -} \ No newline at end of file +
+ )} +
+ ) +} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx index 37c93d5c00..efa8f395d5 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx @@ -1,24 +1,42 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import { createServerFn } from '@tanstack/react-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); -export const withArrowFunction = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793")); +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import { createServerFn } from '@tanstack/react-start' +import { z } from 'zod' +export const withUseServer = createServerFn({ method: 'GET' }).handler( + createSsrRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) +export const withArrowFunction = createServerFn({ method: 'GET' }).handler( + createSsrRpc( + 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', + ), +) export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e")); -export const withoutUseServer = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); -export const withVariable = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); -export const withZodValidator = createServerFn({ - method: 'GET' -}).handler(createSsrRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); -export const withValidatorFn = createServerFn({ - method: 'GET' -}).validator(z.number()).handler(createSsrRpc("5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44")); \ No newline at end of file + method: 'GET', +}).handler( + createSsrRpc( + 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', + ), +) +export const withoutUseServer = createServerFn({ method: 'GET' }).handler( + createSsrRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) +export const withVariable = createServerFn({ method: 'GET' }).handler( + createSsrRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) +export const withZodValidator = createServerFn({ method: 'GET' }).handler( + createSsrRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) +export const withValidatorFn = createServerFn({ method: 'GET' }) + .validator(z.number()) + .handler( + createSsrRpc( + '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', + ), + ) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx index 94a351ffa9..7088a4bc69 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx @@ -1,14 +1,22 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import { createServerFn as serverFn } from '@tanstack/react-start'; -export const withUseServer = serverFn({ - method: 'GET' -}).handler(createSsrRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); -export const withoutUseServer = serverFn({ - method: 'GET' -}).handler(createSsrRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); -export const withVariable = serverFn({ - method: 'GET' -}).handler(createSsrRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); -export const withZodValidator = serverFn({ - method: 'GET' -}).handler(createSsrRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); \ No newline at end of file +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import { createServerFn as serverFn } from '@tanstack/react-start' +export const withUseServer = serverFn({ method: 'GET' }).handler( + createSsrRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) +export const withoutUseServer = serverFn({ method: 'GET' }).handler( + createSsrRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) +export const withVariable = serverFn({ method: 'GET' }).handler( + createSsrRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) +export const withZodValidator = serverFn({ method: 'GET' }).handler( + createSsrRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx index 74d22a2fc4..899aaf3d0d 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx @@ -1,14 +1,30 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import * as TanStackStart from '@tanstack/react-start'; +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import * as TanStackStart from '@tanstack/react-start' export const withUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createSsrRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); + method: 'GET', +}).handler( + createSsrRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), +) export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createSsrRpc("c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2")); + method: 'GET', +}).handler( + createSsrRpc( + 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + ), +) export const withVariable = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createSsrRpc("7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70")); + method: 'GET', +}).handler( + createSsrRpc( + '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + ), +) export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET' -}).handler(createSsrRpc("43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3")); \ No newline at end of file + method: 'GET', +}).handler( + createSsrRpc( + '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + ), +) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx index 59fb4d2fd9..e1d136311b 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx @@ -1,6 +1,10 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import { createServerFn } from '@tanstack/react-start'; -import { z } from 'zod'; -export const withUseServer = createServerFn({ - method: 'GET' -}).validator(z.number()).handler(createSsrRpc("b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320")); \ No newline at end of file +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import { createServerFn } from '@tanstack/react-start' +import { z } from 'zod' +export const withUseServer = createServerFn({ method: 'GET' }) + .validator(z.number()) + .handler( + createSsrRpc( + 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + ), + ) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx index e82ca932e8..ab19c3e1f8 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx @@ -1,38 +1,34 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import { createServerFn, createMiddleware } from '@tanstack/react-start'; -const authMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - auth: 'auth' - } - }); -}); -const adminMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - admin: 'admin' - } - }); -}); -export const createAuthServerFn = createServerFn().middleware([authMiddleware]); -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]); -export const myAuthedFn = createAuthServerFn().handler(createSsrRpc("3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3")); -export const deleteUserFn = createAdminServerFn().handler(createSsrRpc("44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31")); +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import { createServerFn, createMiddleware } from '@tanstack/react-start' +const authMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { auth: 'auth' } }) + }, +) +const adminMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { admin: 'admin' } }) + }, +) +export const createAuthServerFn = createServerFn().middleware([authMiddleware]) +const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) +export const myAuthedFn = createAuthServerFn().handler( + createSsrRpc( + '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', + ), +) +export const deleteUserFn = createAdminServerFn().handler( + createSsrRpc( + '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', + ), +) function createFakeFn() { return { - handler: cb => { - return cb(); - } - }; + handler: (cb) => { + return cb() + }, + } } const x = createFakeFn().handler(() => { - return 'fakeFn'; -}); \ No newline at end of file + return 'fakeFn' +}) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx index d56d81fdda..cfefad2bfb 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx @@ -1,48 +1,51 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc'; -import { createFileRoute } from '@tanstack/react-router'; -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start'; -import { useState } from 'react'; -const getEnv = createIsomorphicFn().server(() => 'server').client(() => 'client'); -const getServerEnv = createServerFn().handler(createSsrRpc("6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2")); -const getEcho = createIsomorphicFn().server((input: string) => 'server received ' + input).client(input => 'client received ' + input); -const getServerEcho = createServerFn().validator((input: string) => input).handler(createSsrRpc("ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1")); +import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' +import { createFileRoute } from '@tanstack/react-router' +import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +const getEnv = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') +const getServerEnv = createServerFn().handler( + createSsrRpc( + '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', + ), +) +const getEcho = createIsomorphicFn() + .server((input: string) => 'server received ' + input) + .client((input) => 'client received ' + input) +const getServerEcho = createServerFn() + .validator((input: string) => input) + .handler( + createSsrRpc( + 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', + ), + ) export const Route = createFileRoute('/isomorphic-fns')({ component: RouteComponent, loader() { - return { - envOnLoad: getEnv() - }; - } -}); + return { envOnLoad: getEnv() } + }, +}) function RouteComponent() { - const { - envOnLoad - } = Route.useLoaderData(); - const [results, setResults] = useState>>(); + const { envOnLoad } = Route.useLoaderData() + const [results, setResults] = useState>>() async function handleClick() { - const envOnClick = getEnv(); - const echo = getEcho('hello'); - const [serverEnv, serverEcho] = await Promise.all([getServerEnv(), getServerEcho({ - data: 'hello' - })]); - setResults({ - envOnClick, - echo, - serverEnv, - serverEcho - }); + const envOnClick = getEnv() + const echo = getEcho('hello') + const [serverEnv, serverEcho] = await Promise.all([ + getServerEnv(), + getServerEcho({ data: 'hello' }), + ]) + setResults({ envOnClick, echo, serverEnv, serverEcho }) } - const { - envOnClick, - echo, - serverEnv, - serverEcho - } = results || {}; - return
+ const { envOnClick, echo, serverEnv, serverEcho } = results || {} + return ( +
- {!!results &&
+ {!!results && ( +

getEnv

@@ -62,6 +65,8 @@ function RouteComponent() { When we called the function on the client it returned:
{JSON.stringify(echo)}
-
} -
; -} \ No newline at end of file +
+ )} +
+ ) +} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx index 7459b65cc0..3bc4879c14 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx @@ -1,86 +1,126 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import { createServerFn } from '@tanstack/react-start'; -import { z } from 'zod'; -const withUseServer_createServerFn_handler = createServerRpc({ - id: "b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320", - name: "withUseServer", - filename: "src/test.ts" -}, opts => withUseServer.__executeServer(opts)); -const withUseServer = createServerFn({ - method: 'GET' -}).handler(withUseServer_createServerFn_handler, async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withArrowFunction_createServerFn_handler = createServerRpc({ - id: "a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793", - name: "withArrowFunction", - filename: "src/test.ts" -}, opts => withArrowFunction.__executeServer(opts)); -const withArrowFunction = createServerFn({ - method: 'GET' -}).handler(withArrowFunction_createServerFn_handler, async () => null); -const withArrowFunctionAndFunction_createServerFn_handler = createServerRpc({ - id: "dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e", - name: "withArrowFunctionAndFunction", - filename: "src/test.ts" -}, opts => withArrowFunctionAndFunction.__executeServer(opts)); -const withArrowFunctionAndFunction = createServerFn({ - method: 'GET' -}).handler(withArrowFunctionAndFunction_createServerFn_handler, async () => test()); -const withoutUseServer_createServerFn_handler = createServerRpc({ - id: "c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2", - name: "withoutUseServer", - filename: "src/test.ts" -}, opts => withoutUseServer.__executeServer(opts)); -const withoutUseServer = createServerFn({ - method: 'GET' -}).handler(withoutUseServer_createServerFn_handler, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withVariable_createServerFn_handler = createServerRpc({ - id: "7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70", - name: "withVariable", - filename: "src/test.ts" -}, opts => withVariable.__executeServer(opts)); -const withVariable = createServerFn({ - method: 'GET' -}).handler(withVariable_createServerFn_handler, abstractedFunction); +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import { createServerFn } from '@tanstack/react-start' +import { z } from 'zod' +const withUseServer_createServerFn_handler = createServerRpc( + { + id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + name: 'withUseServer', + filename: 'src/test.ts', + }, + (opts) => withUseServer.__executeServer(opts), +) +const withUseServer = createServerFn({ method: 'GET' }).handler( + withUseServer_createServerFn_handler, + async function () { + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) + }, +) +const withArrowFunction_createServerFn_handler = createServerRpc( + { + id: 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', + name: 'withArrowFunction', + filename: 'src/test.ts', + }, + (opts) => withArrowFunction.__executeServer(opts), +) +const withArrowFunction = createServerFn({ method: 'GET' }).handler( + withArrowFunction_createServerFn_handler, + async () => null, +) +const withArrowFunctionAndFunction_createServerFn_handler = createServerRpc( + { + id: 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', + name: 'withArrowFunctionAndFunction', + filename: 'src/test.ts', + }, + (opts) => withArrowFunctionAndFunction.__executeServer(opts), +) +const withArrowFunctionAndFunction = createServerFn({ method: 'GET' }).handler( + withArrowFunctionAndFunction_createServerFn_handler, + async () => test(), +) +const withoutUseServer_createServerFn_handler = createServerRpc( + { + id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + name: 'withoutUseServer', + filename: 'src/test.ts', + }, + (opts) => withoutUseServer.__executeServer(opts), +) +const withoutUseServer = createServerFn({ method: 'GET' }).handler( + withoutUseServer_createServerFn_handler, + async () => { + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) + }, +) +const withVariable_createServerFn_handler = createServerRpc( + { + id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + name: 'withVariable', + filename: 'src/test.ts', + }, + (opts) => withVariable.__executeServer(opts), +) +const withVariable = createServerFn({ method: 'GET' }).handler( + withVariable_createServerFn_handler, + abstractedFunction, +) async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) } -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { +function zodValidator( + schema: TSchema, + fn: (input: z.output) => TResult, +) { return async (input: unknown) => { - return fn(schema.parse(input)); - }; + return fn(schema.parse(input)) + } +} +const withZodValidator_createServerFn_handler = createServerRpc( + { + id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + name: 'withZodValidator', + filename: 'src/test.ts', + }, + (opts) => withZodValidator.__executeServer(opts), +) +const withZodValidator = createServerFn({ method: 'GET' }).handler( + withZodValidator_createServerFn_handler, + zodValidator(z.number(), (input) => { + return { 'you gave': input } + }), +) +const withValidatorFn_createServerFn_handler = createServerRpc( + { + id: '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', + name: 'withValidatorFn', + filename: 'src/test.ts', + }, + (opts) => withValidatorFn.__executeServer(opts), +) +const withValidatorFn = createServerFn({ method: 'GET' }) + .validator(z.number()) + .handler(withValidatorFn_createServerFn_handler, async ({ input }) => { + return null + }) +export { + withUseServer_createServerFn_handler, + withArrowFunction_createServerFn_handler, + withArrowFunctionAndFunction_createServerFn_handler, + withoutUseServer_createServerFn_handler, + withVariable_createServerFn_handler, + withZodValidator_createServerFn_handler, + withValidatorFn_createServerFn_handler, } -const withZodValidator_createServerFn_handler = createServerRpc({ - id: "43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3", - name: "withZodValidator", - filename: "src/test.ts" -}, opts => withZodValidator.__executeServer(opts)); -const withZodValidator = createServerFn({ - method: 'GET' -}).handler(withZodValidator_createServerFn_handler, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); -const withValidatorFn_createServerFn_handler = createServerRpc({ - id: "5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44", - name: "withValidatorFn", - filename: "src/test.ts" -}, opts => withValidatorFn.__executeServer(opts)); -const withValidatorFn = createServerFn({ - method: 'GET' -}).validator(z.number()).handler(withValidatorFn_createServerFn_handler, async ({ - input -}) => { - return null; -}); -export { withUseServer_createServerFn_handler, withArrowFunction_createServerFn_handler, withArrowFunctionAndFunction_createServerFn_handler, withoutUseServer_createServerFn_handler, withVariable_createServerFn_handler, withZodValidator_createServerFn_handler, withValidatorFn_createServerFn_handler }; \ No newline at end of file diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx index fd5a36351b..775c32b645 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx @@ -1,58 +1,86 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import { createServerFn as serverFn } from '@tanstack/react-start'; -import { z } from 'zod'; -const withUseServer_createServerFn_handler = createServerRpc({ - id: "b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320", - name: "withUseServer", - filename: "src/test.ts" -}, opts => withUseServer.__executeServer(opts)); -const withUseServer = serverFn({ - method: 'GET' -}).handler(withUseServer_createServerFn_handler, async function () { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withoutUseServer_createServerFn_handler = createServerRpc({ - id: "c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2", - name: "withoutUseServer", - filename: "src/test.ts" -}, opts => withoutUseServer.__executeServer(opts)); -const withoutUseServer = serverFn({ - method: 'GET' -}).handler(withoutUseServer_createServerFn_handler, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withVariable_createServerFn_handler = createServerRpc({ - id: "7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70", - name: "withVariable", - filename: "src/test.ts" -}, opts => withVariable.__executeServer(opts)); -const withVariable = serverFn({ - method: 'GET' -}).handler(withVariable_createServerFn_handler, abstractedFunction); +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import { createServerFn as serverFn } from '@tanstack/react-start' +import { z } from 'zod' +const withUseServer_createServerFn_handler = createServerRpc( + { + id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + name: 'withUseServer', + filename: 'src/test.ts', + }, + (opts) => withUseServer.__executeServer(opts), +) +const withUseServer = serverFn({ method: 'GET' }).handler( + withUseServer_createServerFn_handler, + async function () { + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) + }, +) +const withoutUseServer_createServerFn_handler = createServerRpc( + { + id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + name: 'withoutUseServer', + filename: 'src/test.ts', + }, + (opts) => withoutUseServer.__executeServer(opts), +) +const withoutUseServer = serverFn({ method: 'GET' }).handler( + withoutUseServer_createServerFn_handler, + async () => { + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) + }, +) +const withVariable_createServerFn_handler = createServerRpc( + { + id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + name: 'withVariable', + filename: 'src/test.ts', + }, + (opts) => withVariable.__executeServer(opts), +) +const withVariable = serverFn({ method: 'GET' }).handler( + withVariable_createServerFn_handler, + abstractedFunction, +) async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) } -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { +function zodValidator( + schema: TSchema, + fn: (input: z.output) => TResult, +) { return async (input: unknown) => { - return fn(schema.parse(input)); - }; + return fn(schema.parse(input)) + } +} +const withZodValidator_createServerFn_handler = createServerRpc( + { + id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + name: 'withZodValidator', + filename: 'src/test.ts', + }, + (opts) => withZodValidator.__executeServer(opts), +) +const withZodValidator = serverFn({ method: 'GET' }).handler( + withZodValidator_createServerFn_handler, + zodValidator(z.number(), (input) => { + return { 'you gave': input } + }), +) +export { + withUseServer_createServerFn_handler, + withoutUseServer_createServerFn_handler, + withVariable_createServerFn_handler, + withZodValidator_createServerFn_handler, } -const withZodValidator_createServerFn_handler = createServerRpc({ - id: "43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3", - name: "withZodValidator", - filename: "src/test.ts" -}, opts => withZodValidator.__executeServer(opts)); -const withZodValidator = serverFn({ - method: 'GET' -}).handler(withZodValidator_createServerFn_handler, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); -export { withUseServer_createServerFn_handler, withoutUseServer_createServerFn_handler, withVariable_createServerFn_handler, withZodValidator_createServerFn_handler }; \ No newline at end of file diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx index e759e35f42..bc18c08855 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx @@ -1,60 +1,88 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import * as TanStackStart from '@tanstack/react-start'; -import { z } from 'zod'; -const withUseServer_createServerFn_handler = createServerRpc({ - id: "b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320", - name: "withUseServer", - filename: "src/test.ts" -}, opts => withUseServer.__executeServer(opts)); -const withUseServer = TanStackStart.createServerFn({ - method: 'GET' -}).handler(withUseServer_createServerFn_handler, async function () { - 'use server'; - - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withoutUseServer_createServerFn_handler = createServerRpc({ - id: "c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2", - name: "withoutUseServer", - filename: "src/test.ts" -}, opts => withoutUseServer.__executeServer(opts)); +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import * as TanStackStart from '@tanstack/react-start' +import { z } from 'zod' +const withUseServer_createServerFn_handler = createServerRpc( + { + id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + name: 'withUseServer', + filename: 'src/test.ts', + }, + (opts) => withUseServer.__executeServer(opts), +) +const withUseServer = TanStackStart.createServerFn({ method: 'GET' }).handler( + withUseServer_createServerFn_handler, + async function () { + 'use server' + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) + }, +) +const withoutUseServer_createServerFn_handler = createServerRpc( + { + id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', + name: 'withoutUseServer', + filename: 'src/test.ts', + }, + (opts) => withoutUseServer.__executeServer(opts), +) const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET' + method: 'GET', }).handler(withoutUseServer_createServerFn_handler, async () => { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); -}); -const withVariable_createServerFn_handler = createServerRpc({ - id: "7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70", - name: "withVariable", - filename: "src/test.ts" -}, opts => withVariable.__executeServer(opts)); -const withVariable = TanStackStart.createServerFn({ - method: 'GET' -}).handler(withVariable_createServerFn_handler, abstractedFunction); + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) +}) +const withVariable_createServerFn_handler = createServerRpc( + { + id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', + name: 'withVariable', + filename: 'src/test.ts', + }, + (opts) => withVariable.__executeServer(opts), +) +const withVariable = TanStackStart.createServerFn({ method: 'GET' }).handler( + withVariable_createServerFn_handler, + abstractedFunction, +) async function abstractedFunction() { - console.info('Fetching posts...'); - await new Promise(r => setTimeout(r, 500)); - return axios.get>('https://jsonplaceholder.typicode.com/posts').then(r => r.data.slice(0, 10)); + console.info('Fetching posts...') + await new Promise((r) => setTimeout(r, 500)) + return axios + .get>('https://jsonplaceholder.typicode.com/posts') + .then((r) => r.data.slice(0, 10)) } -function zodValidator(schema: TSchema, fn: (input: z.output) => TResult) { +function zodValidator( + schema: TSchema, + fn: (input: z.output) => TResult, +) { return async (input: unknown) => { - return fn(schema.parse(input)); - }; + return fn(schema.parse(input)) + } } -const withZodValidator_createServerFn_handler = createServerRpc({ - id: "43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3", - name: "withZodValidator", - filename: "src/test.ts" -}, opts => withZodValidator.__executeServer(opts)); +const withZodValidator_createServerFn_handler = createServerRpc( + { + id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', + name: 'withZodValidator', + filename: 'src/test.ts', + }, + (opts) => withZodValidator.__executeServer(opts), +) const withZodValidator = TanStackStart.createServerFn({ - method: 'GET' -}).handler(withZodValidator_createServerFn_handler, zodValidator(z.number(), input => { - return { - 'you gave': input - }; -})); -export { withUseServer_createServerFn_handler, withoutUseServer_createServerFn_handler, withVariable_createServerFn_handler, withZodValidator_createServerFn_handler }; \ No newline at end of file + method: 'GET', +}).handler( + withZodValidator_createServerFn_handler, + zodValidator(z.number(), (input) => { + return { 'you gave': input } + }), +) +export { + withUseServer_createServerFn_handler, + withoutUseServer_createServerFn_handler, + withVariable_createServerFn_handler, + withZodValidator_createServerFn_handler, +} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx index 66bcb9376e..f62fa718d6 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx @@ -1,14 +1,15 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import { createServerFn } from '@tanstack/react-start'; -import { z } from 'zod'; -const withUseServer_createServerFn_handler = createServerRpc({ - id: "b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320", - name: "withUseServer", - filename: "src/test.ts" -}, opts => withUseServer.__executeServer(opts)); -const withUseServer = createServerFn({ - method: 'GET' -}).validator(z.number()).handler(withUseServer_createServerFn_handler, ({ - input -}) => input + 1); -export { withUseServer_createServerFn_handler }; \ No newline at end of file +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import { createServerFn } from '@tanstack/react-start' +import { z } from 'zod' +const withUseServer_createServerFn_handler = createServerRpc( + { + id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', + name: 'withUseServer', + filename: 'src/test.ts', + }, + (opts) => withUseServer.__executeServer(opts), +) +const withUseServer = createServerFn({ method: 'GET' }) + .validator(z.number()) + .handler(withUseServer_createServerFn_handler, ({ input }) => input + 1) +export { withUseServer_createServerFn_handler } diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx index 5a2c26fe0b..26298edd56 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx @@ -1,53 +1,56 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import { createServerFn, createMiddleware } from '@tanstack/react-start'; -const authMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - auth: 'auth' - } - }); -}); -const adminMiddleware = createMiddleware({ - type: 'function' -}).server(({ - next -}) => { - return next({ - context: { - admin: 'admin' - } - }); -}); -const createAuthServerFn = createServerFn().middleware([authMiddleware]); -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]); -const myAuthedFn_createServerFn_handler = createServerRpc({ - id: "3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3", - name: "myAuthedFn", - filename: "src/test.ts" -}, opts => myAuthedFn.__executeServer(opts)); -const myAuthedFn = createAuthServerFn().handler(myAuthedFn_createServerFn_handler, () => { - return 'myAuthedFn'; -}); -const deleteUserFn_createServerFn_handler = createServerRpc({ - id: "44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31", - name: "deleteUserFn", - filename: "src/test.ts" -}, opts => deleteUserFn.__executeServer(opts)); -const deleteUserFn = createAdminServerFn().handler(deleteUserFn_createServerFn_handler, () => { - return 'deleteUserFn'; -}); +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import { createServerFn, createMiddleware } from '@tanstack/react-start' +const authMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { auth: 'auth' } }) + }, +) +const adminMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => { + return next({ context: { admin: 'admin' } }) + }, +) +const createAuthServerFn = createServerFn().middleware([authMiddleware]) +const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) +const myAuthedFn_createServerFn_handler = createServerRpc( + { + id: '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', + name: 'myAuthedFn', + filename: 'src/test.ts', + }, + (opts) => myAuthedFn.__executeServer(opts), +) +const myAuthedFn = createAuthServerFn().handler( + myAuthedFn_createServerFn_handler, + () => { + return 'myAuthedFn' + }, +) +const deleteUserFn_createServerFn_handler = createServerRpc( + { + id: '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', + name: 'deleteUserFn', + filename: 'src/test.ts', + }, + (opts) => deleteUserFn.__executeServer(opts), +) +const deleteUserFn = createAdminServerFn().handler( + deleteUserFn_createServerFn_handler, + () => { + return 'deleteUserFn' + }, +) function createFakeFn() { return { - handler: cb => { - return cb(); - } - }; + handler: (cb) => { + return cb() + }, + } } const x = createFakeFn().handler(() => { - return 'fakeFn'; -}); -export { myAuthedFn_createServerFn_handler, deleteUserFn_createServerFn_handler }; \ No newline at end of file + return 'fakeFn' +}) +export { + myAuthedFn_createServerFn_handler, + deleteUserFn_createServerFn_handler, +} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx index a65629abd0..3ae8622683 100644 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx +++ b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx @@ -1,19 +1,35 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc'; -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start'; -const getEnv = createIsomorphicFn().server(() => 'server').client(() => 'client'); -const getServerEnv_createServerFn_handler = createServerRpc({ - id: "6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2", - name: "getServerEnv", - filename: "src/test.ts" -}, opts => getServerEnv.__executeServer(opts)); -const getServerEnv = createServerFn().handler(getServerEnv_createServerFn_handler, () => getEnv()); -const getEcho = createIsomorphicFn().server((input: string) => 'server received ' + input).client(input => 'client received ' + input); -const getServerEcho_createServerFn_handler = createServerRpc({ - id: "ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1", - name: "getServerEcho", - filename: "src/test.ts" -}, opts => getServerEcho.__executeServer(opts)); -const getServerEcho = createServerFn().validator((input: string) => input).handler(getServerEcho_createServerFn_handler, ({ - data -}) => getEcho(data)); -export { getServerEnv_createServerFn_handler, getServerEcho_createServerFn_handler }; \ No newline at end of file +import { createServerRpc } from '@tanstack/react-start/server-rpc' +import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' +const getEnv = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') +const getServerEnv_createServerFn_handler = createServerRpc( + { + id: '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', + name: 'getServerEnv', + filename: 'src/test.ts', + }, + (opts) => getServerEnv.__executeServer(opts), +) +const getServerEnv = createServerFn().handler( + getServerEnv_createServerFn_handler, + () => getEnv(), +) +const getEcho = createIsomorphicFn() + .server((input: string) => 'server received ' + input) + .client((input) => 'client received ' + input) +const getServerEcho_createServerFn_handler = createServerRpc( + { + id: 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', + name: 'getServerEcho', + filename: 'src/test.ts', + }, + (opts) => getServerEcho.__executeServer(opts), +) +const getServerEcho = createServerFn() + .validator((input: string) => input) + .handler(getServerEcho_createServerFn_handler, ({ data }) => getEcho(data)) +export { + getServerEnv_createServerFn_handler, + getServerEcho_createServerFn_handler, +} diff --git a/packages/start-plugin-core/tests/envOnly/envOnly.test.ts b/packages/start-plugin-core/tests/envOnly/envOnly.test.ts index 128e4f4162..4c18f2da81 100644 --- a/packages/start-plugin-core/tests/envOnly/envOnly.test.ts +++ b/packages/start-plugin-core/tests/envOnly/envOnly.test.ts @@ -3,6 +3,7 @@ import path from 'node:path' import { describe, expect, test } from 'vitest' import { StartCompiler } from '../../src/start-compiler/compiler' +import { formatSnapshot } from '../format-snapshot' // Default test options for StartCompiler function getDefaultTestOptions(env: 'client' | 'server') { @@ -73,9 +74,9 @@ describe('envOnly functions compile correctly', async () => { id: filename, }) - await expect(compiledResult!.code).toMatchFileSnapshot( - `./snapshots/${env}/${filename}`, - ) + await expect( + await formatSnapshot(compiledResult!.code, filename), + ).toMatchFileSnapshot(`./snapshots/${env}/${filename}`) }, ) }) diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx index d56ad1f374..8c97577305 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx @@ -1,4 +1,6 @@ const serverFunc = () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +} +const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx index d56ad1f374..8c97577305 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx @@ -1,4 +1,6 @@ const serverFunc = () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +} +const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx index ee84019143..cad8d612c9 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx @@ -1,6 +1,10 @@ export const fn = () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}; + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +} export const wrappedFn = (() => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}) as () => string; \ No newline at end of file + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +}) as () => string diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx index 6a29fcbfe6..b226e30116 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx @@ -1,32 +1,34 @@ // Server-only function factory export function createServerFactory(name: string) { return () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); - }; + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) + } } - // Client-only function factory export function createClientFactory(name: string) { return () => { - console.log(`Client only: ${name}`); - return `client-${name}`; - }; + console.log(`Client only: ${name}`) + return `client-${name}` + } } - // Arrow function server factory export const createServerArrowFactory = (prefix: string) => { return () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); - }; -}; - + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) + } +} // Arrow function client factory export const createClientArrowFactory = (prefix: string) => { - return () => `${prefix}-client`; -}; - + return () => `${prefix}-client` +} // Top-level for comparison export const topLevelServerFn = () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}; -export const topLevelClientFn = () => 'client'; \ No newline at end of file + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +} +export const topLevelClientFn = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx index d56ad1f374..8c97577305 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx @@ -1,4 +1,6 @@ const serverFunc = () => { - throw new Error("createServerOnlyFn() functions can only be called on the server!"); -}; -const clientFunc = () => 'client'; \ No newline at end of file + throw new Error( + 'createServerOnlyFn() functions can only be called on the server!', + ) +} +const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx index 5373578295..924d8d2442 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx @@ -1,4 +1,6 @@ -const serverFunc = () => 'server'; +const serverFunc = () => 'server' const clientFunc = () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); -}; \ No newline at end of file + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) +} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx index 5373578295..924d8d2442 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx @@ -1,4 +1,6 @@ -const serverFunc = () => 'server'; +const serverFunc = () => 'server' const clientFunc = () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); -}; \ No newline at end of file + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) +} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx index 8f906790b8..078c324406 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx @@ -1,2 +1,2 @@ -export const fn = () => 'server-only-value'; -export const wrappedFn = (() => 'wrapped-server-only-value') as () => string; \ No newline at end of file +export const fn = () => 'server-only-value' +export const wrappedFn = (() => 'wrapped-server-only-value') as () => string diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx index 58b2483a48..fdb022bc0d 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx @@ -1,32 +1,34 @@ // Server-only function factory export function createServerFactory(name: string) { return () => { - console.log(`Server only: ${name}`); - return `server-${name}`; - }; + console.log(`Server only: ${name}`) + return `server-${name}` + } } - // Client-only function factory export function createClientFactory(name: string) { return () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); - }; + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) + } } - // Arrow function server factory export const createServerArrowFactory = (prefix: string) => { - return () => `${prefix}-server`; -}; - + return () => `${prefix}-server` +} // Arrow function client factory export const createClientArrowFactory = (prefix: string) => { return () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); - }; -}; - + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) + } +} // Top-level for comparison -export const topLevelServerFn = () => 'server'; +export const topLevelServerFn = () => 'server' export const topLevelClientFn = () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); -}; \ No newline at end of file + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) +} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx index 5373578295..924d8d2442 100644 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx +++ b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx @@ -1,4 +1,6 @@ -const serverFunc = () => 'server'; +const serverFunc = () => 'server' const clientFunc = () => { - throw new Error("createClientOnlyFn() functions can only be called on the client!"); -}; \ No newline at end of file + throw new Error( + 'createClientOnlyFn() functions can only be called on the client!', + ) +} diff --git a/packages/start-plugin-core/tests/format-snapshot.ts b/packages/start-plugin-core/tests/format-snapshot.ts new file mode 100644 index 0000000000..d152094bea --- /dev/null +++ b/packages/start-plugin-core/tests/format-snapshot.ts @@ -0,0 +1,69 @@ +import { format } from 'prettier' +import { parsers } from 'prettier/plugins/typescript' +import type { ParserOptions } from 'prettier' + +/** + * Formats compiler output before it is compared with a file snapshot, so that + * snapshots record the emitted program instead of the layout choices of the + * code generator (object wrapping, blank lines, parentheses around JSX, ...). + * + * Comments are kept: they are part of the output. Output that does not parse + * is returned unchanged. + */ +export async function formatSnapshot(code: string, filepath: string) { + try { + return await format(await removeBlankLines(code, filepath), { + filepath, + parser: 'typescript', + semi: false, + singleQuote: true, + trailingComma: 'all', + // Do not keep an object expanded because the generator printed it + // over several lines. + objectWrap: 'collapse', + }) + } catch { + return code + } +} + +/** + * Prettier keeps single blank lines from its input. Outside template literals, + * line breaks are not significant, so blank lines can be dropped. + */ +async function removeBlankLines(code: string, filepath: string) { + const parser = parsers.typescript + const ast = await parser.parse(code, { filepath } as ParserOptions) + const templateRanges: Array<[number, number]> = [] + const visit = (node: unknown): void => { + if (Array.isArray(node)) { + node.forEach(visit) + return + } + if (!node || typeof node !== 'object') { + return + } + if ((node as { type?: unknown }).type === 'TemplateElement') { + templateRanges.push([parser.locStart(node), parser.locEnd(node)]) + } + for (const [key, value] of Object.entries(node)) { + if (key !== 'loc' && key !== 'range') { + visit(value) + } + } + } + visit(ast) + + const lines: Array = [] + let lineStart = 0 + for (const line of code.split('\n')) { + const isInTemplate = templateRanges.some( + ([start, end]) => start < lineStart && lineStart < end, + ) + if (line.trim() !== '' || isInTemplate) { + lines.push(line) + } + lineStart += line.length + 1 + } + return lines.join('\n') +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts b/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts index a027fac505..d47bc3972d 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts +++ b/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts @@ -5,6 +5,7 @@ import { generateFromAst, parseAst } from '@tanstack/router-utils' import path from 'pathe' import { describe, expect, test } from 'vitest' import { createHydrateCompilerPlugin } from '../../src/hydrate-when-transform' +import { formatSnapshot } from '../format-snapshot' const fixtureRoot = path.resolve(import.meta.dirname, './test-files') const errorRoot = path.resolve(import.meta.dirname, './error-files') @@ -13,8 +14,13 @@ function fixtureId(filename: string) { return path.join(fixtureRoot, filename) } -function normalizeSnapshotCode(code: string) { - return code.split(fixtureRoot).join('') +// Replace the fixture root before formatting so that line breaks do not +// depend on where the repository is checked out. +async function normalizeSnapshotCode(code: string, filename: string) { + return await formatSnapshot( + code.split(fixtureRoot).join(''), + filename, + ) } async function readFixture(filename: string) { @@ -136,7 +142,9 @@ describe('Hydrate compiler transform fixtures', async () => { const result = compile({ env: 'client', code, id }) await expect( - normalizeSnapshotCode(result?.code ?? 'no-transform'), + result + ? await normalizeSnapshotCode(result.code, filename) + : 'no-transform', ).toMatchFileSnapshot(`./snapshots/client/${filename}`) }) @@ -144,7 +152,9 @@ describe('Hydrate compiler transform fixtures', async () => { const result = compile({ env: 'server', code, id }) await expect( - normalizeSnapshotCode(result?.code ?? 'no-transform'), + result + ? await normalizeSnapshotCode(result.code, filename) + : 'no-transform', ).toMatchFileSnapshot(`./snapshots/server/${filename}`) }) }) @@ -225,7 +235,9 @@ describe('Hydrate compiler transform fixtures', async () => { }) await expect( - normalizeSnapshotCode(loaded?.code ?? 'no-virtual-module'), + loaded + ? await normalizeSnapshotCode(loaded.code, filename) + : 'no-virtual-module', ).toMatchFileSnapshot( `./snapshots/virtual/${filename}.${boundary.exportName}.tsx`, ) @@ -245,7 +257,9 @@ describe('Hydrate compiler transform fixtures', async () => { }) await expect( - normalizeSnapshotCode(nestedPass?.code ?? 'no-transform'), + nestedPass + ? await normalizeSnapshotCode(nestedPass.code, filename) + : 'no-transform', ).toMatchFileSnapshot(`./snapshots/virtual/${filename}.H0.client.tsx`) }) }) diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx index f1d2243d68..5f057addab 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx @@ -1,18 +1,24 @@ -const _H = _lazyRouteComponent(() => import("/hydrateWhenBasic.tsx?tss-hydrate=0_3cf0187f82"), "H0"), - _H0_preload = _H.preload; -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate } from '@tanstack/react-start'; -import { idle, visible } from '@tanstack/react-start/hydration'; -import { FallbackPane } from './widgets'; +const _H = _lazyRouteComponent( + () => import('/hydrateWhenBasic.tsx?tss-hydrate=0_3cf0187f82'), + 'H0', + ), + _H0_preload = _H.preload +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { idle, visible } from '@tanstack/react-start/hydration' +import { FallbackPane } from './widgets' export function Page() { - return
- } h="0_3cf0187f82" p={_H0_preload}> -{<_H />} - -
; -} \ No newline at end of file + return ( +
+ } + h="0_3cf0187f82" + p={_H0_preload} + > + {<_H />} + +
+ ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx index 73070a4fe1..34203df6ad 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx @@ -1,19 +1,33 @@ -const _H3 = _lazyRouteComponent(() => import("/hydrateWhenMultiple.tsx?tss-hydrate=2_21aa371e0f"), "H2"); -const _H2 = _lazyRouteComponent(() => import("/hydrateWhenMultiple.tsx?tss-hydrate=1_21aa371e0f"), "H1"); -const _H = _lazyRouteComponent(() => import("/hydrateWhenMultiple.tsx?tss-hydrate=0_21aa371e0f"), "H0"); -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate } from '@tanstack/react-start'; -import { load, media, visible } from '@tanstack/react-start/hydration'; +const _H3 = _lazyRouteComponent( + () => + import('/hydrateWhenMultiple.tsx?tss-hydrate=2_21aa371e0f'), + 'H2', +) +const _H2 = _lazyRouteComponent( + () => + import('/hydrateWhenMultiple.tsx?tss-hydrate=1_21aa371e0f'), + 'H1', +) +const _H = _lazyRouteComponent( + () => + import('/hydrateWhenMultiple.tsx?tss-hydrate=0_21aa371e0f'), + 'H0', +) +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { load, media, visible } from '@tanstack/react-start/hydration' export function Page() { - return <> + return ( + <> -{<_H />} - + {<_H />} + -{<_H2 />} - + {<_H2 />} + -{<_H3 />} - - ; -} \ No newline at end of file + {<_H3 />} + + + ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx index 70fe4ce862..adec83789c 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx @@ -1,16 +1,24 @@ -const _H2 = _lazyRouteComponent(() => import("/hydrateWhenNested.tsx?tss-hydrate=2_466696e41d"), "H2"); -const _H = _lazyRouteComponent(() => import("/hydrateWhenNested.tsx?tss-hydrate=0_466696e41d"), "H0"); -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate } from '@tanstack/react-start'; -import { idle, visible } from '@tanstack/react-start/hydration'; -const unused = 'remove me from virtual modules'; +const _H2 = _lazyRouteComponent( + () => import('/hydrateWhenNested.tsx?tss-hydrate=2_466696e41d'), + 'H2', +) +const _H = _lazyRouteComponent( + () => import('/hydrateWhenNested.tsx?tss-hydrate=0_466696e41d'), + 'H0', +) +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { idle, visible } from '@tanstack/react-start/hydration' +const unused = 'remove me from virtual modules' export function Page() { - return <> + return ( + <> -{<_H />} - + {<_H />} + -{<_H2 />} - - ; -} \ No newline at end of file + {<_H2 />} + + + ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx index 4d135f70f4..c2af676fa4 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx @@ -1,9 +1,14 @@ -const _H = _lazyRouteComponent(() => import("/hydrateWhenNever.tsx?tss-hydrate=0_b752509d76"), "H0"); -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate } from '@tanstack/react-start'; -import { never } from '@tanstack/react-start/hydration'; +const _H = _lazyRouteComponent( + () => import('/hydrateWhenNever.tsx?tss-hydrate=0_b752509d76'), + 'H0', +) +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { never } from '@tanstack/react-start/hydration' export function Page() { - return -{<_H />} -; -} \ No newline at end of file + return ( + + {<_H />} + + ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx index 1fc3dc39a9..a0353594f2 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx @@ -1,26 +1,47 @@ -const _H3 = _lazyRouteComponent(() => import("/hydrateWhenObjectFallback.tsx?tss-hydrate=2_7f4dc3aa80"), "H2"); -const _H2 = _lazyRouteComponent(() => import("/hydrateWhenObjectFallback.tsx?tss-hydrate=1_7f4dc3aa80"), "H1"); -const _H = _lazyRouteComponent(() => import("/hydrateWhenObjectFallback.tsx?tss-hydrate=0_7f4dc3aa80"), "H0"); -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate } from '@tanstack/react-start'; -import { idle, visible } from '@tanstack/react-start/hydration'; +const _H3 = _lazyRouteComponent( + () => + import('/hydrateWhenObjectFallback.tsx?tss-hydrate=2_7f4dc3aa80'), + 'H2', +) +const _H2 = _lazyRouteComponent( + () => + import('/hydrateWhenObjectFallback.tsx?tss-hydrate=1_7f4dc3aa80'), + 'H1', +) +const _H = _lazyRouteComponent( + () => + import('/hydrateWhenObjectFallback.tsx?tss-hydrate=0_7f4dc3aa80'), + 'H0', +) +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { idle, visible } from '@tanstack/react-start/hydration' const spreadProps = { when: visible(), - fallback:
Bound
-}; + fallback:
Bound
, +} export function Page() { - return <> - Direct
} h="0_7f4dc3aa80"> -{<_H />} - - Inline
- }} h="1_7f4dc3aa80"> -{<_H2 />} - + return ( + <> + Direct} + h="0_7f4dc3aa80" + > + {<_H />} + + Inline, + }} + h="1_7f4dc3aa80" + > + {<_H2 />} + -{<_H3 />} - - ; -} \ No newline at end of file + {<_H3 />} + + + ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx index 56bc8896ce..05028ec03b 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx @@ -1,19 +1,30 @@ -const _H = _lazyRouteComponent(() => import("/hydrateWhenPrefetchState.tsx?tss-hydrate=0_24b5f958eb"), "H0"), - _H0_preload = _H.preload; -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { useState } from 'react'; -import { Hydrate } from '@tanstack/react-start'; -import { interaction } from '@tanstack/react-start/hydration'; +const _H = _lazyRouteComponent( + () => + import('/hydrateWhenPrefetchState.tsx?tss-hydrate=0_24b5f958eb'), + 'H0', + ), + _H0_preload = _H.preload +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { useState } from 'react' +import { Hydrate } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' export function Page() { - const [status, setStatus] = useState('idle'); - const [, setUnusedStatus] = useState('idle'); - return
+ const [status, setStatus] = useState('idle') + const [, setUnusedStatus] = useState('idle') + return ( +

{status}

- { - setStatus('prefetched'); - setUnusedStatus('prefetched'); - }} h="0_24b5f958eb" p={_H0_preload}> -{<_H />} - -
; -} \ No newline at end of file + { + setStatus('prefetched') + setUnusedStatus('prefetched') + }} + h="0_24b5f958eb" + p={_H0_preload} + > + {<_H />} + +
+ ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx index 13b86d4d5d..509b2b988b 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx @@ -1,11 +1,14 @@ -const _H = _lazyRouteComponent(() => import("/hydrateWhenRenamed.tsx?tss-hydrate=0_f555ef3ac2"), "H0"); -import { lazyRouteComponent as _lazyRouteComponent } from "@tanstack/react-router"; -import { Hydrate as HW } from '@tanstack/react-start'; -import { interaction } from '@tanstack/react-start/hydration'; +const _H = _lazyRouteComponent( + () => import('/hydrateWhenRenamed.tsx?tss-hydrate=0_f555ef3ac2'), + 'H0', +) +import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' +import { Hydrate as HW } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' export function Page() { - return -{<_H />} -; -} \ No newline at end of file + return ( + + {<_H />} + + ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx index 8bcf4099ca..71896aa304 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx @@ -1,17 +1,18 @@ -import { Hydrate } from '@tanstack/react-start'; -import { idle, visible } from '@tanstack/react-start/hydration'; -import { Chart } from './widgets'; -import { formatValue } from './format'; -const chartTitle = formatValue('Revenue'); +import { Hydrate } from '@tanstack/react-start' +import { idle, visible } from '@tanstack/react-start/hydration' +import { Chart } from './widgets' +import { formatValue } from './format' +const chartTitle = formatValue('Revenue') export function Page() { - return
- + return ( +
+ -
; -} \ No newline at end of file +
+ ) +} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx index 6959b25b3e..92bb4f9a26 100644 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx +++ b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx @@ -1,16 +1,17 @@ -import { Hydrate } from '@tanstack/react-start'; -import { load, media, visible } from '@tanstack/react-start/hydration'; +import { Hydrate } from '@tanstack/react-start' +import { load, media, visible } from '@tanstack/react-start/hydration' function Summary() { - return
Summary
; + return
Summary
} function Comments() { - return
Comments
; + return
Comments
} function Footer() { - return
Footer
; + return
Footer
} export function Page() { - return <> + return ( + <> @@ -20,5 +21,6 @@ export function Page() {