Skip to content

Commit 051db5e

Browse files
authored
chore(web-components): simplify compile script, tweak api-extractor config to stop spamming CI with warnings (#31422)
1 parent 708e422 commit 051db5e

File tree

6 files changed

+83
-78
lines changed

6 files changed

+83
-78
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "chore: simplify compile script, tweak api-extractor config to stop spamming CI with warnings",
4+
"packageName": "@fluentui/web-components",
5+
"email": "martinhochel@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33

4-
"mainEntryPointFilePath": "dist/dts/index.d.ts",
4+
"mainEntryPointFilePath": "<projectFolder>/dist/dts/index.d.ts",
55

66
"apiReport": {
77
"enabled": true,
8-
"reportFolder": "docs",
8+
"reportFolder": "<projectFolder>/docs",
99
"reportFileName": "api-report.md"
1010
},
1111

1212
"docModel": {
1313
"enabled": true,
14-
"apiJsonFilePath": "dist/fluent-web-components.api.json"
14+
"apiJsonFilePath": "<projectFolder>/dist/fluent-web-components.api.json"
1515
},
16-
1716
"dtsRollup": {
1817
"enabled": true
1918
},
2019
"compiler": {
20+
"skipLibCheck": false,
2121
"tsconfigFilePath": "./tsconfig.api-extractor.json"
22+
},
23+
"messages": {
24+
"tsdocMessageReporting": {
25+
"tsdoc-undefined-tag": {
26+
"logLevel": "none"
27+
},
28+
"tsdoc-unsupported-tag": {
29+
"logLevel": "none"
30+
},
31+
"tsdoc-param-tag-with-invalid-type": {
32+
"logLevel": "none"
33+
},
34+
"tsdoc-param-tag-missing-hyphen": {
35+
"logLevel": "none"
36+
}
37+
},
38+
"extractorMessageReporting": {
39+
"ae-forgotten-export": {
40+
"logLevel": "none"
41+
},
42+
"ae-missing-release-tag": {
43+
"logLevel": "none"
44+
},
45+
"ae-unresolved-link": {
46+
"logLevel": "none"
47+
},
48+
"ae-internal-missing-underscore": {
49+
"logLevel": "none"
50+
},
51+
"ae-different-release-tags": {
52+
"logLevel": "none"
53+
}
54+
}
2255
}
2356
}
Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,27 @@
11
/* eslint-disable no-undef */
2-
import * as path from 'path';
3-
import * as fs from 'fs';
4-
import { fileURLToPath } from 'url';
2+
53
import { execSync } from 'child_process';
64
import chalk from 'chalk';
75

8-
const __filename = fileURLToPath(import.meta.url);
9-
const __dirname = path.dirname(__filename);
10-
11-
const root = path.join(__dirname, '..');
12-
136
main();
147

158
function compile() {
16-
const packageJsonPath = path.join(root, 'package.json');
17-
const tsConfigLibPath = path.join(root, 'tsconfig.lib.json');
18-
const tsConfigSpecPath = path.join(root, 'tsconfig.spec.json');
19-
20-
const tsConfigLib = JSON.parse(fs.readFileSync(tsConfigLibPath, 'utf-8'));
21-
const tsConfigSpec = JSON.parse(fs.readFileSync(tsConfigSpecPath, 'utf-8'));
22-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
23-
24-
const modifiedTsConfigLib = overrideTsConfig({ ...tsConfigLib });
25-
const modifiedTsConfigSpec = overrideTsConfig({ ...tsConfigSpec });
26-
27-
const tempTsconfigLibPath = path.join(root, 'tsconfig.lib-generated.json');
28-
const tempTsconfigSpecPath = path.join(root, 'tsconfig.spec-generated.json');
29-
30-
fs.writeFileSync(tempTsconfigLibPath, JSON.stringify(modifiedTsConfigLib, null, 2), 'utf-8');
31-
fs.writeFileSync(tempTsconfigSpecPath, JSON.stringify(modifiedTsConfigSpec, null, 2), 'utf-8');
32-
33-
const workspaceDependencies = Object.keys(packageJson.dependencies).filter(depName =>
34-
depName.startsWith('@fluentui/'),
35-
);
36-
379
try {
3810
console.log(chalk.bold(`🎬 compile:start`));
3911

40-
console.log(chalk.blueBright(`compile: building workspace dependencies: ${workspaceDependencies}`));
41-
execSync(`lage build --to ${workspaceDependencies}`, { stdio: 'inherit' });
42-
4312
console.log(chalk.blueBright(`compile: generating design tokens`));
44-
execSync(`node ./scripts/generate-tokens.cjs`, { stdio: 'inherit' });
13+
execSync(`node ./scripts/generate-tokens`, { stdio: 'inherit' });
4514

4615
console.log(chalk.blueBright(`compile: running tsc`));
47-
execSync(`tsc -p tsconfig.lib-generated.json`, { stdio: 'inherit' });
48-
execSync(`tsc -p tsconfig.spec-generated.json`, { stdio: 'inherit' });
16+
execSync(`tsc -p tsconfig.lib.json --rootDir ./src --baseUrl .`, { stdio: 'inherit' });
4917

5018
console.log(chalk.bold(`🏁 compile:end`));
5119
} catch (err) {
5220
console.error(err);
5321
process.exit(1);
54-
} finally {
55-
fs.unlinkSync(tempTsconfigLibPath);
56-
fs.unlinkSync(tempTsconfigSpecPath);
5722
}
5823
}
5924

60-
/**
61-
*
62-
* @param {Record<string,any>} config
63-
*/
64-
function overrideTsConfig(config) {
65-
config.compilerOptions.paths = {};
66-
config.compilerOptions.rootDir = './src';
67-
return config;
68-
}
69-
7025
function main() {
7126
compile();
7227
}

packages/web-components/scripts/generate-tokens.cjs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
import chalk from 'chalk';
6+
7+
import tokensPackage from '@fluentui/tokens';
8+
9+
main();
10+
11+
function main() {
12+
console.log(tokensPackage);
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
15+
16+
const fluentTokens = Object.keys(tokensPackage.tokens);
17+
const comment = '// THIS FILE IS GENERATED AS PART OF THE BUILD PROCESS. DO NOT MANUALLY MODIFY THIS FILE\n';
18+
19+
const generatedTokens = fluentTokens.reduce((acc, t) => {
20+
const token = `export const ${t} = 'var(--${t})';\n`;
21+
return acc + token;
22+
}, '');
23+
24+
const dir = path.join(__dirname, '../src', 'theme');
25+
26+
if (!fs.existsSync(dir)) {
27+
fs.mkdirSync(dir, { recursive: true });
28+
}
29+
30+
fs.writeFile(path.join(dir, 'design-tokens.ts'), comment + generatedTokens, err => {
31+
if (err) throw err;
32+
console.log(chalk.greenBright(`Design token file has been successfully created!`));
33+
});
34+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./tsconfig.lib.json",
33
"compilerOptions": {
4-
"paths": {}
4+
"paths": null,
5+
"baseUrl": "."
56
}
67
}

0 commit comments

Comments
 (0)