Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/svelte: remove UMD output and make it use newer types #5023

Merged
merged 11 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"build:svelte": "yarn workspace @uppy/svelte build",
"build:angular": "yarn workspace angular build",
"build:js": "npm-run-all build:lib build:companion build:locale-pack build:svelte build:bundle",
"build:ts": "yarn workspaces list --no-private --json | yarn node ./bin/build-ts.mjs",
"build:ts": "yarn workspaces list --no-private --json | yarn node ./bin/build-ts.mjs && yarn workspace @uppy/svelte validate",
"build:lib": "yarn node ./bin/build-lib.js",
"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",
"build": "npm-run-all --parallel build:ts build:js build:css --serial size",
Expand Down Expand Up @@ -153,7 +153,7 @@
"test:locale-packs:warnings": "yarn workspace @uppy-dev/locale-pack test warnings",
"test:unit": "yarn run build:lib && yarn test:watch --run",
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
"test": "npm-run-all lint test:locale-packs:unused test:unit test:type test:companion",
"test": "npm-run-all lint test:locale-packs:unused test:unit test:companion",
"uploadcdn": "yarn node ./bin/upload-to-cdn.js",
"version": "yarn node ./bin/after-version-bump.js",
"watch:css": "onchange 'packages/{@uppy/,}*/src/*.scss' --initial --verbose -- yarn run build:css",
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/svelte/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# This file need to be there so .gitignored files are still uploaded to the npm registry.
tsconfig.*
22 changes: 16 additions & 6 deletions packages/@uppy/svelte/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{
"name": "@uppy/svelte",
"description": "Uppy plugin that helps integrate Uppy into your Svelte project.",
"svelte": "src/index.js",
"module": "dist/index.mjs",
"main": "dist/index.js",
"type": "module",
"version": "3.1.3",
"scripts": {
"build": "rollup -c",
"prepublishOnly": "yarn run build",
"validate": "svelte-check"
},
"exports": {
".": {
"svelte": "./src/index.js",
"default": "./lib/index.js"
},
"./package.json": "./package.json"
},
"homepage": "https://uppy.io",
"bugs": {
"url": "https://github.com/transloadit/uppy/issues"
Expand All @@ -18,11 +23,15 @@
"type": "git",
"url": "git+https://github.com/transloadit/uppy.git"
},
"dependencies": {
"@uppy/utils": "workspace:^"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.0.0",
"@tsconfig/svelte": "^5.0.0",
"rollup": "^2.60.2",
"rollup": "^4.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-svelte-types": "^1.0.6",
"svelte": "^4.0.0",
"svelte-check": "^3.0.0",
"svelte-preprocess": "^5.0.0"
Expand All @@ -33,7 +42,7 @@
"@uppy/drag-drop": "workspace:^",
"@uppy/progress-bar": "workspace:^",
"@uppy/status-bar": "workspace:^",
"svelte": "^3.0.0 || ^4.0.0"
"svelte": "^4.0.0"
},
"publishConfig": {
"access": "public"
Expand All @@ -46,6 +55,7 @@
],
"files": [
"src",
"dist"
"lib",
"typings"
]
}
20 changes: 6 additions & 14 deletions packages/@uppy/svelte/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import svelte from 'rollup-plugin-svelte'
import resolve from '@rollup/plugin-node-resolve'
import preprocess from 'svelte-preprocess'
import pkg from './package.json'

const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, m => m.toUpperCase())
.replace(/-\w/g, m => m[1].toUpperCase())
Comment on lines -6 to -9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad this hack isn't needed anymore

import svelteDts from 'rollup-plugin-svelte-types';

const globals = {
'@uppy/dashboard': 'Dashboard',
Expand All @@ -16,19 +11,13 @@ const globals = {
}

export default {
input: 'src/index.js',
input: 'src/index.ts',
output: [
{
file: pkg.module,
file: 'lib/index.js',
format: 'es',
globals,
},
{
file: pkg.main,
format: 'umd',
name,
globals,
},
],
plugins: [
svelte({
Expand All @@ -38,5 +27,8 @@ export default {
resolve({
resolveOnly: ['svelte'],
}),
svelteDts.default({
declarationDir: './lib/'
})
],
}
10 changes: 5 additions & 5 deletions packages/@uppy/svelte/src/components/Dashboard.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
import { onMount, onDestroy } from 'svelte'
import type { Uppy } from '@uppy/core';
import DashboardPlugin from '@uppy/dashboard'

let container: HTMLElement;
let plugin: DashboardPlugin;
let plugin: DashboardPlugin<M, B>;

export let uppy: Uppy;
export let uppy: Uppy<M, B>;
export let props: Object | undefined = {};
export let plugins: string[] = [];

Expand All @@ -20,9 +20,9 @@
}

uppy.use(DashboardPlugin, options);
plugin = uppy.getPlugin(options.id) as DashboardPlugin;
plugin = uppy.getPlugin(options.id) as DashboardPlugin<M, B>;
}
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
uppyInstance.removePlugin(plugin);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/svelte/src/components/DashboardModal.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
import { onMount, onDestroy } from 'svelte'
import type { Uppy } from '@uppy/core';
import DashboardPlugin from '@uppy/dashboard'

let container: HTMLElement;
let plugin: DashboardPlugin;
let plugin: DashboardPlugin<M, B>;

export let uppy: Uppy;
export let uppy: Uppy<M, B>;
export let props: Object | undefined = {};
export let open: boolean;
let lastOpen: boolean = open;
Expand All @@ -22,10 +22,10 @@
}

uppy.use(DashboardPlugin, options);
plugin = uppy.getPlugin(options.id) as DashboardPlugin;
plugin = uppy.getPlugin(options.id) as DashboardPlugin<M, B>;
if(open) plugin.openModal();
}
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
uppyInstance.removePlugin(plugin);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/svelte/src/components/DragDrop.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
import { onMount, onDestroy } from 'svelte'
import type { Uppy } from '@uppy/core';
import DragDropPlugin from '@uppy/drag-drop'

let container: HTMLElement;
let plugin: DragDropPlugin;
let plugin: DragDropPlugin<M, B>;

export let uppy: Uppy;
export let uppy: Uppy<M, B>;
export let props: Object | undefined = {};

const installPlugin = () => {
Expand All @@ -18,9 +18,9 @@
}

uppy.use(DragDropPlugin, options);
plugin = uppy.getPlugin(options.id) as DragDropPlugin;
plugin = uppy.getPlugin(options.id) as DragDropPlugin<M, B>;
}
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
uppyInstance.removePlugin(plugin);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/svelte/src/components/ProgressBar.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
import { onMount, onDestroy } from 'svelte'
import type { Uppy } from '@uppy/core';
import ProgressBarPlugin from '@uppy/progress-bar'

let container: HTMLElement;
let plugin: ProgressBarPlugin;
let plugin: ProgressBarPlugin<M, B>;

export let uppy: Uppy;
export let uppy: Uppy<M, B>;
export let props: Object | undefined = {};

const installPlugin = () => {
Expand All @@ -18,9 +18,9 @@
}

uppy.use(ProgressBarPlugin, options);
plugin = uppy.getPlugin(options.id) as ProgressBarPlugin;
plugin = uppy.getPlugin(options.id) as ProgressBarPlugin<M, B>;
}
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
uppyInstance.removePlugin(plugin);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/svelte/src/components/StatusBar.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
<script lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body">
import { onMount, onDestroy } from 'svelte'
import type { Uppy } from '@uppy/core';
import StatusBarPlugin from '@uppy/status-bar'

let container: HTMLElement;
let plugin: StatusBarPlugin;
let plugin: StatusBarPlugin<M, B>;

export let uppy: Uppy;
export let uppy: Uppy<M, B>;
export let props: Object | undefined = {};

const installPlugin = () => {
Expand All @@ -18,9 +18,9 @@
}

uppy.use(StatusBarPlugin, options);
plugin = uppy.getPlugin(options.id) as StatusBarPlugin;
plugin = uppy.getPlugin(options.id) as StatusBarPlugin<M, B>;
}
const uninstallPlugin = (uppyInstance: Uppy = uppy) => {
const uninstallPlugin = (uppyInstance: Uppy<M, B> = uppy) => {
uppyInstance.removePlugin(plugin);
}

Expand Down
1 change: 0 additions & 1 deletion packages/@uppy/svelte/src/empty.ts

This file was deleted.

File renamed without changes.
13 changes: 9 additions & 4 deletions packages/@uppy/svelte/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"extends": [
"../../../tsconfig.shared.json",
"@tsconfig/svelte/tsconfig.json",
],
"compilerOptions": {
"esModuleInterop": true,
"sourceMap": true,
"noEmit": true,
"emitDeclarationOnly": false,
"rootDir": "./src",
"outDir": "./lib",
},
"include": ["src/**/*"],
"include": ["./src/**/*.*", "./typings/index.d.ts"],
"exclude": ["node_modules/*"],
}
5 changes: 5 additions & 0 deletions packages/@uppy/svelte/typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.svelte' {
import { SvelteComponent } from 'svelte'

export default class extends SvelteComponent<any> {}
}
Loading
Loading