title: How to import PlotlyJS with ECMAScript 6 modules
body: <p>I'm trying to implement PlotlyJS (<a href="https://cdn.plot.ly/plotly-latest.min.js" rel="nofollow noreferrer">last version</a>) with ES6 modules like this:</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;script src="main.js" type="module"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>main.js</p>
  
  <pre><code>import * as Plotly from './plotly.js';
  </code></pre>
  
  <p>But I have this error "Uncaught TypeError: Cannot read property 'document' of undefined at plotly.js"</p>
  
  <pre><code>plotly.js:21576 Uncaught TypeError: Cannot read property 'document' of undefined
  at plotly.js:21576
  at Object.151 (plotly.js:31122)
  at o (plotly.js:7)
  at plotly.js:7
  at Object.699.../constants/numerical (plotly.js:102912)
  at o (plotly.js:7)
  at plotly.js:7
  at Object.1.../src/lib (plotly.js:10)
  at o (plotly.js:7)
  at plotly.js:7
  </code></pre>
  
  <p>The problem is in library, I think. Any idea?</p>
  
  <p><a href="https://i.stack.imgur.com/ctR7M.png" rel="nofollow noreferrer">Line of error code in plotly.js</a></p>