Search code examples
javascriptsafariangular8openseadragon

'OpenSeadragon' import call expects exactly one argument issue on Safari


I'm having an issue with my website not loading on Safari and getting an error message

SyntaxError: Unexpected identifier 'OpenSeadragon'. import call expects exactly one argument.

This issue only appears to be happening in Safari (seen both on iPhone and iMac) and not an issue on Chrome or Firefox.

When I click on the error message it takes me to a main.min.js file that was downloaded from cdn.jsdelivr.net. I'm not an expert in web development so I'm not sure what's wrong with the lines that are highlighted, and also don't know how I'd modify this file anyway, since I don't deliver the file.

enter image description here

These are the relevant lines for how I'm including OpenSeadragon into my website in my index.html file.

enter image description here

Any help that can be provided would be appreciated.


Solution

  • It looks like you are using ES6 source file instead of output bundle for openseadragon-annotations npm package.

    Chrome and Firefox were smart enough to pick up ES6 module syntax automatically, but you were supposed to use the output bundle file.

    According to the Webpack build configuration the output file is dist/openseadragon-annotations.js.

    Try replacing src/main.min.js with dist/openseadragon-annotations.js like this:

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/openseadragon/openseadragon.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/openseadragon-annotations.js"></script>