1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-25 11:13:52 +02:00

Switched to custom universal module definition. closes #998 closes #847 closes #998

This commit is contained in:
Steve Heffernan 2014-02-13 19:20:30 -08:00
parent 468b07c651
commit 310a0630c9
5 changed files with 50 additions and 18 deletions

View File

@ -18,7 +18,10 @@
"goog", "goog",
"console", "console",
"require", "require",
"define",
"module",
"exports",
"PlayerTest", "PlayerTest",
"asyncTest", "asyncTest",

View File

@ -159,6 +159,18 @@ module.exports = function(grunt) {
dest: 'dist/video-js-' + version.full + '.zip' dest: 'dist/video-js-' + version.full + '.zip'
} }
} }
usebanner: {
dist: {
options: {
position: 'top',
banner: '/*! Video.js v' + version.full + ' <%= pkg.copyright %> */ ',
linebreak: true
},
files: {
src: [ 'build/files/minified.video.js']
}
}
}
}); });
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
@ -173,15 +185,16 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('videojs-doc-generator'); grunt.loadNpmTasks('videojs-doc-generator');
grunt.loadNpmTasks('grunt-zip'); grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-banner');
// grunt.loadTasks('./docs/tasks/'); // grunt.loadTasks('./docs/tasks/');
// grunt.loadTasks('../videojs-doc-generator/tasks/'); // grunt.loadTasks('../videojs-doc-generator/tasks/');
// Default task. // Default task.
grunt.registerTask('default', ['jshint', 'less', 'build', 'minify', 'dist']); grunt.registerTask('default', ['jshint', 'less', 'build', 'minify', 'usebanner', 'dist']);
// Development watch task // Development watch task
grunt.registerTask('dev', ['jshint', 'less', 'build', 'qunit:source']); grunt.registerTask('dev', ['jshint', 'less', 'build', 'qunit:source']);
grunt.registerTask('test', ['jshint', 'less', 'build', 'minify', 'qunit']); grunt.registerTask('test', ['default', 'less', 'build', 'minify', 'usebanner', 'qunit']);
var fs = require('fs'), var fs = require('fs'),
gzip = require('zlib').gzip; gzip = require('zlib').gzip;
@ -248,7 +261,7 @@ module.exports = function(grunt) {
+ ' --js_output_file=' + dest + ' --js_output_file=' + dest
+ ' --create_source_map ' + dest + '.map --source_map_format=V3' + ' --create_source_map ' + dest + '.map --source_map_format=V3'
+ ' --jscomp_warning=checkTypes --warning_level=VERBOSE' + ' --jscomp_warning=checkTypes --warning_level=VERBOSE'
+ ' --output_wrapper "/*! Video.js v' + version.full + ' ' + pkg.copyright + ' */ (function() {%output%})();"'; + ' --output_wrapper "(function() {%output%})();"';
//@ sourceMappingURL=video.js.map //@ sourceMappingURL=video.js.map
// Add each js file // Add each js file

View File

@ -2,7 +2,7 @@
"name": "video.js", "name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.", "description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "4.3.0", "version": "4.3.0",
"copyright": "Copyright 2013 Brightcove, Inc. https://github.com/videojs/video.js/blob/master/LICENSE", "copyright": "Copyright 2014 Brightcove, Inc. https://github.com/videojs/video.js/blob/master/LICENSE",
"keywords": ["html5", "flash", "video", "player"], "keywords": ["html5", "flash", "video", "player"],
"homepage": "http://videojs.com", "homepage": "http://videojs.com",
"author": "Steve Heffernan", "author": "Steve Heffernan",
@ -13,6 +13,7 @@
"type": "git", "type": "git",
"url": "https://github.com/zencoder/video-js.git" "url": "https://github.com/zencoder/video-js.git"
}, },
"main": "./dist/video-js/video.js",
"dependencies": { "dependencies": {
"videojs-swf": "4.3.4" "videojs-swf": "4.3.4"
}, },
@ -44,18 +45,6 @@
"videojs-doc-generator": "0.0.1", "videojs-doc-generator": "0.0.1",
"qunitjs": "~1.12.0", "qunitjs": "~1.12.0",
"grunt-zip": "0.10.2", "grunt-zip": "0.10.2",
"browserify-shim": "~3.2.2" "grunt-banner": "~0.2.0"
},
"main": "./dist/video-js/video.dev.js",
"browser": {
"videojs": "./dist/video-js/video.js"
},
"browserify-shim": {
"videojs": "window.videojs"
},
"browserify": {
"transform": [
"browserify-shim"
]
} }
} }

View File

@ -116,3 +116,18 @@ if (vjs.CDN_VERSION !== 'GENERATED'+'_CDN_VSN') {
* @type {Object} * @type {Object}
*/ */
vjs.players = {}; vjs.players = {};
/*!
* Custom Universal Module Definition (UMD)
*
* Video.js will never be a non-browser lib so we can simplify UMD a bunch and
* still support requirejs and browserify. This also needs to be closure
* compiler compatible, so string keys are used.
*/
if (typeof define === 'function' && define['amd']) {
define([], function(){ return videojs; });
// checking that module is an object too because of umdjs/umd#35
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = videojs;
}

View File

@ -14,6 +14,18 @@
Check publicly available APIs against compiled lib Check publicly available APIs against compiled lib
--> -->
<script type="text/javascript"> <script type="text/javascript">
// Test AMD Support
// window.define = function(a, b){
// console.log(a, b);
// };
// define.amd = true;
// Test CJS Support
// Have to remove qunit and tests to because module becomes a function
// window.module = window.exports = {};
// window.module.exports = {};
(function(){ (function(){
// ADD NEW TEST FILES HERE // ADD NEW TEST FILES HERE