autodesk-platform-services / aps-simple-viewer-nodejs

Simple Viewer (Node.js):Autodesk Platform Services application built by following the Simple Viewer tutorial from https://tutorials.autodesk.io.
https://aps-simple-viewer-nodejs.autodesk.io
MIT License
35 stars 38 forks source link

Move to ES6 modules #20

Open petrbroz opened 10 months ago

petrbroz commented 10 months ago

Migrating the Node.js code to ES6 modules might not only make the code more up-to-date but also streamline the step-by-step tutorials. For example, if we want to add functionality into a Node.js file incrementally, instead of

const service = module.exports = {};

service.someFunction = async () => {
  // ...
};

service.anotherFunction = async () => {
  // ...
};

we can just do

export async function someFunction() {
  // ...
}

export async function anotherFunction() {
  // ...
}
AlexanderMelde commented 2 months ago

It would also drastically improve the developer experience when using this in bundled apps, e.g. using Angular framework, Vite etc. Huge JS files like the viewer3D.js files are not something we really like to include in our apps as it breaks the usual pattern of managing dependencies in a package.json.

petrbroz commented 2 months ago

Unfortunately, the Terms & Conditions at the top of viewer3D.js state that

The Autodesk Viewer SDK JavaScript must be delivered from an Autodesk-hosted URL.

So bundling the JavaScript SDK is not something we support.

AlexanderMelde commented 2 months ago

Yeah, we just saw that as well. Are there any plans that this is going to change in the future?

The rest of our app is offline compatible. Do you know of a more detailed statement regarding this? What about caching the js file on the client (e.g. only downloading it during the first installation)?

petrbroz commented 2 months ago

There are no plans to change this restriction as far as I know. Please see https://aps.autodesk.com/blog/disconnected-workflows for more details on how you can cache viewer assets in an official/supported way.