I am currently in the process of compiling a third-party module called pdfassembler
and I want to ensure that the source code for the import
statements is included in the compiled output instead of references to require
statements.
Within the src/pdfassember.ts
file, there is an example of:
import { PDFDocument } from 'pdfjs-dist/lib/core/document';
Instead of importing the code, it is converted to:
require('/Users/.../pdfassembler/node_modules/pdfjs-dist/lib/core/document.js')
This means that the source code is not being included in the compilation result.
After running tsc --traceModules
, I receive messages like:
======== Module name 'pdfjs-dist/lib/core/document' was successfully resolved to '/Users/bmh/Repos/pdfassembler/node_modules/pdfjs-dist/lib/core/document.js'. ========
It is unclear how to resolve this issue of the imports not being included. Despite checking the Typescript documentation on module resolution, I am unable to find a solution, especially given that the typescriptlang.org website is currently down.
While researching, I came across a discussion about the difference between "import vs require", but the available answers did not provide a clear solution to this problem.
I also noticed that PDF.js has @types/pdfjs-dist
, which could potentially be helpful, but I am unsure of how to utilize it in this scenario.
An ideal response would provide guidance on how to compile pdfassembler without any require
statements. Additionally, understanding what Typescript expects and how to navigate this issue would be valuable information.