Skip to content

Commit 65836c7

Browse files
committed
Improve tsconfigs
1 parent e93cdd1 commit 65836c7

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
},
1818
"scripts": {
1919
"dev": "vite",
20-
"build": "vite build && vue-tsc --emitDeclarationOnly && mv dist/lib dist/types",
21-
"build:site": "vue-tsc --noEmit && vite --config vite.site.config.ts build",
20+
"build": "vite build && vue-tsc --emitDeclarationOnly --project tsconfig.dist.json && mv dist/lib dist/types && rm -rf favicon.ico",
21+
"build:site": "vue-tsc --noEmit --project tsconfig.site.json && vite --config vite.site.config.ts build",
2222
"preview": "vite preview"
2323
},
2424
"types": "./dist/types/main.d.ts",

src/components/Sortable.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { ref, PropType, watch, onUnmounted, Prop } from "vue";
33
import Sortable, { SortableOptions } from "sortablejs";
44
5-
let sortable: Sortable | null = null;
65
const props = defineProps({
76
options: {
87
type: Object as PropType<
@@ -53,10 +52,11 @@ const emit = defineEmits<{
5352
}>();
5453
5554
const containerRef = ref<HTMLElement | null>(null);
55+
const sortable = ref<Sortable | null>(null);
5656
5757
watch(containerRef, (newDraggable) => {
5858
if (newDraggable) {
59-
sortable = new Sortable(newDraggable, {
59+
sortable.value = new Sortable(newDraggable, {
6060
...props.options,
6161
onChoose: (event) => emit("choose", event),
6262
onUnchoose: (event) => emit("unchoose", event),
@@ -75,9 +75,10 @@ watch(containerRef, (newDraggable) => {
7575
});
7676
7777
onUnmounted(() => {
78-
if (sortable) {
79-
sortable.destroy();
78+
if (sortable.value) {
79+
sortable.value.destroy();
8080
containerRef.value = null;
81+
sortable.value = null;
8182
}
8283
});
8384
</script>

tsconfig.dist.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"useDefineForClassFields": true,
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"strict": true,
8+
"jsx": "preserve",
9+
"sourceMap": true,
10+
"resolveJsonModule": true,
11+
"isolatedModules": true,
12+
"esModuleInterop": true,
13+
"lib": ["esnext", "dom"],
14+
"skipLibCheck": true,
15+
"baseUrl": "./",
16+
"rootDir": "./",
17+
"declaration": true,
18+
"outDir": "dist",
19+
"allowSyntheticDefaultImports": true
20+
},
21+
"files": ["lib/main.ts", "src/components/Sortable.vue"],
22+
"references": [{ "path": "./tsconfig.node.json" }]
23+
}

tsconfig.json renamed to tsconfig.site.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"rootDir": "./",
1717
"declaration": true,
1818
"outDir": "dist",
19-
"allowSyntheticDefaultImports": true,
19+
"allowSyntheticDefaultImports": true
2020
},
2121
"include": ["src/**/*.ts", "src/**/*.vue", "lib/**/*.ts"],
2222
"references": [{ "path": "./tsconfig.node.json" }]

0 commit comments

Comments
 (0)