-
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.
Merge branch 'master' into add-mhtml-extension-to-filetypeiconmap
- Loading branch information
Showing
308 changed files
with
4,089 additions
and
771 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
import { preset, task, resolveCwd } from '@fluentui/scripts-tasks'; | ||
import * as path from 'path'; | ||
import { preset, task, series } from '@fluentui/scripts-tasks'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore - parallel-webpack has no types | ||
import { run } from 'parallel-webpack'; | ||
|
||
import { bundleSizeCollect } from './scripts/bundle-size-collect'; | ||
import { mergeBundleSizes } from './scripts/merge-bundlesizes'; | ||
|
||
preset(); | ||
|
||
// This pacakge doesn't currently have any files that are included in the eslint task | ||
// (it only runs on src, not config files) | ||
task('code-style', 'prettier'); | ||
|
||
task('bundle-size-collect', () => { | ||
const packageName = process.env.PACKAGE ?? ''; | ||
bundleSizeCollect({ packageName }); | ||
}); | ||
|
||
task('bundle', done => { | ||
run(resolveCwd('webpack.config.js'), {}, done); | ||
const configPath = path.join(__dirname, 'webpack.config.js'); | ||
const options = {}; | ||
run(configPath, options, done); | ||
}); | ||
|
||
task('bundle-size-merge', () => { | ||
const root = path.join(__dirname, 'dist'); | ||
mergeBundleSizes( | ||
[path.join(root, 'react/bundlesize.json'), path.join(root, 'react-northstar/bundlesize.json')], | ||
path.join(root, 'bundlesizes.json'), | ||
); | ||
}); | ||
|
||
task('bundle-size', series('bundle', 'bundle-size-collect')); |
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,40 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
/** | ||
* | ||
* collates bundle size information from minified files in apps/test-bundles/dist/<packageName> and writes to apps/test-bundles/dist/<packageName>/bundlesizes.json. | ||
* | ||
* It is uploaded as an artifact by the build definition in Azure Dev Ops and used to compare baseline and PR file size information which gets reported by Size Auditor | ||
*/ | ||
export function bundleSizeCollect(config: { packageName: string; filename?: string }) { | ||
const { packageName, filename: outputFilename = 'bundlesize.json' } = config; | ||
|
||
if (!packageName) { | ||
throw new Error('🚨 No packageName provided! Set it via env variable name "PACKAGE"'); | ||
} | ||
|
||
const distRoot = path.join(__dirname, '../dist', packageName.replace('@fluentui/', '')); | ||
|
||
const sizes: Record<string, number> = {}; | ||
|
||
const items = fs.readdirSync(distRoot); | ||
items.forEach(item => { | ||
const file = path.join(distRoot, item); | ||
|
||
const isMinifiedJavascriptFile = item.match(/.min.js$/); | ||
if (isMinifiedJavascriptFile) { | ||
sizes[getComponentName(item)] = getFilesizeInBytes(file); | ||
} | ||
}); | ||
|
||
fs.writeFileSync(path.join(distRoot, outputFilename), JSON.stringify({ sizes })); | ||
|
||
function getFilesizeInBytes(fileName: string) { | ||
return fs.statSync(fileName).size; | ||
} | ||
|
||
function getComponentName(fileName: string) { | ||
return path.basename(fileName, '.min.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as fs from 'fs'; | ||
|
||
export function mergeBundleSizes(configPaths: string[], mergeConfigPath: string) { | ||
const result: { sizes: { [entryName: string]: number } } = { | ||
sizes: {}, | ||
}; | ||
|
||
configPaths.forEach(configPath => { | ||
const json = JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
Object.assign(result.sizes, json.sizes); | ||
}); | ||
|
||
fs.writeFileSync(mergeConfigPath, JSON.stringify(result)); | ||
} |
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
Oops, something went wrong.