feat: build profiling

This commit is contained in:
cha0s 2022-03-17 18:27:44 -05:00
parent a7150c1d92
commit 78b4d3a828

View File

@ -1,9 +1,15 @@
import {join} from 'path';
import airbnb from '@neutrinojs/airbnb';
import {Hooks} from '../flecks';
import commands from './commands';
import R from '../bootstrap/require';
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
export {dump as dumpYml, load as loadYml} from 'js-yaml';
export {
@ -21,10 +27,21 @@ export {JsonStream, transform} from './stream';
export default {
[Hooks]: {
'@flecks/core.build': (target, config, flecks) => {
const {'eslint.exclude': exclude} = flecks.get('@flecks/core/server');
if (-1 !== exclude.indexOf(target)) {
return;
const {
'eslint.exclude': exclude,
profile,
} = flecks.get('@flecks/core/server');
if (-1 !== profile.indexOf(target)) {
config.use.push(({config}) => {
config
.plugin('profiler')
.use(
R.resolve('webpack/lib/debug/ProfilingPlugin'),
[{outputPath: join(FLECKS_CORE_ROOT, `profile.build-${target}.json`)}],
);
});
}
if (-1 === exclude.indexOf(target)) {
const baseConfig = R(flecks.buildConfig('.eslint.defaults.js', target));
config.use.unshift(
airbnb({
@ -38,6 +55,7 @@ export default {
},
}),
);
}
},
'@flecks/core.build.config': () => [
/**
@ -68,6 +86,10 @@ export default {
* Build targets to exclude from ESLint.
*/
'eslint.exclude': [],
/**
* Build targets to profile with `webpack.debug.ProfilingPlugin`.
*/
profile: [],
}),
},
};