-
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
Inline Static Assets in Builds #10619
Comments
Tangential to this discussion, for those that are using CesiumJS from |
@TJKoury You have some experience with doing this, via rollup I believe, in https://github.com/DigitalArsenal/c137.js. Are there any gotchas that you may have experienced in the process? |
Plenty gotchas! I'll start with the big one (for me): WebWorkers. My approach was to import all the webworkers into a single file. The packager can walk the dependency tree and pull everything into a single worker that can be called whenever you need a worker. That is then injected as a string into TaskProcessor.js. Since this will now be part of the official build you can probably come up with a more elegant solution (import it using the esbuild loader option per the above). |
@ggetz I’m considering applying for a grant through the new program so I can dedicate some time towards adapting my old approach to the current build system. If this will be duplicating effort, let me know. |
@TJKoury Awesome! Please go ahead! |
@ggetz I'm assuming since it's now in the backlog that this is no longer a priority? |
@TJKoury this is still on our shortlist. I moved it to backlog because no one on the Cesium side is currently scheduled to work on it. Mostly just reorganizing the labels on my side. |
Ok, standing by. I did apply for the grant program. |
I've done some prototypes of inlining worker in the |
Just tested it out, looks good and works very well with the new build system. |
@ggetz Now that you have created an approach that works with your new build system, let me know if there's anything I can do to speed things along. |
Thanks @TJKoury! Now that inline workers are shipping in |
Question: do you think CSS should be bundled by default? All build tool chains are able to handle CSS imports, either natively or using a plug-in. |
@ggetz What about building it in by default for the ES6 modules, so that it works in build systems like Vite? Instead of making it a global, it can be imported as a string from a Resources.js module, which can also have the images, JSON, CSS, .wasm binaries as base64, etc. If this approach is something you would consider, let me know. |
@TJKoury Sorry for delay here! I think additional CSS imports are a commonality that users will be used to and be able to find resources to handle. Just for some context, up until this point, we've tended to package the ES6 modules as minimally as possible with the ides that users we have more flexibility in their build process. And we've packaged the built
Are you talking about the workers in particular here? We'd be open to other approaches. |
Brought up on the forum: https://community.cesium.com/t/porting-from-1-100-to-1-120-to-load-google-3d-tileset/34809/6 |
The current CesiumJS distribution consists of a single, bundled JS entry point,
Cesium.js
, which inlines all library JS code. It also ships with several other static files, including standaloneWorker
JS files, third partywasm
files, JSON data, images/textures, and CSS files. Depending on what features of the library is being used, some or all of these static files are required to be loaded at runtime.While we've operated with these static files as part of the distribution since the beginning, it can require extra infrastructure on the part of developers depending on CesiumJS. We'd like to re-evaluate our strategy and look into providing a single-file CesiumJS distribution
As a first step, we could allow an optional
inline
flag as part of the build script. esbuild has aloader
option which allows other file types besides JS to be inlined most likely as data urls.After ensuring everything works, we should put some thought into potentially shipping by default as part of the release zip.
The text was updated successfully, but these errors were encountered: