11

When configuring Rollupjs to generate a library, if the input is an array which consists of multiple javascript files. How can we do to these inputs will be generated in just a single output js file?

export const lgService = {
  input: [
    './src/app/services/livegiver/lgservices.js', 
    './src/app/services/readable-stream.js'
  ],
  output: {
    file: outputPath + 'LiveGiver/index.js',
    format: 'es'
  }
}

Expected:

  Input: [a.js, b.js]
  Output: dist/index.js

Actual:

  Input: [a.js, b.js]
  Output: dist/a.js; dist/b.js

2 Answers 2

4

You can't — multiple inputs implies multiple outputs. To do what you're describing, you'll need to have a single entry module that looks something like this:

import './app/services/livegiver/lgservices.js';
import './app/services/readable-stream.js';

If you need to generate that module dynamically you could use something like rollup-plugin-virtual.

Sign up to request clarification or add additional context in comments.

Comments

3

You can import all your js files into index.js. and export from index.js like the below

export { default as YourComponent} from "component path";

then in your rollup.config.js file.

export const lgService = {
  input: './src/app/index.js',
  output: {
    file: outputPath + '/index.js',
  }
}

this is tested in rollup v2.57.0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.