Skip to content

Commit

Permalink
Fix erroneus git foceful push
Browse files Browse the repository at this point in the history
  • Loading branch information
difanta committed Nov 27, 2023
2 parents 64adf9d + f5c1186 commit 7ab3e06
Show file tree
Hide file tree
Showing 25 changed files with 389 additions and 121 deletions.
2 changes: 2 additions & 0 deletions documentation/docs/10-getting-started/10-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ title: Introduction

SvelteKit is a framework for rapidly developing robust, performant web applications using [Svelte](https://svelte.dev/). If you're coming from React, SvelteKit is similar to Next. If you're coming from Vue, SvelteKit is similar to Nuxt.

To learn more about the kinds of applications you can build with SvelteKit, see the [FAQ](/faq#what-can-i-make-with-sveltekit).

## What is Svelte?

In short, Svelte is a way of writing user interface components — like a navigation bar, comment section, or contact form — that users see and interact with in their browsers. The Svelte compiler converts your components to JavaScript that can be run to render the HTML for the page and to CSS that styles the page. You don't need to know Svelte to understand the rest of this guide, but it will help. If you'd like to learn more, check out [the Svelte tutorial](https://svelte.dev/tutorial).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ title: Cloudflare Pages

To deploy to [Cloudflare Pages](https://developers.cloudflare.com/pages/), use [`adapter-cloudflare`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare).

This adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project is recommended so that `event.platform` is automatically typed.
This adapter will be installed by default when you use [`adapter-auto`](adapter-auto). If you plan on staying with Cloudflare Pages you can switch from [`adapter-auto`](adapter-auto) to using this adapter directly so that type declarations will be automatically applied and you can set Cloudflare-specific options.

## Comparisons

- `adapter-cloudflare` – supports all SvelteKit features; builds for [Cloudflare Pages](https://blog.cloudflare.com/cloudflare-pages-goes-full-stack/)
- `adapter-cloudflare-workers` – supports all SvelteKit features; builds for Cloudflare Workers
- `adapter-static` – only produces client-side static assets; compatible with Cloudflare Pages

> Unless you have a specific reason to use `adapter-cloudflare-workers`, it's recommended that you use `adapter-cloudflare` instead. Both adapters have equivalent functionality, but Cloudflare Pages offers features like GitHub integration with automatic builds and deploys, preview deployments, instant rollback and so on.
## Usage

Install with `npm i -D @sveltejs/adapter-cloudflare`, then add the adapter to your `svelte.config.js`:
Expand Down Expand Up @@ -94,7 +92,9 @@ declare global {
export {};
```

> `platform.env` is only available in your build, you can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler) to test it locally.
### Testing Locally

`platform.env` is only available in the final build and not in dev mode. For testing the build, you can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler) **version 3**. Once you have built your site, run `wrangler pages dev .svelte-kit/cloudflare`. Ensure you have your [bindings](https://developers.cloudflare.com/workers/wrangler/configuration/#bindings) in your `wrangler.toml`.

## Notes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ title: Cloudflare Workers

To deploy to [Cloudflare Workers](https://workers.cloudflare.com/), use [`adapter-cloudflare-workers`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare-workers).

Unless you have a specific reason to use this adapter, we recommend using [`adapter-cloudflare`](adapter-cloudflare) instead.

> Requires [Wrangler v2](https://developers.cloudflare.com/workers/wrangler/get-started/).
> Unless you have a specific reason to use `adapter-cloudflare-workers`, it's recommended that you use `adapter-cloudflare` instead. Both adapters have equivalent functionality, but Cloudflare Pages offers features like GitHub integration with automatic builds and deploys, preview deployments, instant rollback and so on.
## Usage

Expand Down Expand Up @@ -79,9 +77,9 @@ export default {
};
```

## Environment variables
## Bindings

The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object, containing KV/DO namespaces etc, is passed to SvelteKit via the `platform` property along with `context` and `caches`, meaning you can access it in hooks and endpoints:
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/platform/environment-variables/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with `context` and `caches`, meaning that you can access it in hooks and endpoints:

```js
// @errors: 7031
Expand All @@ -90,6 +88,8 @@ export async function POST({ request, platform }) {
}
```

> SvelteKit's built-in `$env` module should be preferred for environment variables.
To make these types available to your app, reference them in your `src/app.d.ts`:

```diff
Expand All @@ -108,7 +108,9 @@ declare global {
export {};
```

> `platform.env` is only available in your build, you can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler) to test it locally.
### Testing Locally

`platform.env` is only available in the final build and not in dev mode. For testing the build, you can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler). Once you have built your site, run `wrangler dev`. Ensure you have your [bindings](https://developers.cloudflare.com/workers/wrangler/configuration/#bindings) in your `wrangler.toml`. Wrangler version 3 is recommended.

## Troubleshooting

Expand Down
2 changes: 0 additions & 2 deletions documentation/docs/25-build-and-deploy/99-writing-adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export default function (options) {
}
```

The types for `Adapter` and its parameters are available in [types/index.d.ts](https://github.com/sveltejs/kit/blob/master/packages/kit/types/index.d.ts).

Within the `adapt` method, there are a number of things that an adapter should do:

- Clear out the build directory
Expand Down
22 changes: 22 additions & 0 deletions documentation/faq/10-what-can-i-make-with-sveltekit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: What can I make with SvelteKit?
---

SvelteKit can be used to create most kinds of applications. Out of the box, SvelteKit supports many features including:

- Dynamic page content with [load](/docs/load) functions and [API routes](/docs/routing#server).
- SEO-friendly dynamic content with [server-side rendering (SSR)](/docs/glossary#ssr).
- User-friendly progressively-enhanced interactive pages with SSR and [Form Actions](/docs/form-actions).
- Static pages with [prerendering](/docs/page-options#prerender).

SvelteKit can also be deployed to a wide spectrum of hosted architectures via [adapters](/docs/adapters). In cases where SSR is used (or server-side logic is added without prerendering), those functions will be adapted to the target backend. Some examples include:

- Self-hosted dynamic web applications with a [Node.js backend](/docs/adapter-node).
- Serverless web applications with backend loaders and APIs deployed as remote functions. See [zero-config deployments](/docs/adapter-auto) for popular deployment options.
- [Static pre-rendered sites](/docs/adapter-static) such as a blog or multi-page site hosted on a CDN or static host. Statically-generated sites are shipped without a backend.
- [Single-page Applications (SPAs)](/docs/single-page-apps) with client-side routing and rendering for API-driven dynamic content. SPAs are shipped without a backend and are not server-rendered. This option is commonly chosen when bundling SvelteKit with an app written in PHP, .Net, Java, C, Golang, Rust, etc.
- A mix of the above; some routes can be static, and some routes can use backend functions to fetch dynamic information. This can be configured with [page options](/docs/page-options) that includes the option to opt out of SSR.

In order to support SSR, a JS backend — such as Node.js or Deno-based server, serverless function, or edge function — is required.

It is also possible to write custom adapters or leverage community adapters to deploy SvelteKit to more platforms such as specialized server environments, browser extensions, or native applications. See [How do I use X with SvelteKit](#integrations) for more examples and integrations.
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/node": "^16.18.6",
"@types/sade": "^1.7.4",
"@types/set-cookie-parser": "^2.4.2",
"dts-buddy": "^0.0.10",
"dts-buddy": "^0.1.9",
"marked": "^4.2.3",
"rollup": "^3.7.0",
"svelte": "^4.0.5",
Expand Down
12 changes: 2 additions & 10 deletions packages/kit/src/core/adapt/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function create_builder({
write(dest, fallback);
},

generateManifest: ({ relativePath, routes: subset }) => {
generateManifest({ relativePath, routes: subset }) {
return generate_manifest({
build_data,
relative_path: relativePath,
Expand Down Expand Up @@ -189,15 +189,7 @@ export function create_builder({
return Array.from(new Set([...server_assets, ...client_assets]));
},

// @ts-expect-error
writePrerendered(dest, opts) {
// TODO remove for 1.0
if (opts?.fallback) {
throw new Error(
'The fallback option no longer exists — use builder.generateFallback(fallback) instead'
);
}

writePrerendered(dest) {
const source = `${config.kit.outDir}/output/prerendered`;
return [...copy(`${source}/pages`, dest), ...copy(`${source}/dependencies`, dest)];
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../exports/public"],
"types": ["../../../../types/internal"]
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
19 changes: 19 additions & 0 deletions packages/kit/src/core/sync/write_types/test/layout/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
19 changes: 19 additions & 0 deletions packages/kit/src/core/sync/write_types/test/slugs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../../../../../exports/public"],
"types": ["../../../../../types/internal"]
}
},
"include": ["./**/*.js"],
"exclude": ["./**/.svelte-kit/**"]
}
Loading

0 comments on commit 7ab3e06

Please sign in to comment.