Skip to content

Commit

Permalink
refactor(pdf)!: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Feb 4, 2023
1 parent 7e2b63a commit f3720a6
Show file tree
Hide file tree
Showing 9 changed files with 2,289 additions and 2,392 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ in `main.(js|ts)`

```js
import { createApp } from 'vue';
import pdfMake from 'vue3-pdfmake';
import { PDFPlugin } from 'vue3-pdfmake';
import App from './App.vue';

const app = createApp(App);
//...
app.use(pdfMake);
app.use(PDFPlugin);
//...
app.mount('#app');
```
Expand All @@ -40,6 +40,4 @@ app.mount('#app');
pdf.createPdf({}).download();
});
</script>
```

> WARNING: Depending on how the instance was initialized, use `const pdf = usePDF().default` instead `const pdf = usePDF()`
```
34 changes: 12 additions & 22 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
export default {
entries: [
{
input: 'src/index.ts',
outDir: 'dist',
name: 'index',
format: 'esm',
ext: 'mjs',
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'./src/index',
],
rollup: {
emitCJS: true,
},
{
input: 'src/index.ts',
outDir: 'dist',
name: 'index',
format: 'cjs',
ext: 'cjs',
},
],
rollup: {
emitCJS: true,
},
declaration: true,
externals: ['pdfmake'],
}
clean: true,
declaration: true,
externals: ['pdfmake'],
})
7 changes: 1 addition & 6 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<script setup>
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue'
import { usePDF } from 'vue3-pdfmake';
const pdfmake = usePDF()
Expand All @@ -11,8 +7,7 @@ pdfmake.createPdf({}).download();
</script>

<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + Vite" />
<p>PDFMake!</p>
</template>

<style>
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import PDF from 'vue3-pdfmake'
import { PDFPlugin } from 'vue3-pdfmake'

createApp(App).use(PDF).mount('#app')
createApp(App).use(PDFPlugin).mount('#app')
33 changes: 20 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
"license": "MIT",
"version": "1.2.1",
"description": "A pdfmake plugin for Vue 3",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/betterwrite/vue-pdfmake"
Expand All @@ -17,7 +23,8 @@
"minor": "generi log minor",
"major": "generi log major",
"dev": "yarn build && vite",
"demo": "yarn build && vite --port 5000 preview"
"demo": "yarn build && vite --port 5000 preview",
"prepublish": "yarn build"
},
"keywords": [
"vue",
Expand All @@ -37,20 +44,20 @@
}
},
"devDependencies": {
"@types/jsdom": "^16.2.6",
"@types/node": "^14.14.22",
"@vitejs/plugin-vue": "^2.3.2",
"generi": "0.3.0",
"typescript": "^4.1.3",
"unbuild": "0.7.4",
"vite": "2.9.8",
"vue": "^3.0.0"
"@types/jsdom": "^16.2.15",
"@types/node": "^14.18.36",
"@vitejs/plugin-vue": "^2.3.4",
"generi": "0.5.2",
"typescript": "^4.9.5",
"unbuild": "1.1.1",
"vite": "4.1.1",
"vue": "^3.2.47"
},
"files": [
"dist",
"package.json"
],
"engines": {
"node": ">= 12"
"node": ">= 14"
}
}
Loading

0 comments on commit f3720a6

Please # to comment.