forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonosize.config.mjs
More file actions
53 lines (50 loc) · 2.06 KB
/
Copy pathmonosize.config.mjs
File metadata and controls
53 lines (50 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// @ts-check
import fs from 'node:fs';
import path from 'node:path';
import webpackBundler from 'monosize-bundler-webpack';
import gitStorage from 'monosize-storage-git';
/**
* Single source of truth for the bundle-size report artifact name and path.
*
* `monosize-storage-git` reads the base report from a GitHub Actions artifact by
* matching this exact name, but it does NOT control the `actions/upload-artifact`
* step that produces it — so these values must be consumed by the workflow instead
* of being duplicated there. See `.github/scripts/monosize-report-artifact-meta.mjs`.
*/
export const reportArtifactName = 'monosize-bundle-size-report';
export const reportOutputPath = 'dist/bundle-size-report.json';
/** @type {import('monosize').MonoSizeConfig} */
const config = {
repository: 'https://github.com/microsoft/fluentui',
storage: gitStorage({
owner: 'microsoft',
repo: 'fluentui',
workflowFileName: 'bundle-size-base.yml',
outputPath: reportOutputPath,
artifactName: reportArtifactName,
}),
bundler: webpackBundler(config => {
config.externals = config.externals ?? {};
config.externals = {
react: 'React',
'react/jsx-runtime': 'jsxRuntime',
'react-dom': 'ReactDOM',
'react/compiler-runtime': 'ReactCompilerRuntime',
};
// ESM-first packages emit bare subpath imports (e.g. `use-sync-external-store/shim`) that lack
// a file extension. Once measured packages are `type: module`, webpack treats their `lib/` as
// ESM and enforces fully-specified imports; disable that so legacy CJS deps still resolve.
config.module = config.module ?? {};
config.module.rules = config.module.rules ?? [];
config.module.rules.push({ test: /\.[cm]?js$/, resolve: { fullySpecified: false } });
return config;
}),
reportResolvers: {
packageName: async packageRoot => {
const packageJson = await fs.promises.readFile(path.join(packageRoot, 'package.json'), 'utf-8');
const json = JSON.parse(packageJson);
return json.name.replace('@fluentui/', '');
},
},
};
export default config;