Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot redefine property: vfs #2716

Closed
vinch opened this issue Apr 17, 2024 · 2 comments
Closed

TypeError: Cannot redefine property: vfs #2716

vinch opened this issue Apr 17, 2024 · 2 comments

Comments

@vinch
Copy link

vinch commented Apr 17, 2024

Hello. I'm using pdfmake in a SvelteKit (1.20) project in TypeScript and simply doing the imports via the method presented in the documentation gives me an error.

I'm doing this :

import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';

(<any>pdfMake).vfs = pdfFonts.pdfMake.vfs;

And I get the following error :

TypeError: Cannot redefine property: vfs

What am I doing wrong?

@YTDev
Copy link

YTDev commented Apr 21, 2024

Try to add this to rollup config:
....
build: {
rollupOptions: {

    context: "window",
    moduleContext: (id) => {
      if (id.includes('pdfmake/build/vfs_fonts.js')) {
        return 'window';
      }
    },
  },
},

@liborm85
Copy link
Collaborator

liborm85 commented Nov 2, 2024

Resolved see #2654 (comment).

@liborm85 liborm85 closed this as completed Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants