-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support Webpack, don't use require.resolve()
#76
Comments
If you are using Next.js, another workaround suggested in #69 (comment) also works: in brief, specify |
I might be wrong, but pdfjs may be using the fonts to better recognise text within the PDF documents. I would be happy for you (or someone else) to see if removing the font directory would have any impact on the conversion process! If it doesn't, I'll gladly accept a PR. |
Can confirm that this solution seems to work as well. |
Please try this with v0.2.0 of this package, which removes the dependency on node-specific libs, including |
@LoneRifle I haven't been able to take a good look at it, but this is the error I get by simply updating to the latest version and removing the work-around:
If I re-add the work-around (the one where you add |
@LoneRifle Here is my test platform. Desktop (please complete the following information):
Test
|
Is your feature request related to a problem? Please describe.
Because of the use of the function
require.resolve()
in this code: https://github.com/opengovsg/pdf2md/blob/master/lib/util/pdf.js#L19 the use of pdf2md in my project results in errors in production builds at runtime. The project uses WebPack to bundle the code and that particular function cannot be used.An explanation of the problem can be found in this Webpack issue: webpack/webpack#13931
(It's basically because once a project has been bundled, asking a module for it's filename just doesn't make sense anymore)
Describe the solution you'd like
I'd like the code to either not use that method by using an alternative or provide some kind of option/flag that avoids its use.
Also, given the fact that this project is about converting a PDF file to Markdown, which is text-only, is providing font directories even useful? Would it perhaps be possible to do without?
Describe alternatives you've considered
The work-around mentioned in the Webpack issue fortunately works. It's a completely incidental fix that reduces runtime code efficiency, so I'd prefer not to use it.
The text was updated successfully, but these errors were encountered: