From 9c68b406e05db4be2066fb97865ad6271efbd015 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Mon, 24 Feb 2025 10:16:25 +1100 Subject: [PATCH] chore: add playground setup with Vue 3 and TypeScript; update dependencies --- package-lock.json | 19 +++++++++++++ package.json | 2 ++ playground/App.vue | 22 ++++++++++++++++ {src => playground}/assets/vue.svg | 0 index.html => playground/index.html | 3 +-- {src => playground}/main.ts | 0 {src => playground}/style.css | 0 {src => playground}/vite-env.d.ts | 0 src/App.vue | 30 --------------------- src/components/HelloWorld.vue | 41 ----------------------------- src/components/SingleDatePicker.vue | 7 +++++ src/index.ts | 3 +++ src/shims-vue.d.ts | 6 +++++ tsconfig.app.json | 25 +++++++++++------- tsconfig.node.json | 2 +- vite.config.ts | 24 +++++++++++++++-- 16 files changed, 98 insertions(+), 86 deletions(-) create mode 100644 playground/App.vue rename {src => playground}/assets/vue.svg (100%) rename index.html => playground/index.html (67%) rename {src => playground}/main.ts (100%) rename {src => playground}/style.css (100%) rename {src => playground}/vite-env.d.ts (100%) delete mode 100644 src/App.vue delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/SingleDatePicker.vue create mode 100644 src/index.ts create mode 100644 src/shims-vue.d.ts diff --git a/package-lock.json b/package-lock.json index e06d59e..86f3363 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,9 @@ "vue": "^3.5.13" }, "devDependencies": { + "@types/node": "^22.13.5", "@vitejs/plugin-vue": "^5.2.1", + "@vue/compiler-sfc": "^3.5.13", "@vue/tsconfig": "^0.7.0", "typescript": "~5.7.2", "vite": "^6.1.0", @@ -768,6 +770,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/node": { + "version": "22.13.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.5.tgz", + "integrity": "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } + }, "node_modules/@vitejs/plugin-vue": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.1.tgz", @@ -1240,6 +1252,13 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, "node_modules/vite": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/vite/-/vite-6.1.1.tgz", diff --git a/package.json b/package.json index abe4949..7b52fc1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "vue": "^3.5.13" }, "devDependencies": { + "@types/node": "^22.13.5", "@vitejs/plugin-vue": "^5.2.1", + "@vue/compiler-sfc": "^3.5.13", "@vue/tsconfig": "^0.7.0", "typescript": "~5.7.2", "vite": "^6.1.0", diff --git a/playground/App.vue b/playground/App.vue new file mode 100644 index 0000000..803573f --- /dev/null +++ b/playground/App.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/src/assets/vue.svg b/playground/assets/vue.svg similarity index 100% rename from src/assets/vue.svg rename to playground/assets/vue.svg diff --git a/index.html b/playground/index.html similarity index 67% rename from index.html rename to playground/index.html index dde16aa..3f99fb8 100644 --- a/index.html +++ b/playground/index.html @@ -2,12 +2,11 @@ - Vite + Vue + TS
- + diff --git a/src/main.ts b/playground/main.ts similarity index 100% rename from src/main.ts rename to playground/main.ts diff --git a/src/style.css b/playground/style.css similarity index 100% rename from src/style.css rename to playground/style.css diff --git a/src/vite-env.d.ts b/playground/vite-env.d.ts similarity index 100% rename from src/vite-env.d.ts rename to playground/vite-env.d.ts diff --git a/src/App.vue b/src/App.vue deleted file mode 100644 index 58b0f21..0000000 --- a/src/App.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index b58e52b..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - diff --git a/src/components/SingleDatePicker.vue b/src/components/SingleDatePicker.vue new file mode 100644 index 0000000..d48a713 --- /dev/null +++ b/src/components/SingleDatePicker.vue @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..fc54e6d --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +/// + +export { default as SingleDatePicker } from './components/SingleDatePicker.vue' \ No newline at end of file diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts new file mode 100644 index 0000000..b352c2a --- /dev/null +++ b/src/shims-vue.d.ts @@ -0,0 +1,6 @@ + +declare module '*.vue' { + import { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} \ No newline at end of file diff --git a/tsconfig.app.json b/tsconfig.app.json index 7fb078c..dd9acdd 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -1,14 +1,19 @@ { - "extends": "@vue/tsconfig/tsconfig.dom.json", "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - - /* Linting */ + "outDir": "dist_types", + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "isolatedModules": true, "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] -} + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "playground/**/*.ts", "playground/**/*.d.ts", "playground/**/*.tsx", "playground/**/*.vue"] +} \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json index db0becc..719b151 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -20,5 +20,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["vite.config.ts"] + "include": ["playground/**/*.ts", "playground/**/*.tsx", "playground/**/*.vue", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] } diff --git a/vite.config.ts b/vite.config.ts index bbcf80c..2f72f1e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,27 @@ import { defineConfig } from 'vite' +import { fileURLToPath, URL } from 'node:url' import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ -export default defineConfig({ +export default defineConfig(({ mode }) => ({ plugins: [vue()], -}) + build: { + lib: { + entry: fileURLToPath(new URL('src/index.ts', import.meta.url)), + name: 'Datenel for Vue3', + }, + rollupOptions: { + external: ['vue'], + output: { + globals: { + vue: 'Vue', + }, + }, + }, + }, + server: { + open: true, + port: 1926 + }, + root: mode === 'development' ? 'playground' : '.' +}))