mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:51:59 +00:00
**Context**
In order for the SvelteKit app to work in production and to ensure that navigating between the React and SvelteKit app "just works" a couple of things need to happen:
- the server needs to know for which routes to serve the SvelteKit app
- when navigating to a new page, the React app needs to know whether that page should be served by the SvelteKit app or not. If it should, it performs a page refresh, which will cause the server to send the SvelteKit app.
- the same applies to the SvelteKit app, but vice versa, except that it performs a page refresh automatically for every route that it doesn't support (the SvelteKit app is a subset of the React app).
Until now this logic was controlled by the `web-next` and `web-next-rollout` feature flags.
When `web-next` is set the server will serve the SvelteKit app for all routes supported by the app.
When `web-next-rollout` is set the server will server the SvelteKit app only for a certain subset of pages.
These two sets of pages are currently maintained separately in different places on server, the React app and the SvelteKit app. Multiple steps need to be taken to make a SvelteKit page available in production and that is not easy to maintain.
**New approach**
With this new approach, making a SvelteKit page available in production is much simpler.
To make it available as "opt-in" (`web-next` feature flag):
1. Add new page as usual.
2. Run `sg generate`.
To roll it out by default on e.g. S2 (`web-next-rollout` feature flag).
1. Add `// @sg EnableRollout` to the corresponding `+page.ts` file.
2. Run `sg generate`.
**How it works**
Ultimately what the server, the React app and SvelteKit app have to do is determine whether the SvelteKit supports a given path name.
Because SvelteKit uses file based routing we can determine at build time which SvelteKit routes exist. We can also take the route IDs and convert them to regular expression, [much like SvelteKit does itself](
|
||
|---|---|---|
| .. | ||
| appliance | ||
| batcheshelper | ||
| blobstore | ||
| bundled-executor | ||
| cody-gateway | ||
| embeddings | ||
| executor | ||
| executor-kubernetes | ||
| frontend | ||
| gitserver | ||
| loadtest | ||
| migrator | ||
| msp-example | ||
| pings | ||
| precise-code-intel-worker | ||
| repo-updater | ||
| searcher | ||
| server | ||
| symbols | ||
| syntactic-code-intel-worker | ||
| telemetry-gateway | ||
| worker | ||
| README.md | ||
This directory contains Sourcegraph services and binaries.
When a services is added, removed, or when a service's dependencies change, update our architecture diagram.