Skip to content

Commit

Permalink
gulpfile: Apply browserify's umd wrapper instead of export flvjs obje…
Browse files Browse the repository at this point in the history
…ct into window

Apply browserify-derequire plugin
  • Loading branch information
xqq committed Nov 2, 2016
1 parent 0ceb197 commit 190a597
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
12 changes: 8 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ const source = require('vinyl-source-stream');

function doWatchify() {
let customOpts = {
entries: 'src/flv.js',
entries: 'src/index.js',
standalone: 'flvjs',
debug: true,
transform: [babelify]
transform: [babelify],
plugin: ['browserify-derequire']
};

let opts = Object.assign({}, watchify.args, customOpts);
Expand Down Expand Up @@ -91,9 +93,11 @@ gulp.task('lint', function () {

gulp.task('build', ['clean', 'lint'], function () {
let b = browserify({
entries: 'src/flv.js',
entries: 'src/index.js',
standalone: 'flvjs',
debug: true,
transform: [babelify]
transform: [babelify],
plugin: ['browserify-derequire']
});

return doBundle(b);
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
"name": "flv.js",
"version": "1.0.0",
"description": "HTML5 FLV Player",
"keywords": ["html5", "flv", "mse", "javascript"],
"main": "./dist/flv.js",
"types": "./d.ts/flv.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Bilibili/flv.js"
},
"keywords": [
"html5",
"flv",
"mse",
"javascript"
],
"scripts": {
"dev": "gulp watch",
"build": "gulp release",
Expand All @@ -22,6 +27,7 @@
"babel-preset-es2015": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"browserify-derequire": "^0.9.4",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-cli": "^1.2.2",
Expand Down
4 changes: 1 addition & 3 deletions src/flv.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {ErrorTypes, ErrorDetails} from './player/player-errors.js';
import LoggingControl from './utils/logging-control.js';
import {InvalidArgumentException} from './utils/exception.js';

// entry/index file
// here are all the interfaces

// install polyfills
Polyfill.install();
Expand Down Expand Up @@ -77,6 +77,4 @@ flvjs.NativePlayer = NativePlayer;
flvjs.LoggingControl = LoggingControl;


// export interfaces to global context
window.flvjs = flvjs;
export default flvjs;
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// entry/index file

// make it compatible with browserify's umd wrapper
module.exports = require('./flv.js').default;

0 comments on commit 190a597

Please sign in to comment.