build: remove commonjs exports

This commit is contained in:
Pig Fang 2017-12-24 11:40:15 +08:00
parent 88502a3db1
commit 04a88a2e30
24 changed files with 29 additions and 21 deletions

View File

@ -6,6 +6,9 @@
}
}]
],
"plugins": [
"transform-inline-environment-variables"
],
"env": {
"test": {
"plugins": [

View File

@ -30,7 +30,7 @@ module.exports = {
"ecmaVersion": 2017
},
"env":{
"commonjs": true,
"node": true,
"es6": true,
"browser": true,
"jest": true,

View File

@ -23,6 +23,7 @@
"timers": "fake"
},
"devDependencies": {
"babel-plugin-transform-inline-environment-variables": "^0.2.0",
"babel-plugin-transform-remove-console": "^6.8.5",
"babel-preset-env": "^1.6.1",
"codecov": "^3.0.0",

View File

@ -51,7 +51,7 @@ async function sendFeedback() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
sendFeedback,
initTables

View File

@ -25,6 +25,6 @@ async function submitColor() {
$('#color-submit').click(submitColor);
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = submitColor;
}

View File

@ -191,7 +191,7 @@ async function deletePlayer(pid) {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
changeOwner,
showNicknameInSwal,

View File

@ -67,7 +67,7 @@ async function deletePlugin(name) {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
deletePlugin,
enablePlugin,

View File

@ -271,7 +271,7 @@ function initPluginsTable() {
});
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
initUsersTable,
initPlayersTable,

View File

@ -101,7 +101,7 @@ async function checkForUpdates() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
checkForUpdates,
progressPolling,

View File

@ -215,7 +215,7 @@ $('body').on('keypress', '.score', function(event){
}
});
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
changeUserPwd,
changeBanStatus,

View File

@ -10,6 +10,6 @@ function refreshCaptcha() {
$('.captcha').click(refreshCaptcha);
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = refreshCaptcha;
}

View File

@ -59,6 +59,6 @@ var docCookies = {
}
};
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = docCookies;
}

View File

@ -48,7 +48,7 @@ function trans(key, parameters = {}) {
return temp;
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
trans,
loadLocales,

View File

@ -69,7 +69,7 @@ function showModal(msg, title = 'Message', type = 'default', options = {}) {
}).modal(options);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
showMsg,
showModal,

View File

@ -115,6 +115,6 @@ $('.fa-pause').click(function () {
$('.fa-forward').click(() => MSP.setStatus('running', ! MSP.getStatus('running')));
$('.fa-repeat' ).click(() => MSP.setStatus('rotation', ! MSP.getStatus('rotation')));
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = TexturePreview;
}

View File

@ -139,7 +139,7 @@ function url(relativeUri = '') {
return blessing.base_url + relativeUri;
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
url,
fetch,

View File

@ -226,7 +226,7 @@ function updateBreadCrumb() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
initSkinlib,
renderSkinlib,

View File

@ -222,7 +222,7 @@ async function deleteTexture(tid) {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
toggleLiked,
addToCloset,

View File

@ -131,6 +131,6 @@ function upload() {
});
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = upload;
}

View File

@ -337,7 +337,7 @@ async function setTexture() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
setAsAvatar,
renderCloset,

View File

@ -204,7 +204,7 @@ async function addNewPlayer() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
addNewPlayer,
clearTexture,

View File

@ -181,7 +181,7 @@ async function deleteAccount() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = {
changeEmail,
deleteAccount,

View File

@ -36,6 +36,6 @@ async function sign() {
}
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
if (process.env.NODE_ENV === 'test') {
module.exports = sign;
}

View File

@ -685,6 +685,10 @@ babel-plugin-transform-exponentiation-operator@^6.22.0:
babel-plugin-syntax-exponentiation-operator "^6.8.0"
babel-runtime "^6.22.0"
babel-plugin-transform-inline-environment-variables@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-environment-variables/-/babel-plugin-transform-inline-environment-variables-0.2.0.tgz#37dad411a819667fd69c33e72f7a14ea1a50ba98"
babel-plugin-transform-regenerator@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f"