-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web-components): introduce ts-solution configs and monorepo set…
…up/DX (#26843) * chore(web-components): implement ts path aliases setup with valid ts compilation * chore(web-components): refactor test setup and test/sb utils approach * fix(web-components): tweak npmignore to not ship non relevant assets * chore: re-generate api-report * generate change file * fixup! chore(web-components): refactor test setup and test/sb utils approach
- Loading branch information
Showing
28 changed files
with
217 additions
and
53 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-web-components-516db34f-7e06-4348-a459-507ea3b7c881.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "chore(web-components): introduce ts-solution configs and monorepo setup/DX", | ||
"packageName": "@fluentui/web-components", | ||
"email": "martinhochel@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"checkJs": true, | ||
"noEmit": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["*", "../public", "../src/**/*.stories.*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
packages/web-components/build/clean.cjs → packages/web-components/scripts/clean.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* eslint-disable no-undef */ | ||
import * as path from 'path'; | ||
import * as fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import { execSync } from 'child_process'; | ||
import chalk from 'chalk'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const root = path.join(__dirname, '..'); | ||
|
||
main(); | ||
|
||
function compile() { | ||
const packageJsonPath = path.join(root, 'package.json'); | ||
const tsConfigLibPath = path.join(root, 'tsconfig.lib.json'); | ||
const tsConfigSpecPath = path.join(root, 'tsconfig.spec.json'); | ||
|
||
const tsConfigLib = JSON.parse(fs.readFileSync(tsConfigLibPath, 'utf-8')); | ||
const tsConfigSpec = JSON.parse(fs.readFileSync(tsConfigSpecPath, 'utf-8')); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); | ||
|
||
const modifiedTsConfigLib = overrideTsConfig({ ...tsConfigLib }); | ||
const modifiedTsConfigSpec = overrideTsConfig({ ...tsConfigSpec }); | ||
|
||
const tempTsconfigLibPath = path.join(root, 'tsconfig.lib-generated.json'); | ||
const tempTsconfigSpecPath = path.join(root, 'tsconfig.spec-generated.json'); | ||
|
||
fs.writeFileSync(tempTsconfigLibPath, JSON.stringify(modifiedTsConfigLib, null, 2), 'utf-8'); | ||
fs.writeFileSync(tempTsconfigSpecPath, JSON.stringify(modifiedTsConfigSpec, null, 2), 'utf-8'); | ||
|
||
const workspaceDependencies = Object.keys(packageJson.dependencies).filter(depName => | ||
depName.startsWith('@fluentui/'), | ||
); | ||
|
||
try { | ||
console.log(chalk.bold(`🎬 compile:start`)); | ||
|
||
console.log(chalk.blueBright(`compile: building workspace dependencies: ${workspaceDependencies}`)); | ||
execSync(`lage build --to ${workspaceDependencies}`, { stdio: 'inherit' }); | ||
|
||
console.log(chalk.blueBright(`compile: running tsc`)); | ||
execSync(`tsc -p tsconfig.lib-generated.json`, { stdio: 'inherit' }); | ||
execSync(`tsc -p tsconfig.spec-generated.json`, { stdio: 'inherit' }); | ||
|
||
console.log(chalk.bold(`🏁 compile:end`)); | ||
} catch (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} finally { | ||
fs.unlinkSync(tempTsconfigLibPath); | ||
fs.unlinkSync(tempTsconfigSpecPath); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param {Record<string,any>} config | ||
*/ | ||
function overrideTsConfig(config) { | ||
config.compilerOptions.paths = {}; | ||
config.compilerOptions.rootDir = './src'; | ||
return config; | ||
} | ||
|
||
function main() { | ||
compile(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable no-undef */ | ||
/** | ||
* | ||
* @param r {__WebpackModuleApi.RequireContext} | ||
*/ | ||
function importAll(r) { | ||
r.keys().forEach(r); | ||
} | ||
|
||
// Explicitly add to browser test | ||
importAll(require.context('../dist/esm', true, /\.spec\.js$/)); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/web-components/src/counter-badge/counter-badge.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/web-components/src/progress-bar/progress-bar.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.