Skip to content

Commit 6cc8ac4

Browse files
committed
Build svelte components
1 parent f70a88a commit 6cc8ac4

22 files changed

+96
-167
lines changed

.gitignore

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
dist
2-
types
1+
.DS_Store
32
node_modules
3+
/build
4+
/dist
5+
/.svelte-kit
6+
/package
7+
.env
8+
.env.*
9+
!.env.example
10+
vite.config.js.timestamp-*
11+
vite.config.ts.timestamp-*
412
package-lock.json
513
yarn.lock
6-
bun.lockb
14+
bun.lockb
15+
pnpm-lock.yaml

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

LICENSE

-21
This file was deleted.

readme.md README.md

File renamed without changes.

build.js

-87
This file was deleted.

package.json

+36-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@westacks/inertia-svelte",
3-
"version": "1.0.19",
3+
"version": "1.0.20",
44
"license": "MIT",
55
"description": "The Svelte adapter for Inertia.js",
66
"author": "Dmytro Morozov <puny.flash@gmail.com>",
@@ -16,51 +16,56 @@
1616
"svelte",
1717
"inertia"
1818
],
19+
"scripts": {
20+
"build": "svelte-kit sync && svelte-package && publint",
21+
"prepublishOnly": "npm run build",
22+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
23+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
24+
},
1925
"files": [
2026
"dist",
21-
"types"
27+
"!dist/**/*.test.*",
28+
"!dist/**/*.spec.*"
2229
],
23-
"type": "module",
24-
"main": "dist/index.cjs",
25-
"types": "dist/index.d.ts",
30+
"peerDependencies": {
31+
"svelte": "^4.0.0"
32+
},
33+
"devDependencies": {
34+
"@sveltejs/adapter-auto": "^3.1.1",
35+
"@sveltejs/kit": "^2.5.0",
36+
"@sveltejs/package": "^2.2.6",
37+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
38+
"publint": "^0.2.7",
39+
"svelte": "^4.2.9",
40+
"svelte-check": "^3.6.3",
41+
"tslib": "^2.6.2",
42+
"typescript": "^5.3.3",
43+
"vite": "^5.0.12"
44+
},
2645
"exports": {
2746
".": {
2847
"types": "./dist/index.d.ts",
29-
"import": "./dist/index.js",
30-
"require": "./dist/index.cjs"
48+
"svelte": "./dist/index.js"
3149
},
3250
"./server": {
3351
"types": "./dist/server.d.ts",
34-
"import": "./dist/server.js",
35-
"require": "./dist/server.cjs"
52+
"svelte": "./dist/server.js"
53+
},
54+
"./components/*": {
55+
"types": "./dist/components/*",
56+
"svelte": "./dist/components/*"
3657
}
3758
},
59+
"import": "./dist/index.js",
60+
"types": "./dist/index.d.ts",
61+
"type": "module",
3862
"typesVersions": {
39-
"*": {
40-
"server": [
41-
"dist/server.d.ts"
63+
">4.0": {
64+
".": [
65+
"./dist/index.d.ts"
4266
]
4367
}
4468
},
45-
"scripts": {
46-
"dev": "node ./build.js --watch",
47-
"build": "npm run clean && node ./build.js && tsc --emitDeclarationOnly",
48-
"clean": "rm -rf dist",
49-
"prepublishOnly": "npm run build"
50-
},
51-
"devDependencies": {
52-
"@tsconfig/svelte": "^5.0.2",
53-
"@types/lodash": "^4.14.202",
54-
"esbuild": "^0.19.11",
55-
"esbuild-node-externals": "^1.12.0",
56-
"esbuild-svelte": "^0.8.0",
57-
"svelte": "^4.2.8",
58-
"svelte-preprocess": "^5.1.3",
59-
"typescript": "^5.3.3"
60-
},
61-
"peerDependencies": {
62-
"svelte": "^3.20.0 || ^4.0.0"
63-
},
6469
"dependencies": {
6570
"@inertiajs/core": "^1.0.14",
6671
"lodash": "^4.17.21"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/createInertiaApp.ts src/lib/createInertiaApp.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Page, router, setupProgress } from '@inertiajs/core'
2-
import { ComponentType } from 'svelte'
1+
import { type Page, router, setupProgress } from '@inertiajs/core'
2+
import type { ComponentType } from 'svelte'
33
import SvelteApp from './components/App.svelte'
44
import SSR from './components/SSR.svelte'
55
import store from './store'
6-
import { ComponentResolver, InertiaComponentType } from './types'
6+
import type { ComponentResolver, InertiaComponentType } from './types'
77

88
interface CreateInertiaAppProps {
99
id?: string

src/index.ts src/lib/index.ts

File renamed without changes.

src/link.ts src/lib/link.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { VisitOptions, mergeDataIntoQueryString, router, shouldIntercept } from '@inertiajs/core'
2-
import { Action } from 'svelte/action'
1+
import { type VisitOptions, mergeDataIntoQueryString, router, shouldIntercept } from '@inertiajs/core'
2+
import type { Action } from 'svelte/action'
33

44
interface ActionElement extends HTMLElement {
55
href?: string

src/page.ts src/lib/page.ts

File renamed without changes.
File renamed without changes.

src/server.ts src/lib/server.ts

File renamed without changes.

src/store.ts src/lib/store.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Page } from '@inertiajs/core'
1+
import type { Page } from '@inertiajs/core'
2+
import type { InertiaComponentType } from './types'
23
import { writable } from 'svelte/store'
3-
import { InertiaComponentType } from './types'
44

55
interface Store {
66
component: InertiaComponentType | null

src/types.ts src/lib/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { PageProps } from '@inertiajs/core'
2-
import { ComponentType } from 'svelte'
1+
import type { PageProps } from '@inertiajs/core'
2+
import type { ComponentType } from 'svelte'
33

44
export type ComponentResolver = (name: string) => ComponentType | Promise<ComponentType>
55

src/useForm.ts src/lib/useForm.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { ActiveVisit, Errors, Method, Page, PendingVisit, Progress, RequestPayload, VisitOptions, router } from '@inertiajs/core'
1+
import type { ActiveVisit, Errors, Method, Page, PendingVisit, Progress, RequestPayload, VisitOptions } from '@inertiajs/core'
2+
import { router } from '@inertiajs/core'
23
import { cloneDeep, isEqual } from 'lodash'
3-
import { Writable, writable } from 'svelte/store'
4+
import { type Writable, writable } from 'svelte/store'
45
import type { AxiosProgressEvent } from 'axios'
56

67
interface InertiaFormProps<TForm extends Record<string, unknown>> {
@@ -51,7 +52,7 @@ export default function useForm<TForm extends Record<string, unknown>>(
5152
: null
5253
let defaults = typeof data === 'function' ? cloneDeep(data()) : cloneDeep(data)
5354
let cancelToken: { cancel: () => void } | null = null
54-
let recentlySuccessfulTimeoutId: number | null = null
55+
let recentlySuccessfulTimeoutId: ReturnType<typeof setTimeout> | null = null
5556
let transform = (data: TForm) => data as object
5657

5758
const store = writable<InertiaFormProps<TForm>>({

svelte.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import adapter from '@sveltejs/adapter-auto';
2+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3+
4+
/** @type {import('@sveltejs/kit').Config} */
5+
const config = {
6+
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
7+
// for more information about preprocessors
8+
preprocess: vitePreprocess(),
9+
10+
kit: {
11+
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12+
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
13+
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
14+
adapter: adapter()
15+
}
16+
};
17+
18+
export default config;

tsconfig.json

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
{
2-
"extends": "@tsconfig/svelte/tsconfig.json",
3-
"include": ["src/index.ts", "src/server.ts"],
2+
"extends": "./.svelte-kit/tsconfig.json",
43
"compilerOptions": {
5-
"noEmitOnError": true,
6-
7-
"lib": ["DOM", "DOM.Iterable", "ES2020"],
8-
"target": "ES2020",
9-
4+
"allowJs": true,
5+
"checkJs": true,
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"resolveJsonModule": true,
9+
"skipLibCheck": true,
10+
"sourceMap": true,
11+
"strict": true,
1012
"declaration": true,
1113
"declarationDir": "dist",
1214

1315
"module": "ES2020",
1416
"moduleResolution": "Node",
15-
"resolveJsonModule": true,
1617
"allowSyntheticDefaultImports": true,
1718

1819
"noImplicitThis": true,
1920
"noUnusedLocals": true,
2021
"noUnusedParameters": true,
2122
"preserveConstEnums": true,
2223
"removeComments": true,
23-
"typeRoots": ["./node_modules/@types"],
24-
// Overwrite the default config from @tsconfig/svelte for consistency
25-
"verbatimModuleSyntax": false
26-
// "strict": true
27-
}
24+
},
2825
}

vite.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { sveltekit } from '@sveltejs/kit/vite';
2+
import { defineConfig } from 'vite';
3+
4+
export default defineConfig({
5+
plugins: [sveltekit()]
6+
});

0 commit comments

Comments
 (0)