Using jQuery DataTables with Rollup.js : <p>Ok I'm using the tool rollup for the first time and I love how small it is making the code. Tree shaking is great. However, I'm having some trouble getting it to include everything correctly. I tried having a single entry point, exp.js, where I export things from various files like this:</p>

<pre><code>export {
    dashboardCharts
} from './dashboard.js';
</code></pre>

<p>my rollup.config.js looks like </p>

<pre><code>export default {
    // tell rollup our main entry point
    input: [
        'assets/js/exp.js',
    ],

    output: {
      name: 'helloworld',
      file: 'build/js/main.js',
        format: 'iife'
        // format: 'umd'
    },
    plugins: [
        resolve({
            // pass custom options to the resolve plugin
            customResolveOptions: {
              moduleDirectory: 'node_modules'
            }
        }),
        multiEntry()
        // terser(),
    ],
};
</code></pre>

<p>The file dashboard.js includes the datatables library, so datatables gets included in the bundle main.js. However, datatables tests whether it should take the commonjs path or not by testing </p>

<pre><code>else if ( typeof exports === 'object' ) {
    // CommonJS
    module.exports = function (root, $) {
</code></pre>

<p>and I'm trying to execute this in the browser, so I don't want the commonjs path. Rollup's top level scope is declared like</p>

<pre><code>var helloworld = (function (exports) {
</code></pre>

<p>so exports ends up being an empty object, the browser tries to execute the commonjs path and we get a "module is not defined" error. </p>

<p>I feel like I'm really close, but I'm missing a simple solution here. I also tried doing a umd format instead of iife, but it didn't help. Is there a different version of datatables I should be using?</p>
