-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge won't parse JS code that uses import.meta.url #8251
Comments
This only affects the unbuilt versions of Cesium Viewer and Sandcastle on Edge. Built versions work as expected. The main issue is that we ship the unbuilt versions in the Cesium release zip, the hosted versions on cesiumjs.org work fine. |
@mramato is this something you're going to take care of? |
I've looked into it, but at first glance Edge looks to be in worse shape than I thought. I was thinking of addressing this by having the Sandcastle we ship with Cesium always use CesiumUnminified instead of the built version, which would make it faster and work in Edge too (which is the only browser it currently has problems with). |
@mramato Should this still be marked |
import.meta.url is only at stage 3 of the standards and tools like webpack and babel do not have good support. Not all browser do either. I ran into problems just trying to update the cesium-webpack-example because of it and Edge won't even part JS code with import.meta.url in it. This PR removes import.meta.url usage and just does a little extra work so that all of our developer setups properly set CESIUM_BASE_URL. Most ES6 development setups would require setting CESIUM_BASE_URL anyway, so this doesn't change much of anything for our end users. Folks using combined versions of Cesium.js are unaffected. I also tightened up our regex for `getBaseUrlFromCesiumScript` because Cesium.js is always named Cesium.js if it is available, which wasn't the case years ago when this code was written. This should prevent accidental detection of the wrong script, for example `CesiumViewer.js` would get selected as a false positive. This type of check is only valid for non-ES6 module usage anyway, since there is no `script` tag inserter for individual ES6 modules. Fixes #8251 You can now load Cesium Viewer unbuilt in Edge (but it takes forever)
To those watching: did you ever wind up digging into ways to work around the SyntaxError? I was just reading over webpack/webpack#7353 which talks about https://webpack.js.org/guides/asset-modules/#url-assets. The short version is that Webpack is able to statically analyze This issue actually means there's two problems: this one, i.e. writing a polyfill/fallback that avoids the SyntaxError, and also the root cause of #8401, which is that the way Cesium handles asset references has too much indirection to support static analysis. I'm also commenting over there to explain what I mean by that. |
We use
import.meta.url
inbuildModuleUrl
to find the current module location and build CESIUM_BASE_URL. Apparently Edge won't even parse code withimport.meta.url
in it and silently fails without any kind of indication.We may be able to avoid
import.meta.url
completely and take a different approach.There's some other weirdness in
buildModuleUrl
as well that we may want to review since a lot has changed since it was written.The text was updated successfully, but these errors were encountered: