I need to use an ES6 library (Luxon) and want to compile down the files to ES5, but Rollup adds the files as ES6.
The library has a special /build
folder with different output formats.
How can I configure Rollup to make use of that instead of doing nothing with the library?
First of all, you have two options here:
/build
directory of the package instead of the ES6
version of the package, using an alias with @rollup/plugin-aliasI'll go with the second approach because is the one you asked for:
npm i @rollup/plugin-alias
rollup.config.js
import it import alias from '@rollup/plugin-alias';
plugins
:const path = require('path');
module.exports = {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [
alias({
entries: [
{ find: 'luxon', replacement: path.resolve(process.cwd(), 'node_modules/luxon/build') },
]
})
]
};