Skip to content

Commit b2346fa

Browse files
authored
@uppy/svelte: remove UMD output and make it use newer types (#5023)
1 parent 34dbaf5 commit b2346fa

14 files changed

+275
-57
lines changed

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"build:svelte": "yarn workspace @uppy/svelte build",
121121
"build:angular": "yarn workspace angular build",
122122
"build:js": "npm-run-all build:lib build:companion build:locale-pack build:svelte build:bundle",
123-
"build:ts": "yarn workspaces list --no-private --json | yarn node ./bin/build-ts.mjs",
123+
"build:ts": "yarn workspaces list --no-private --json | yarn node ./bin/build-ts.mjs && yarn workspace @uppy/svelte validate",
124124
"build:lib": "yarn node ./bin/build-lib.js",
125125
"build:locale-pack": "yarn workspace @uppy-dev/locale-pack build && eslint packages/@uppy/locales/src/en_US.js --fix && yarn workspace @uppy-dev/locale-pack test unused",
126126
"build": "npm-run-all --parallel build:ts build:js build:css --serial size",
@@ -153,7 +153,7 @@
153153
"test:locale-packs:warnings": "yarn workspace @uppy-dev/locale-pack test warnings",
154154
"test:unit": "yarn run build:lib && yarn test:watch --run",
155155
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
156-
"test": "npm-run-all lint test:locale-packs:unused test:unit test:type test:companion",
156+
"test": "npm-run-all lint test:locale-packs:unused test:unit test:companion",
157157
"uploadcdn": "yarn node ./bin/upload-to-cdn.js",
158158
"version": "yarn node ./bin/after-version-bump.js",
159159
"watch:css": "onchange 'packages/{@uppy/,}*/src/*.scss' --initial --verbose -- yarn run build:css",

Diff for: packages/@uppy/svelte/.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# This file need to be there so .gitignored files are still uploaded to the npm registry.
1+
tsconfig.*

Diff for: packages/@uppy/svelte/package.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
{
22
"name": "@uppy/svelte",
33
"description": "Uppy plugin that helps integrate Uppy into your Svelte project.",
4-
"svelte": "src/index.js",
5-
"module": "dist/index.mjs",
6-
"main": "dist/index.js",
4+
"type": "module",
75
"version": "3.1.3",
86
"scripts": {
97
"build": "rollup -c",
108
"prepublishOnly": "yarn run build",
119
"validate": "svelte-check"
1210
},
11+
"exports": {
12+
".": {
13+
"svelte": "./src/index.js",
14+
"default": "./lib/index.js"
15+
},
16+
"./package.json": "./package.json"
17+
},
1318
"homepage": "https://uppy.io",
1419
"bugs": {
1520
"url": "https://github.com/transloadit/uppy/issues"
@@ -18,11 +23,15 @@
1823
"type": "git",
1924
"url": "git+https://github.com/transloadit/uppy.git"
2025
},
26+
"dependencies": {
27+
"@uppy/utils": "workspace:^"
28+
},
2129
"devDependencies": {
2230
"@rollup/plugin-node-resolve": "^13.0.0",
2331
"@tsconfig/svelte": "^5.0.0",
24-
"rollup": "^2.60.2",
32+
"rollup": "^4.0.0",
2533
"rollup-plugin-svelte": "^7.0.0",
34+
"rollup-plugin-svelte-types": "^1.0.6",
2635
"svelte": "^4.0.0",
2736
"svelte-check": "^3.0.0",
2837
"svelte-preprocess": "^5.0.0"
@@ -33,7 +42,7 @@
3342
"@uppy/drag-drop": "workspace:^",
3443
"@uppy/progress-bar": "workspace:^",
3544
"@uppy/status-bar": "workspace:^",
36-
"svelte": "^3.0.0 || ^4.0.0"
45+
"svelte": "^4.0.0"
3746
},
3847
"publishConfig": {
3948
"access": "public"
@@ -46,6 +55,7 @@
4655
],
4756
"files": [
4857
"src",
49-
"dist"
58+
"lib",
59+
"typings"
5060
]
5161
}

Diff for: packages/@uppy/svelte/rollup.config.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import svelte from 'rollup-plugin-svelte'
22
import resolve from '@rollup/plugin-node-resolve'
33
import preprocess from 'svelte-preprocess'
4-
import pkg from './package.json'
5-
6-
const name = pkg.name
7-
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
8-
.replace(/^\w/, m => m.toUpperCase())
9-
.replace(/-\w/g, m => m[1].toUpperCase())
4+
import svelteDts from 'rollup-plugin-svelte-types';
105

116
const globals = {
127
'@uppy/dashboard': 'Dashboard',
@@ -16,19 +11,13 @@ const globals = {
1611
}
1712

1813
export default {
19-
input: 'src/index.js',
14+
input: 'src/index.ts',
2015
output: [
2116
{
22-
file: pkg.module,
17+
file: 'lib/index.js',
2318
format: 'es',
2419
globals,
2520
},
26-
{
27-
file: pkg.main,
28-
format: 'umd',
29-
name,
30-
globals,
31-
},
3221
],
3322
plugins: [
3423
svelte({
@@ -38,5 +27,8 @@ export default {
3827
resolve({
3928
resolveOnly: ['svelte'],
4029
}),
30+
svelteDts.default({
31+
declarationDir: './lib/'
32+
})
4133
],
4234
}

Diff for: packages/@uppy/svelte/src/components/Dashboard.svelte

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
22
import { onMount, onDestroy } from 'svelte'
33
import type { Uppy } from '@uppy/core';
44
import DashboardPlugin from '@uppy/dashboard'
55
66
let container: HTMLElement;
7-
let plugin: DashboardPlugin;
7+
let plugin: DashboardPlugin<M, B>;
88
9-
export let uppy: Uppy;
9+
export let uppy: Uppy<M, B>;
1010
export let props: Object | undefined = {};
1111
export let plugins: string[] = [];
1212
@@ -20,9 +20,9 @@
2020
}
2121
2222
uppy.use(DashboardPlugin, options);
23-
plugin = uppy.getPlugin(options.id) as DashboardPlugin;
23+
plugin = uppy.getPlugin(options.id) as DashboardPlugin<M, B>;
2424
}
25-
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
25+
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
2626
uppyInstance.removePlugin(plugin);
2727
}
2828

Diff for: packages/@uppy/svelte/src/components/DashboardModal.svelte

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
22
import { onMount, onDestroy } from 'svelte'
33
import type { Uppy } from '@uppy/core';
44
import DashboardPlugin from '@uppy/dashboard'
55
66
let container: HTMLElement;
7-
let plugin: DashboardPlugin;
7+
let plugin: DashboardPlugin<M, B>;
88
9-
export let uppy: Uppy;
9+
export let uppy: Uppy<M, B>;
1010
export let props: Object | undefined = {};
1111
export let open: boolean;
1212
let lastOpen: boolean = open;
@@ -22,10 +22,10 @@
2222
}
2323
2424
uppy.use(DashboardPlugin, options);
25-
plugin = uppy.getPlugin(options.id) as DashboardPlugin;
25+
plugin = uppy.getPlugin(options.id) as DashboardPlugin<M, B>;
2626
if(open) plugin.openModal();
2727
}
28-
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
28+
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
2929
uppyInstance.removePlugin(plugin);
3030
}
3131

Diff for: packages/@uppy/svelte/src/components/DragDrop.svelte

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
22
import { onMount, onDestroy } from 'svelte'
33
import type { Uppy } from '@uppy/core';
44
import DragDropPlugin from '@uppy/drag-drop'
55
66
let container: HTMLElement;
7-
let plugin: DragDropPlugin;
7+
let plugin: DragDropPlugin<M, B>;
88
9-
export let uppy: Uppy;
9+
export let uppy: Uppy<M, B>;
1010
export let props: Object | undefined = {};
1111
1212
const installPlugin = () => {
@@ -18,9 +18,9 @@
1818
}
1919
2020
uppy.use(DragDropPlugin, options);
21-
plugin = uppy.getPlugin(options.id) as DragDropPlugin;
21+
plugin = uppy.getPlugin(options.id) as DragDropPlugin<M, B>;
2222
}
23-
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
23+
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
2424
uppyInstance.removePlugin(plugin);
2525
}
2626

Diff for: packages/@uppy/svelte/src/components/ProgressBar.svelte

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
22
import { onMount, onDestroy } from 'svelte'
33
import type { Uppy } from '@uppy/core';
44
import ProgressBarPlugin from '@uppy/progress-bar'
5-
5+
66
let container: HTMLElement;
7-
let plugin: ProgressBarPlugin;
7+
let plugin: ProgressBarPlugin<M, B>;
88
9-
export let uppy: Uppy;
9+
export let uppy: Uppy<M, B>;
1010
export let props: Object | undefined = {};
1111
1212
const installPlugin = () => {
@@ -18,9 +18,9 @@
1818
}
1919
2020
uppy.use(ProgressBarPlugin, options);
21-
plugin = uppy.getPlugin(options.id) as ProgressBarPlugin;
21+
plugin = uppy.getPlugin(options.id) as ProgressBarPlugin<M, B>;
2222
}
23-
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
23+
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
2424
uppyInstance.removePlugin(plugin);
2525
}
2626

Diff for: packages/@uppy/svelte/src/components/StatusBar.svelte

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
22
import { onMount, onDestroy } from 'svelte'
33
import type { Uppy } from '@uppy/core';
44
import StatusBarPlugin from '@uppy/status-bar'
5-
5+
66
let container: HTMLElement;
7-
let plugin: StatusBarPlugin;
7+
let plugin: StatusBarPlugin<M, B>;
88
9-
export let uppy: Uppy;
9+
export let uppy: Uppy<M, B>;
1010
export let props: Object | undefined = {};
1111
1212
const installPlugin = () => {
@@ -18,9 +18,9 @@
1818
}
1919
2020
uppy.use(StatusBarPlugin, options);
21-
plugin = uppy.getPlugin(options.id) as StatusBarPlugin;
21+
plugin = uppy.getPlugin(options.id) as StatusBarPlugin<M, B>;
2222
}
23-
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
23+
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
2424
uppyInstance.removePlugin(plugin);
2525
}
2626

Diff for: packages/@uppy/svelte/src/empty.ts

-1
This file was deleted.
File renamed without changes.

Diff for: packages/@uppy/svelte/tsconfig.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
2-
"extends": "@tsconfig/svelte/tsconfig.json",
2+
"extends": [
3+
"../../../tsconfig.shared.json",
4+
"@tsconfig/svelte/tsconfig.json",
5+
],
36
"compilerOptions": {
4-
"esModuleInterop": true,
5-
"sourceMap": true,
7+
"noEmit": true,
8+
"emitDeclarationOnly": false,
9+
"rootDir": "./src",
10+
"outDir": "./lib",
611
},
7-
"include": ["src/**/*"],
12+
"include": ["./src/**/*.*", "./typings/index.d.ts"],
813
"exclude": ["node_modules/*"],
914
}

Diff for: packages/@uppy/svelte/typings/index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.svelte' {
2+
import { SvelteComponent } from 'svelte'
3+
4+
export default class extends SvelteComponent<any> {}
5+
}

0 commit comments

Comments
 (0)