Error from webviewer.min.js

WebViewer Version: 10.3.0

I have 2 questions.

I’m upgrading from 8.12.0 to 10.3.0 by installing package from npm, then copying everything inside the @pdftron/webviewer/public” folder. It works fine; however, when I copied the file “webviewer.min.js”, which is outside the “public” folder, I got this error in runtime.

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "apryse-webviewer" has already been used with this registry
    at target.<computed> [as define] (http://localhost:4200/polyfills.js:10718:27)
    at Module.<anonymous> (http://localhost:4200/vendor.js:3923:20)
    at n (http://localhost:4200/vendor.js:3276:19)
    at Object.<anonymous> (http://localhost:4200/vendor.js:3326:23)
    at n (http://localhost:4200/vendor.js:3276:19)
    at http://localhost:4200/vendor.js:3310:19
    at http://localhost:4200/vendor.js:3311:4
    at http://localhost:4200/vendor.js:3264:30
    at 90939 (http://localhost:4200/vendor.js:3265:2)
    at __webpack_require__ (http://localhost:4200/runtime.js:23:42)

This error also occured after I completely removing old files and folders and copied everything from the npm package to my asset folder: no old files existed at all.
Why did this error occured?

also, when I just use the old “webviewer.min.js” from version 8.12.0 together with files/folders copied from “public” folder in 10.3.0 package, the log shown that the value of “webviewer.min.js” is “8.12.1” as in the following image for a while before the value become “10.3.0” later. I wonder why the version was not matched immediately?

1 Like

Hi mcsmiley,

Are you installing WebViewer through npm? Then you don’t need to copy this file webviewer.min.js over to the public folder after upgrading, just what’s inside here node_modules/@pdftron/webviewer/public. You can also add a post-install script, similar to what we have here in our React sample: https://github.com/PDFTron/webviewer-react-sample/blob/master/tools/copy-webviewer-files.js#L5

Since webviewer.min.js is the entry script for WebViewer in node_modules, importing it twice might cause an issue if you’re using the new WebComponent feature.

Hope this helps!

Regards,
Maggie V.

1 Like