@component-hook/pdf-canvas 1.2.2-alpha.4 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,24 +62,19 @@ async function uploadFile(event: Event) {
|
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
64
|
<template>
|
|
65
|
-
<div
|
|
65
|
+
<div>
|
|
66
66
|
<pdf-canvas
|
|
67
67
|
v-if="currentPdf"
|
|
68
68
|
:file="currentPdf"
|
|
69
69
|
/>
|
|
70
70
|
|
|
71
|
-
<p
|
|
72
|
-
v-else
|
|
73
|
-
class="font-mono text-sm"
|
|
74
|
-
>
|
|
75
|
-
Please select a PDF file or image.
|
|
76
|
-
</p>
|
|
71
|
+
<p v-else>Please select a PDF file or image.</p>
|
|
77
72
|
|
|
78
73
|
<button class="relative">
|
|
79
74
|
<input
|
|
80
75
|
type="file"
|
|
81
76
|
accept="application/pdf, .jpg, .png"
|
|
82
|
-
class="
|
|
77
|
+
class="absolute top-0 left-0 h-[36px] w-[94px] cursor-pointer opacity-0"
|
|
83
78
|
@change="uploadFile"
|
|
84
79
|
/>
|
|
85
80
|
select file
|
|
@@ -127,6 +122,33 @@ export function DrawPdf() {
|
|
|
127
122
|
}
|
|
128
123
|
```
|
|
129
124
|
|
|
125
|
+
## ⚠️ Required Vite Configuration
|
|
126
|
+
|
|
127
|
+
If you're using Vite in development mode, you must exclude this package from Vite's dependency optimization, because it internally uses a Web Worker which doesn't work well when Vite pre-bundles dependencies.
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
// vite.config.js or vite.config.ts
|
|
131
|
+
import { defineConfig } from 'vite';
|
|
132
|
+
|
|
133
|
+
export default defineConfig({
|
|
134
|
+
// …other Vite config
|
|
135
|
+
optimizeDeps: {
|
|
136
|
+
exclude: ['@component-hook/pdf-canvas'],
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Why Is This Necessary?
|
|
142
|
+
|
|
143
|
+
- Vite's dev server does pre-bundling of dependencies (using esbuild) to improve performance.
|
|
144
|
+
- However, modules using Web Workers (like this component) may break or fail to initialize correctly during this pre-bundling stage.
|
|
145
|
+
|
|
146
|
+
### Web Worker & Vite Known Issue
|
|
147
|
+
|
|
148
|
+
- This is a known issue: the Vite team is aware of difficulties when optimizing dependencies that use Web Workers.
|
|
149
|
+
- For more background, see this GitHub issue: [Vite/Rolldown-Vite #362](https://github.com/vitejs/rolldown-vite/issues/362)
|
|
150
|
+
- Once Vite improves its Web Worker optimization, it may become safe to remove this exclusion — but for now, it's required to ensure correct behavior in dev mode.
|
|
151
|
+
|
|
130
152
|
## License
|
|
131
153
|
|
|
132
154
|
This project is licensed under the MIT License.
|