2018-05-05 03:37:18 +00:00
|
|
|
import sourceMaps from 'rollup-plugin-sourcemaps';
|
|
|
|
import typescript from 'rollup-plugin-typescript2';
|
2018-05-18 03:15:07 +00:00
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
|
|
|
import nodeResolve from 'rollup-plugin-node-resolve';
|
|
|
|
import globals from 'rollup-plugin-node-globals';
|
|
|
|
import builtins from 'rollup-plugin-node-builtins';
|
|
|
|
import json from 'rollup-plugin-json';
|
2018-05-05 03:37:18 +00:00
|
|
|
|
|
|
|
const pkg = require('./package.json');
|
|
|
|
|
|
|
|
const libraryName = 'ens-validation';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include all of the dependencies here to exclude all node modules from the build
|
|
|
|
* Make sure to also include node libraries you're using e.g. 'crypto'
|
|
|
|
*/
|
|
|
|
|
2018-05-18 03:15:07 +00:00
|
|
|
// const external = [...Object.keys(pkg.dependencies || {})];
|
|
|
|
const external = ['lodash', 'utf8', 'url'];
|
2018-05-05 03:37:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Include all of the dependencies again here to squash rollup warnings
|
|
|
|
*/
|
2018-05-18 03:15:07 +00:00
|
|
|
const outputGlobals = {};
|
2018-05-05 03:37:18 +00:00
|
|
|
|
|
|
|
// tslint:disable-next-line
|
|
|
|
export default {
|
|
|
|
input: `src/index.ts`,
|
|
|
|
|
|
|
|
output: [
|
|
|
|
{
|
|
|
|
file: pkg.main,
|
|
|
|
name: libraryName,
|
|
|
|
format: 'umd',
|
2018-05-18 03:15:07 +00:00
|
|
|
globals: outputGlobals,
|
2018-05-05 03:37:18 +00:00
|
|
|
sourcemap: true,
|
|
|
|
},
|
2018-05-18 03:15:07 +00:00
|
|
|
{ file: pkg.module, format: 'es', globals: outputGlobals, sourcemap: true },
|
2018-05-05 03:37:18 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
// exclude all node modules
|
|
|
|
external,
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
include: 'src/**',
|
|
|
|
},
|
|
|
|
plugins: [
|
2018-05-18 03:15:07 +00:00
|
|
|
builtins(),
|
|
|
|
nodeResolve({ jsnext: true, main: true, browser: true }),
|
|
|
|
commonjs({
|
|
|
|
exclude: ['node_modules/rollup-plugin-node-globals/**'],
|
|
|
|
namedExports: {
|
|
|
|
'./node_modules/punycode/punycode.js': ['toUnicode' ],
|
|
|
|
'./node_modules/rollup-plugin-node-builtins/src/es6/url.js': [ 'Url' ],
|
|
|
|
'./node_modules/xregexp/lib/index.js': [ 'OuterXRegExp' ],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
globals(),
|
|
|
|
json(),
|
2018-05-05 03:37:18 +00:00
|
|
|
// Compile TypeScript files
|
|
|
|
typescript({
|
|
|
|
useTsconfigDeclarationDir: true,
|
|
|
|
tsconfig: './tsconfig-build.json',
|
|
|
|
}),
|
|
|
|
// Resolve source maps to the original source
|
|
|
|
sourceMaps(),
|
|
|
|
],
|
|
|
|
};
|