-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add providers to tanstack start #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aXenDeveloper
wants to merge
1
commit into
feat/tanstack_start_0
Choose a base branch
from
feat/tanstack_start_2
base: feat/tanstack_start_0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import type { VitNodeI18nConfig } from '@vitnode/core/lib/i18n/types' | ||
|
|
||
| /** | ||
| * The languages this app serves. | ||
| * | ||
| * Its own module, the way `apps/docs` has one, so the web config and (later) the | ||
| * API config can point at the same object instead of drifting apart - the site | ||
| * and the emails it sends have to agree on which languages exist. | ||
| * | ||
| * Packages ship their own translations, so nothing here lists them: `pl` has no | ||
| * `messages` entry and falls back to `en` key by key. Add | ||
| * `messages: { pl: { "@vitnode/core": () => import("./locales/...") } }` to | ||
| * reword something without forking the package that owns it. | ||
| */ | ||
| export const i18n = { | ||
| defaultLocale: 'en', | ||
| /** | ||
| * Explicit, because the app renders on a server: without one, `use-intl` | ||
| * formats dates in whatever zone the server happens to run in and warns that | ||
| * the client will disagree. Stage 3, which owns the locale runtime, is where a | ||
| * per-visitor zone would come from. | ||
| */ | ||
| timeZone: 'UTC', | ||
| locales: [ | ||
| { | ||
| code: 'en', | ||
| name: 'English', | ||
| }, | ||
| { | ||
| code: 'pl', | ||
| name: 'Polski', | ||
| }, | ||
| ], | ||
| } satisfies VitNodeI18nConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { queryOptions } from '@tanstack/react-query' | ||
| import { createServerFn } from '@tanstack/react-start' | ||
|
|
||
| import { loadShellIntl } from '#/server/messages.server' | ||
|
|
||
| /** | ||
| * The shell's locale and its `core.global` strings, fetched on the server. | ||
| * | ||
| * A server function rather than a plain loader: the messages are read from JSON | ||
| * inside each package's `dist`, which only exists on the server, and the plugin | ||
| * registry they are merged from must never reach the browser bundle. Start | ||
| * strips the handler - and everything only it imports - out of the client build. | ||
| */ | ||
| export const getShellIntl = createServerFn().handler( | ||
| async () => await loadShellIntl(), | ||
| ) | ||
|
|
||
| /** | ||
| * The same request, as a query. | ||
| * | ||
| * Going through the QueryClient rather than returning it from the loader is what | ||
| * makes the shell's copy of it *the* copy: the root loader warms it on the | ||
| * server, the SSR integration dehydrates it into the HTML, and the component | ||
| * reads it out of the hydrated cache instead of asking the server again. It is | ||
| * also the first real exercise of the Stage 2 pipeline - router context, loader, | ||
| * `ensureQueryData`, dehydrate, hydrate - which is worth having under something | ||
| * the page visibly needs rather than a synthetic query. | ||
| * | ||
| * `staleTime: Infinity`: a locale's messages change when the app is redeployed. | ||
| */ | ||
| export const shellIntlQueryOptions = () => | ||
| queryOptions({ | ||
| queryFn: async () => await getShellIntl(), | ||
| queryKey: ['vitnode', 'shell-intl'] as const, | ||
| staleTime: Infinity, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import type { LocaleMessagesMap } from '@vitnode/core/lib/i18n/types' | ||
|
|
||
| import { CONFIG_PLUGIN as BLOG } from '@vitnode/blog/const' | ||
| import { CONFIG_PLUGIN as CORE } from '@vitnode/core/config' | ||
| import { CONFIG_PLUGIN as EXAMPLE } from '@vitnode/example/const' | ||
|
|
||
| /** | ||
| * Where this app reads each installed package's translations from. | ||
| * | ||
| * Every VitNode package ships a locale barrel - `@vitnode/core/locales/index` - | ||
| * that loads its own files with a runtime | ||
| * `import("./en.json", { with: { type: "json" } })`. That is exactly right under | ||
| * Node, which is how `apps/api` and `apps/docs` read them, and unusable here: a | ||
| * bundler resolves that specifier relative to whichever chunk the barrel ended up | ||
| * in, the JSON is not next to it, and the built server silently loads nothing - | ||
| * every string renders as its own key. | ||
| * | ||
| * So the loaders are declared here instead, with static specifiers a bundler can | ||
| * follow. Each resolves through the package's `./locales/*.json` export to the | ||
| * real file and lands in the build as a chunk fetched on demand, which is the | ||
| * same laziness the barrels wanted. | ||
| * | ||
| * The cost is a line here per language a package ships. `apps/docs` already | ||
| * declares its own overrides this way, so the shape is not new - but it is a | ||
| * copy, and worth removing: make the barrels statically analysable and this file | ||
| * becomes one call to `buildMessagesSources`. | ||
| */ | ||
| export const packageMessages: Record<string, LocaleMessagesMap> = { | ||
| [BLOG.pluginId]: { | ||
| en: async () => await import('@vitnode/blog/locales/en.json'), | ||
| }, | ||
| [CORE.pluginId]: { | ||
| en: async () => await import('@vitnode/core/locales/en.json'), | ||
| }, | ||
| [EXAMPLE.pluginId]: { | ||
| en: async () => await import('@vitnode/example/locales/en.json'), | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new application shell only declares the viewport dimensions and title, leaving out a page description,
theme-color, anduser-scalableconfiguration. Every route inherits this root head, so production pages will ship without the repository-required SEO and viewport metadata; add the missing fields here.AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.