DEV Community

Discussion on: We reduced our vendor.js from 210kb to 16kb in about five minutes of work and ten lines of code

Collapse
 
bennypowers profile image
Benny Powers ๐Ÿ‡ฎ๐Ÿ‡ฑ๐Ÿ‡จ๐Ÿ‡ฆ

you could even

  (async () => {
    const moduleSpecifier = './utils.mjs';
    const { default: utils, doStuff } = await import(moduleSpecifier)
    utils();
    // โ†’ logs 'Hi from the default export!'
    doStuff();
    // โ†’ logs 'Doing stuffโ€ฆ'
  })();

Which is similar to the static syntax

import { default as utils, doStuff } from './utils.js';