upgrade SvelteKit

This commit is contained in:
Ben McCann
2022-08-19 08:35:24 -07:00
parent b87e42e98c
commit 00536227b5
8 changed files with 2866 additions and 2465 deletions

5216
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,21 @@
{
"name": "sveltesociety.dev",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "svelte-kit dev",
"start": "svelte-kit dev --open",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"dev": "vite dev",
"start": "vite dev --open",
"build": "vite build",
"preview": "vite preview",
"lint": "prettier --check ./**/*.{js,ts,css,md,svelte,html,json} && eslint --ignore-path .gitignore .",
"format": "prettier --write ./**/*.{js,ts,css,md,svelte,html,json}",
"test": "jest",
"prepare": "husky install"
},
"devDependencies": {
"@macfja/svelte-persistent-store": "^1.2.0",
"@macfja/svelte-persistent-store": "1.2.0",
"@sveltejs/adapter-static": "next",
"@sveltejs/kit": "next",
"@sveltejs/kit": "1.0.0-next.405",
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
@@ -22,7 +23,7 @@
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-svelte3": "^3.2.0",
"graphql-request": "^3.5.0",
"highlight.js": "^11.2.0",
"highlight.js": "^11.6.0",
"husky": "^7.0.2",
"jest": "^27.1.0",
"lint-staged": "^11.1.2",
@@ -30,16 +31,13 @@
"prettier": "~2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.46.3",
"svelte-highlight": "^5.2.0",
"svelte-preprocess": "^4.10.2",
"svelte-select": "^4.4.0",
"ts-jest": "^27.0.5",
"tslib": "^2.0.0",
"typescript": "^4.4.2"
},
"type": "module",
"dependencies": {
"svelte-highlight": "^5.2.0"
},
"lint-staged": {
"*.{js,ts,css,md,svx,svelte,html,json}": "prettier --write"
}

View File

@@ -5,9 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png" />
%svelte.head%
%sveltekit.head%
</head>
<body>
<div id="sveltekit-entry">%svelte.body%</div>
<div>%sveltekit.body%</div>
</body>
</html>

View File

@@ -1,9 +1,6 @@
/**
* @type {import('@sveltejs/kit').RequestHandler}
*/
import type { EndpointOutput } from '@sveltejs/kit';
import type { RequestHandler } from '@sveltejs/kit';
export async function get(): Promise<EndpointOutput> {
export const GET: RequestHandler = async function () {
const events = await Promise.all(
Object.entries(import.meta.glob('./*.svx')).map(async ([path, page]) => {
const { metadata } = await page();
@@ -25,4 +22,4 @@ export async function get(): Promise<EndpointOutput> {
error: new Error(),
body: undefined
};
}
};

View File

@@ -1,8 +1,6 @@
import type { EndpointOutput } from '@sveltejs/kit';
/**
* @type {import('@sveltejs/kit').RequestHandler}
*/
export async function get(): Promise<EndpointOutput> {
import type { RequestHandler } from '@sveltejs/kit';
export const GET: RequestHandler = async function () {
const pages = await Promise.all(
Object.entries(import.meta.glob('./**/*.svx')).map(async ([path, page]) => {
const { metadata } = await page();
@@ -35,4 +33,4 @@ export async function get(): Promise<EndpointOutput> {
error: new Error(),
body: undefined
};
}
};

View File

@@ -29,25 +29,16 @@ const config = {
extensions: extensions,
kit: {
adapter: adapter(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#sveltekit-entry',
vite: {
optimizeDeps: {
// workaround Vite issue to fix highlighting on cheatsheet
// https://github.com/metonym/svelte-highlight/issues/158
include: ['highlight.js/lib/core']
},
resolve: {
alias: {
// these are the aliases and paths to them
$components: path.resolve('./src/lib/components'),
$layout: path.resolve('./src/lib/components/layout'),
$layouts: path.resolve('./src/lib/layouts'),
$utils: path.resolve('./src/lib/utils'),
$styles: path.resolve('./src/lib/styles'),
$stores: path.resolve('./src/lib/stores')
}
}
},
prerender: {
default: true
}
}
};

View File

@@ -1,30 +1,3 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2020",
"lib": ["es2020"],
"target": "es2019",
/**
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
to enforce using \`import type\` instead of \`import\` for Types.
*/
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"resolveJsonModule": true,
/**
To have warnings/errors of the Svelte compiler at the correct position,
enable source maps by default.
*/
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"allowJs": true,
"checkJs": true,
"paths": {
"$lib/*": ["src/lib/*"]
}
},
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
"extends": "./.svelte-kit/tsconfig.json"
}

8
vite.config.js Normal file
View File

@@ -0,0 +1,8 @@
import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()]
};
export default config;