Skip to content

Multiple Entry Points each with Multiple Formats (with JS API) #3422

@agilgur5

Description

@agilgur5

Documentation Is:

  • Missing
  • Needed
  • Confusing
  • Not Sure?

Please Explain in Detail...

I'm not entirely sure if what I'm asking about is possible, this might be a feature request. Per the title, I have a few entry points, and each of those needs to output multiple formats, and chunks should be shared between them.

So something like:

rollup({
  input: ['src/ponyfill.js', 'src/polyfill.js'],
  output: [{
    dir: 'dist/esm/'
    format: 'esm'
  }, {
    dir: 'dist/cjs/'
    format: 'cjs'
  }]
}) 

Where src/polyfill.js imports src/ponyfill.js.

And, ideally would like to be able to have per-output plugins too, e.g. for minified vs. non-minified bundle.

This is related to #3325, as:

  1. Can't do multiple configs via the API
  2. bundle.write only takes one OutputOptions, not an array of OutputOptions, so I think this isn't possible via the API

Based on 2. I think I'd currently have to run rollup and bundle.write once on each format right now, which is pretty time-consuming as none of the work is re-used between formats.

This is something I'm running into in with supporting multiple entries in TSDX: jaredpalmer/tsdx#367 . Currently rollup is ran on each format and on each input, which is very time-consuming and, more problematically, no code is shared between the two bundles.

Also seems related to the quite older #1150

Your Proposal for Changes

Clarify if this is possible (with the API and CLI). If not, what are the current workarounds? Running rollup for each format with multiple inputs?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions