josip2312 / jivancic-blog

1 stars 0 forks source link

About "Build a typescript component library with Vite" > typescript-declarations #1

Open Lyokolux opened 2 years ago

Lyokolux commented 2 years ago

Hey 👋

Thanks for your post. It got me started to build a vue 3 version of vue-blurhash 👏 I followed the instruction (https://jivancic.com/posts/build-a-component-library.html#typescript-declarations), and as of 2022-07-09 with the latest version of vue/vite/..., I was not able to generate the d.ts files for the plugin and its components.

Here my dependencies:

"dependencies": {
    "blurhash": "^1.1.5",
    "vue": "^3.2.37"
  },
  "devDependencies": {
    "@rushstack/eslint-patch": "^1.1.0",
    "@types/jsdom": "^16.2.14",
    "@types/node": "^16.11.41",
    "@vitejs/plugin-vue": "^2.3.3",
    "@vue/eslint-config-typescript": "^11.0.0",
    "@vue/test-utils": "^2.0.0",
    "@vue/tsconfig": "^0.1.3",
    "concurrently": "^7.2.2",
    "eslint": "^8.5.0",
    "eslint-plugin-vue": "^9.0.0",
    "histoire": "^0.7.9",
    "jsdom": "^20.0.0",
    "node-mv": "^0.1.3",
    "npm-run-all": "^4.1.5",
    "typescript": "~4.7.4",
    "vite": "^2.9.12",
    "vite-plugin-dts": "^1.2.1",
    "vitest": "^0.15.1",
    "vue-tsc": "^0.38.1"
  }

and some of my scripts:

"scripts": {
    "dev": "vite",
    "build": "run-p type-check build-only",
    "build-only": "vite build",
    "preview": "vite preview --port 4173",
    "test:unit": "vitest --environment jsdom",
    "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
    "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
}

I noted that:

PS: I will update my post as soon the package is published, so you can get a link to check my repo. EDIT: here is the link: https://github.com/Lyokolux/vue3-blurhash/tree/dev (it is on the dev branch for now)

josip2312 commented 2 years ago

You have a problem on this line https://github.com/Lyokolux/vue3-blurhash/blob/e7f9d89c42edb293e06b6188d79caeeca95ce13c/lib/index.ts#L2

The blurhash library does not provide a default export so it fails here