Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve type-checking perf within all apps #31426

Merged
merged 7 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/perf-test-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"just": "just-scripts",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"type-check": "tsc -p . --noEmit",
"type-check": "just-scripts type-check",
"test:perf": "just-scripts perf-test"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions apps/perf-test-react-components/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "ES2019",
"outDir": "lib",
"jsx": "react",
"lib": ["ES2019", "DOM"],
"types": ["webpack-env"]
},
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
19 changes: 13 additions & 6 deletions apps/perf-test-react-components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ES2019",
"outDir": "lib",
"module": "commonjs",
"target": "ES2019",
"noEmit": true,
"isolatedModules": true,
"importHelpers": true,
"jsx": "react",
"experimentalDecorators": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"lib": ["ES2019", "DOM"],
"types": ["webpack-env"]
"skipLibCheck": true
},
"include": ["src"]
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
}
]
}
2 changes: 1 addition & 1 deletion apps/perf-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"just": "just-scripts",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"type-check": "tsc -p . --noEmit",
"type-check": "just-scripts type-check",
"test:perf": "just-scripts perf-test"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions apps/perf-test/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"outDir": "lib",
"jsx": "react",
"lib": ["ES2015", "DOM"],
"types": ["webpack-env", "node"]
},
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
14 changes: 8 additions & 6 deletions apps/perf-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"extends": "../../tsconfig.base.v8.json",
"compilerOptions": {
"target": "es5",
"outDir": "lib",
"module": "commonjs",
"jsx": "react",
"experimentalDecorators": true,
"preserveConstEnums": true,
"lib": ["ES2015", "DOM"],
"types": ["webpack-env", "node"]
"preserveConstEnums": true
},
"include": ["src"]
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
}
]
}
2 changes: 1 addition & 1 deletion apps/react-18-tests-v8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "8.0.0",
"private": true,
"scripts": {
"type-check": "tsc -p tsconfig.react-compat-check.json",
"type-check": "just-scripts type-check",
"format": "prettier -w . --ignore-path ../.prettierignore",
"format:check": "yarn format -c",
"e2e": "cypress run --component",
Expand Down
7 changes: 0 additions & 7 deletions apps/react-18-tests-v8/tsconfig.react-compat-check.json

This file was deleted.

2 changes: 1 addition & 1 deletion apps/react-18-tests-v9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"private": true,
"scripts": {
"type-check": "tsc -p tsconfig.react-compat-check.json",
"type-check": "just-scripts type-check",
"lint": "eslint --ext .js,.ts,.tsx ./src",
"test": "jest --passWithNoTests",
"format": "prettier -w . --ignore-path ../.prettierignore",
Expand Down
7 changes: 0 additions & 7 deletions apps/react-18-tests-v9/tsconfig.react-compat-check.json

This file was deleted.

2 changes: 1 addition & 1 deletion apps/recipes-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "prettier . -w --ignore-path ../../.prettierignore",
"lint": "just-scripts lint",
"start": "start-storybook",
"type-check": "tsc"
"type-check": "just-scripts type-check"
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
Expand Down
2 changes: 1 addition & 1 deletion apps/ssr-tests-v9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "just-scripts lint",
"storybook": "start-storybook",
"test": "jest --passWithNoTests",
"type-check": "tsc -b tsconfig.json",
"type-check": "just-scripts type-check",
"test-ssr": "test-ssr \"./src/stories/**/*.stories.tsx\""
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions apps/ssr-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Server-side rendering tests for @fluentui/react.",
"private": true,
"scripts": {
"type-check": "tsc -p . --noEmit --baseUrl .",
"build": "just-scripts build",
"bundle": "just-scripts bundle",
"test": "just-scripts test",
Expand Down
7 changes: 6 additions & 1 deletion apps/ssr-tests/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ describe('Utilities', () => {
});
});

/**
*
* @param {string} componentName
* @param {React.FunctionComponent} component
*/
function testRender(componentName, component) {
it(`${componentName} can render in a server environment`, done => {
let elem = React.createElement(component);

try {
ReactDOMServer.renderToString(elem);
done();
} catch (e) {
} catch (/** @type {any} */ e) {
done(new Error(e));
}
});
Expand Down
14 changes: 14 additions & 0 deletions apps/ssr-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"noEmit": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"checkJs": true,
"allowJs": true,
"types": ["node", "mocha"]
},
"include": ["test/"]
}
2 changes: 1 addition & 1 deletion apps/vr-tests-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "just-scripts lint",
"start": "start-storybook",
"test": "just-scripts test",
"type-check": "tsc",
"type-check": "tsc -p . --noEmit --baseUrl .",
"vr:build": "yarn build",
"vr:test": "storywright --browsers chromium --url dist/storybook --destpath dist/screenshots --waitTimeScreenshot 500 --concurrency 4 --headless true"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"just": "just-scripts",
"lint": "just-scripts lint",
"start": "start-storybook -p 3000",
"type-check": "tsc",
"type-check": "tsc -p . --noEmit --baseUrl .",
"vr:build": "yarn build",
"vr:test": "storywright --browsers chromium --url dist/storybook --destpath dist/screenshots --waitTimeScreenshot 500 --concurrency 4 --headless true"
},
Expand Down
6 changes: 5 additions & 1 deletion scripts/tasks/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,32 @@ export function getTsPathAliasesConfig() {
const tsConfigFileNames = {
root: 'tsconfig.json',
lib: 'tsconfig.lib.json',
app: 'tsconfig.app.json',
};
const tsConfigFilePaths = {
root: path.join(cwd, tsConfigFileNames.root),
lib: path.join(cwd, tsConfigFileNames.lib),
app: path.join(cwd, tsConfigFileNames.app),
};
const tsConfigFileContents = {
root: fs.existsSync(tsConfigFilePaths.root) ? fs.readFileSync(tsConfigFilePaths.root, 'utf-8') : null,
lib: fs.existsSync(tsConfigFilePaths.lib) ? fs.readFileSync(tsConfigFilePaths.lib, 'utf-8') : null,
app: fs.existsSync(tsConfigFilePaths.app) ? fs.readFileSync(tsConfigFilePaths.app, 'utf-8') : null,
};
const tsConfigs = {
root: tsConfigFileContents.root
? (parseJson(tsConfigFileContents.root, { expectComments: true }) as TsConfig)
: null,
lib: tsConfigFileContents.lib ? (parseJson(tsConfigFileContents.lib, { expectComments: true }) as TsConfig) : null,
app: tsConfigFileContents.app ? (parseJson(tsConfigFileContents.app, { expectComments: true }) as TsConfig) : null,
};
const packageJson: PackageJson = JSON.parse(fs.readFileSync(path.join(cwd, './package.json'), 'utf-8'));

const isUsingTsSolutionConfigs =
tsConfigs.root &&
tsConfigs.root.references &&
tsConfigs.root.references.length > 0 &&
Boolean(tsConfigFileContents.lib);
(Boolean(tsConfigFileContents.lib) || Boolean(tsConfigFileContents.app));

return {
tsConfigFileNames,
Expand Down
Loading