UNPKG

745 BJavaScriptView Raw
1/** Copyright (c) 2018 Uber Technologies, Inc.
2 *
3 * This source code is licensed under the MIT license found in the
4 * LICENSE file in the root directory of this source tree.
5 *
6 * @flow
7 */
8
9/* eslint-env node */
10
11const {Compiler} = require('../build/compiler');
12const analyzer = require('bundle-analyzer');
13
14exports.run = async function profileHandler(
15 {dir = '.', port, environment} /*: any */
16) {
17 const compiler = new Compiler({env: environment, dir, watch: true});
18 const server = analyzer.start({
19 dir: `${dir}/.fusion/dist/${environment}/client`,
20 port,
21 });
22 const watcher = compiler.start(() => {
23 server.update();
24 });
25 return {
26 compiler,
27 stop() {
28 watcher.close();
29 server.close();
30 },
31 };
32};