initial perf, which gets stripped out in production (#4131)

This commit is contained in:
Josh Ponelat
2018-05-30 22:44:19 +02:00
committed by kyle
parent d91e4e84b8
commit 5ea2150ae7
9 changed files with 61 additions and 8 deletions

View File

@@ -41,7 +41,7 @@ var commonRules = [
{ test: /\.(woff|woff2)(\?.*)?$/,
loader: "url-loader?limit=100000" },
{ test: /\.(ttf|eot)(\?.*)?$/,
loader: "file-loader" }
loader: "file-loader" },
]
module.exports = function(rules, options) {

View File

@@ -154,7 +154,8 @@
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "0.5.9",
"webpack": "^2.6.1",
"webpack-bundle-size-analyzer": "^2.5.0"
"webpack-bundle-size-analyzer": "^2.5.0",
"webpack-strip-block": "^0.2.0"
},
"config": {
"deps_check_dir": ".deps_check"

View File

@@ -104,6 +104,10 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
let specStr = specSelectors.specStr()
/* develblock:start */
require("root/src/perf").start("resolve")
/* develblock:end */
return resolve({
fetch,
spec: json,
@@ -131,6 +135,9 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
errActions.newThrownErrBatch(preparedErrors)
}
/* develblock:start */
require("root/src/perf").stop("resolve")
/* develblock:end */
return specActions.updateResolved(spec)
})
}

View File

@@ -42,7 +42,15 @@ export default {
},
[UPDATE_RESOLVED]: (state, action) => {
return state.setIn(["resolved"], fromJSOrdered(action.payload))
/* develblock:start */
require("root/src/perf").start("UPDATE_RESOLVED")
/* develblock:end */
const resolved = fromJSOrdered(action.payload)
/* develblock:start */
require("root/src/perf").stop("UPDATE_RESOLVED")
/* develblock:end */
return state.setIn(["resolved"], resolved)
},
[UPDATE_RESOLVED_SUBTREE]: (state, action) => {

View File

@@ -15,9 +15,15 @@ const idFn = a => a
function createStoreWithMiddleware(rootReducer, initialState, getSystem) {
let middlwares = [
// createLogger( {
// stateTransformer: state => state && state.toJS()
// } ),
/* develblock:start */
// Measure actions
() => next => action => {
require("root/src/perf").start("action:"+action.type)
const res = next(action)
require("root/src/perf").stop("action:"+action.type)
return res
},
/* develblock:end */
systemThunkMiddleware( getSystem )
]

16
src/perf.js Normal file
View File

@@ -0,0 +1,16 @@
// This uses experimental console methods, to track performance
module.exports = {
start(str) {
/* develblock:start */
// eslint-disable-next-line no-console
console.time(str)
/* develblock:end */
},
stop(str) {
/* develblock:start */
// eslint-disable-next-line no-console
console.timeEnd(str)
/* develblock:end */
}
}

View File

@@ -15,7 +15,17 @@ let rules = [
},
{ loader: "babel-loader?retainLines=true" }
]
}
},
// This will strip out blocks of code that start with:
/* develblock:start */
// And end with
/* develblock:end */
{
test: /\.jsx?$/,
enforce: "pre",
exclude: /(node_modules|\.spec\.js)/,
loader: "webpack-strip-block"
},
]
rules = rules.concat(styleRules)

View File

@@ -35,7 +35,7 @@ const rules = [
}
}
]
}
},
]
module.exports = require("./make-webpack-config")(rules, {

View File

@@ -5,4 +5,9 @@ config.plugins = config.plugins.filter(plugin => {
return plugin.constructor.name !== "UglifyJsPlugin"
})
config.module.rules = config.module.rules.filter(rule => {
// Disable minification
return rule.loader != "webpack-strip-block"
})
module.exports = config