title: Rollup including my react library into bundle even though I have externals written
body: <p>I am trying to build a component library for myself with a few overrides. But it's constantly giving me an insane challenge. I can't import it into my projects. Rollup for some reason is packing the whole react lib into my bundle.js file.</p>
  <p>This rollup config</p>
  <pre><code>/* eslint-disable */
  import { readdirSync } from 'fs';
  import path from 'path';
  import babel from 'rollup-plugin-babel';
  import commonjs from 'rollup-plugin-commonjs';
  import external from 'rollup-plugin-peer-deps-external';
  import replace from 'rollup-plugin-replace';
  import resolve from 'rollup-plugin-node-resolve';
  import postcss from 'rollup-plugin-postcss';
  import { terser } from 'rollup-plugin-terser';
  import pkg from './package.json';
  
  const EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.json'];
  const CODES = [
    'THIS_IS_UNDEFINED',
    'MISSING_GLOBAL_NAME',
    'CIRCULAR_DEPENDENCY'
  ];
  
  const discardWarning = (warning) =&gt; {
    if (CODES.includes(warning.code)) {
      return;
    }
  
    console.error(warning);
  };
  
  const env = process.env.NODE_ENV;
  
  const commonPlugins = () =&gt; [
    postcss({
      extract: true,
      modules: true,
      use: ['sass']
    }),
    external(),
    babel({
      babelrc: false,
      presets: [['@babel/preset-env', { modules: false }], '@babel/preset-react'],
      extensions: EXTENSIONS,
      exclude: [
        'node_modules/**',
        'src/*/*.stories.js',
        'src/*/*.spec.js',
        'src/*/*.test.js'
      ]
    }),
    commonjs({
      include: /node_modules/
    }),
    replace({ 'process.env.NODE_ENV': JSON.stringify(env) }),
    resolve()
  ];
  
  export default [
    {
      onwarn: discardWarning,
      input: 'src/index.js',
      output: {
        esModule: false,
        file: pkg.unpkg,
        format: 'cjs',
        name: 'ph-shared',
        exports: 'named'
        globals: {
          antd: 'antd',
          react: 'React',
          'react-dom': 'ReactDOM'
        }
      },
      external: ['react', '@ant-design', 'react-notification-system', 'antd'],
      plugins: [...commonPlugins(), env === 'production' &amp;&amp; terser()],
      output: [{ dir: 'dist', format: 'cjs', exports: 'named', sourcemap: true }]
    }
  ];
  </code></pre>
  <p>and this is package.json file</p>
  <pre><code>{
    &quot;name&quot;: &quot;ph-shared&quot;,
    &quot;version&quot;: &quot;0.0.1&quot;,
    &quot;author&quot;: &quot;usmantahirr&quot;,
    &quot;description&quot;: &quot;Component library for PH&quot;,
    &quot;main&quot;: &quot;src/index.js&quot;,
    &quot;source&quot;: &quot;src/index.js&quot;,
    &quot;module&quot;: &quot;dist/bundle.js&quot;,
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;&gt;=12&quot;
    },
    &quot;scripts&quot;: {
      &quot;build&quot;: &quot;rollup -c&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
      &quot;lint&quot;: &quot;eslint ./src/&quot;,
      &quot;lint:fix&quot;: &quot;eslint ./src/ --fix&quot;,
      &quot;storybook&quot;: &quot;start-storybook -p 6006&quot;,
      &quot;build-storybook&quot;: &quot;build-storybook&quot;
    },
    &quot;husky&quot;: {
      &quot;hooks&quot;: {
        &quot;pre-commit&quot;: &quot;lint-staged&quot;
      }
    },
    &quot;lint-staged&quot;: {
      &quot;*.{js,jsx,css}&quot;: [
        &quot;prettier --write&quot;,
        &quot;npm run lint:fix&quot;,
        &quot;git add&quot;
      ]
    },
    &quot;peerDependencies&quot;: {
      &quot;@ant-design/icons&quot;: &quot;^4.2.2&quot;,
      &quot;react-notification-system&quot;: &quot;^0.4.0&quot;,
      &quot;antd&quot;: &quot;^4.6.4&quot;,
      &quot;react&quot;: &quot;^16.13.1&quot;,
      &quot;node-sass&quot;: &quot;^4.14.1&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@ant-design/icons&quot;: &quot;^4.2.2&quot;,
      &quot;@babel/core&quot;: &quot;^7.11.6&quot;,
      &quot;@babel/preset-env&quot;: &quot;^7.11.5&quot;,
      &quot;@babel/preset-react&quot;: &quot;^7.10.4&quot;,
      &quot;@storybook/addon-actions&quot;: &quot;^6.0.21&quot;,
      &quot;@storybook/addon-essentials&quot;: &quot;^6.0.21&quot;,
      &quot;@storybook/addon-knobs&quot;: &quot;^6.0.21&quot;,
      &quot;@storybook/addon-links&quot;: &quot;^6.0.21&quot;,
      &quot;@storybook/preset-create-react-app&quot;: &quot;^3.1.4&quot;,
      &quot;@storybook/react&quot;: &quot;^6.0.21&quot;,
      &quot;antd&quot;: &quot;^4.6.4&quot;,
      &quot;babel&quot;: &quot;^6.23.0&quot;,
      &quot;babel-loader&quot;: &quot;^8.1.0&quot;,
      &quot;eslint&quot;: &quot;^6.8.0&quot;,
      &quot;eslint-config-prettier&quot;: &quot;^6.7.0&quot;,
      &quot;eslint-config-standard&quot;: &quot;^14.1.0&quot;,
      &quot;eslint-config-standard-react&quot;: &quot;^9.2.0&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.18.2&quot;,
      &quot;eslint-plugin-node&quot;: &quot;^11.0.0&quot;,
      &quot;eslint-plugin-prettier&quot;: &quot;^3.1.1&quot;,
      &quot;eslint-plugin-promise&quot;: &quot;^4.2.1&quot;,
      &quot;eslint-plugin-react&quot;: &quot;^7.17.0&quot;,
      &quot;eslint-plugin-standard&quot;: &quot;^4.0.1&quot;,
      &quot;husky&quot;: &quot;^1.3.1&quot;,
      &quot;lint-staged&quot;: &quot;^8.1.5&quot;,
      &quot;node-sass&quot;: &quot;^4.14.1&quot;,
      &quot;prettier&quot;: &quot;^2.0.4&quot;,
      &quot;react-is&quot;: &quot;^16.13.1&quot;,
      &quot;react-notification-system&quot;: &quot;^0.4.0&quot;,
      &quot;react-scripts&quot;: &quot;^3.4.3&quot;,
      &quot;rollup-plugin-babel&quot;: &quot;^4.4.0&quot;,
      &quot;rollup-plugin-commonjs&quot;: &quot;^10.1.0&quot;,
      &quot;rollup-plugin-node-resolve&quot;: &quot;^5.2.0&quot;,
      &quot;rollup-plugin-peer-deps-external&quot;: &quot;^2.2.3&quot;,
      &quot;rollup-plugin-postcss&quot;: &quot;^3.1.8&quot;,
      &quot;rollup-plugin-replace&quot;: &quot;^2.2.0&quot;,
      &quot;rollup-plugin-terser&quot;: &quot;^7.0.2&quot;,
      &quot;sass-resources-loader&quot;: &quot;^2.1.0&quot;,
      &quot;styled-components&quot;: &quot;^5.2.0&quot;
    },
    &quot;dependencies&quot;: {}
  }
  </code></pre>
  <p>I also want to override some antD styles using SCSS. and it's converting all the classes with funny names even though they are not scss modules. It's extracting out a single file with all of my classes renamed. I was expecting only scss modules classes to be renamed.</p>