title: How to import ES2015 modules functions selectively, but with namespacing?
body: <p>I'm getting started with Rollup and D3 version 4, which is written in ES2015 modules. I've written a some code using the traditional D3 namespace "d3". Now I want to create a custom bundle using Rollup. I want to using tree-shaking, because I'm probably only using about half the functions in d3, and I want to keep things as light as possible.</p>
  
  <p>I'm clear that I can import functions selectively, e.g.:</p>
  
  <pre><code>import {scaleLinear} from "d3-scale";
  import {
        event,
        select,
        selectAll
  } from "d3-selection";
  </code></pre>
  
  <p>That is going to get very verbose very fast, because half of d3 is a lot of functions. I can live with that. The bigger problem is that it also would require completely rewriting all my function identifiers without a namespace. I don't much care for that, because I prefer to namespace library code.</p>
  
  <p>I understand that I can import all of the module:</p>
  
  <pre><code>import * as d3 from "d3";
  </code></pre>
  
  <p>which preserves the d3 object namespace, which is good for my code organization. But then Rollup can't tree-shake the unused functions out of the bundle.</p>
  
  <p>What I'm dreaming of is something like:</p>
  
  <pre><code>import {
        event,
        select,
        selectAll
  } as d3 from "d3-selection";
  </code></pre>
  
  <p>but that sort of feature/syntax doesn't seem to exist in the spec. How can I both selectively target individual parts of a module, and preserve namespacing during an import?</p>