-
Notifications
You must be signed in to change notification settings - Fork 2.1k
"export 'default' (imported as 'pdfMake') was not found in 'pdfmake/build/pdfmake' Angular 10.0.0 #2009
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
Comments
Same here |
This
or this
doesn't work? |
No, I tried everything I could think of, including your two suggestions. |
Try ask on angular support. Because these are standard imports, I don't know what the problem is in angular |
I am also seeing this issue. And this library is the only one that breaks on import after upgrading to Angular 10 |
I will second that. None of my other imports broke either after upgrading to Angular 10. |
Same here with Angular 10 |
Report it to angular support. |
The break happened when Angular updated the TypeScript version It uses. This TS update must include stricter standards for exporting. Since Angular Support can’t update the pdfmake code to be compliant with the TypeScript export standards, I guess we will have to look for a solution to replace pdfmake. |
pdfmake use CommonJS standard with pdfmake/src/browser-extensions/pdfMake.js Lines 262 to 274 in 1c6d6f5
There must be some way in typescript to import such a library with commonjs syntax. Angular support does not need to update anything in pdfmake library, only say how to import libraries with commonjs in new angular. |
According to post in angular blog typescript is updated to 3.9 in Angular 10. Release announcement for typescript 3.9 say:
Which means it has to be imported somehow. I don't use typescript or angular, must try how to do it, someone else. |
I am not getting the typescript compilation error, but the imported pdfmake module was undefined after upgrading to angular v10. I noticed in the pdfmake code that, as a last resort, the import will define the createPdf function on a "global" object (which is the window object in a web browser environment). so this worked for me: import "pdfmake/build/pdfmake";
const pdfMake = { createPdf: window["createPdf"] } |
This comment has been minimized.
This comment has been minimized.
But according to the TS documentation it should work... Can anyone prepare simple example with TypeScript 3.9 and pdfmake, where I just run npm install and something else and this will cause this error? Thanks. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Tested with TypeScript 4.0.2, and this way is working: import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
(<any>pdfMake).vfs = pdfFonts.pdfMake.vfs; In TypeScript |
No reaction. I take the problem as solved as write above. |
Same issue. Anyone get a fix/workaround for this? I really am not looking forward to copying the source into my project and fixing a copy of the project. |
@aaronfrost try this import "pdfmake/build/pdfmake"
const pdfMake = window["pdfMake"]; |
@wittibs It worked for me but on ReactJs, thanks :) If it can help anyone, here is my imports
|
|
var pdfMake = require('pdfmake/build/pdfmake'); |
THANK FUCK! This finally worked. What a piece of shit importing approach for such a good library... I hope they fix it... After wasting 3 fucking hours on this, here is the final working solution: import "pdfmake/build/pdfmake";
const pdfMake = window["pdfMake"];
pdfMake.fonts = {
Roboto: {
normal: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Regular.ttf",
bold: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Medium.ttf",
italics: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Italic.ttf",
bolditalics: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-MediumItalic.ttf",
},
}; |
Worked perfectly for me! |
Thank you!! |
Thanks.It worked for me , i'm using Angular 16.2.0 and typescript 5.1.3 . |
how make to use in pure javascript ? |
This works in angular 17 : |
After updating from Angular version 9.1.11 to version 10.0.0, I am receiving this error:
"export 'default' (imported as 'pdfMake') was not found in 'pdfmake/build/pdfmake'
The text was updated successfully, but these errors were encountered: