Transpile specific `node_modules` package with rollup and babel

Viewed 1266

I'm using rollup and would like to babel transpile a single node_modules package to ES5 (more precisely: to work with IE11).

With the following set-up it transpiles some of the code — classes → functions for example — but it doesn't transpile const to var's:

rollup.config.js:

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'umd',
  },
  plugins: [
    resolve(),
    commonjs(),
    babel({
      babelHelpers: 'bundled', 
      exclude: 'node_modules\/(?!(roughjs)\/).*', // ← Here I try to ES5 transpile roughjs which lives in `node_modules/roughjs/bundled/rough.esm.js`
    }),
  ],
};

.babelrc

{
  "presets": [["@babel/env", { "modules": false }]]
}

package.json:

// ...
"browserslist": "> 0.5%, IE 11, not dead",
// ...

My question is: how do I successfully transpile a single or multiple node_modules packages (given above example, if of help)?

0 Answers
Related