-
-
Notifications
You must be signed in to change notification settings - Fork 626
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
(0 , import_jspdf_autotable.default) is not a function #1044
Comments
Ensure that both jspdf and jspdf-autotable are up to date. Even though your package.json and lock files haven't changed, it's possible that an update was applied to one of these packages without updating the version numbers in your package.json. You can check for updates by running npm outdated and then updating the packages as necessary. |
I bumped jspdf-autotable to 3.8.2, ran
What I really am not understanding yet is exactly what changed here. I know the code using this hasn't changed, and I know the versions haven't changed, which at this point I think leaves only the builder? Running this Angular via So I'm unclear on whose issue this even is. For now, the only workaround I can think of is to determine what is wrong with the code that is being transpiled and what (if anything) can be done to work around it. |
The issue might be related to changes in how jspdf-autotable exports its functionality. If the library has changed its export mechanism between versions, your import statement might need to be updated to match the new export format. |
The problem could also stem from how the Angular build process transpiles the code. Angular uses TypeScript and a set of tools (like Babel or esbuild) to transpile TypeScript code to JavaScript. If there's a mismatch in how these tools interpret the library's exports, it could lead to the error you're seeing. |
There's a problem with v3 in angular 17 which causes the plugin to work with You shouldn't see this problem with static imports though, try to |
Yes, I posted the transpiled code in the original post. It's from esbuild. This clearly has something to do with CommonJS vs. ESM due to that I'm not sure exactly why this is only a problem with I also noticed there is a v4 in the works with changes probably relevant. |
Yes, v4 should solve all problems regarding the module system, but I tested with angular 17 and I don't see this problem in a production build, I don't see |
This has been fixed by removing |
Great, was able to reproduce it with Confirmed that this is solved in v4 where we moved away from the default export and properly exported the EMS version of the library. |
If it can help anyone, regarding @mmghv solution, I made a simple function : // get-autotable.ts
import autoTable from 'jspdf-autotable';
// until its fixed in V4 https://github.com/simonbengtsson/jsPDF-AutoTable/issues/1044
export function getAutoTable() {
return (typeof autoTable === 'function' ? autoTable : (autoTable as any).default) as (d: jsPDFDocument, options: UserOptions) => void;
} // other-file.ts
import { getAutoTable } from './get-autotable';
getAutoTable()(jsPdfFile, ...) Question if someone comes around, is there a type for the autoTable function, did not find it, so I repeated the signature I use |
We are experiencing an issue after a deployment today of our Angular 17 project that we did not catch in testing, and we have not been able to reproduce yet locally. I'm trying to determine exactly what is going on.
In the Angular project, we import and use jdfPDF-AutoTable as follows:
With today's production build, at runtime this now fails with:
In checking the source that this is transpiling to, I see:
I don't understand why this is suddenly failing for us. I verified that the Angular code has not changed in months, and we do weekly releases. This was working last week. Our package.json and lock files have not changed either, and we run
npm ci
so this shouldn't be a version issue:Does anyone have any insight into what is going on here, and possible a fix or a workaround to get this working again?
The text was updated successfully, but these errors were encountered: