pdf.js import undefined for web component

I am trying to write a web component using lit-html which will render a user selected PDF file using pdf.js. However pdf.js import gives me the following error:

import 'pdfjs-dist/build/pdf.js';

TypeError: "root is undefined"
    webpackUniversalModuleDefinition http://localhost:8003/node_modules/pdfjs-dist/build/pdf.js:21
    <anonymous> http://localhost:8003/node_modules/pdfjs-dist/build/pdf.js:21

I can render a pdf file if I use a script tag for pdf.js in an html file.

22 thoughts on “pdf.js import undefined for web component”

Leave a Comment