Rollup Inferno

In notebook:
Work Notes
Created at:
2017-05-17
Updated:
2017-05-17
Tags:
JavaScript
Worked well for me
  import commonjsPlugin from 'rollup-plugin-commonjs';
import browserifyPlugin from 'rollup-plugin-browserify-transform';
import nodeResolvePlugin from 'rollup-plugin-node-resolve';
import babelPlugin from 'rollup-plugin-babel';
import envify from 'envify';
import json from 'rollup-plugin-json';
import path from 'path';
import replace from 'rollup-plugin-replace';
import alias from 'rollup-plugin-alias';

export default {
    entry: path.join(__dirname, 'src/main.js'),
    format: 'iife',
    moduleName: 'app',
    plugins: [
        alias({
            'inferno-compat': path.resolve(__dirname, 'node_modules/inferno-compat/dist-es/index.js'),
            'inferno-component': path.resolve(__dirname, 'node_modules/inferno-component/dist-es/index.js'),
            'inferno-create-class': path.resolve(__dirname, 'node_modules/inferno-create-class/dist-es/index.js'),
            'inferno-create-element': path.resolve(__dirname, 'node_modules/inferno-create-element/dist-es/index.js'),
            'inferno-shared': path.resolve(__dirname, 'node_modules/inferno-shared/dist-es/index.js'),
            'inferno-hyperscript': path.resolve(__dirname, 'node_modules/inferno-hyperscript/dist-es/index.js'),
            'inferno-mobx': path.resolve(__dirname, 'node_modules/inferno-mobx/dist-es/index.js'),
            'inferno-redux': path.resolve(__dirname, 'node_modules/inferno-redux/dist-es/index.js'),
            'inferno-router': path.resolve(__dirname, 'node_modules/inferno-router/dist-es/index.js'),
            'inferno-server': path.resolve(__dirname, 'node_modules/inferno-server/dist-es/index.js'),
            inferno: path.resolve(__dirname, 'node_modules/inferno/dist-es/index.js')
        }),
        json({
            // All JSON files will be parsed by default,
            // but you can also specifically include/exclude files
            include: 'node_modules/**',  // Default: undefined
            preferConst: true // Default: false
        }),
        babelPlugin({
            exclude: 'node_modules/**',
            plugins: [
                ['transform-es2015-computed-properties', {loose: true}],
                ['babel-plugin-inferno', {imports: true}]]
        }),
        browserifyPlugin(envify),
        nodeResolvePlugin({
            jsnext: false,  // Default: false
            main: true,  // Default: true
            browser: false,  // Default: false
            preferBuiltins: false,
            extensions: ['.js']
        }),
        commonjsPlugin({
            include: ['node_modules/**', '**/*.js', '**/*.jsx'],
            extensions: ['.js']
        }),
        replace({
            'process.env.NODE_ENV': JSON.stringify('production'),
            'process.env.TEST': false
        })
    ],
    dest: path.join('test', 'bundle.js')
};
My version, based on the above
  import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'
import path from 'path'
import replace from 'rollup-plugin-replace'
import alias from 'rollup-plugin-alias'
// import uglify from 'rollup-plugin-uglify'

export default {
  entry: 'src/App.js',
  format: 'iife',
  moduleName: 'App',
  exports: 'named',
  external: [ 'ramda' ],
  globals: {
    // inferno: 'Inferno',
    ramda: 'R'
  },
  plugins: [
    alias({
      'inferno-shared': path.resolve(__dirname, 'node_modules/inferno-shared/dist-es/index.js'),
      'inferno-create-element': path.resolve(__dirname, 'node_modules/inferno-create-element/dist-es/index.js'),
      inferno: path.resolve(__dirname, 'node_modules/inferno/dist-es/index.js')
    }),
    resolve({
      jsnext: true,
      main: true,
      // modulesOnly: true,
      browser: true
    }),
    commonjs({
      namedExports: {
        // 'inferno': 'Inferno',
        'ramda': 'R'
        // 'node_modules/inferno/index.js': 'Inferno'
      }
    }),
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
      'process.env.TEST': false
    })
    // uglify()
  ],
  dest: 'public/js/startComp.js'
}