Skip to content

Commit d632373

Browse files
authored
[infra] Migrate build command to code-infra (#46614)
1 parent 46e6588 commit d632373

File tree

29 files changed

+200
-301
lines changed

29 files changed

+200
-301
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ jobs:
253253
- run:
254254
name: Build declaration files
255255
command: |
256-
pnpm -r build:stable && pnpm -r build:types
256+
pnpm -r build
257257
- run:
258258
name: Log defect declaration files
259259
command: |

apps/bare-next-app/next.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default {
77
ignoreBuildErrors: true,
88
},
99
devIndicators: {
10-
buildActivity: true,
11-
buildActivityPosition: 'bottom-right',
10+
position: 'bottom-right',
1211
},
1312
};

apps/pigment-css-next-app/next.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ const nextConfig = {
113113
typescript: {
114114
ignoreBuildErrors: true,
115115
},
116-
devIndicators: {
117-
buildActivity: true,
118-
buildActivityPosition: 'bottom-right',
119-
},
120116
};
121117

122118
export default withPigment(nextConfig, pigmentOptions);
Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
// @ts-check
2-
const path = require('path');
2+
import { fileURLToPath } from 'node:url';
3+
import * as path from 'node:path';
4+
// @ts-ignore
5+
import getBaseConfig from '@mui/internal-code-infra/babel-config';
36

47
/**
58
* @typedef {import('@babel/core')} babel
69
*/
710

8-
const errorCodesPath = path.resolve(__dirname, './docs/public/static/error-codes.json');
11+
const filename = fileURLToPath(import.meta.url);
12+
const dirname = path.dirname(filename);
13+
14+
const errorCodesPath = path.resolve(dirname, './docs/public/static/error-codes.json');
915
const missingError = process.env.MUI_EXTRACT_ERROR_CODES === 'true' ? 'write' : 'annotate';
1016

1117
/**
1218
* @param {string} relativeToBabelConf
1319
* @returns {string}
1420
*/
1521
function resolveAliasPath(relativeToBabelConf) {
16-
const resolvedPath = path.relative(process.cwd(), path.resolve(__dirname, relativeToBabelConf));
22+
const resolvedPath = path.relative(process.cwd(), path.resolve(dirname, relativeToBabelConf));
1723
return `./${resolvedPath.replace('\\', '/')}`;
1824
}
1925

2026
/** @type {babel.ConfigFunction} */
21-
module.exports = function getBabelConfig(api) {
27+
export default function getBabelConfig(api) {
28+
const baseConfig = getBaseConfig(api);
2229
const useESModules = api.env(['regressions', 'stable']);
2330

2431
const defaultAlias = {
@@ -41,58 +48,8 @@ module.exports = function getBabelConfig(api) {
4148
test: resolveAliasPath('./test'),
4249
};
4350

44-
const presets = [
45-
[
46-
'@babel/preset-env',
47-
{
48-
bugfixes: true,
49-
browserslistEnv: api.env() || process.env.NODE_ENV,
50-
debug: process.env.MUI_BUILD_VERBOSE === 'true',
51-
modules: useESModules ? false : 'commonjs',
52-
},
53-
],
54-
[
55-
'@babel/preset-react',
56-
{
57-
runtime: 'automatic',
58-
},
59-
],
60-
'@babel/preset-typescript',
61-
];
62-
63-
// Essentially only replace in production builds.
64-
// When aliasing we want to keep the original extension
65-
const outFileExtension = process.env.MUI_OUT_FILE_EXTENSION || null;
66-
6751
/** @type {babel.PluginItem[]} */
6852
const plugins = [
69-
'babel-plugin-optimize-clsx',
70-
[
71-
'@babel/plugin-transform-runtime',
72-
{
73-
useESModules,
74-
// any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
75-
version: process.env.MUI_BABEL_RUNTIME_VERSION || '^7.25.0',
76-
},
77-
],
78-
[
79-
'babel-plugin-transform-react-remove-prop-types',
80-
{
81-
mode: 'unsafe-wrap',
82-
},
83-
],
84-
[
85-
'transform-inline-environment-variables',
86-
{
87-
include: [
88-
'MUI_VERSION',
89-
'MUI_MAJOR_VERSION',
90-
'MUI_MINOR_VERSION',
91-
'MUI_PATCH_VERSION',
92-
'MUI_PRERELEASE',
93-
],
94-
},
95-
],
9653
[
9754
'@mui/internal-babel-plugin-minify-errors',
9855
{
@@ -101,16 +58,6 @@ module.exports = function getBabelConfig(api) {
10158
runtimeModule: '@mui/utils/formatMuiErrorMessage',
10259
},
10360
],
104-
...(useESModules
105-
? [
106-
[
107-
'@mui/internal-babel-plugin-resolve-imports',
108-
{
109-
outExtension: outFileExtension,
110-
},
111-
],
112-
]
113-
: []),
11461
];
11562

11663
if (process.env.NODE_ENV === 'test') {
@@ -122,14 +69,15 @@ module.exports = function getBabelConfig(api) {
12269
},
12370
]);
12471
}
72+
const basePlugins = (baseConfig.plugins || []).filter(
73+
(/** @type {[unknown, unknown, string]} */ [, , pluginName]) =>
74+
pluginName !== '@mui/internal-babel-plugin-display-name',
75+
);
76+
basePlugins.push(...plugins);
12577

12678
return {
127-
assumptions: {
128-
noDocumentAll: true,
129-
},
130-
presets,
131-
plugins,
132-
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
79+
...baseConfig,
80+
plugins: basePlugins,
13381
overrides: [
13482
{
13583
exclude: /\.test\.(m?js|ts|tsx)$/,
@@ -181,4 +129,4 @@ module.exports = function getBabelConfig(api) {
181129
},
182130
},
183131
};
184-
};
132+
}

package.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,11 @@
113113
"@babel/core": "^7.28.0",
114114
"@babel/node": "^7.28.0",
115115
"@babel/plugin-transform-react-constant-elements": "^7.27.1",
116-
"@babel/plugin-transform-runtime": "^7.28.0",
117-
"@babel/preset-env": "^7.28.0",
118-
"@babel/preset-react": "^7.27.1",
119-
"@babel/preset-typescript": "^7.27.1",
120-
"@babel/register": "^7.27.1",
121116
"@mui-internal/api-docs-builder": "workspace:^",
122117
"@mui-internal/api-docs-builder-core": "workspace:^",
123-
"@mui/internal-babel-plugin-minify-errors": "^2.0.8-canary.3",
124-
"@mui/internal-babel-plugin-resolve-imports": "^2.0.7-canary.12",
118+
"@mui/internal-babel-plugin-minify-errors": "^2.0.8-canary.4",
125119
"@mui/internal-bundle-size-checker": "^1.0.9-canary.18",
126-
"@mui/internal-code-infra": "0.0.2-canary.29",
120+
"@mui/internal-code-infra": "^0.0.2-canary.31",
127121
"@mui/internal-docs-utils": "workspace:^",
128122
"@mui/internal-scripts": "workspace:^",
129123
"@mui/internal-test-utils": "workspace:^",
@@ -149,10 +143,6 @@
149143
"babel-loader": "^10.0.0",
150144
"babel-plugin-istanbul": "^7.0.0",
151145
"babel-plugin-module-resolver": "^5.0.2",
152-
"babel-plugin-optimize-clsx": "^2.6.2",
153-
"babel-plugin-react-remove-properties": "^0.3.0",
154-
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
155-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
156146
"chalk": "^5.5.0",
157147
"compression-webpack-plugin": "^11.1.0",
158148
"concurrently": "^9.2.0",

packages-internal/scripts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "2.0.12",
44
"author": "MUI Team",
55
"description": "Utilities supporting MUI libraries build and docs generation. This is an internal package not meant for general use.",
6-
"main": "build/index.js",
76
"exports": {
87
"./typescript-to-proptypes": {
98
"types": "./build/typescript-to-proptypes/index.d.ts",

packages/mui-codemod/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
"scripts": {
1515
"test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/mui-codemod/**/*.test.?(c|m)[jt]s?(x)'",
1616
"prebuild": "rimraf build",
17-
"build:node": "node ../../scripts/build.mjs node --out-dir ./build",
18-
"build:copy-files": "node ../../scripts/copyFiles.mjs codemod.js",
19-
"build": "pnpm build:node && pnpm build:copy-files",
17+
"build:copy-files": "code-infra copy-files codemod.js",
18+
"build": "code-infra build --bundle cjs --buildTypes false && pnpm build:copy-files",
2019
"release": "pnpm build && pnpm publish"
2120
},
2221
"repository": {

packages/mui-core-downloads-tracker/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"url": "https://opencollective.com/mui-org"
2020
},
2121
"scripts": {
22-
"build": "mkdir build && pnpm build:copy-files",
23-
"build:copy-files": "node ../../scripts/copyFiles.mjs",
22+
"build": "code-infra copy-files package.json",
2423
"prebuild": "rimraf build",
2524
"release": "pnpm build && pnpm publish"
2625
},

packages/mui-docs/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "7.3.1",
44
"author": "MUI Team",
55
"description": "MUI Docs - Documentation building blocks.",
6-
"main": "./src/index.js",
76
"keywords": [
87
"react",
98
"react-component",
@@ -22,11 +21,8 @@
2221
},
2322
"homepage": "https://github.com/mui/material-ui/tree/master/packages/mui-docs",
2423
"scripts": {
25-
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
26-
"build:node": "node ../../scripts/build.mjs node",
27-
"build:stable": "node ../../scripts/build.mjs stable",
28-
"build:types": "tsx ../../scripts/buildTypes.mts",
29-
"build:copy-files": "node ../../scripts/copyFiles.mjs ./src/translations/translations.json:./translations/translations.json ./src/translations/translations.json:./esm/translations/translations.json ./src/translations/translations.json:./modern/translations/translations.json",
24+
"build": "code-infra build && pnpm build:copy-files",
25+
"build:copy-files": "code-infra copy-files ./src/translations/translations.json:./translations/translations.json ./src/translations/translations.json:./esm/translations/translations.json",
3026
"prebuild": "rimraf build",
3127
"release": "pnpm build && pnpm publish",
3228
"test": "exit 0",
@@ -72,5 +68,8 @@
7268
},
7369
"engines": {
7470
"node": ">=14.0.0"
71+
},
72+
"exports": {
73+
"./*": "./src/*/index.ts"
7574
}
7675
}

packages/mui-envinfo/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bin": "./envinfo.js",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/mui/material-ui",
9+
"url": "git+https://github.com/mui/material-ui.git",
1010
"directory": "packages/mui-envinfo"
1111
},
1212
"license": "MIT",
@@ -16,17 +16,15 @@
1616
"homepage": "https://github.com/mui/material-ui/tree/HEAD/packages/mui-envinfo",
1717
"files": [],
1818
"scripts": {
19-
"build": "pnpm build:node && pnpm build:copy-files",
20-
"build:node": "node scripts/build",
21-
"build:copy-files": "node ../../scripts/copyFiles.mjs"
19+
"build": "code-infra build --bundle cjs --buildTypes false --skipBabelRuntimeCheck && pnpm build:copy-files",
20+
"build:copy-files": "code-infra copy-files"
2221
},
2322
"dependencies": {
2423
"envinfo": "^7.14.0"
2524
},
2625
"devDependencies": {
2726
"@types/chai": "^4.3.20",
28-
"chai": "^4.5.0",
29-
"fs-extra": "^11.3.1"
27+
"chai": "^4.5.0"
3028
},
3129
"publishConfig": {
3230
"access": "public",

0 commit comments

Comments
 (0)