Accepted answer

Because you've specified d3-scale as an external module, if your bundle is included as a <script> tag then it needs to exist on the page already, and Rollup needs to know what the corresponding global variable is (which is d3 — D3 is slightly unusual in that all the different packages are attached to the same namespace).

In other words, you need to do something like this...

<script src=""></script>
<script src="build/js/main.min.js"></script>

...and tell Rollup about d3:

import babel from 'rollup-plugin-babel';

export default {
  entry: 'src/scripts/main.js',
  dest: 'build/js/main.min.js',
  format: 'iife',
  external: [ 'd3-scale' ],
  globals: { 'd3-scale: 'd3' }, // <--- note this line
  plugins: [
      exclude: 'node_modules/**',

Alternatively, to include d3-scale and its dependencies in your bundle, use rollup-plugin-node-resolve.

Related Query

More Query from same tag