Skip to content

Commit

Permalink
chore(scripts): remove obsolete configs and fix webpack perf tsconfig…
Browse files Browse the repository at this point in the history
… path
  • Loading branch information
Hotell committed Apr 3, 2023
1 parent 618bccf commit 52d15ed
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
18 changes: 10 additions & 8 deletions packages/fluentui/perf/gulp/perf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express from 'express';
import fs from 'fs';
import * as fs from 'fs';
import * as path from 'path';
import type { Server } from 'http';
import { series, task } from 'gulp';
import { colors, log } from 'gulp-util';
Expand All @@ -20,7 +21,7 @@ import type {
ReducedMeasures,
} from '../types';

const { paths } = config;
import { packageDist } from './shared';

const DEFAULT_RUN_TIMES = 10;
let server: Server;
Expand Down Expand Up @@ -114,6 +115,7 @@ const createMarkdownTable = (perExamplePerfMeasures: PerExamplePerfMeasures) =>

async function runMeasures(
browser: Browser,
url: string,
filter: string,
mode: string,
times: number,
Expand All @@ -129,7 +131,7 @@ async function runMeasures(

if (mode === 'new-page') {
for (let i = 0; i < times; i++) {
const page = await browser.openPage(`http://${config.server_host}:${config.perf_port}`);
const page = await browser.openPage(url);

const measuresFromStep = await page.executeJavaScript<ProfilerMeasureCycle>(codeToExecute);
measures.push(measuresFromStep);
Expand All @@ -138,7 +140,7 @@ async function runMeasures(
await page.close();
}
} else if (mode === 'same-page') {
const page = await browser.openPage(`http://${config.server_host}:${config.perf_port}`);
const page = await browser.openPage(url);

// Empty run to skip slow first run
await page.executeJavaScript<ProfilerMeasureCycle>(codeToExecute);
Expand All @@ -158,7 +160,7 @@ async function runMeasures(
return measures;
}

task('perf:clean', () => del(paths.perfDist(), { force: true }));
task('perf:clean', () => del(packageDist, { force: true }));

task('perf:build', cb => {
webpackPlugin(require('./webpack.config').webpackConfig, cb);
Expand Down Expand Up @@ -187,12 +189,12 @@ task('perf:run', async () => {
let measures: ProfilerMeasureCycle[];

try {
measures = await runMeasures(browser, filter, mode, times);
measures = await runMeasures(browser, `http://${config.server_host}:${config.perf_port}`, filter, mode, times);
} finally {
await browser.close();
}

const resultsFile = paths.perfDist('result.json');
const resultsFile = path.join(packageDist, 'result.json');
const perExamplePerfMeasures = sumByExample(measures);

fs.writeFileSync(resultsFile, JSON.stringify(perExamplePerfMeasures, null, 2));
Expand All @@ -204,7 +206,7 @@ task('perf:run', async () => {

task('perf:serve', cb => {
server = express()
.use(express.static(paths.perfDist()))
.use(express.static(packageDist))
.listen(config.perf_port, config.server_host, () => {
log(colors.yellow('Server running at http://%s:%d'), config.server_host, config.perf_port);
cb();
Expand Down
6 changes: 6 additions & 0 deletions packages/fluentui/perf/gulp/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as path from 'path';

export const packageRoot = path.join(__dirname, '..');

export const packageDist = path.join(packageRoot, 'dist');
export const packageSrc = path.join(packageRoot, 'src');
17 changes: 6 additions & 11 deletions packages/fluentui/perf/gulp/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import webpack from 'webpack';
import { config } from '@fluentui/scripts-gulp';
import { getDefaultEnvironmentVars } from '@fluentui/scripts-monorepo';

const { paths } = config;
import { packageDist, packageSrc, packageRoot } from './shared';

export const webpackConfig: webpack.Configuration = {
name: 'client',
target: 'web',
// eslint-disable-next-line no-extra-boolean-cast
mode: Boolean(argv.debug) ? 'development' : 'production',
entry: {
app: path.join(__dirname, '..', 'src/index'),
app: path.join(packageSrc, 'index'),
},
output: {
filename: `[name].js`,
path: path.join(__dirname, '..', 'dist'),
path: packageDist,
pathinfo: true,
publicPath: config.compiler_public_path,
},
Expand All @@ -44,14 +44,14 @@ export const webpackConfig: webpack.Configuration = {
new webpack.DefinePlugin(getDefaultEnvironmentVars(!argv.debug)),
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: paths.e2e('tsconfig.json'),
configFile: path.join(packageRoot, 'tsconfig.json'),
},
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.join(__dirname, '..', 'src/index.html'),
to: path.join(__dirname, '..', 'dist'),
from: path.join(packageRoot, 'src/index.html'),
to: packageDist,
},
],
}),
Expand All @@ -63,16 +63,11 @@ export const webpackConfig: webpack.Configuration = {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
...config.lernaAliases({ type: 'webpack' }),
src: paths.packageSrc('react-northstar'),

// We are using React in production mode with tracing.
// https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',

// Can be removed once Prettier will be upgraded to v2
// https://github.com/prettier/prettier/issues/6903
'@microsoft/typescript-etw': false,
},
},
performance: {
Expand Down
2 changes: 1 addition & 1 deletion packages/fluentui/perf/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as minimatch from 'minimatch';
import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { ProfilerMeasure, ProfilerMeasureCycle } from '../types';
import type { ProfilerMeasure, ProfilerMeasureCycle } from '../types';

const mountNode = document.querySelector('#root');
const performanceExamplesContext = require.context('@fluentui/docs/src/examples/', true, /.perf.tsx$/);
Expand Down
7 changes: 2 additions & 5 deletions scripts/gulp/src/webpack/webpack.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getDefaultEnvironmentVars } from '@fluentui/scripts-monorepo';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import webpack from 'webpack';

import { getDefaultEnvironmentVars } from '@fluentui/scripts-monorepo';

import config from '../config';

Expand All @@ -25,10 +25,7 @@ const webpackConfig: webpack.Configuration = {
global: true,
},
module: {
noParse: [
/anchor-js/,
/prettier\/parser-typescript/, // prettier issue, should be solved after upgrade prettier to version 2 https://github.com/prettier/prettier/issues/6903
],
noParse: [/anchor-js/],
rules: [
{
test: /\.(js|ts|tsx)$/,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.v0.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"strictNullChecks": false,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types", "./typings"],
"baseUrl": ".",
"paths": {
Expand Down

0 comments on commit 52d15ed

Please sign in to comment.