Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sveltejs/kit
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/sveltejs/kit:
  Version Packages (next) (sveltejs#1543)
  type fixes for adapter-node and adapter-static (sveltejs#1578)
  Upgrade to Vite 2.3.3 (sveltejs#1580)
  fix: improve getRawBody parsing & handle error(s) (sveltejs#1528)
  create-svelte: add svelte-check for TS (sveltejs#1556)
  pass validated svelte config to adapters (sveltejs#1559)
  types: group related and reduce potential inconsistencies (sveltejs#1539)
  Use sveltekit tag on StackOverflow (sveltejs#1558)
  Fix create-svelte build-template script (sveltejs#1555)
  Remove err param from Polka .listen() callback (sveltejs#1550)
  bump: polka and sirv versions (sveltejs#1548)
  svelte-kit package (sveltejs#1499)
  • Loading branch information
sidharthv96 committed May 29, 2021
2 parents 7d2f668 + a66affe commit f306d84
Show file tree
Hide file tree
Showing 74 changed files with 712 additions and 172 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-pillows-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Add svelte-kit package command
7 changes: 7 additions & 0 deletions .changeset/odd-ligers-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-vercel': patch
'@sveltejs/kit': patch
---

ensure `content-length` limit respected; handle `getRawBody` error(s)
8 changes: 8 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"fluffy-dryers-jump",
"forty-months-prove",
"four-cheetahs-yawn",
"four-pillows-give",
"friendly-rivers-argue",
"funny-needles-talk",
"fuzzy-cougars-compare",
Expand Down Expand Up @@ -169,6 +170,7 @@
"nine-starfishes-destroy",
"nine-tomatoes-poke",
"ninety-singers-invite",
"odd-ligers-swim",
"old-files-jump",
"olive-frogs-drive",
"orange-boats-love",
Expand Down Expand Up @@ -202,13 +204,15 @@
"rare-ways-watch",
"real-bikes-matter",
"real-cherries-exercise",
"rich-clocks-chew",
"rotten-cats-pump",
"rotten-singers-taste",
"rude-olives-wink",
"rude-tomatoes-thank",
"selfish-avocados-develop",
"selfish-owls-own",
"serious-books-push",
"seven-bags-sniff",
"seven-impalas-march",
"seven-jars-argue",
"shaggy-elephants-sell",
Expand All @@ -225,13 +229,15 @@
"six-geese-study",
"six-rules-collect",
"sixty-terms-decide",
"slow-buses-beam",
"slow-fans-own",
"small-pigs-doubt",
"smart-bears-leave",
"smart-mugs-chew",
"smart-pears-accept",
"smooth-dryers-heal",
"smooth-items-exercise",
"smooth-items-march",
"smooth-rockets-sneeze",
"smooth-shoes-mix",
"smooth-shrimps-fly",
Expand Down Expand Up @@ -284,6 +290,7 @@
"tricky-buses-punch",
"tricky-walls-approve",
"tricky-wolves-confess",
"twelve-feet-deny",
"twelve-goats-knock",
"twelve-onions-burn",
"two-crabs-tease",
Expand All @@ -298,6 +305,7 @@
"warm-cameras-fix",
"warm-cheetahs-wash",
"warm-jars-move",
"weak-parents-guess",
"weak-swans-lie",
"wet-bees-exist",
"wet-dingos-perform",
Expand Down
8 changes: 8 additions & 0 deletions .changeset/rich-clocks-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@sveltejs/adapter-begin': patch
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-static': patch
'@sveltejs/kit': patch
---

bump `polka` and `sirv` dependency versions
5 changes: 5 additions & 0 deletions .changeset/seven-bags-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Add svelte-check to TS templates
5 changes: 5 additions & 0 deletions .changeset/slow-buses-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Upgrade to Vite 2.3.4
11 changes: 11 additions & 0 deletions .changeset/smooth-items-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@sveltejs/adapter-begin': patch
'@sveltejs/adapter-cloudflare-workers': patch
'@sveltejs/adapter-netlify': patch
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-static': patch
'@sveltejs/adapter-vercel': patch
'@sveltejs/kit': patch
---

Pass validated svelte config to adapter adapt function
5 changes: 5 additions & 0 deletions .changeset/twelve-feet-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

gitignore package directory
5 changes: 5 additions & 0 deletions .changeset/weak-parents-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Adjust build-template script to include package.json
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/questions-and-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ assignees: ''

This issue tracker is intended to collect bug reports and feature requests.

For help with installation, information on how features work, or questions about specific features of SvelteKit, please come and join us in the [Svelte Discord](https://svelte.dev/chat), or ask your question on [Stack Overflow](https://stackoverflow.com/questions/tagged/svelte). Any issues open for help requests will be closed to keep from clogging up the issue tracker.
For help with installation, information on how features work, or questions about specific features of SvelteKit, please come and join us in the [Svelte Discord](https://svelte.dev/chat), or ask your question on [Stack Overflow](https://stackoverflow.com/questions/tagged/sveltekit). Any issues open for help requests will be closed to keep from clogging up the issue tracker.
44 changes: 44 additions & 0 deletions documentation/docs/12-packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Packaging
---

You can use SvelteKit to build component libraries as well as apps.

When you're creating an app, the contents of `src/routes` is the public-facing stuff; [`src/lib`](#modules-lib) contains your app's internal library.

A SvelteKit component library has the exact same structure as a SvelteKit app, except that `src/lib` is the public-facing bit. `src/routes` might be a documentation or demo site that accompanies the library, or it might just be a sandbox you use during development.

Running `svelte-kit package` will take the contents of `src/lib` and generate a `package` directory (which can be [configured](#configuration-package)) containing the following:

- All the files in `src/lib`, unless you [configure](#configuration-package) custom `include`/`exclude` options. Svelte components will be preprocessed (but note the [caveats](#packaging-caveats) below)
- A `package.json` that copies the `name`, `version`, `description`, `keywords`, `homepage`, `bugs`, `license`, `author`, `contributors`, `funding`, `repository`, `dependencies`, `private` and `publishConfig` fields from the root of the project, and adds a `"type": "module"` and an `"exports"` field

The `"exports"` field contains the package's entry points. By default, all files in `src/lib` will be treated as an entry point unless they start with (or live in a directory that starts with) an underscore, but you can [configure](#configuration-package) this behaviour. If you have a `src/lib/index.js` or `src/lib/index.svelte` file, it will be treated as the package root.

For example, if you had a `src/lib/Foo.svelte` component and a `src/lib/index.js` module that re-exported it, a consumer of your library could do either of the following:

```js
import { Foo } from 'your-library';
```

```js
import Foo from 'your-library/Foo.svelte';
```

## Publishing

To publish the generated package:

```
npm publish package
```

If you configure a custom [`package.dir`](#configuration-package), change `package` accordingly.

## Caveats

This is a relatively experimental feature and is not yet fully implemented:

- if a preprocessor is specified, `.svelte` files are transformed (meaning they can contain TypeScript, for example), but `.d.ts` files are not generated
- `.ts` files are not currently transformed, and will cause the process to fail
- all other files are copied across as-is
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion documentation/docs/99-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Please see the [FAQ](/faq) for solutions to common issues and helpful tips and t

### Support

You can ask for help on [Discord](https://svelte.dev/chat) and [StackOverflow](https://stackoverflow.com/questions/tagged/svelte). Please first search for information related to your issue in the FAQ, Google or another search engine, issue tracker, and Discord chat history in order to be respectful of others' time. There are many more people asking questions than answering them, so this will help in allowing the community to grow in a scalable fashion.
You can ask for help on [Discord](https://svelte.dev/chat) and [StackOverflow](https://stackoverflow.com/questions/tagged/sveltekit). Please first search for information related to your issue in the FAQ, Google or another search engine, issue tracker, and Discord chat history in order to be respectful of others' time. There are many more people asking questions than answering them, so this will help in allowing the community to grow in a scalable fashion.
13 changes: 13 additions & 0 deletions packages/adapter-begin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @sveltejs/adapter-begin

## 1.0.0-next.10

### Patch Changes

- bf77940: bump `polka` and `sirv` dependency versions
- 028abd9: Pass validated svelte config to adapter adapt function
- Updated dependencies [6372690]
- Updated dependencies [c3d36a3]
- Updated dependencies [bf77940]
- Updated dependencies [2172469]
- Updated dependencies [028abd9]
- @sveltejs/kit@1.0.0-next.110

## 1.0.0-next.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-begin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function () {
const adapter = {
name: '@sveltejs/adapter-begin',

async adapt(utils) {
async adapt({ utils }) {
utils.log.minor('Parsing app.arc file');
const { static: static_mount_point } = parse_arc('app.arc');

Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-begin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-begin",
"version": "1.0.0-next.9",
"version": "1.0.0-next.10",
"main": "index.cjs",
"types": "index.d.ts",
"scripts": {
Expand All @@ -24,7 +24,7 @@
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"rollup": "^2.47.0",
"sirv": "^1.0.11",
"sirv": "^1.0.12",
"typescript": "^4.2.4"
},
"exports": {
Expand Down
12 changes: 12 additions & 0 deletions packages/adapter-cloudflare-workers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @sveltejs/adapter-cloudflare-workers

## 1.0.0-next.10

### Patch Changes

- 028abd9: Pass validated svelte config to adapter adapt function
- Updated dependencies [6372690]
- Updated dependencies [c3d36a3]
- Updated dependencies [bf77940]
- Updated dependencies [2172469]
- Updated dependencies [028abd9]
- @sveltejs/kit@1.0.0-next.110

## 1.0.0-next.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function () {
/** @type {import('@sveltejs/kit').Adapter} */
const adapter = {
name: '@sveltejs/adapter-cloudflare-workers',
async adapt(utils) {
async adapt({ utils }) {
const { site } = validate_config(utils);

const bucket = site.bucket;
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-cloudflare-workers",
"version": "1.0.0-next.9",
"version": "1.0.0-next.10",
"type": "module",
"exports": {
"import": "./index.js"
Expand Down
12 changes: 12 additions & 0 deletions packages/adapter-netlify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @sveltejs/adapter-netlify

## 1.0.0-next.15

### Patch Changes

- 028abd9: Pass validated svelte config to adapter adapt function
- Updated dependencies [6372690]
- Updated dependencies [c3d36a3]
- Updated dependencies [bf77940]
- Updated dependencies [2172469]
- Updated dependencies [028abd9]
- @sveltejs/kit@1.0.0-next.110

## 1.0.0-next.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function () {
const adapter = {
name: '@sveltejs/adapter-netlify',

async adapt(utils) {
async adapt({ utils }) {
const { publish, functions } = validate_config().build;

utils.rimraf(publish);
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-netlify",
"version": "1.0.0-next.14",
"version": "1.0.0-next.15",
"type": "module",
"exports": {
"import": "./index.js"
Expand Down
14 changes: 14 additions & 0 deletions packages/adapter-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @sveltejs/adapter-node

## 1.0.0-next.23

### Patch Changes

- c3d36a3: ensure `content-length` limit respected; handle `getRawBody` error(s)
- bf77940: bump `polka` and `sirv` dependency versions
- 028abd9: Pass validated svelte config to adapter adapt function
- Updated dependencies [6372690]
- Updated dependencies [c3d36a3]
- Updated dependencies [bf77940]
- Updated dependencies [2172469]
- Updated dependencies [028abd9]
- @sveltejs/kit@1.0.0-next.110

## 1.0.0-next.22

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare function plugin(options: { out?: string }): import('@sveltejs/kit').Adapter;
declare function plugin(options?: { out?: string }): import('@sveltejs/kit').Adapter;

export = plugin;
2 changes: 1 addition & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function ({ out = 'build' } = {}) {
const adapter = {
name: '@sveltejs/adapter-node',

async adapt(utils) {
async adapt({ utils }) {
utils.log.minor('Copying assets');
const static_directory = join(out, 'assets');
utils.copy_client_files(static_directory);
Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-node",
"version": "1.0.0-next.22",
"version": "1.0.0-next.23",
"type": "module",
"exports": {
"import": "./index.js"
Expand All @@ -26,9 +26,9 @@
"c8": "^7.7.2",
"compression": "^1.7.4",
"node-fetch": "^3.0.0-beta.9",
"polka": "^1.0.0-next.14",
"polka": "^1.0.0-next.15",
"rollup": "^2.47.0",
"sirv": "^1.0.11",
"sirv": "^1.0.12",
"typescript": "^4.2.4",
"uvu": "^0.5.1"
},
Expand Down
8 changes: 2 additions & 6 deletions packages/adapter-node/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import * as app from './app.js';

const { HOST = '0.0.0.0', PORT = 3000 } = process.env;

const instance = createServer({ render: app.render }).listen(PORT, HOST, (err) => {
if (err) {
console.log('error', err);
} else {
console.log(`Listening on port ${PORT}`);
}
const instance = createServer({ render: app.render }).listen(PORT, HOST, () => {
console.log(`Listening on port ${PORT}`);
});

export { instance };
14 changes: 12 additions & 2 deletions packages/adapter-node/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ export function createServer({ render }) {
prerendered_handler,
async (req, res) => {
const parsed = new URL(req.url || '', 'http://localhost');

let body;

try {
body = await getRawBody(req);
} catch (err) {
res.statusCode = err.status || 400;
return res.end(err.reason || 'Invalid request body');
}

const rendered = await render({
method: req.method,
headers: req.headers, // TODO: what about repeated headers, i.e. string[]
path: parsed.pathname,
rawBody: await getRawBody(req),
query: parsed.searchParams
query: parsed.searchParams,
rawBody: body
});

if (rendered) {
Expand Down
Loading

0 comments on commit f306d84

Please sign in to comment.