Skip to content

Commit

Permalink
fix: updating and migrating package to svelte-package 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Apr 11, 2023
1 parent 08988d9 commit 539f6a2
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 24 deletions.
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 89 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"scripts": {
"dev": "vite dev --open --host",
"build": "vite build",
"package": "svelte-package",
"package": "svelte-package -o package",
"preview": "vite preview",
"test": "vitest",
"coverage": "vitest run --coverage",
Expand All @@ -38,7 +38,7 @@
"@sveltejs/adapter-auto": "2.0.0",
"@sveltejs/adapter-vercel": "2.4.1",
"@sveltejs/kit": "1.15.2",
"@sveltejs/package": "2.0.2",
"@sveltejs/package": "^2.0.0",
"@tailwindcss/forms": "^0.5.3",
"@testing-library/dom": "^9.2.0",
"@testing-library/svelte": "^3.2.2",
Expand All @@ -51,6 +51,7 @@
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte3": "^4.0.0",
"esm-env": "^1.0.0",
"highlight.js": "^11.7.0",
"husky": "^8.0.3",
"jsdom": "^21.1.1",
Expand Down Expand Up @@ -80,15 +81,99 @@
"tippy.js": "^6.3.7"
},
"peerDependencies": {
"@sveltejs/kit": "1.15.2",
"svelte": "^3.55.1"
},
"exports": {
"./package.json": "./package.json",
".": "./index.js",
"./actions": "./actions/index.js",
"./plugin": "./plugin/index.js",
"./plugin": "./package/plugin/index.js",
"./types": "./types/index.js",
"./utils": "./utils/index.js",
"./icons": "./icons.js",
"./enums": "./enums.js"
"./enums": "./enums.js",
"./plugin/base": {
"types": "./package/plugin/base/index.d.ts",
"svelte": "./package/plugin/base/index.js",
"default": "./package/plugin/base/index.js"
},
"./plugin/colors": {
"types": "./package/plugin/colors/index.d.ts",
"svelte": "./package/plugin/colors/index.js",
"default": "./package/plugin/colors/index.js"
},
"./plugin/components": {
"types": "./package/plugin/components/index.d.ts",
"svelte": "./package/plugin/components/index.js",
"default": "./package/plugin/components/index.js"
},
"./plugin/node_modules/color": {
"types": "./package/plugin/node_modules/color/index.d.ts",
"svelte": "./package/plugin/node_modules/color/index.js",
"default": "./package/plugin/node_modules/color/index.js"
},
"./plugin/node_modules/color-convert": {
"types": "./package/plugin/node_modules/color-convert/index.d.ts",
"svelte": "./package/plugin/node_modules/color-convert/index.js",
"default": "./package/plugin/node_modules/color-convert/index.js"
},
"./plugin/node_modules/color-name": {
"types": "./package/plugin/node_modules/color-name/index.d.ts",
"svelte": "./package/plugin/node_modules/color-name/index.js",
"default": "./package/plugin/node_modules/color-name/index.js"
},
"./plugin/node_modules/color-string": {
"types": "./package/plugin/node_modules/color-string/index.d.ts",
"svelte": "./package/plugin/node_modules/color-string/index.js",
"default": "./package/plugin/node_modules/color-string/index.js"
},
"./plugin/node_modules/is-arrayish": {
"types": "./package/plugin/node_modules/is-arrayish/index.d.ts",
"svelte": "./package/plugin/node_modules/is-arrayish/index.js",
"default": "./package/plugin/node_modules/is-arrayish/index.js"
},
"./plugin/node_modules/simple-swizzle": {
"types": "./package/plugin/node_modules/simple-swizzle/index.d.ts",
"svelte": "./package/plugin/node_modules/simple-swizzle/index.js",
"default": "./package/plugin/node_modules/simple-swizzle/index.js"
}
},
"files": [
"package"
],
"typesVersions": {
">4.0": {
"plugin/base": [
"./package/plugin/base/index.d.ts"
],
"plugin/colors": [
"./package/plugin/colors/index.d.ts"
],
"plugin/components": [
"./package/plugin/components/index.d.ts"
],
"plugin": [
"./package/plugin/index.d.ts"
],
"plugin/node_modules/color": [
"./package/plugin/node_modules/color/index.d.ts"
],
"plugin/node_modules/color-convert": [
"./package/plugin/node_modules/color-convert/index.d.ts"
],
"plugin/node_modules/color-name": [
"./package/plugin/node_modules/color-name/index.d.ts"
],
"plugin/node_modules/color-string": [
"./package/plugin/node_modules/color-string/index.d.ts"
],
"plugin/node_modules/is-arrayish": [
"./package/plugin/node_modules/is-arrayish/index.d.ts"
],
"plugin/node_modules/simple-swizzle": [
"./package/plugin/node_modules/simple-swizzle/index.d.ts"
]
}
}
}
4 changes: 2 additions & 2 deletions src/docs/components/search/Search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
toggle_switch
} from '../../icons';
import { close, info } from '../../../lib/icons';
import { browser } from '$app/environment';
import { BROWSER } from 'esm-env';
import HoverBackground from '$lib/components/HoverBackground.svelte';
let input: HTMLInputElement;
Expand Down Expand Up @@ -103,7 +103,7 @@
}
}
$: if (open && browser && input) {
$: if (open && BROWSER && input) {
input.focus();
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/stores/theme.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { browser } from '$app/environment';
import { BROWSER } from 'esm-env';
import { writable } from 'svelte/store';

const defaultValue = 'light';
const initialValue = browser ? window.localStorage.getItem('theme') ?? defaultValue : defaultValue;
const initialValue = BROWSER ? window.localStorage.getItem('theme') ?? defaultValue : defaultValue;

const theme = writable<string>(initialValue);
theme.subscribe((value) => {
if (browser) {
if (BROWSER) {
window.localStorage.setItem('theme', value === 'dark' ? 'dark' : 'light');
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { theme } from '$lib/stores';
import { page } from '$app/stores';
import { Button, Drawer, Swap, Icon, Layout, Portal, Row, Toggle, Col, Divider } from '../lib';
import { browser } from '$app/environment';
import { DEV, BROWSER } from 'esm-env';
import { Navigation, Search } from '../docs';
import { brightness_4, brightness_5 } from '../docs/icons';
import { menu, close } from '../lib/icons';
Expand All @@ -19,12 +19,12 @@
}
$: darkTheme = $theme === 'dark';
$: if (browser && darkTheme) {
$: if (BROWSER && darkTheme) {
const htmlElement = document.documentElement;
// htmlElement.classList.add('dark');
htmlElement.dataset.theme = 'dark';
theme.set('dark');
} else if (browser) {
} else if (BROWSER) {
const htmlElement = document.documentElement;
// htmlElement.classList.remove('dark');
htmlElement.dataset.theme = 'light';
Expand All @@ -36,7 +36,7 @@
async function scrollToTop(pathname: string) {
const newPath = pathname;
if (path !== newPath) {
if (browser) {
if (BROWSER) {
const scrollEl = document.getElementById('content-body') as HTMLDivElement;
if (scrollEl) {
scrollEl.scrollTop = 0;
Expand Down
10 changes: 1 addition & 9 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ const config = {
kit: {
adapter: vercel()
},
package: {
exports: (filepath) => {
return filepath.endsWith('index.js');
},
files: (filepath) => {
return filepath.indexOf('test') == -1 ? true : false;
}
}
};
};

export default config;

1 comment on commit 539f6a2

@vercel
Copy link

@vercel vercel bot commented on 539f6a2 Apr 11, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

stwui – ./

stwui.vercel.app
stwui-git-main-n00nday.vercel.app
stwui-n00nday.vercel.app

Please sign in to comment.