feat: Rollup (#24)

Update to use Rollup to generate the main and umd files.

BREAKING CHANGE: drop bower support.
This commit is contained in:
Gary Katsevman 2017-06-09 14:00:51 -04:00 committed by GitHub
commit 47ef11f890
19 changed files with 547 additions and 450 deletions

View file

@ -1,4 +1,4 @@
{
"presets": [ "es3", ["es2015"] ],
"presets": [ "es3", ["es2015", {"loose": true}] ],
"plugins": ["transform-object-assign"]
}

1
.gitignore vendored
View file

@ -31,7 +31,6 @@ node_modules/
# Build-related directories
dist/
docs/api/
es5/
test/dist/
test/test-expected.js
test/test-manifests.js

View file

@ -1,11 +1,18 @@
sudo: false
dist: trusty
language: node_js
node_js:
- 'node'
- '4.2'
- '8'
- '6'
- '4'
before_script:
# Set up a virtual screen for Firefox.
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable

View file

@ -1,11 +1,3 @@
CHANGELOG
=========
## HEAD (Unreleased)
_(none)_
--------------------
## 2.1.0 (2017-02-23)
* parse FORCED attribute of media-groups [#15](https://github.com/videojs/m3u8-parser/pull/15)
* Pass any CHARACTERISTICS value of a track with the track object [#14](https://github.com/videojs/m3u8-parser/pull/14)

View file

@ -12,7 +12,7 @@ Make sure you have NodeJS 0.10 or higher and npm installed.
### Making Changes
Refer to the [video.js plugin standards][standards] for more detail on best practices and tooling for video.js plugin authorship.
Refer to the [video.js plugin conventions][conventions] for more detail on best practices and tooling for video.js plugin authorship.
When you've made your changes, push your commit(s) to your fork and issue a pull request against the original repository.
@ -27,4 +27,4 @@ Testing is a crucial part of any software project. For all but the most trivial
[karma]: http://karma-runner.github.io/
[local]: http://localhost:9999/test/
[standards]: https://github.com/videojs/generator-videojs-plugin/docs/standards.md
[conventions]: https://github.com/videojs/generator-videojs-plugin/blob/master/docs/conventions.md

View file

@ -1,4 +1,4 @@
Copyright 2016 brandonocasey <brandonocasey@gmail.com>
Copyright Brightcove, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -1,10 +0,0 @@
{
"name": "m3u8-parser",
"author": "Brightcove, Inc",
"license": "Apache-2.0",
"main": [
"dist/m3u8-parser.min.js"
],
"keywords": []
}

View file

@ -5,10 +5,11 @@
<title>m3u8-parser Demo</title>
</head>
<body>
<p>Open dev tools to try it out</p>
<ul>
<li><a href="/test/">Run unit tests in browser.</a></li>
<li><a href="/docs/api/">Read generated docs.</a></li>
<li><a href="test/">Run unit tests in browser.</a></li>
<li><a href="docs/api/">Read generated docs.</a></li>
</ul>
<script src="/dist/m3u8-parser.js"></script>
<script src="dist/m3u8-parser.js"></script>
</body>
</html>

View file

@ -2,8 +2,8 @@
"name": "m3u8-parser",
"version": "2.1.0",
"description": "m3u8 parser",
"jsnext:main": "src/index.js",
"main": "es5/index.js",
"main": "dist/m3u8-parser.cjs.js",
"module": "dist/m3u8-parser.es.js",
"repository": {
"type": "git",
"url": "git@github.com:videojs/m3u8-parser.git"
@ -25,20 +25,26 @@
"scripts": {
"prebuild": "npm run clean",
"build": "npm-run-all -p build:*",
"build:js": "npm-run-all build:js:babel build:js:browserify build:js:bannerize build:js:uglify",
"build:js": "npm-run-all build:js:rollup-modules build:js:rollup-umd build:js:bannerize build:js:uglify",
"build:js:babel": "babel src -d es5",
"build:js:bannerize": "bannerize dist/m3u8-parser.js --banner=scripts/banner.ejs",
"build:js:browserify": "browserify . -s m3u8-parser -o dist/m3u8-parser.js",
"build:js:uglify": "uglifyjs dist/m3u8-parser.js --comments --mangle --compress -o dist/m3u8-parser.min.js",
"build:test": "babel-node scripts/build-test.js",
"build:js:rollup-modules": "rollup -c scripts/modules.rollup.config.js",
"build:js:rollup-umd": "rollup -c scripts/umd.rollup.config.js",
"build:js:uglify": "uglifyjs dist/m3u8-parser.js --comments --mangle --compress -o dist/m3u8-parser.min.js",
"prebuild:test": "node scripts/m3u8.js",
"build:test": "rollup -c scripts/test.rollup.config.js",
"change": "chg add",
"clean": "rimraf dist test/dist es5 && mkdirp dist test/dist es5",
"clean": "rimraf dist test/dist",
"postclean": "mkdirp dist test/dist",
"docs": "npm-run-all docs:*",
"docs:api": "jsdoc src -r -d docs/api",
"docs:toc": "doctoc README.md",
"lint": "vjsstandard",
"start": "npm-run-all -p watch start:*",
"prestart": "npm run build",
"start": "npm-run-all -p start:server watch",
"start:serve": "babel-node scripts/server.js",
"start:server": "static -a 0.0.0.0 -p 9999 -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}' .",
"pretest": "npm-run-all lint build",
"test": "karma start test/karma.conf.js",
"test:chrome": "npm run pretest && karma start test/karma.conf.js --browsers Chrome",
@ -46,13 +52,16 @@
"test:ie": "npm run pretest && karma start test/karma.conf.js --browsers IE",
"test:safari": "npm run pretest && karma start test/karma.conf.js --browsers Safari",
"preversion": "npm test",
"version": "babel-node scripts/version.js",
"version": "node scripts/version.js",
"postversion": "babel-node scripts/postversion.js",
"prepublish": "npm run build",
"watch": "npm-run-all -p watch:*",
"watch:js": "npm-run-all -p watch:js:babel watch:js:browserify",
"watch:js-modules": "rollup -c scripts/modules.rollup.config.js -w",
"watch:js-umd": "rollup -c scripts/umd.rollup.config.js -w",
"watch:js:babel": "npm run build:js:babel -- --watch",
"watch:js:browserify": "watchify . -v -g browserify-shim -o dist/m3u8-parser.js"
"watch:js:browserify": "watchify . -v -g browserify-shim -o dist/m3u8-parser.js",
"watch:test": "rollup -c scripts/test.rollup.config.js -w",
"prepublish": "npm run build"
},
"keywords": [],
"author": "Brightcove, Inc",
@ -65,20 +74,17 @@
"ignore": [
"dist",
"docs",
"es5",
"test/dist",
"test/karma.conf.js",
"test/test-expected.js",
"test/test-manifests.js",
"test/manifests.js",
"test/fixtures/m3u8/**/*.js"
]
},
"files": [
"CONTRIBUTING.md",
"bower.json",
"dist/",
"docs/",
"es5/",
"index.html",
"scripts/",
"src/",
@ -86,11 +92,10 @@
],
"dependencies": {},
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.11.4",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-es3": "^1.0.1",
"babelify": "^7.3.0",
"bannerize": "^1.0.2",
@ -99,24 +104,39 @@
"browserify-shim": "^3.8.12",
"budo": "^8.0.4",
"chg": "^0.3.2",
"conventional-changelog-cli": "^1.3.1",
"conventional-changelog-videojs": "^3.0.0",
"doctoc": "^0.15.0",
"glob": "^6.0.3",
"global": "^4.3.0",
"jsdoc": "^3.4.0",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-detect-browsers": "^2.0.2",
"karma-firefox-launcher": "^0.1.7",
"karma-ie-launcher": "^0.2.0",
"karma-qunit": "^0.1.9",
"karma-safari-launcher": "^0.1.1",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-detect-browsers": "^2.2.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-qunit": "^1.2.1",
"karma-safari-launcher": "^1.0.0",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"npm-run-all": "^1.5.1",
"qunitjs": "^1.21.0",
"rimraf": "^2.5.1",
"sinon": "~1.14.0",
"uglify-js": "^2.6.1",
"videojs-standard": "5.2.0",
"node-static": "^0.7.9",
"npm-run-all": "^4.0.2",
"qunitjs": "^2.3.2",
"rimraf": "^2.6.1",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-json": "^2.1.1",
"rollup-plugin-multi-entry": "^2.0.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-watch": "^3.2.2",
"semver": "^5.3.0",
"sinon": "^2.2.0",
"uglify-js": "^3.0.7",
"videojs-standard": "^6.0.0",
"watchify": "^3.7.0"
},
"generator-videojs-plugin": {
"version": "5.0.0"
}
}

View file

@ -1,3 +1,4 @@
'use strict';
/* eslint no-console: 0 */
const fs = require('fs');

22
scripts/m3u8.js Normal file
View file

@ -0,0 +1,22 @@
'use strict';
const m3u8 = require('./export-m3u8s.js');
const args = require('minimist')(process.argv.slice(2), {
boolean: ['watch', 'clean', 'build'],
default: {
build: true
},
alias: {
b: 'build',
c: 'clean',
w: 'watch'
}
});
if (args.w) {
m3u8.watch();
} else if (args.c) {
m3u8.clean();
} else if (args.b) {
m3u8.build();
}

View file

@ -0,0 +1,37 @@
/**
* Rollup configuration for packaging the plugin in a module that is consumable
* by either CommonJS (e.g. Node or Browserify) or ECMAScript (e.g. Rollup).
*
* These modules DO NOT include their dependencies as we expect those to be
* handled by the module system.
*/
import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
export default {
moduleName: 'm3u8-parser',
entry: 'src/index.js',
legacy: true,
plugins: [
json(),
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [
'es3',
['es2015', {
loose: true,
modules: false
}]
],
plugins: [
'external-helpers',
'transform-object-assign'
]
})
],
targets: [
{dest: 'dist/m3u8-parser.cjs.js', format: 'cjs'},
{dest: 'dist/m3u8-parser.es.js', format: 'es'}
]
};

View file

@ -0,0 +1,57 @@
/**
* Rollup configuration for packaging the plugin in a test bundle.
*
* This includes all dependencies for both the plugin and its tests.
*/
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import multiEntry from 'rollup-plugin-multi-entry';
import resolve from 'rollup-plugin-node-resolve';
export default {
moduleName: 'm3u8-parser-test',
entry: 'test/**/*.test.js',
dest: 'test/dist/bundle.js',
format: 'iife',
external: [
'qunit',
'qunitjs',
'sinon'
],
globals: {
qunit: 'QUnit',
qunitjs: 'QUnit',
sinon: 'sinon'
},
legacy: true,
plugins: [
multiEntry({
exports: false
}),
resolve({
browser: true,
main: true,
jsnext: true
}),
json(),
commonjs({
sourceMap: false
}),
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [
'es3',
['es2015', {
loose: true,
modules: false
}]
],
plugins: [
'external-helpers',
'transform-object-assign'
]
})
]
};

View file

@ -0,0 +1,44 @@
/**
* Rollup configuration for packaging the plugin in a module that is consumable
* as the `src` of a `script` tag or via AMD or similar client-side loading.
*
* This module DOES include its dependencies.
*/
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
export default {
moduleName: 'm3u8-parser',
entry: 'src/index.js',
dest: 'dist/m3u8-parser.js',
format: 'umd',
legacy: true,
plugins: [
resolve({
browser: true,
main: true,
jsnext: true
}),
json(),
commonjs({
sourceMap: false
}),
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [
'es3',
['es2015', {
loose: true,
modules: false
}]
],
plugins: [
'external-helpers',
'transform-object-assign'
]
})
]
};

View file

@ -1,69 +1,10 @@
import {exec} from 'child_process';
import fs from 'fs';
import path from 'path';
const execSync = require('child_process').execSync;
const path = require('path');
const semver = require('semver');
const pkg = require('../package.json');
/* eslint no-console: 0 */
const pkg = require(path.join(__dirname, '../package.json'));
/**
* Determines whether or not the project has the CHANGELOG setup by checking
* for the presence of a CHANGELOG.md file and the necessary dependency and
* npm script.
*
* @return {Boolean}
*/
const hasChangelog = () => {
try {
fs.statSync(path.join(__dirname, '../CHANGELOG.md'));
} catch (x) {
return false;
}
return pkg.devDependencies.hasOwnProperty('chg') &&
pkg.scripts.hasOwnProperty('change');
};
/**
* Determines whether or not the project has the Bower setup by checking for
* the presence of a bower.json file.
*
* @return {Boolean}
*/
const hasBower = () => {
try {
fs.statSync(path.join(__dirname, '../bower.json'));
return true;
} catch (x) {
return false;
}
};
const commands = [];
// If the project has a CHANGELOG, update it for the new release.
if (hasChangelog()) {
commands.push(`chg release "${pkg.version}"`);
commands.push('git add CHANGELOG.md');
}
// If the project supports Bower, perform special extra versioning step.
if (hasBower()) {
commands.push('git add package.json');
commands.push(`git commit -m "${pkg.version}"`);
// We only need a build in the Bower-supported case because of the
// temporary addition of the dist/ directory.
commands.push('npm run build');
commands.push('git add -f dist');
}
if (commands.length) {
exec(commands.join(' && '), (err, stdout, stderr) => {
if (err) {
process.stdout.write(err.stack);
process.exit(err.status || 1);
} else {
process.stdout.write(stdout);
}
});
if (!semver.prerelease(pkg.version)) {
process.chdir(path.resolve(__dirname, '..'));
execSync('conventional-changelog -p videojs -i CHANGELOG.md -s');
execSync('git add CHANGELOG.md');
}

View file

@ -12,7 +12,7 @@ import LineStream from './line-stream';
import ParseStream from './parse-stream';
import Parser from './parser';
module.exports = {
export {
LineStream,
ParseStream,
Parser

View file

@ -3,14 +3,14 @@
<head>
<meta charset="utf-8">
<title>m3u8-parser Unit Tests</title>
<link rel="stylesheet" href="/node_modules/qunitjs/qunit/qunit.css">
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="/node_modules/sinon/pkg/sinon.js"></script>
<script src="/node_modules/sinon/pkg/sinon-ie.js"></script>
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
<script src="/test/dist/bundle.js"></script>
<script src="../node_modules/sinon/pkg/sinon.js"></script>
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../test/dist/bundle.js"></script>
</body>
</html>

View file

@ -1,48 +1,34 @@
module.exports = function(config) {
var browsers = config.browsers;
var frameworks = ['qunit'];
var plugins = ['karma-qunit'];
var addBrowserLauncher = function(browser) {
plugins.push('karma-' + browser.toLowerCase() + '-launcher');
var detectBrowsers = {
enabled: false,
usePhantomJS: false
};
// On Travis CI, we can only run in Firefox.
// On Travis CI, we can only run in Firefox and Chrome; so, enforce that.
if (process.env.TRAVIS) {
browsers = ['Firefox'];
browsers.forEach(addBrowserLauncher);
config.browsers = ['Firefox', 'travisChrome'];
}
// If specific browsers are requested on the command line, load their
// launchers.
} else if (browsers.length) {
browsers.forEach(addBrowserLauncher);
// If no browsers are specified, we will do a `karma-detect-browsers` run,
// which means we need to set up that plugin and all the browser plugins
// we are supporting.
} else {
frameworks.push('detectBrowsers');
plugins.push('karma-detect-browsers');
['chrome', 'firefox', 'ie', 'safari'].forEach(addBrowserLauncher);
// If no browsers are specified, we enable `karma-detect-browsers`
// this will detect all browsers that are available for testing
if (!config.browsers.length) {
detectBrowsers.enabled = true;
}
config.set({
basePath: '..',
frameworks: frameworks,
frameworks: ['qunit', 'detectBrowsers'],
files: [
'node_modules/sinon/pkg/sinon.js',
'node_modules/sinon/pkg/sinon-ie.js',
'test/dist/bundle.js'
],
browsers: browsers,
plugins: plugins,
detectBrowsers: {
usePhantomJS: false
customLaunchers: {
travisChrome: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
detectBrowsers: detectBrowsers,
reporters: ['dots'],
port: 9876,
colors: true,

File diff suppressed because it is too large Load diff