client/build: remove babel when not transpiling
This commit is contained in:
parent
69fe8ec31a
commit
249d6073c0
4 changed files with 21 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"preset": "google",
|
preset: "google",
|
||||||
"fileExtensions": [".js", "jscs"],
|
fileExtensions: [".js", "jscs"],
|
||||||
"validateIndentation": 4,
|
validateIndentation: 4,
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,6 @@ function writeJsBundle(b, path, message, compress) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bundleJs(config) {
|
function bundleJs(config) {
|
||||||
const babelify = require('babelify');
|
|
||||||
const browserify = require('browserify');
|
const browserify = require('browserify');
|
||||||
const external = [
|
const external = [
|
||||||
'lodash',
|
'lodash',
|
||||||
|
@ -126,7 +125,6 @@ function bundleJs(config) {
|
||||||
'js-cookie',
|
'js-cookie',
|
||||||
'page',
|
'page',
|
||||||
'nprogress',
|
'nprogress',
|
||||||
'babel-polyfill',
|
|
||||||
];
|
];
|
||||||
glob('./js/**/*.js', {}, (er, files) => {
|
glob('./js/**/*.js', {}, (er, files) => {
|
||||||
if (!process.argv.includes('--no-vendor-js')) {
|
if (!process.argv.includes('--no-vendor-js')) {
|
||||||
|
@ -134,6 +132,9 @@ function bundleJs(config) {
|
||||||
for (let lib of external) {
|
for (let lib of external) {
|
||||||
b.require(lib);
|
b.require(lib);
|
||||||
}
|
}
|
||||||
|
if (config.transpile) {
|
||||||
|
b.add(require.resolve('babel-polyfill'));
|
||||||
|
}
|
||||||
writeJsBundle(
|
writeJsBundle(
|
||||||
b, './public/vendor.min.js', 'Bundled vendor JS', true);
|
b, './public/vendor.min.js', 'Bundled vendor JS', true);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +143,7 @@ function bundleJs(config) {
|
||||||
let outputFile = fs.createWriteStream('./public/app.min.js');
|
let outputFile = fs.createWriteStream('./public/app.min.js');
|
||||||
let b = browserify({debug: config.debug});
|
let b = browserify({debug: config.debug});
|
||||||
if (config.transpile) {
|
if (config.transpile) {
|
||||||
b = b.transform(babelify);
|
b = b.transform('babelify');
|
||||||
}
|
}
|
||||||
writeJsBundle(
|
writeJsBundle(
|
||||||
b.external(external).add(files),
|
b.external(external).add(files),
|
||||||
|
|
|
@ -14,15 +14,15 @@ const UsersHeaderView = require('../views/users_header_view.js');
|
||||||
const UsersPageView = require('../views/users_page_view.js');
|
const UsersPageView = require('../views/users_page_view.js');
|
||||||
const EmptyView = require('../views/empty_view.js');
|
const EmptyView = require('../views/empty_view.js');
|
||||||
|
|
||||||
const rankNames = {
|
const rankNames = new Map([
|
||||||
anonymous: 'Anonymous',
|
['anonymous', 'Anonymous'],
|
||||||
restricted: 'Restricted user',
|
['restricted', 'Restricted user'],
|
||||||
regular: 'Regular user',
|
['regular', 'Regular user'],
|
||||||
power: 'Power user',
|
['power', 'Power user'],
|
||||||
moderator: 'Moderator',
|
['moderator', 'Moderator'],
|
||||||
administrator: 'Administrator',
|
['administrator', 'Administrator'],
|
||||||
nobody: 'Nobody',
|
['nobody', 'Nobody'],
|
||||||
};
|
]);
|
||||||
|
|
||||||
class UsersController {
|
class UsersController {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -96,7 +96,7 @@ class UsersController {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
api.get('/user/' + ctx.params.name).then(response => {
|
api.get('/user/' + ctx.params.name).then(response => {
|
||||||
response.user.rankName = rankNames[response.user.rank];
|
response.user.rankName = rankNames.get(response.user.rank);
|
||||||
ctx.state.user = response.user;
|
ctx.state.user = response.user;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
this._cachedUser = response.user;
|
this._cachedUser = response.user;
|
||||||
|
@ -228,7 +228,7 @@ class UsersController {
|
||||||
if (rankIdx > myRankIdx) {
|
if (rankIdx > myRankIdx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ranks[rankIdentifier] = Object.values(rankNames)[rankIdx];
|
ranks[rankIdentifier] = rankNames.values()[rankIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
|
|
|
@ -1,32 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('babel-polyfill');
|
|
||||||
|
|
||||||
const keys = Reflect.ownKeys;
|
|
||||||
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
|
|
||||||
const concat = Function.bind.call(Function.call, Array.prototype.concat);
|
|
||||||
const isEnumerable = Function.bind.call(
|
|
||||||
Function.call, Object.prototype.propertyIsEnumerable);
|
|
||||||
|
|
||||||
if (!Object.values) {
|
|
||||||
Object.values = function values(O) {
|
|
||||||
return reduce(keys(O), (v, k) => concat(
|
|
||||||
v, typeof k === 'string' && isEnumerable(O, k) ?
|
|
||||||
[O[k]] :
|
|
||||||
[]), []);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Object.entries) {
|
|
||||||
Object.entries = function entries(O) {
|
|
||||||
return reduce(
|
|
||||||
keys(O), (e, k) =>
|
|
||||||
concat(e, typeof k === 'string' && isEnumerable(O, k) ?
|
|
||||||
[[k, O[k]]] :
|
|
||||||
[]), []);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix iterating over NodeList in Chrome and Opera
|
// fix iterating over NodeList in Chrome and Opera
|
||||||
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
||||||
|
|
||||||
|
@ -39,6 +12,7 @@ Node.prototype.prependChild = function(child) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// non standard
|
||||||
Promise.prototype.always = function(onResolveOrReject) {
|
Promise.prototype.always = function(onResolveOrReject) {
|
||||||
return this.then(
|
return this.then(
|
||||||
onResolveOrReject,
|
onResolveOrReject,
|
||||||
|
@ -48,6 +22,7 @@ Promise.prototype.always = function(onResolveOrReject) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// non standard
|
||||||
if (!String.prototype.format) {
|
if (!String.prototype.format) {
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
let str = this.toString();
|
let str = this.toString();
|
||||||
|
@ -66,6 +41,7 @@ if (!String.prototype.format) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// non standard
|
||||||
Number.prototype.between = function(a, b, inclusive) {
|
Number.prototype.between = function(a, b, inclusive) {
|
||||||
const min = Math.min(a, b);
|
const min = Math.min(a, b);
|
||||||
const max = Math.max(a, b);
|
const max = Math.max(a, b);
|
||||||
|
|
Loading…
Reference in a new issue