How to use aws sdk in CesiumJS source files

Hi, I am trying to use aws sdk in the source files. After npm install package.json file, when I use import AWS from ‘aws-sdk’ and run npm run build it prints

importer: ‘Source/Core/Resource.js’,
message: “‘aws-sdk’ is imported by Source/Core/Resource.js, but could not be resolved – treating it as an external dependency”,
source: ‘aws-sdk’,
url: ‘rollup.js’,
toString: [Function (anonymous)]”

in the console. Does anyone know how to solve this issue? Thank you.

@Eli Hi Eli, I saw your comment on my github issue, would you mind giving any input on this matter? Thank you so much!

CesiumJS does not use a node resolver in it’s roll-up configuration, because our policy is that all CesiumJS code is valid JS code

import { S3 }  from "aws-sdk"

Is invalid JavaScript that requires a special toolchain in order to make valid. You have a few options.

  1. Change CesiumJS’s build system in your fork to use @rollup/plugin-node-resolve - npm. This requires basic roll-up knowledge.

  2. Include aws-sdk/dist/aws-sdk.min.js directly in your HTML as a non-module requirement and use AWS as a global in your code.

  3. Don’t fork CesiumJS at all and instead extend on top of it to do what you want (I’m not sure what your ultimate goal here is but I don’t think it requires a CesiumJS fork to accomplish).

Hope that helps,


Hi Matt, really really appreciate the input here! I am now able to solve the issue using the methods you suggested. Thank you!