WorldWideTelescope / wwt-web-client

The WorldWide Telescope web client lets you explore the universe in your browser.
https://worldwidetelescope.org/webclient/
MIT License
104 stars 35 forks source link

Issues with loading dependencies #352

Closed Carifio24 closed 2 years ago

Carifio24 commented 2 years ago

I noticed this issue while trying to load my test HiPS slice in the webclient (previously I had been using the research app). Despite loading in pako and uuid before the engine (see #349), I'm seeing the following two errors when I load up the web client:

Uncaught (in promise) TypeError: Failed to resolve module specifier 'pako'. The base URL is about:blank because import() is called from a CORS-cross-origin script.
    at wwtsdk.min.js:formatted:34862:64
    at define (wwtsdk.min.js:formatted:1042:28)
    at wwtsdk.min.js:formatted:1045:12
    at wwtsdk.min.js:formatted:2:160
    at wwtsdk.min.js:formatted:3:2

Uncaught (in promise) TypeError: Failed to resolve module specifier 'uuid'. The base URL is about:blank because import() is called from a CORS-cross-origin script.
    at wwtsdk.min.js:formatted:34866:71
    at define (wwtsdk.min.js:formatted:1042:28)
    at wwtsdk.min.js:formatted:1045:12
    at wwtsdk.min.js:formatted:2:160
    at wwtsdk.min.js:formatted:3:2

The import statements that the errors are referencing shouldn't even trigger if pako and uuid are present already, which they should be here (as we're pulling them in via script tags). For pako, this error doesn't actually seem to matter - I can save a tour just fine (and pako is present in the browser's Window object). For uuid, however, this isn't the case - loading a HiPS catalog doesn't work, and uuid isn't defined in the window (which it should be).

However, I can't reproduce this locally - when I run the web client from my machine, everything works fine. Based on the errors, could there be some CORS setting on the web client that's causing an issue with the script imports?

As for why this only ends up affecting uuid, the only lead I have is from the minified JS in wwtsdk.min.js. After some pretty-printing, the minified JS for the imports looks like:

        let pako;
        "undefined" != typeof window && "pako"in window ? pako = window.pako : import("pako").then(function(result) {
            pako = result
        });
        let uuid;
        return "undefined" != typeof window && "uuid"in window ? uuid = window.uuid : import("uuid").then(function(result) {
            uuid = result
        }),

I'm not sure why the uuid statement gets a return at the front while pako doesn't, but I wonder if this asymmetry is having some effect.

pkgw commented 2 years ago

As discussed over Zoom, we now think this is just that a new release of the webclient needs to be made. The testing_webclient version doesn't display this issue.

pkgw commented 2 years ago

I just pushed through a webclient release and this indeed seems to be fixed now.