Skip to content

Commit

Permalink
fix: remove manual types. add rollup plugin. update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
guastallaigor committed Jun 5, 2021
1 parent df2dbd2 commit a8e6f21
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 260 deletions.
12 changes: 0 additions & 12 deletions docs/pages/en/1.getting-started/1.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ You can now start using [`<vue-testimonials>`](/component/vue-testimonials) in y
Remember that Vue Testimonials only supports Vue 3 (and Vite) projects!
:::

## TypeScript

If you're using TypeScript, you may want to add additional types in your "types" array at `tsconfig.json`.

```json [tsconfig.json]
{
"compilerOptions": {
"types": ["vue-testimonials", "vite/client"]
}
}
```

## Upgrading

:::alert{type="warning"}
Expand Down
120 changes: 0 additions & 120 deletions lib/index.d.ts

This file was deleted.

18 changes: 9 additions & 9 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import VueTestimonials from './component/VueTestimonials.vue'

let installed = false

function installFunction(Vue: App): void {
function install(Vue: App): void {
if (installed) return
installed = true
Vue.component(VueTestimonials.name, VueTestimonials)
}

let GlobalVue = null
let GlobalVue: any

const plugin = { install: installFunction }
const plugin = { install }

if (typeof window !== 'undefined') {
GlobalVue = (window as any).Vue
} else if (typeof global !== 'undefined') {
GlobalVue = (global as any).Vue
if (window && 'Vue' in window) {
GlobalVue = window['Vue']
} else if (global && 'Vue' in global) {
GlobalVue = global['Vue']
}

if (GlobalVue) {
if (GlobalVue && typeof GlobalVue.use === 'function') {
GlobalVue.use(plugin)
}

export default { install: installFunction }
export default { install }
114 changes: 0 additions & 114 deletions lib/local-types/index.d.ts

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-testimonials",
"version": "0.1.7",
"version": "0.1.8",
"description": "Vue Testimonials is a Vue 3 testimonials component made with Vite and TypeScript",
"homepage": "https://github.com/guastallaigor/vue-testimonials#readme",
"author": {
Expand Down Expand Up @@ -37,7 +37,7 @@
],
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && cpx 'lib/index.d.ts' 'dist'",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"lint:eslint": "eslint lib/**/*.{ts,vue}",
"lint:prettier": "prettier -w -u lib/**/*.{ts,vue}",
Expand Down Expand Up @@ -67,6 +67,7 @@
"eslint-plugin-vue": "^7.10.0",
"husky": "^6.0.0",
"prettier": "^2.3.0",
"rollup-plugin-typescript2": "^0.30.0",
"typescript": "^4.1.3",
"vite": "^2.3.5",
"vite-svg-loader": "^2.0.2",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"sourceMap": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"noImplicitAny": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { UserConfig } from 'vite'
import svgLoader from 'vite-svg-loader'
import vue from '@vitejs/plugin-vue'
import typescript from 'rollup-plugin-typescript2'
const path = require('path')

const config: UserConfig = {
Expand All @@ -12,7 +13,7 @@ const config: UserConfig = {
},
],
},
plugins: [vue(), svgLoader()],
plugins: [vue(), svgLoader(), typescript()],
build: {
lib: {
entry: path.resolve(__dirname, 'lib/index.ts'),
Expand Down
Loading

0 comments on commit a8e6f21

Please sign in to comment.