/* global process require */

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

var pkg = require('./package.json');

var banner = `/**
 * Fluture bundled; version ${process.env.VERSION || `${pkg.version} (dirty)`}
 */
`;

var typeref = `/// <reference types="https://cdn.jsdelivr.net/gh/fluture-js/Fluture@${
  process.env.VERSION || pkg.version
}/index.d.ts" />`;

export default [{
  input: 'index.cjs.js',
  plugins: [node(), commonjs({include: 'node_modules/**'})],
  output: {
    banner: banner,
    format: 'iife',
    name: 'Fluture',
    file: 'dist/bundle.js'
  }
}, {
  input: 'index.js',
  plugins: [node(), commonjs({include: 'node_modules/**'})],
  output: {
    banner: `${banner}\n${typeref}\n`,
    format: 'es',
    file: 'dist/module.js'
  }
}];

@@ -19,19 +19,56 @@
 require 
-*/%0A
+Set */%0A%0Aimport %7BreadFileSync%7D from 'fs';
 %0Aimport 
@@ -203,105 +203,580 @@
 var 
-banner = %60/**%0A * Fluture bundled; version $%7Bprocess.env.VERSION %7C%7C %60$%7Bpkg.version%7D (dirty)%60%7D%0A */%0A
+dependencies = pkg =%3E %7B%0A  var deps = Object.keys(pkg.dependencies %7C%7C %7B%7D).concat(Object.keys(pkg.peerDependencies %7C%7C %7B%7D));%0A  return Array.from(new Set(deps.concat(deps.flatMap(dependency =%3E (%0A    dependencies(require(%60$%7Bdependency%7D/package.json%60))%0A  )))));%0A%7D;%0A%0Avar banner = %60/**%0A * Fluture bundled; version $%7Bprocess.env.VERSION %7C%7C %60$%7Bpkg.version%7D (dirty)%60%7D%0A */%0A%60;%0A%0Avar footer = %60/** Fluture license%0A%0A$%7BreadFileSync('./LICENSE')%7D*/%0A%0A$%7Bdependencies(pkg).map(dependency =%3E %60/** $%7Bdependency%7D license%0A%0A$%7BreadFileSync(%60./node_modules/$%7Bdependency%7D/LICENSE%60)%7D*/%60%0A).join('%5Cn%5Cn')%7D
 %60;%0A%0A
@@ -1055,16 +1055,36 @@
 banner,%0A
+    footer: footer,%0A
     form
@@ -1285,16 +1285,36 @@
 ef%7D%5Cn%60,%0A
+    footer: footer,%0A
     form

Include copyright licenses in bundled distributions