Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new build that outs source es6 files into es5 folder #3445

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8cecf54
use babel-register module
gkatsev Jul 20, 2016
a6e896f
fixup weird paths
gkatsev Jul 20, 2016
5501186
add babel build and output es5/ directory
gkatsev Jul 20, 2016
eb26a7e
fixup track-enums exporting
gkatsev Jul 20, 2016
3146ec3
use es5/video.js as the main for packager users
gkatsev Jul 20, 2016
8f3ad4e
TextTrack is a default es6 export, so, we need to grab the default pr…
gkatsev Jul 21, 2016
f508af5
add babel-plugin-transform-runtime
gkatsev Jul 22, 2016
ab87184
add es3 babel transforms
gkatsev Aug 1, 2016
d5e0437
use babel plugin to inline versions
gkatsev Aug 2, 2016
20929fc
remove browserify-versionify for versions from the build system
gkatsev Aug 3, 2016
788c3a3
switch to babel-plugin-inline-json
gkatsev Aug 11, 2016
c66ef7e
remove browserify-versionify dep
gkatsev Aug 11, 2016
995b151
Revert "remove browserify-versionify dep"
gkatsev Aug 11, 2016
99e0674
add newline after a var
gkatsev Aug 16, 2016
532d868
fix cdn-links task
gkatsev Aug 16, 2016
6c74dab
remove saucelabs task since it's no longer used
gkatsev Aug 16, 2016
f234446
use babelrc for building videojs
gkatsev Aug 16, 2016
e77bb4b
never generate sourcemaps
gkatsev Aug 16, 2016
23ec89d
ignore es5 built files for the linter
gkatsev Aug 16, 2016
560047f
shell:lint to 'npm run lint'
gkatsev Aug 17, 2016
163c7dc
remove exorcise from build
gkatsev Aug 17, 2016
fd690c2
remove all of exorcise
gkatsev Aug 17, 2016
7a86fdc
only display errors as part of the linting pre-push hook
gkatsev Aug 17, 2016
fe00483
make sure to import flash and close-button
gkatsev Aug 17, 2016
6c65b26
clean up es5 folder on 'grunt clean:build'
gkatsev Aug 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015-loose"],
"plugins": ["transform-es3-property-literals", "transform-es3-member-expression-literals", "inline-json"]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ test/coverage/*
.sass-cache

dist/*
es5/*

.idea/
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Exclude everything but the contents of the dist directory.
**/*
!dist/**
!es5/**
!src/css/**
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('babel/register');
require('babel-register');

// Need to `require` a separate Grunt file so we can use ES6 syntax via
// Babel's require hook.
Expand Down
69 changes: 30 additions & 39 deletions build/grunt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {gruntCustomizer, gruntOptionsMaker} from './options-customizer.js';
import chg from 'chg';

module.exports = function(grunt) {
require('time-grunt')(grunt);

Expand All @@ -16,29 +18,10 @@ module.exports = function(grunt) {

const browserifyGruntDefaults = {
browserifyOptions: {
debug: true,
standalone: 'videojs'
},
plugin: [
['browserify-derequire']
],
transform: [
require('babelify').configure({
sourceMapRelative: './',
loose: ['all']
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}],
['browserify-versionify', {
placeholder: '__SWF_VERSION__',
version: pkg.dependencies['videojs-swf']
}]
]
};

Expand All @@ -47,7 +30,7 @@ module.exports = function(grunt) {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
body: chg.find(version.full).changesRaw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is so that the babel json config plugin doesn't try and replace this.

},
},
files: {
Expand Down Expand Up @@ -111,14 +94,11 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg,
clean: {
build: ['build/temp/*'],
build: ['build/temp/*', 'es5'],
dist: ['dist/*']
},
uglify: {
options: {
sourceMap: true,
sourceMapIn: 'build/temp/video.js.map',
sourceMapRoot: '../../src/js',
preserveComments: 'some',
mangle: true,
compress: {
Expand Down Expand Up @@ -153,6 +133,10 @@ module.exports = function(grunt) {
files: ['src/css/**/*'],
tasks: ['skin']
},
babel: {
files: ['src/js/**/*.js'],
tasks: ['babel:es5']
},
jshint: {
files: ['src/**/*', 'test/unit/**/*.js', 'Gruntfile.js'],
tasks: 'jshint'
Expand Down Expand Up @@ -317,11 +301,21 @@ module.exports = function(grunt) {
}
})
},
babel: {
es5: {
files: [{
expand: true,
cwd: 'src/js/',
src: ['**/*.js', '!base-styles.js'],
dest: 'es5/'
}]
}
},
browserify: {
options: browserifyGruntOptions(),
build: {
files: {
'build/temp/video.js': ['src/js/video.js']
'build/temp/video.js': ['es5/video.js']
}
},
dist: {
Expand All @@ -334,7 +328,7 @@ module.exports = function(grunt) {
]
}),
files: {
'build/temp/video.js': ['src/js/video.js']
'build/temp/video.js': ['es5/video.js']
}
},
watch: {
Expand All @@ -343,14 +337,15 @@ module.exports = function(grunt) {
keepAlive: true
},
files: {
'build/temp/video.js': ['src/js/video.js']
'build/temp/video.js': ['es5/video.js']
}
},
tests: {
options: {
browserifyOptions: {
debug: true,
standalone: false
verbose: true,
standalone: false,
transform: ['babelify']
},
plugin: [
['proxyquireify/plugin']
Expand All @@ -367,14 +362,6 @@ module.exports = function(grunt) {
}
}
},
exorcise: {
build: {
options: {},
files: {
'build/temp/video.js.map': ['build/temp/video.js'],
}
}
},
coveralls: {
options: {
// warn instead of failing when coveralls errors
Expand Down Expand Up @@ -406,6 +393,10 @@ module.exports = function(grunt) {
options: {
logConcurrentOutput: true
},
tests: [
'watch:babel',
'browserify:tests'
],
// Run multiple watch tasks in parallel
// Needed so watchify can cache intelligently
watchAll: [
Expand Down Expand Up @@ -439,7 +430,7 @@ module.exports = function(grunt) {
},
shell: {
lint: {
command: 'vjsstandard',
command: 'npm run lint',
options: {
preferLocal: true
}
Expand All @@ -457,8 +448,8 @@ module.exports = function(grunt) {
'shell:lint',
'clean:build',

'babel:es5',
'browserify:build',
'exorcise:build',
'concat:novtt',
'concat:vtt',
'usebanner:novtt',
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/cdn-links.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(grunt) {
grunt.registerTask('cdn-links', 'Update the version of CDN links in docs', function(){
let doc = grunt.file.read('docs/guides/setup.md');
let version = require('../package.json').version;
let version = require('../../package.json').version;

// remove the patch version to point to the latest patch
version = version.replace(/(\d+\.\d+)\.\d+/, '$1');
Expand Down
24 changes: 0 additions & 24 deletions build/tasks/saucelabs.js

This file was deleted.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "5.11.4",
"main": "./es5/video.js",
"style": "./dist/video-js.css",
"copyright": "Copyright Brightcove, Inc. <https://www.brightcove.com/>",
"license": "Apache-2.0",
"keywords": [
Expand All @@ -21,9 +23,8 @@
"type": "git",
"url": "https://github.com/videojs/video.js.git"
},
"main": "./dist/video.js",
"style": "./dist/video-js.css",
"dependencies": {
"babel-runtime": "^6.9.2",
"global": "4.3.0",
"lodash-compat": "3.10.2",
"object.assign": "4.0.3",
Expand All @@ -36,8 +37,14 @@
"xhr": "2.2.0"
},
"devDependencies": {
"babel": "^5.2.2",
"babelify": "^6.0.1",
"babel-cli": "^6.11.4",
"babel-plugin-inline-json": "^1.1.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
"babel-plugin-transform-es3-property-literals": "^6.8.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-register": "^6.9.0",
"babelify": "^7.3.0",
"blanket": "^1.1.6",
"browserify-derequire": "^0.9.4",
"browserify-istanbul": "^0.2.1",
Expand All @@ -48,6 +55,7 @@
"ghooks": "^1.3.2",
"gkatsev-grunt-sass": "^1.1.1",
"grunt": "^0.4.4",
"grunt-babel": "^6.0.0",
"grunt-banner": "^0.4.0",
"grunt-browserify": "3.5.1",
"grunt-cli": "~0.1.13",
Expand All @@ -60,7 +68,6 @@
"grunt-contrib-uglify": "^0.8.0",
"grunt-contrib-watch": "~0.1.4",
"grunt-coveralls": "^1.0.0",
"grunt-exorcise": "^1.0.1",
"grunt-fastly": "^0.1.3",
"grunt-github-releaser": "^0.1.17",
"grunt-karma": "^2.0.0",
Expand Down Expand Up @@ -92,6 +99,7 @@
"vjsstandard": {
"ignore": [
"**/Gruntfile.js",
"**/es5/**",
"**/build/**",
"**/dist/**",
"**/docs/**",
Expand All @@ -104,7 +112,7 @@
},
"config": {
"ghooks": {
"pre-push": "npm run lint"
"pre-push": "npm run lint -- --errors"
}
}
}
2 changes: 2 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ import VideoTrackList from './tracks/video-track-list.js';
// are always included in the video.js package. Importing the modules will
// execute them and they will register themselves with video.js.
import './tech/loader.js';
import './tech/flash.js';
import './poster-image.js';
import './tracks/text-track-display.js';
import './loading-spinner.js';
import './big-play-button.js';
import './close-button.js';
import './control-bar/control-bar.js';
import './error-display.js';
import './tracks/text-track-settings.js';
Expand Down
4 changes: 3 additions & 1 deletion src/js/tech/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class Flash extends Tech {
// Otherwise this adds a CDN url.
// The CDN also auto-adds a swf URL for that specific version.
if (!options.swf) {
options.swf = '//vjs.zencdn.net/swf/__SWF_VERSION__/video-js.swf';
const ver = require('videojs-swf/package.json').version;

options.swf = `//vjs.zencdn.net/swf/${ver}/video-js.swf`;
}

// Generate ID for swf object
Expand Down
10 changes: 4 additions & 6 deletions src/js/tracks/track-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* "",
* };
*/
const VideoTrackKind = {
export const VideoTrackKind = {
alternative: 'alternative',
captions: 'captions',
main: 'main',
Expand All @@ -37,7 +37,7 @@ const VideoTrackKind = {
* "",
* };
*/
const AudioTrackKind = {
export const AudioTrackKind = {
'alternative': 'alternative',
'descriptions': 'descriptions',
'main': 'main',
Expand All @@ -57,7 +57,7 @@ const AudioTrackKind = {
* "metadata"
* };
*/
const TextTrackKind = {
export const TextTrackKind = {
subtitles: 'subtitles',
captions: 'captions',
descriptions: 'descriptions',
Expand All @@ -70,10 +70,8 @@ const TextTrackKind = {
*
* enum TextTrackMode { "disabled", "hidden", "showing" };
*/
const TextTrackMode = {
export const TextTrackMode = {
disabled: 'disabled',
hidden: 'hidden',
showing: 'showing'
};

export default { VideoTrackKind, AudioTrackKind, TextTrackKind, TextTrackMode };
4 changes: 2 additions & 2 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import EventTarget from './event-target';
import * as Events from './utils/events.js';
import Player from './player';
import plugin from './plugins.js';
import mergeOptions from '../../src/js/utils/merge-options.js';
import mergeOptions from './utils/merge-options.js';
import * as Fn from './utils/fn.js';
import TextTrack from './tracks/text-track.js';
import AudioTrack from './tracks/audio-track.js';
Expand Down Expand Up @@ -132,7 +132,7 @@ setup.autoSetupTimeout(1, videojs);
*
* @type {String}
*/
videojs.VERSION = '__VERSION__';
videojs.VERSION = require('../../package.json').version;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is where the babel plugin comes in, my question is: Why even bother trying to make it a literal? We could just use it like this and have rollup shake off everything from the package.json that we don't use (effectively making it literal anyway).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would mean that anyone who wants to require videojs will need to use rollup or whatever to exclude everything.
this is also the reason for removing browserify-versionify. It makes it bundler agnostic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok that makes sense


/**
* The global options object. These are the settings that take effect
Expand Down
7 changes: 1 addition & 6 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ module.exports = function(config) {
browserify: {
debug: true,
plugin: ['proxyquireify/plugin'],
transform: [
require('babelify').configure({
sourceMapRelative: './',
loose: ['all']
})
]
transform: ['babelify']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets configured via .babelrc.

},

plugins: [
Expand Down
Loading