Permalink
Browse files

[JW8-2319] Update to webpack 4.29 and babel 7 (#3275)

* Update to webpack 4.29 and babel 7
- Remove use of side-effects on module imports in tests
- Make Events and SimpleModel base classes for ES6 output compatibility
JW8-2319
  • Loading branch information...
robwalch authored and johnBartos committed Feb 1, 2019
1 parent b5d1b4d commit 24bfb49c47c75a6bac5beacc80323a2f91937da0
@@ -7,7 +7,6 @@ const fs = require('fs');
const webpack = require('webpack');
const webpackConfigs = require('./webpack.config');
const webpackCompilers = {};
const env = process.env;
const execSync = require('child_process').execSync;

function runCommand(command, dir) {
@@ -17,32 +16,13 @@ function runCommand(command, dir) {
});
}

function getBuildVersion(packageInfo) {
// Build Version: {major.minor.revision}
let metadata = '';
if (env.BUILD_NUMBER) {
const branch = env.GIT_BRANCH;
metadata = 'opensource';
if (branch) {
metadata += '_' + branch.replace(/^origin\//, '').replace(/[^0-9A-Za-z-]/g, '-');
}
metadata += '.' + env.BUILD_NUMBER;
} else {
const now = new Date();
now.setTime(now.getTime()-now.getTimezoneOffset()*60000);
metadata = 'local.' + now.toISOString().replace(/[.-:T]/g, '-').replace(/Z|\.\d/g, '');
}
return packageInfo.version +'+'+ metadata;
}

module.exports = function(grunt) {

require('load-grunt-tasks')(grunt);

const packageInfo = grunt.file.readJSON('package.json');
const buildVersion = getBuildVersion(packageInfo);

console.log('%s v%s', packageInfo.name, buildVersion);
console.log('%s v%s', packageInfo.name, packageInfo.version);

grunt.initConfig({
starttime: new Date(),
@@ -227,7 +207,7 @@ module.exports = function(grunt) {
});

grunt.registerTask('hooks', 'Install Pre Push Hook', function() {
runCommand('yarn run hooks', '.');
runCommand('yarn hooks', '.');
});

grunt.registerTask('notice', 'Create notice.txt file', function() {
@@ -242,7 +222,7 @@ module.exports = function(grunt) {
});

grunt.registerTask('lint', 'ESLints JavaScript & Stylelints LESS', function(target) {
let command = 'yarn run lint';
let command = 'yarn lint';
if (target === 'js') {
command = command + ':js';
}
@@ -253,7 +233,7 @@ module.exports = function(grunt) {
});

grunt.registerTask('docs', 'Generate API documentation', function() {
runCommand('yarn run docs', '.');
runCommand('yarn docs', '.');
});

grunt.registerTask('karma:local', [
@@ -1,10 +1,9 @@
Last 10 Chrome versions
Last 10 ChromeAndroid versions
Last 10 Firefox versions
Chrome >= 55
ChromeAndroid >= 55
Firefox >= 51
FirefoxAndroid >= 54
Safari >= 9
Last 4 Edge versions
Edge >= 12
IE 11
ExplorerMobile 11
iOS >= 9.2
Android >= 4.4
@@ -0,0 +1,25 @@
'use strict';

/* eslint-env node */
/* eslint no-process-env: 0 */

const packageInfo = require('./package.json');
const env = process.env;

module.exports = () => {
// Build Version: {major.minor.revision}
let metadata = '';
if (env.BUILD_NUMBER) {
const branch = env.GIT_BRANCH;
metadata = 'opensource';
if (branch) {
metadata += '_' + branch.replace(/^origin\//, '').replace(/[^0-9A-Za-z-]/g, '-');
}
metadata += '.' + env.BUILD_NUMBER;
} else {
const now = new Date();
now.setTime(now.getTime() - now.getTimezoneOffset() * 60000);
metadata = 'local.' + now.toISOString().replace(/[.\-:T]/g, '-').replace(/Z|\.\d/g, '');
}
return `${packageInfo.version}+${metadata}`;
};
@@ -5,23 +5,13 @@

const path = require('path');
const puppeteer = require('puppeteer');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js')({ release: true });
const merge = require('webpack-merge');
const webpackConfig = require('./webpack.config.js')({ debug: true });

const webpackKarmaConfig = Object.assign({}, webpackConfig, {
const webpackTestConfig = merge(webpackConfig, {
entry: null,
output: null,
mode: 'development',
devtool: false,
plugins: [
new webpack.DefinePlugin({
__SELF_HOSTED__: true,
__REPO__: '\'\'',
__DEBUG__: false,
__BUILD_VERSION__: '\'' + '8.2.2' + '\'',
__FLASH_VERSION__: 18.0
}),
],
externals: {
$: {
commonjs: 'jquery',
@@ -30,42 +20,34 @@ const webpackKarmaConfig = Object.assign({}, webpackConfig, {
},
sinon: 'sinon'
},
resolve: Object.assign({}, webpackConfig.resolve, {
alias: Object.assign({}, webpackConfig.resolve.alias || {}, {
resolve: {
alias: {
'test/underscore': path.resolve(__dirname + '/node_modules/underscore/underscore.js'),
'utils/video': path.resolve(__dirname + '/test/mock/video.js'),
// Tests using jQuery: api-test, jwplayer-selectplayer-test, setup-test
jquery: path.resolve(__dirname + '/node_modules/jquery/dist/jquery.js'),
sinon: path.resolve(__dirname + '/node_modules/sinon/pkg/sinon.js'),
data: path.resolve(__dirname + '/test/data'),
mock: path.resolve(__dirname + '/test/mock')
})
}),
module: Object.assign({}, webpackConfig.module, {
}
},
module: {
rules: [
{
enforce: 'post',
test: /\.js$/,
include: /(src)\/(js)\//,
loader: 'istanbul-instrumenter-loader'
}
].concat(webpackConfig.module.rules || []).map(rule => {
if (rule.options && rule.options.presets) {
rule.options.presets = rule.options.presets.map(preset => {
if (Array.isArray(preset) && preset[0] === 'env' && preset[1]) {
// karma-webpack fails if modules are not converted to commonjs by default
delete preset[1].modules;
}
return preset;
});
include: path.resolve('src/js/'),
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
}
return rule;
}),
],
noParse: [
/node_modules\/sinon\//,
/node_modules\/jquery\//
].concat(webpackConfig.module.noParse || [])
})
]
}
});

module.exports = function(config) {
@@ -159,7 +141,7 @@ module.exports = function(config) {
fixWebpackSourcePaths: true
},

webpack: webpackKarmaConfig,
webpack: webpackTestConfig,

// number of browsers to run at once
concurrency: Infinity
@@ -5,24 +5,23 @@
"repository": "git@github.com:jwplayer/jwplayer.git",
"homepage": "https://github.com/jwplayer/jwplayer",
"license": "CC-BY-NC-SA-3.0",
"private": true,
"dependencies": {},
"devDependencies": {
"@babel/core": "7.2.2",
"@babel/helper-module-imports": "7.0.0",
"@babel/preset-env": "7.3.1",
"async": "2.6.0",
"autoprefixer": "8.2.0",
"autoprefixer-loader": "3.2.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.4",
"babel-preset-env": "1.6.1",
"babel-loader": "8.0.5",
"chai": "4.1.2",
"css-loader": "0.28.11",
"css-loader": "2.1.0",
"danger": "3.4.5",
"eslint": "5.7.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-no-for-of-loops": "1.0.0",
"eslint-plugin-no-unsanitized": "3.0.2",
"esprima": "4.0.1",
"fast-diff": "1.1.2",
"file-loader": "1.1.11",
"grunt": "^1.0.2",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.1.0",
@@ -31,7 +30,6 @@
"grunt-contrib-watch": "1.0.0",
"grunt-karma": "2.0.0",
"grunt-postcss": "0.9.0",
"import-loader": "1.0.1",
"intersection-observer": "0.5.0",
"istanbul-instrumenter-loader": "3.0.1",
"jquery": "3.3.1",
@@ -50,30 +48,27 @@
"karma-sinon": "1.0.5",
"karma-sinon-chai": "2.0.2",
"karma-webpack": "3.0.5",
"less": "3.0.1",
"less": "3.9.0",
"less-loader": "4.1.0",
"load-grunt-tasks": "3.5.2",
"loader-utils": "1.1.0",
"marked": "0.3.19",
"mocha": "5.2.0",
"node-libs-browser": "2.1.0",
"postcss-easing-gradients": "3.0.0",
"postcss-loader": "2.1.3",
"postcss-easing-gradients": "3.0.1",
"postcss-loader": "3.0.0",
"postcss-safe-parser": "3.0.1",
"promise-polyfill": "7.1.1",
"puppeteer": "1.11.0",
"raw-loader": "0.5.1",
"requirejs": "2.3.5",
"simple-style-loader": "0.4.3",
"simple-style-loader": "0.4.4",
"sinon": "7.2.3",
"sinon-chai": "3.3.0",
"source-map": "0.7.2",
"stylelint": "9.2.0",
"svg-inline-loader": "0.8.0",
"underscore": "1.8.3",
"url-loader": "1.0.1",
"webpack": "4.5.0",
"webpack-cli": "2.0.13"
"webpack": "4.29.0",
"webpack-cli": "3.2.1",
"webpack-merge": "4.2.1"
},
"scripts": {
"build": "grunt",
@@ -1,3 +1,4 @@
/* eslint-disable quote-props, quotes */
export default {
"advertising": {
"admessage": "This ad will end in xx",
@@ -16,12 +16,9 @@ import { PlayerError, composePlayerError, convertToPlayerError,
SETUP_ERROR_LOADING_PLAYLIST, SETUP_ERROR_PROMISE_API_CONFLICT, SETUP_ERROR_UNKNOWN,
MSG_TECHNICAL_ERROR } from 'api/errors';

const ModelShim = function() {};
Object.assign(ModelShim.prototype, SimpleModel);

const CoreShim = function(originalContainer) {
this._events = {};
this.modelShim = new ModelShim();
this.modelShim = new SimpleModel();
this.modelShim._qoeItem = new Timer();
this.mediaShim = {};
this.setup = new Setup(this.modelShim);
Oops, something went wrong.

0 comments on commit 24bfb49

Please sign in to comment.