Skip to content

Commit 0210994

Browse files
authored
[code-infra] Move MuiError babel macro to babel plugin (#43904)
1 parent 2774ea9 commit 0210994

File tree

64 files changed

+449
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+449
-443
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ default-job: &default-job
4242
TEST_GATE: << parameters.test-gate >>
4343
AWS_REGION_ARTIFACTS: eu-central-1
4444
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
45+
DANGER_DISABLE_TRANSPILATION: 'true'
4546
working_directory: /tmp/material-ui
4647
docker:
4748
- image: cimg/node:20.17

.codesandbox/ci.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"node": "20",
55
"packages": [
66
"packages/markdown",
7-
"packages/mui-babel-macros",
87
"packages/mui-base",
98
"packages/mui-codemod",
109
"packages/mui-core-downloads-tracker",
@@ -33,7 +32,6 @@
3332
"@mui/docs": "packages/mui-docs/build",
3433
"@mui/icons-material": "packages/mui-icons-material/build",
3534
"@mui/internal-test-utils": "packages-internal/test-utils",
36-
"@mui/internal-babel-macros": "packages/mui-babel-macros",
3735
"@mui/internal-docs-utils": "packages-internal/docs-utils",
3836
"@mui/internal-markdown": "packages/markdown",
3937
"@mui/internal-scripts": "packages-internal/scripts",

babel.config.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ module.exports = function getBabelConfig(api) {
7878

7979
/** @type {babel.PluginItem[]} */
8080
const plugins = [
81-
[
82-
'babel-plugin-macros',
83-
{
84-
muiError: {
85-
errorCodesPath,
86-
missingError,
87-
},
88-
},
89-
],
9081
'babel-plugin-optimize-clsx',
9182
[
9283
'@babel/plugin-transform-runtime',
@@ -114,6 +105,13 @@ module.exports = function getBabelConfig(api) {
114105
],
115106
},
116107
],
108+
[
109+
'@mui/internal-babel-plugin-minify-errors',
110+
{
111+
missingError,
112+
errorCodesPath,
113+
},
114+
],
117115
...(useESModules
118116
? [
119117
[

dangerfile.ts renamed to dangerFileContent.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// danger has to be the first thing required!
2-
import { danger, markdown } from 'danger';
31
import { exec } from 'child_process';
2+
import type * as dangerModule from 'danger';
43
import { loadComparison } from './scripts/sizeSnapshot';
54
import replaceUrl from './packages/api-docs-builder/utils/replaceUrl';
65

6+
declare const danger: (typeof dangerModule)['danger'];
7+
declare const markdown: (typeof dangerModule)['markdown'];
8+
79
const circleCIBuildNumber = process.env.CIRCLE_BUILD_NUM;
810
const circleCIBuildUrl = `https://app.circleci.com/pipelines/github/mui/material-ui/jobs/${circleCIBuildNumber}`;
911
const dangerCommand = process.env.DANGER_COMMAND;

dangerfile.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// danger uses babelify under the hood. The implementation is buggy and fails on our
2+
// custom plugins in our codebase. We'll just disable it and do our own compilation.
3+
// Danger must always be run with envirnonent variable `DANGER_DISABLE_TRANSPILATION="true"`.
4+
require('@babel/register')({
5+
extensions: ['.js', '.ts', '.tsx'],
6+
});
7+
require('./dangerFileContent');

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"docs:typescript:formatted": "tsx ./docs/scripts/formattedTSDemos",
3838
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js,.mjs\" ./docs/scripts/updateIconSynonyms && pnpm prettier",
3939
"docs:zipRules": "cd docs && rm mui-vale.zip && zip -r mui-vale.zip mui-vale && cd ../ && vale sync",
40-
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --concurrency 8 build:modern",
40+
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --concurrency 1 build:modern",
4141
"rsc:build": "tsx ./packages/rsc-builder/buildRsc.ts",
4242
"template:screenshot": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/generateTemplateScreenshots",
4343
"template:update-theme": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/updateTemplatesTheme",
@@ -139,7 +139,6 @@
139139
"@typescript-eslint/parser": "^7.18.0",
140140
"babel-loader": "^9.2.1",
141141
"babel-plugin-istanbul": "^7.0.0",
142-
"babel-plugin-macros": "^3.1.0",
143142
"babel-plugin-module-resolver": "^5.0.2",
144143
"babel-plugin-optimize-clsx": "^2.6.2",
145144
"babel-plugin-react-remove-properties": "^0.3.0",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
throw /* minify-error */ new Error('exists');
2+
throw /* minify-error */ new Error('will be created');

0 commit comments

Comments
 (0)