title: ES module imports - can it always be done? A failed example trying to import socket.io-client
body: <p>I'm trying to use a &quot;build-less&quot; process so I'm using a plain module <code>script</code> in an html file (following the Preact docs):</p>
  <pre><code>&lt;script type=&quot;module&quot;&gt;
    import {
      html,
      render,
    } from 'https://unpkg.com/htm/preact/index.mjs?module';
   
    function App(props) {
      return html`&lt;h1&gt;Hello ${props.name}!&lt;/h1&gt;`;
    }
  
    render(html`&lt;${App} name=&quot;world&quot; /&gt;`, document.getElementById('root'));
  &lt;/script&gt;
  </code></pre>
  <p>I'm able to get the client socket.io working if I by-pass the module system and rely on the <code>window</code> global (note: I'm serving the html file from an http server that's been passed to socket.io's server and have <code>/socket.io/socket.io.js</code> automatically installed):</p>
  <pre><code>&lt;script src=&quot;/socket.io/socket.io.js&quot;&gt;&lt;/script&gt;
  
  &lt;!-- in previous module script: --&gt;
    const socket = window.io();
  
    socket.on('connect', () =&gt; {
      console.log('socket id&gt;&gt;', socket.id);
    });
  </code></pre>
  <p>I would like to import the socket.io client from an ES module. I know I could encapsulate the <code>window</code> use in my own JS file and then import that in the module script in my html, but I'm trying to do this instead and it isn't working:</p>
  <pre><code>  import io from '/socket.io.js'; // after copying socket.io.js to my public dir
    import { io } from 'https://cdnjs.cloudflare.com/ajax/libs/engine.io-client/3.5.0/engine.io.js'; // I have tried several variations of urls and what is imported
  </code></pre>
  <p>Judging by:</p>
  <blockquote>
  <p>Uncaught SyntaxError: The requested module '/socket.io.js' does not
  provide an export named 'default'</p>
  </blockquote>
  <p>and by the &quot;polyfill&quot;ed (if that's the correct term) commonjs globals like <code>module</code> in the probably-webpack bundle which is <code>socket.io.js</code> - it is likely that there just is no support for ES modules for this library.</p>
  <p>I will probably be facing this issue over and over so I have decided to go back to having a build step.</p>
  <p>My question is - is there a way around this &quot;3rd party libraries not supporting ES module imports out of the box&quot;? Maybe with a little work on my part I can get around this and try completing a small project without a build step in development.</p>