Closed gouteru closed 6 months ago
That error comes from an update of pdfjs-dist that started to use await operator in top-level that is a "new" feature of ECMAScript. If you are aware about browser compatibility you could check it here (practically all browsers support it): https://caniuse.com/?search=top%20level%20await
The solution is set this config in your vite.config.ts
:
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
supported: {
'top-level-await': true,
},
},
},
plugins: [vue()],
})
Thanks for prompt response, the error solved with adding the setting to vite.config.
thanks a lot!
When I build my app with vue-pdf , I got the build error below. How can I solve the error?
package.json { "name": "vue3app2onsenui", "version": "0.0.0", "private": true, "type": "module", "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview", "test:unit": "vitest", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore", "format": "prettier --write src/" }, "dependencies": { "@tato30/vue-pdf": "^1.10.0", "@vuepic/vue-datepicker": "^7.4.1", "@vueup/vue-quill": "^1.2.0", "firebase": "^9.23.0", "jssha": "^3.3.1", "onsenui": "^2.12.8", "pinia": "^2.1.7", "vue": "^3.3.11", "vue-onsenui": "^3.0.0", "vue-router": "^4.2.5" }, "devDependencies": { "@rushstack/eslint-patch": "^1.3.3", "@vitejs/plugin-vue": "^4.5.2", "@vue/eslint-config-prettier": "^8.0.0", "@vue/test-utils": "^2.4.3", "eslint": "^8.49.0", "eslint-plugin-vue": "^9.17.0", "jsdom": "^23.0.1", "prettier": "^3.0.3", "unplugin-auto-import": "^0.17.5", "unplugin-vue-components": "^0.26.0", "vite": "^5.0.10", "vitest": "^1.0.4" } }