-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Deep import of pdfmake #1041
Description
Do NOT ignore this template or your issue will have a very high chance to be closed without comment.
Describe the bug
I am trying to use pdfmake with Vue 3 and vite. I get the following errors:
[vite] Avoid deep import "pdfmake/build/pdfmake" (imported by /src/App.vue)
because "pdfmake" has been pre-optimized by vite into a single file.
Prefer importing directly from the module entry:import { ... } from "pdfmake"
If the dependency requires deep import to function properly,
add the deep path to optimizeDeps.include in vite.config.js.[vite] Avoid deep import "pdfmake/build/vfs_fonts" (imported by /src/App.vue)
because "pdfmake" has been pre-optimized by vite into a single file.
Prefer importing directly from the module entry:import { ... } from "pdfmake"
If the dependency requires deep import to function properly,
add the deep path to optimizeDeps.include in vite.config.js.
I am importing it like this
import * as pdfMake from "pdfmake/build/pdfmake"; import * as pdfFonts from 'pdfmake/build/vfs_fonts'; (<any>pdfMake).vfs = pdfFonts.pdfMake.vfs;
and my vite.config.ts file looks like this:
optimizeDeps: { include: ['pdfmake/build/pdfmake', 'pdfmake/build/vfs_fonts'] }
Reproduction
Please provide a link to a repo that can reproduce the problem you ran into.
A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.
System Info
- required
viteversion:"^1.0.0-rc.8" - required Operating System: Windows
- required Node version: 10.16.1
- Optional:
- npm/yarn version
- Installed
vueversion (fromyarn.lockorpackage-lock.json) "^3.0.2", - Installed
@vue/compiler-sfcversion : "^3.0.2",
Logs (Optional if provided reproduction)
- Run
viteorvite buildwith the--debugflag. - Provide the error log here.