Bundling with Rollup

FormValidation was rewritten in ES6 from v1.0.0. It comes with the dist/es6 directory that consists of ES6 compatible classes. This guide shows how you can bundle FormValidation with Rollup .
Assume that your folder has the following structure:
        
the-root-directory
|
├── node_modules
├── vendors
| └── formvalidation
| └── dist
| └── es6
└── rollup.config.js
Now, you can set the alias to FormValidation by installing the :
        
// Run this command from the root directory
$ npm install /plugin-alias --save-dev
and using it in rollup.config.js :
        
// rollup.config.js
import alias from '/plugin-alias' ;
const path = require ( 'path' ) ;
module . exports = {
plugins : [
alias ( {
entries : [
{
find : 'formvalidation' ,
replacement : path . resolve ( __dirname , 'vendors/formvalidation/dist/es6' ) ,
} ,
] ,
} ) ,
] ,
} ;
From now on, you can import any file from FormValidation ES6 package as following:
        
// Use the algorithms
import luhn from 'formvalidation/algorithms/luhn' ;
// Use the validators
import creditCard from 'formvalidation/validators/creditCard' ;
const result = creditCard ( ) . validate ( {
value : ... ,
options : {
message : ... ,
} ,
} ) ;
// Use the core library
import formValidation from 'formvalidation/core/Core' ;
// Use the plugins
import Icon from 'formvalidation/plugins/Icon' ;
import Trigger from 'formvalidation/plugins/Trigger' ;
import Bootstrap from 'formvalidation/plugins/Bootstrap' ;
...

See also