aps-simple-viewer-nodejs icon indicating copy to clipboard operation
aps-simple-viewer-nodejs copied to clipboard

Move to ES6 modules

Open petrbroz opened this issue 1 year ago • 4 comments

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() {
  // ...
}

petrbroz avatar Jan 22 '24 10:01 petrbroz

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.

AlexanderMelde avatar Sep 16 '24 11:09 AlexanderMelde

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.

petrbroz avatar Sep 16 '24 12:09 petrbroz

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)?

AlexanderMelde avatar Sep 16 '24 13:09 AlexanderMelde

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.

petrbroz avatar Sep 17 '24 07:09 petrbroz