Combine multiple es6 classes into single library using rollup js
Asked Answered
Q

1

6

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.

Quarterage answered 4/6, 2018 at 16:40 Comment(0)
W
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.

Wideopen answered 11/11, 2018 at 0:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.