backspaces
backspaces

Reputation: 3952

Can Rollup & Plugins convert the majority of legacy libraries to es6 modules?

Our team's project is entirely es6 modules (ESM) internally, but has dependencies that have not yet made esm versions.

We've created various solutions, but they are definitely not modern, mainstream solutions. By this I mean Rollup workflows which convert legacy formats to esm. Or equivalent.

So here's the question: are there now Rollup converters/plugins which can let us bundle all, or at least most, legacy formats into esm? I.e. convert commonJS, iife, umd, amd, (and other) library formats into esm, or can at least be bundled into an esm bundle?

Upvotes: 3

Views: 1800

Answers (1)

Rich Harris
Rich Harris

Reputation: 29615

There are plugins that are designed to do this:

The CommonJS plugin should cover UMD as well. They're not caveat-free — AMD is very hard to convert to ESM in some cases, and you can do some fairly nasty stuff with CommonJS that is hard to recreate (bundlers like webpack get around it by effectively simulating a Node environment), but they handle the common cases.

For the rest, if the maintainers won't accept PRs that add an ESM build alongside the default one (some won't, frustratingly), you might have to fork — depends on what you depend on :)

Upvotes: 5

Related Questions