Forum Discussion

scottvorthmann's avatar
scottvorthmann
New member | Level 2
3 years ago

ES modules for the modern web

All of the examples I've found use outmoded global scripts, and your Javascript SDK is not available in ES module form.
I suggest you modernize your SDK packaging, and also modernize your examples.  Not only will this improve security, but it will also enhance the public perception of Dropbox among web developers.

3 Replies

  • Jay's avatar
    Jay
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    3 years ago

    Hi scottvorthmann, thanks for the message.

     

    Could you clarify this in more detail on how this would affect your workflow and any examples you can provide on what to improve?

  • scottvorthmann's avatar
    scottvorthmann
    New member | Level 2
    3 years ago

    An ES module packaging would allow my app to load the Dropbox SDK dynamically, using now-standard dynamic module imports, which is beneficial since I only need it for certain situations.  I could even use it in a web worker, again loaded dynamically.

     

    I attempted to use the Dropbox SDK and bundle my app using esbuild.  It failed to resolve "crypto" and "utils".  Perhaps this is an issue with your package.json, or perhaps your "module" is just an IIFE that assumes other libraries have been defined globally.  Since the introduction of ES modules, it is a bad practice to pollute the global namespace, or to rely on global definitions from other libraries.

     

    Even Node.js supports ES modules, so older types of modules are not necessary.  For more info, see:

    https://auth0.com/blog/javascript-module-systems-showdown/  (6 years old)
    https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/  (4 years old)


  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    3 years ago

    Thanks for the detailed request! I've sent this along to the relevant team.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!