5

How can I import a.js and b.js and export as combined bundle.js in UMD format using rollupjs?

Here is the example:

//a.js
export default class A {
...
}

//b.js
export default class B {
...
}

My current rollup.config.js is:

export default [
  {
    input: ["path/a.js", "path/b.js"],
    output: {
      file: "path/bundle.js",
      format: "umd",
      name: "Bundle"
    },
    plugins: [
      // list of plugins
    ]
  }
}

However, this is not working as intended.

Anything wrong with this config?

Thanks for your help.

sungl
  • 1,155
  • 1
  • 7
  • 16

1 Answers1

3

You need a file to tie them together. So along with a.js and b.js, have a main.js that looks like this:

import A from './a';
import B from './b';

export default {
  A,
  B,
};

Then update your rollup.config.js with input: path/main.js.

austingray
  • 8,727
  • 1
  • 12
  • 18