vaadin-component-factory / vcf-pdf-viewer-flow

Vaadin Addon for providing pdf viewing functionality
Apache License 2.0
8 stars 6 forks source link

Component does not work with Vaadin 23.3 #25

Closed probert94 closed 1 year ago

probert94 commented 1 year ago

I tried upgrading my project from Vaadin 23.2 to 23.3. Unfortunately I get the following error: SyntaxError: The requested module '/VAADIN/generated/jar-resources/print-js/dist/print.js' does not provide an export named 'default'

The issue can be reproduced with a Vaadin starter: 1) Add vcf-pdf-viewer 2.5.2 as a dependency. 2) Add the following code to MainView.java:

    public MainView() {
        PdfViewer pdfViewer = new PdfViewer();
        StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf"));
        pdfViewer.setSrc(resource);
        pdfViewer.openThumbnailsView();
        add(pdfViewer);
    }

It seems like there is a problem with pdf-js and vite but we are already using Vaadin 23.2 with vite so the issue is not related to vite only.

TatuLund commented 1 year ago

PDF.js a such is not fully, compatible with vite: see https://github.com/mozilla/pdf.js/issues/10317#issuecomment-1112675400

However workaround may exists to import the worked differently https://erindoyle.dev/using-pdfjs-with-vite/

Meanwhile, there is webpack fallback option in Vaadin 23, which allows to use the add-on in the current form.

probert94 commented 1 year ago

I forgot to mention, that we are already using Vaadin 23.2 with vite, so its not (only) a vite issue. I think it might be related to a stricter typescript validation in vaadin 23.3, as we got a lot of typescript related errors when trying to update.

javier-godoy commented 1 year ago

Fix has been released in version 2.5.3