I've uploaded a minified pdf.js file (CDN link) into a static resource, but when trying to use it, pdfjsLib is undefined no matter what I try. It was my unstanding that pdfjsLib would be defined and exported in the imported script file, and that Salesforce would attach the export onto the window object. What is possibly going wrong here?
import { LightningElement, api } from 'lwc'
import { loadScript } from 'lightning/platformResourceLoader'
import pdfjs from '@salesforce/resourceUrl/pdfjs'
export default class PdfRender extends LightningElement {
async renderedCallback() {
try {
await loadScript(this, pdfjs)
console.log(window.pdfjsLib) // undefined
} catch (e) {
console.error('There was an issue loading PDF.js: ' + e.message)
}
}
}