1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-13 10:32:26 +02:00

chore: update rollup and uglify and the build process (#5096)

This is upgrades rollup and uglify to latest versions. It also rewrites the rollup config to take advantage of the newest features of rollup. Minification is also split up into a separate process, mostly to speed up the build. The total build type can go down from about 2.5 minutes to around 1 minute for all the generated javascript files.
This commit is contained in:
Gary Katsevman 2018-04-19 13:23:53 -04:00 committed by GitHub
parent b10b9f960c
commit 97db94e8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 439 additions and 484 deletions

View File

@ -82,29 +82,6 @@ module.exports = function(grunt) {
build: ['build/temp/*', 'es5'],
dist: ['dist/*']
},
uglify: {
options: {
preserveComments: 'some',
screwIE8: false,
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
}
},
build: {
files: {
'build/temp/alt/video.novtt.min.js': 'build/temp/alt/video.novtt.js',
'build/temp/video.min.js': 'build/temp/video.js'
}
}
},
dist: {},
watch: {
dist: {
@ -116,10 +93,6 @@ module.exports = function(grunt) {
],
tasks: ['copy:dist']
},
minify: {
files: ['build/temp/video.js'],
tasks: ['uglify']
},
skin: {
files: ['src/css/**/*'],
tasks: ['skin']
@ -362,7 +335,7 @@ module.exports = function(grunt) {
}
},
rollupall: {
command: 'npm run rollup -- --no-progress && npm run rollup-minify -- --no-progress',
command: 'npm run rollup -- --no-progress && npm run minify',
options: {
preferLocal: true
}

46
build/minify.js Normal file
View File

@ -0,0 +1,46 @@
import fs from 'fs';
import uglify from 'uglify-js';
import maxmin from 'maxmin';
const options = {
nameCache: {},
output: {
comments: 'some'
},
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true,
typeofs: false
}
};
const minify = (file, dest) => {
const code = fs.readFileSync(file, 'utf8');
const minified = uglify.minify(code, options);
if (minified.error) {
console.error(minified.error);
return;
}
if (minified.warnings) {
console.warn(minified.warnings);
}
fs.writeFileSync(dest, minified.code, 'utf8');
console.log('File', dest, 'created:', maxmin(code, minified.code, true));
};
console.log('Minifying files\n');
minify('dist/video.js', 'dist/video.min.js');
minify('dist/alt/video.novtt.js', 'dist/alt/video.novtt.min.js');
minify('dist/alt/video.core.js', 'dist/alt/video.core.min.js');
minify('dist/alt/video.core.novtt.js', 'dist/alt/video.core.novtt.min.js');

View File

@ -1,312 +0,0 @@
import { rollup } from 'rollup';
import duration from 'humanize-duration';
import watch from 'rollup-watch';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import filesize from 'rollup-plugin-filesize';
import progress from 'rollup-plugin-progress';
import ignore from 'rollup-plugin-ignore';
import uglify from 'rollup-plugin-uglify';
import alias from 'rollup-plugin-alias';
import minimist from 'minimist';
import _ from 'lodash';
import pkg from '../package.json';
import fs from 'fs';
import path from 'path';
const args = minimist(process.argv.slice(2), {
boolean: ['watch', 'minify', 'progress'],
default: {
progress: true
},
alias: {
w: 'watch',
m: 'minify',
p: 'progress'
}
});
if (args.watch) {
args.progress = false;
}
const compiledLicense = _.template(fs.readFileSync('./build/license-header.txt', 'utf8'));
const bannerData = _.pick(pkg, ['version', 'copyright']);
const primedResolve = resolve({
jsnext: true,
main: true,
browser: true
});
const primedCjs = commonjs({
sourceMap: false
});
const primedBabel = babel({
babelrc: false,
exclude: 'node_modules/**(!http-streaming)',
presets: [
['es2015', {
loose: true,
modules: false
}]
],
plugins: ['external-helpers']
});
const core = {
options: {
entry: 'src/js/video.js',
plugins: [
json(),
primedBabel,
args.progress ? progress() : {},
filesize()
],
onwarn(warning) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT' ||
warning.code === 'UNRESOLVED_IMPORT') {
return;
}
// eslint-disable-next-line no-console
console.warn(warning.message);
},
legacy: true
},
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData)),
useStrict: false,
format: 'cjs',
dest: 'core.js'
};
const es = {
options: {
entry: 'src/js/index.js',
plugins: [
alias({
'video.js': path.resolve(__dirname, '../src/js/video.js'),
'@videojs/http-streaming': path.resolve(__dirname, '../node_modules/@videojs/http-streaming/dist/videojs-http-streaming.es.js')
}),
json(),
primedBabel,
args.progress ? progress() : {},
filesize()
],
onwarn(warning) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT' ||
warning.code === 'UNRESOLVED_IMPORT') {
return;
}
// eslint-disable-next-line no-console
console.warn(warning.message);
},
legacy: true
},
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData)),
useStrict: false,
format: 'es',
dest: 'dist/video.es.js'
};
const cjs = Object.assign({}, es, {
format: 'cjs',
dest: 'dist/video.cjs.js'
});
const umd = {
options: {
entry: 'src/js/index.js',
plugins: [
alias({
'video.js': path.resolve(__dirname, '../src/js/video.js')
}),
primedResolve,
json(),
primedCjs,
primedBabel,
args.progress ? progress() : {},
filesize()
],
legacy: true
},
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData)),
useStrict: false,
format: 'umd',
dest: 'dist/video.js'
};
const minifiedUmd = Object.assign({}, _.cloneDeep(umd), {
dest: 'dist/video.min.js'
});
minifiedUmd.options.plugins.splice(4, 0, uglify({
preserveComments: 'some',
screwIE8: false,
mangle: true,
compress: {
/* eslint-disable camelcase */
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
/* eslint-enable camelcase */
}
}));
const coreUmd = {
options: {
entry: 'src/js/video.js',
plugins: [
primedResolve,
json(),
primedCjs,
primedBabel,
args.progress ? progress() : {},
filesize()
],
legacy: true
},
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData)),
useStrict: false,
format: 'umd',
dest: 'dist/alt/video.core.js'
};
const minifiedCoreUmd = Object.assign({}, _.cloneDeep(coreUmd), {
dest: 'dist/alt/video.core.min.js'
});
minifiedCoreUmd.options.plugins.splice(4, 0, uglify({
preserveComments: 'some',
screwIE8: false,
mangle: true,
compress: {
/* eslint-disable camelcase */
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
/* eslint-enable camelcase */
}
}));
/**
* video.js without vtt.js
*/
const novttUmd = Object.assign({}, _.cloneDeep(umd), {
banner: compiledLicense(Object.assign({includesVtt: false}, bannerData)),
dest: 'dist/alt/video.novtt.js'
});
novttUmd.options.plugins.unshift(ignore(['videojs-vtt.js']));
const minifiedNovttUmd = Object.assign({}, _.cloneDeep(minifiedUmd), {
banner: compiledLicense(Object.assign({includesVtt: false}, bannerData)),
dest: 'dist/alt/video.novtt.min.js'
});
minifiedNovttUmd.options.plugins.unshift(ignore(['videojs-vtt.js']));
/**
* Core video.js without vtt.js
*/
const novttCoreUmd = Object.assign({}, _.cloneDeep(coreUmd), {
banner: compiledLicense(Object.assign({includesVtt: false}, bannerData)),
dest: 'dist/alt/video.core.novtt.js'
});
novttCoreUmd.options.plugins.unshift(ignore(['videojs-vtt.js']));
const minifiedNovttCoreUmd = Object.assign({}, _.cloneDeep(minifiedCoreUmd), {
banner: compiledLicense(Object.assign({includesVtt: false}, bannerData)),
dest: 'dist/alt/video.core.novtt.min.js'
});
minifiedNovttUmd.options.plugins.unshift(ignore(['videojs-vtt.js']));
function runRollup({options, useStrict, format, dest, banner}) {
rollup(options)
.then(function(bundle) {
bundle.write({
useStrict,
format,
dest,
banner,
moduleName: 'videojs',
sourceMap: false
});
}, function(err) {
// eslint-disable-next-line no-console
console.error(err);
});
}
if (!args.watch) {
if (args.minify) {
runRollup(minifiedUmd);
runRollup(minifiedCoreUmd);
runRollup(minifiedNovttUmd);
runRollup(minifiedNovttCoreUmd);
} else {
runRollup(es);
runRollup(cjs);
runRollup(umd);
runRollup(core);
runRollup(coreUmd);
runRollup(novttUmd);
runRollup(novttCoreUmd);
}
} else {
const props = ['format', 'dest', 'banner', 'useStrict'];
const watchers = [
['es', watch({rollup},
Object.assign({},
es.options,
_.pick(es, props)))],
['cjs', watch({rollup},
Object.assign({},
cjs.options,
_.pick(cjs, props)))],
['umd', watch({rollup},
Object.assign({moduleName: 'videojs'},
umd.options,
_.pick(umd, props)))],
['novtt', watch({rollup},
Object.assign({moduleName: 'videojs'},
novttUmd.options,
_.pick(novttUmd, props)))]
];
watchers.forEach(function([type, watcher]) {
watcher.on('event', (details) => {
if (details.code === 'BUILD_START') {
// eslint-disable-next-line no-console
console.log(`Bundling ${type}...`);
return;
}
if (details.code === 'BUILD_END') {
// eslint-disable-next-line no-console
console.log(`Bundled ${type} in %s`, duration(details.duration));
return;
}
if (details.code === 'ERROR') {
// eslint-disable-next-line no-console
console.error(details.error.toString());
return;
}
});
});
}

312
package-lock.json generated
View File

@ -4,6 +4,18 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/estree": {
"version": "0.0.38",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.38.tgz",
"integrity": "sha512-F/v7t1LwS4vnXuPooJQGBRKRGIoxWUTmA4VHfqjOccFsNDThD5bfUNpITive6s352O7o384wcpEaDV8rHCehDA==",
"dev": true
},
"@types/node": {
"version": "9.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.5.tgz",
"integrity": "sha512-NOLEgsT6UiDTjnWG5Hd2Mg25LRyz/oe8ql3wbjzgSFeRzRROhPmtlsvIrei4B46UjERF0td9SZ1ZXPLOdcrBHg==",
"dev": true
},
"@videojs/http-streaming": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-1.0.0.tgz",
@ -6631,6 +6643,23 @@
"uri-path": "1.0.0"
},
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"dev": true
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"dev": true,
"requires": {
"center-align": "0.1.3",
"right-align": "0.1.3",
"wordwrap": "0.0.2"
}
},
"gzip-size": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-1.0.0.tgz",
@ -6662,6 +6691,35 @@
"get-stdin": "4.0.1",
"meow": "3.7.0"
}
},
"uglify-js": {
"version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
"integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
"dev": true,
"requires": {
"source-map": "0.5.7",
"uglify-to-browserify": "1.0.2",
"yargs": "3.10.0"
}
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
"dev": true
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"dev": true,
"requires": {
"camelcase": "1.2.1",
"cliui": "2.1.0",
"decamelize": "1.2.0",
"window-size": "0.1.0"
}
}
}
},
@ -6888,6 +6946,25 @@
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=",
"dev": true
},
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"dev": true,
"optional": true
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"dev": true,
"optional": true,
"requires": {
"center-align": "0.1.3",
"right-align": "0.1.3",
"wordwrap": "0.0.2"
}
},
"source-map": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
@ -6896,6 +6973,47 @@
"requires": {
"amdefine": "1.0.1"
}
},
"uglify-js": {
"version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
"integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
"dev": true,
"optional": true,
"requires": {
"source-map": "0.5.7",
"uglify-to-browserify": "1.0.2",
"yargs": "3.10.0"
},
"dependencies": {
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true,
"optional": true
}
}
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
"dev": true,
"optional": true
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"dev": true,
"optional": true,
"requires": {
"camelcase": "1.2.1",
"cliui": "2.1.0",
"decamelize": "1.2.0",
"window-size": "0.1.0"
}
}
}
},
@ -9625,12 +9743,12 @@
"integrity": "sha512-LVHw0U6IPJjwk9i9f7Xe26NqaUHTNlIt4SSWoEfYFROeVKHN6MIjOhbRheI3dg8Jbq5WCuMFQ0QU3EgZpmzFPg=="
},
"magic-string": {
"version": "0.22.4",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.4.tgz",
"integrity": "sha512-kxBL06p6iO2qPBHsqGK2b3cRwiRGpnmSuVWNhwHcMX7qJOUr1HvricYP1LZOCdkQBUp0jiWg2d6WJwR3vYgByw==",
"version": "0.22.5",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz",
"integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==",
"dev": true,
"requires": {
"vlq": "0.2.2"
"vlq": "0.2.3"
}
},
"mailcomposer": {
@ -12835,12 +12953,6 @@
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
"dev": true
},
"require-relative": {
"version": "0.8.7",
"resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz",
"integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=",
"dev": true
},
"require-uncached": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz",
@ -12967,10 +13079,14 @@
}
},
"rollup": {
"version": "0.47.6",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.47.6.tgz",
"integrity": "sha512-bH3eWh7MzbiKTQcHQN7Ievqbs/yY7T+ZcJYboBYkp7BkRlAr2DXHPfiqlvlEH/M95giEBpinHEi/s9CVIgYT6w==",
"dev": true
"version": "0.58.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.58.1.tgz",
"integrity": "sha512-m423aUHITpMlcqz0grLddNGxMpBC2yYmgKwSlKNXxEi8PfNKTknh69JDo1bB1T9ezJQeqAoyFo2+U3qMQ4/I6g==",
"dev": true,
"requires": {
"@types/estree": "0.0.38",
"@types/node": "9.6.5"
}
},
"rollup-plugin-alias": {
"version": "1.4.0",
@ -12982,36 +13098,41 @@
}
},
"rollup-plugin-babel": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-2.7.1.tgz",
"integrity": "sha1-FlKBl7D5OKFTb0RoPHqT1XMYL1c=",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-3.0.3.tgz",
"integrity": "sha512-5kzM/Rr4jQSRPLc2eN5NuD+CI/6AAy7S1O18Ogu4U3nq1Q42VJn0C9EMtqnvxtfwf1XrezOtdA9ro1VZI5B0mA==",
"dev": true,
"requires": {
"babel-core": "6.26.0",
"babel-plugin-transform-es2015-classes": "6.24.1",
"object-assign": "4.1.1",
"rollup-pluginutils": "1.5.2"
}
},
"rollup-plugin-commonjs": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.1.tgz",
"integrity": "sha512-ZTwAetmKimCsuWost/+n4FaOpMoczBRTx+kuQaZCIKXTx/R1wNBezuX5NS0vnPKM3hBoErdpAqmNyVSCi5XKbg==",
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.1.0.tgz",
"integrity": "sha512-NrfE0g30QljNCnlJr7I2Xguz+44mh0dCxvfxwLnCwtaCK2LwFUp1zzAs8MQuOfhH4mRskqsjfOwGUap/L+WtEw==",
"dev": true,
"requires": {
"acorn": "5.1.2",
"estree-walker": "0.5.0",
"magic-string": "0.22.4",
"resolve": "1.4.0",
"estree-walker": "0.5.1",
"magic-string": "0.22.5",
"resolve": "1.7.1",
"rollup-pluginutils": "2.0.1"
},
"dependencies": {
"estree-walker": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.0.tgz",
"integrity": "sha512-/bEAy+yKAZQrEWUhGmS3H9XpGqSDBtRzX0I2PgMw9kA2n1jN22uV5B5p7MFdZdvWdXCRJztXAfx6ZeRfgkEETg==",
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.1.tgz",
"integrity": "sha512-7HgCgz1axW7w5aOvgOQkoR1RMBkllygJrssU3BvymKQ95lxXYv6Pon17fBRDm9qhkvXZGijOULoSF9ShOk/ZLg==",
"dev": true
},
"resolve": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
"integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
"dev": true,
"requires": {
"path-parse": "1.0.5"
}
},
"rollup-pluginutils": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz",
@ -13033,9 +13154,9 @@
}
},
"rollup-plugin-filesize": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-filesize/-/rollup-plugin-filesize-1.4.2.tgz",
"integrity": "sha1-7r31cSF+L+FKsUplNL8h93GgU7E=",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-filesize/-/rollup-plugin-filesize-1.5.0.tgz",
"integrity": "sha512-J5Ja0xgba4YqWthoui95TlLJLgcheh78vB0SXJTEyB2AfhspJEN6wFJHFzRStVYPtD0zIyg6A5H+2UhaX5bVcw==",
"dev": true,
"requires": {
"boxen": "1.2.1",
@ -13043,14 +13164,6 @@
"deep-assign": "2.0.0",
"filesize": "3.5.11",
"gzip-size": "3.0.0"
},
"dependencies": {
"colors": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
"integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=",
"dev": true
}
}
},
"rollup-plugin-ignore": {
@ -13087,36 +13200,34 @@
}
},
"rollup-plugin-node-resolve": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.0.tgz",
"integrity": "sha1-i4l8TDAw1QASd7BRSyXSygloPuA=",
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.3.0.tgz",
"integrity": "sha512-9zHGr3oUJq6G+X0oRMYlzid9fXicBdiydhwGChdyeNRGPcN/majtegApRKHLR5drboUvEWU+QeUmGTyEZQs3WA==",
"dev": true,
"requires": {
"browser-resolve": "1.11.2",
"builtin-modules": "1.1.1",
"builtin-modules": "2.0.0",
"is-module": "1.0.0",
"resolve": "1.4.0"
},
"dependencies": {
"builtin-modules": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-2.0.0.tgz",
"integrity": "sha512-3U5kUA5VPsRUA3nofm/BXX7GVHKfxz0hOBAPxXrIvHzlDRkQVqEn6yi8QJegxl4LzOHLdvb7XF5dVawa/VVYBg==",
"dev": true
}
}
},
"rollup-plugin-progress": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-progress/-/rollup-plugin-progress-0.2.1.tgz",
"integrity": "sha1-48kyoDFjdNqvN/RxyG1K37nK7lc=",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-progress/-/rollup-plugin-progress-0.4.0.tgz",
"integrity": "sha1-7AtO4zlkNGRUEjJykmKLh7O0Tx4=",
"dev": true,
"requires": {
"chalk": "1.1.3",
"rollup-pluginutils": "1.5.2"
}
},
"rollup-plugin-uglify": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-1.0.2.tgz",
"integrity": "sha1-1KpvXfE1Iurhuhd4DHxMcJYDg1k=",
"dev": true,
"requires": {
"uglify-js": "2.8.29"
}
},
"rollup-pluginutils": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz",
@ -13127,35 +13238,6 @@
"minimatch": "3.0.4"
}
},
"rollup-watch": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/rollup-watch/-/rollup-watch-4.3.1.tgz",
"integrity": "sha512-6yjnIwfjpSrqA8IafyIu7fsEyeImNR4aDjA1bQ7KWeVuiA+Clfsx8+PGQkyABWIQzmauQ//tIJ5wAxLXsXs8qQ==",
"dev": true,
"requires": {
"chokidar": "1.7.0",
"require-relative": "0.8.7",
"rollup-pluginutils": "2.0.1"
},
"dependencies": {
"estree-walker": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.3.1.tgz",
"integrity": "sha1-5rGlHPcpJSTnI3wxLl/mZgwc4ao=",
"dev": true
},
"rollup-pluginutils": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz",
"integrity": "sha1-fslbNXP2VDpGpkYb2afFRFJdD8A=",
"dev": true,
"requires": {
"estree-walker": "0.3.1",
"micromatch": "2.3.11"
}
}
}
},
"run-async": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz",
@ -14733,50 +14815,26 @@
"dev": true
},
"uglify-js": {
"version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
"integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
"version": "3.3.21",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.21.tgz",
"integrity": "sha512-uy82472lH8tshK3jS3c5IFb5MmNKd/5qyBd0ih8sM42L3jWvxnE339U9gZU1zufnLVs98Stib9twq8dLm2XYCA==",
"dev": true,
"requires": {
"source-map": "0.5.7",
"uglify-to-browserify": "1.0.2",
"yargs": "3.10.0"
"commander": "2.15.1",
"source-map": "0.6.1"
},
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"commander": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"dev": true,
"requires": {
"center-align": "0.1.3",
"right-align": "0.1.3",
"wordwrap": "0.0.2"
}
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"dev": true,
"requires": {
"camelcase": "1.2.1",
"cliui": "2.1.0",
"decamelize": "1.2.0",
"window-size": "0.1.0"
}
}
}
},
@ -15570,9 +15628,9 @@
}
},
"vlq": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.2.tgz",
"integrity": "sha1-4xbVJXtAuGu0PLjV/qXX9U1rDKE=",
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz",
"integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==",
"dev": true
},
"vm-browserify": {

View File

@ -18,10 +18,9 @@
"scripts": {
"changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"build": "grunt dist",
"rollup-all": "npm run rollup && npm run rollup-minify",
"rollup": "babel-node build/rollup.js",
"rollup-minify": "babel-node build/rollup.js --minify",
"rollup-dev": "babel-node build/rollup.js --watch",
"minify": "babel-node build/minify.js",
"rollup": "rollup -c",
"rollup-dev": "rollup -c -w",
"watch": "npm run rollup-dev",
"assets": "node build/assets.js",
"clean": "grunt clean",
@ -87,7 +86,6 @@
"grunt-contrib-connect": "~1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "~2.2.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "~1.0.0",
"grunt-coveralls": "^1.0.0",
"grunt-karma": "^2.0.0",
@ -118,6 +116,7 @@
"load-grunt-tasks": "^3.1.0",
"lodash": "^4.16.6",
"markdown-table": "^1.0.0",
"maxmin": "^2.1.0",
"minimist": "^1.2.0",
"npm-run-all": "^4.1.2",
"proxyquireify": "^3.0.0",
@ -129,23 +128,21 @@
"remark-toc": "^5.0.0",
"remark-validate-links": "^7.0.0",
"replace": "^0.3.0",
"rollup": "^0.47.5",
"rollup": "^0.58.1",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-filesize": "^1.2.1",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-filesize": "^1.5.0",
"rollup-plugin-ignore": "^1.0.3",
"rollup-plugin-json": "^2.1.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-progress": "^0.2.1",
"rollup-plugin-uglify": "^1.0.2",
"rollup-watch": "^4.0.0",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-progress": "^0.4.0",
"semver": "^5.5.0",
"shelljs": "^0.8.1",
"sinon": "^1.16.1",
"time-grunt": "^1.1.1",
"tui-jsdoc-template": "^1.1.0",
"uglify-js": "~2.8.8",
"uglify-js": "^3.3.21",
"unified": "^6.1.6",
"videojs-flash": "^2.1.0",
"videojs-standard": "^6.0.1",
@ -170,8 +167,7 @@
"greenkeeper": {
"ignore": [
"sinon",
"webpack",
"uglify-js"
"webpack"
]
}
}

194
rollup.config.js Normal file
View File

@ -0,0 +1,194 @@
import path from 'path';
import fs from 'fs';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import filesize from 'rollup-plugin-filesize';
import progress from 'rollup-plugin-progress';
import ignore from 'rollup-plugin-ignore';
import alias from 'rollup-plugin-alias';
import _ from 'lodash';
import pkg from './package.json';
const compiledLicense = _.template(fs.readFileSync('./build/license-header.txt', 'utf8'));
const bannerData = _.pick(pkg, ['version', 'copyright']);
const banner = compiledLicense(Object.assign({includesVtt: true}, bannerData));
const watch = {
clearScreen: false
};
const onwarn = (warning) => {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT' ||
warning.code === 'UNRESOLVED_IMPORT' ||
(warning.code === 'UNKNOWN_OPTION' &&
warning.message.indexOf('progress') !== -1)) {
return;
}
// eslint-disable-next-line no-console
console.warn(warning.message);
};
const primedIgnore = ignore(['videojs-vtt.js']);
const primedResolve = resolve({
jsnext: true,
main: true,
browser: true
});
const primedCjs = commonjs({
sourceMap: false
});
const primedBabel = babel({
babelrc: false,
exclude: 'node_modules/**(!http-streaming)',
compact: false,
presets: [
['es2015', {
loose: true,
modules: false
}]
],
plugins: ['external-helpers']
});
export default cliargs => [
// es, cjs
{
input: 'src/js/index.js',
output: [
{
format: 'es',
file: 'dist/video.es.js',
strict: false,
banner
}, {
format: 'cjs',
file: 'dist/video.cjs.js',
strict: false,
banner
}
],
plugins: [
alias({
'video.js': path.resolve(__dirname, './src/js/video.js'),
'@videojs/http-streaming': path.resolve(__dirname, './node_modules/@videojs/http-streaming/dist/videojs-http-streaming.es.js')
}),
json(),
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
},
// standard umd file
{
input: 'src/js/index.js',
output: {
format: 'umd',
file: 'dist/video.js',
name: 'videojs',
strict: false,
banner
},
plugins: [
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
}),
primedResolve,
json(),
primedCjs,
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
},
// novtt umd
{
input: 'src/js/index.js',
output: {
format: 'umd',
file: 'dist/alt/video.novtt.js',
name: 'videojs',
strict: false,
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData))
},
plugins: [
primedIgnore,
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
}),
primedResolve,
json(),
primedCjs,
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
},
// core
{
input: 'src/js/video.js',
output: {
format: 'cjs',
file: 'core.js',
strict: false,
banner
},
plugins: [
json(),
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
},
// core umd
{
input: 'src/js/video.js',
output: {
format: 'cjs',
file: 'dist/alt/video.core.js',
strict: false,
banner
},
plugins: [
primedResolve,
json(),
primedCjs,
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
},
// core novtt umd
{
input: 'src/js/video.js',
output: {
format: 'cjs',
file: 'dist/alt/video.core.novtt.js',
strict: false,
banner: compiledLicense(Object.assign({includesVtt: true}, bannerData))
},
plugins: [
primedIgnore,
primedResolve,
json(),
primedCjs,
primedBabel,
cliargs.progress !== false ? progress() : {},
filesize()
],
onwarn,
watch
}
];