-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Remove import.meta.url usage #8314
Conversation
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)
Thanks for the pull request @mramato!
Reviewers, don't forget to make sure that:
|
The easiest way to test this (other than letting CI pass) is running all of the built versions of everything |
This was also needed for CesiumGS/cesium-webpack-example#13 to work with the latest versions of everything. |
So
I was unaware of this. How would I know that I need to do this as a developer using CesiumJS? This only matters if you're importing the unbuilt CesiumJS into your ES6 app, which isn't as common as just using the built version? I'm just trying to figure out how common the need to know to set |
No, CESIUM_BASE_URL tells CesiumJS where all of it's external files, such as WebWorkers, approximateTerrainHeights.json, skybox textures, etc.. live. It has nothing to do with built vs unbuilt.
If we can't auto-detect the correct location, we throw an error and spit out instructions in the console.
If you are just copying the |
Thanks for the explanation Matt. I think the only thing I have is to consider changing:
to:
The former explains what the problem is, but it doesn't give me enough info to fix it (what should be in the CESIUM_BASE_URL?) Although "CesiumJS's assets" is also kind of vague. Most JS libraries won't tend to have external assets/workers like we do, but those that do will tend to have this information in their "webpack project template" or equivalent tutorial. So I think that may be the best way to document this information in the future. Let me know what you think. I'd be happy to merge as-is and open an issue for documenting what BASE_URL is for and when to set it. |
Let's merge and handle the doc update in a separate issue. I think we can get to a slightly longer explanation that doesn't leave any room for confusion. |
import.meta.url
is only at stage 3 of the standards track and tools like webpack and babel do not have good support. Not all browsers do either. I ran into problems just trying to update the cesium-webpack-example 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 exampleCesiumViewer.js
would get selected as a false positive. This type of check is only valid for non-ES6 module usage anyway, since there is noscript
tag inserter for individual ES6 modules.Fixes #8251 You can now load Cesium Viewer unbuilt in Edge (but it takes forever). But the real reason for this is improving compatibility with the current tooling ecosystem.