CesiumJS with older browsers

Hi, I’m trying to build an application with cesium for an old browser (less than chrome 59), and yes it’s a requirement to run on old browsers, since Cesium 1.109 where the workers are no longer AMD modules, I couldn’t run the application on the old browser, I’ve tried to run babel on it with tons of variations and tries but failed, is it possible, either theoretically or in practice to get cesium to work with a chrome that doesn’t support ESM (chrome < 61) either by compiling Cesium myself with different configurations, or some other way I didn’t think of, I would love any help I could get, thanks.

Hi @Mike_Smith,

I think you should be able to package for older browsers by bundling CesiumJS yourself. Babel should be enough to transpile most of the source code, including the workers, with a targeted approach.

We should be able to recommend a plan to do so. Could you let us know a bit more about how you are importing CesiumJS and your build configuration? For example, it would be helpful to know if you are using the library as IIFE (loading it as a global Cesium variable) and what paths you are importing.

Thanks,
Gabby

1 Like

Hey @Gabby_Getz thanks for the help, so basically I have an Angular project in an Nx monorepo, I have it setup as the cesium team recommended in this blog:

It’s nx so my configurations are inside a project.json file, but pretty much the same, I’m using the index.js file (non IIFE) because I thought at first that the IIFE is the problem with older browsers, and also it was recommended to use non IIFE as long as I remember, the builder is webpack for my project, about the paths I’m using, did you mean actually parts of cesium in my code? like ImageryLayers and other stuff? or just the file(index.js) that importing for the build.

Thanks.

Hi Mike,

As a disclaimer, I’m not very familiar with Angular, but I’m happy to try from the webpack side of things.

@Aristeidis_Bampakos may have some additional insight on the Angular aspects.

But this info is helpful!

  1. You could try using the IIFE distribution (Build/Cesium/Cesium.js). The workers are inlined in this version, and shouldn’t need to be run in a browser with support for ESM workers.
  2. If you can access the webpack configuration, you could try bundling the workers yourself, then packaging them into a global variable.
    • Each worker will need to be bundled as its own entry point. The output should be configured for IIFE, and babel should be used to transpile down as needed.
    • Once bundled, the contents will need to be mapped by module name to a CESIUM_WORKERS global variable. See the CesiumJS builds script for how we accomplish this.

I hope that’s enough to get you stared.