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
“code: ‘UNRESOLVED_IMPORT’,
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.
-
Change CesiumJS’s build system in your fork to use @rollup/plugin-node-resolve - npm. This requires basic roll-up knowledge.
-
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.
-
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,
Matt
Hi Matt, really really appreciate the input here! I am now able to solve the issue using the methods you suggested. Thank you!
Is there a way to use the new version of the AWS SDK with the Cesium ION API? The API of the SDK looks quite different.
The new version can be used in the browser and is much smaller than V2.