hello, everyone. I just recently picked up Cesium again, and I noticed that the code structure has been significantly updated. The full switch to ESM looks very good. However, I have some problems using sandcastle. I need to access Cesium core submodules in sandcastle instead of compiled Cesium.js. Is there any best practice or article blog about sandcastle?
Hey @xuncanzhe1, thanks for the question!
It just so happens that we are currently rebuilding and upgrading Sandcastle! One of the changes is to treat the JS code in a sandcastle as a type="module" script so import statements work, both from CesiumJS and external scripts. Feel free to read more or leave feedback in this thread: Upgrading Sandcastle: We Need Your Input!
That said, you should have full access to everything Cesium exports in the global Cesium object in Sandcastle. Can you share more about what you’re not able to access? Or explain more what specific problems you’re running into using Sandcastle?
Hello, Thanks for your reply and information. I noticed that sandcastle uses Build/CesiumUnminified/index.js, a compiled ESM mode file. But I want to use Source/Cesium.js so that I can view it directly after updating the module code and refreshing the browser. I changed the reference path to Source/Cesium.js, but the browser prompts that this method cannot be used directly: export { Buffer } from ‘@cesium/engine’;
You are correct, currently sandcastle is set up to use the full, bundled ESM module for the cesium package. It’s not set up to use the workspace packages like @cesium/engine directly. This is something we may be able to consider for the new version of Sandcastle but it’s unlikely to change in the current version.
It sounds like you’re trying to use Sandcastle to test some changes to CesiumJS itself locally. If that’s the case the local development server, started with npm start, will automatically rebuild the index.js file after you make changes and refresh. This should let you see any updates take effect immediately.
Got it, thanks for the information.