title: Importing RxJS 6 in browser?
body: <p>Now that <a href="https://caniuse.com/#feat=es6-module" rel="noreferrer">all modern browser support javascript modules</a>, I'm trying out  <code>import</code>ing code right in the browser. We can get <code>npm</code> modules from <a href="http://unpkg.com" rel="noreferrer">unpkg.com</a>, and I've found the <a href="https://jspm.io/" rel="noreferrer">jspm</a> project, which wraps <code>npm</code> modules into a format that can be consumed by the browser. </p>
  
  <p>But I'm still having problems, most notably with <a href="https://github.com/ReactiveX/rxjs" rel="noreferrer">RxJS</a>. RxJS, as of version 6, recommends you import constructors and operators like this:</p>
  
  <pre><code>import { Observable, Subject, ReplaySubject, from, of, range } from 'rxjs';
  import { map, filter, switchMap } from 'rxjs/operators';
  </code></pre>
  
  <p>But if I try to do that in the browser with:</p>
  
  <pre><code>import { Observable, Subject, ReplaySubject, from, of, range } from 'https://dev.jspm.io/rxjs@6';
  import { map, filter, switchMap } from 'https://dev.jspm.io/rxjs@6/operators';
  </code></pre>
  
  <p>I get errors along these lines:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: The requested module '<a href="https://dev.jspm.io/rxjs@6/operators" rel="noreferrer">https://dev.jspm.io/rxjs@6/operators</a>' does not provide an export named 'map'</p>
  </blockquote>
  
  <p>I can get around it by importing the whole <code>rxjs</code> module and teasing out what I need, like I would using a CDN:</p>
  
  <pre><code>import rxjs from 'https://dev.jspm.io/rxjs@6';
  const { Observable } = rxjs;
  import operators from 'https://dev.jspm.io/rxjs@6/operators';
  const { map } = operators;
  </code></pre>
  
  <p>but this defeats what the Rx team is trying to do to decrease the final bundle size, etc. </p>
  
  <p>I'm sure this isn't just an RxJS problem. </p>
  
  <p>What is the solution here moving forward to get our dev javascript (imports directly into the browser) to look like what we'd finally want to pass to a bundler? </p>