Skip to content

Deep import of pdfmake #1041

@ljcremer

Description

@ljcremer

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 vite version:"^1.0.0-rc.8"
  • required Operating System: Windows
  • required Node version: 10.16.1
  • Optional:
    • npm/yarn version
    • Installed vue version (from yarn.lock or package-lock.json) "^3.0.2",
    • Installed @vue/compiler-sfc version : "^3.0.2",

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions