eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.02k stars 1.37k forks source link

Importing html2pdf.js in Webpack: "failed to parse source map /node_modules/html2pdf.js/dist/es6-promise.map" #570

Open quiaro opened 2 years ago

quiaro commented 2 years ago

Hello! We're on v0.10.0 of the library and we're using Create React App (react-scripts@5.0.0). We're running into an issue when we try to import html2pdf.js:

import html2pdf from 'html2pdf.js';

Our dev server returns the following:

Failed to parse source map from '.../node_modules/html2pdf.js/dist/es6-promise.map' file: Error: ENOENT: no such file or directory, open '.../scheduler_web/node_modules/html2pdf.js/dist/es6-promise.map'
WARNING in ./node_modules/html2pdf.js/dist/html2pdf.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '.../node_modules/html2pdf.js/dist/es6-promise.map' file: Error: ENOENT: no such file or directory, open '.../node_modules/html2pdf.js/dist/es6-promise.map'
 @ ./src/manage_data/app/utils/pdf.utils.js 3:0-35 52:9-17
 @ ./src/manage_data/app/pages/data_summary_schedule_data_page.js 33:0-60 190:11-33

It looks like the problem is related to line 5729 in html2pdf.js:

//# sourceMappingURL=es6-promise.map

... since this source map is not included in html2pdf.js/dist folder. I was able to verify that including es6-promise.map in html2pdf.js/dist did clear the warning.

Workaround

It looks like the minified version of the library is not importing es6-promise.map so I've changed the import for this file instead:

import html2pdf from 'html2pdf.js/dist/html2pdf.min.js';

Let me know if you need any other information. Thank you for this useful library 🙏

rommelmamedov commented 1 year ago

Any updates on this?

Arsik0153 commented 1 year ago

Getting this error too

BabOuDev commented 11 months ago

Same here... Reverting to 0.9.3 fixed it!

MickL commented 4 months ago

This issue is open for nearly 2 years, still not fixed. Is this project still active? @eKoopmans