initial perf, which gets stripped out in production (#4131)
This commit is contained in:
@@ -41,7 +41,7 @@ var commonRules = [
|
|||||||
{ test: /\.(woff|woff2)(\?.*)?$/,
|
{ test: /\.(woff|woff2)(\?.*)?$/,
|
||||||
loader: "url-loader?limit=100000" },
|
loader: "url-loader?limit=100000" },
|
||||||
{ test: /\.(ttf|eot)(\?.*)?$/,
|
{ test: /\.(ttf|eot)(\?.*)?$/,
|
||||||
loader: "file-loader" }
|
loader: "file-loader" },
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = function(rules, options) {
|
module.exports = function(rules, options) {
|
||||||
|
|||||||
@@ -154,7 +154,8 @@
|
|||||||
"uglifyjs-webpack-plugin": "^1.2.5",
|
"uglifyjs-webpack-plugin": "^1.2.5",
|
||||||
"url-loader": "0.5.9",
|
"url-loader": "0.5.9",
|
||||||
"webpack": "^2.6.1",
|
"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": {
|
"config": {
|
||||||
"deps_check_dir": ".deps_check"
|
"deps_check_dir": ".deps_check"
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
|
|||||||
|
|
||||||
let specStr = specSelectors.specStr()
|
let specStr = specSelectors.specStr()
|
||||||
|
|
||||||
|
/* develblock:start */
|
||||||
|
require("root/src/perf").start("resolve")
|
||||||
|
/* develblock:end */
|
||||||
|
|
||||||
return resolve({
|
return resolve({
|
||||||
fetch,
|
fetch,
|
||||||
spec: json,
|
spec: json,
|
||||||
@@ -131,6 +135,9 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
|
|||||||
errActions.newThrownErrBatch(preparedErrors)
|
errActions.newThrownErrBatch(preparedErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* develblock:start */
|
||||||
|
require("root/src/perf").stop("resolve")
|
||||||
|
/* develblock:end */
|
||||||
return specActions.updateResolved(spec)
|
return specActions.updateResolved(spec)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,15 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
[UPDATE_RESOLVED]: (state, action) => {
|
[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) => {
|
[UPDATE_RESOLVED_SUBTREE]: (state, action) => {
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ const idFn = a => a
|
|||||||
function createStoreWithMiddleware(rootReducer, initialState, getSystem) {
|
function createStoreWithMiddleware(rootReducer, initialState, getSystem) {
|
||||||
|
|
||||||
let middlwares = [
|
let middlwares = [
|
||||||
// createLogger( {
|
/* develblock:start */
|
||||||
// stateTransformer: state => state && state.toJS()
|
// 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 )
|
systemThunkMiddleware( getSystem )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
16
src/perf.js
Normal file
16
src/perf.js
Normal 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 */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,17 @@ let rules = [
|
|||||||
},
|
},
|
||||||
{ loader: "babel-loader?retainLines=true" }
|
{ 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)
|
rules = rules.concat(styleRules)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const rules = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = require("./make-webpack-config")(rules, {
|
module.exports = require("./make-webpack-config")(rules, {
|
||||||
|
|||||||
@@ -5,4 +5,9 @@ config.plugins = config.plugins.filter(plugin => {
|
|||||||
return plugin.constructor.name !== "UglifyJsPlugin"
|
return plugin.constructor.name !== "UglifyJsPlugin"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
config.module.rules = config.module.rules.filter(rule => {
|
||||||
|
// Disable minification
|
||||||
|
return rule.loader != "webpack-strip-block"
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = config
|
module.exports = config
|
||||||
|
|||||||
Reference in New Issue
Block a user