I'm trying to compile a third party module pdfassembler to include the source of imports that are currently referenced by require statements in the compiled result.
The src/pdfassember.ts file has e.g.
import { PDFDocument } from 'pdfjs-dist/lib/core/document'; which instead of being imported is converted into
require('/Users/.../pdfassembler/node_modules/pdfjs-dist/lib/core/document.js') ... instead of the source code.
Running tsc --traceModules gives e.g.
======== Module name 'pdfjs-dist/lib/core/document' was successfully resolved to '/Users/bmh/Repos/pdfassembler/node_modules/pdfjs-dist/lib/core/document.js'. ========
It's not clear how to have the imports included. The Typescript documentation on module resolution offers no indication of why this might be happening. (And at the time of writing typescriptlang.org is down)
I expect this is a species of the problem of "import vs require", but the answer there offers did not point to any apparent solutions.
The import PDF.js has an @types/pdfjs-dist, and it occurred to me that this may be usable, but it's not clear how.
An ideal answer would indicate how to compile pdfassembler without any require statements, but it'd be useful to know generally what Typescript is doing/expecting and how to work around this sort of problem.