-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[code-infra] Move MuiError babel macro to babel plugin (#43904)
- Loading branch information
Showing
64 changed files
with
449 additions
and
443 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// danger uses babelify under the hood. The implementation is buggy and fails on our | ||
// custom plugins in our codebase. We'll just disable it and do our own compilation. | ||
// Danger must always be run with envirnonent variable `DANGER_DISABLE_TRANSPILATION="true"`. | ||
require('@babel/register')({ | ||
extensions: ['.js', '.ts', '.tsx'], | ||
}); | ||
require('./dangerFileContent'); |
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.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
packages-internal/babel-plugin-minify-errors/__fixtures__/error-code-extraction/input.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,2 @@ | ||
throw /* minify-error */ new Error('exists'); | ||
throw /* minify-error */ new Error('will be created'); |
4 changes: 2 additions & 2 deletions
4
...ixtures__/error-code-extraction/output.js → ...ixtures__/error-code-extraction/output.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import _formatMuiErrorMessage from '@mui/utils/formatMuiErrorMessage'; | ||
throw new Error(process.env.NODE_ENV !== 'production' ? `exists` : _formatMuiErrorMessage(1)); | ||
throw new Error(process.env.NODE_ENV !== 'production' ? 'exists' : _formatMuiErrorMessage(1)); | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' ? `will be created` : _formatMuiErrorMessage(2), | ||
process.env.NODE_ENV !== 'production' ? 'will be created' : _formatMuiErrorMessage(2), | ||
); |
3 changes: 3 additions & 0 deletions
3
packages-internal/babel-plugin-minify-errors/__fixtures__/interpolation/error-codes.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,3 @@ | ||
{ | ||
"1": "MUI: %s, %s" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages-internal/babel-plugin-minify-errors/__fixtures__/interpolation/input.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,5 @@ | ||
const foo = 'foo'; | ||
const bar = 'bar'; | ||
throw /* minify-error */ new Error(`MUI: ${foo}, ${bar}`); | ||
throw /* minify-error */ new Error(`MUI: ${foo}` + `, ${bar}`); | ||
throw /* minify-error */ new Error('MUI: ' + `${foo}, ${bar}`); |
18 changes: 18 additions & 0 deletions
18
packages-internal/babel-plugin-minify-errors/__fixtures__/interpolation/output.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,18 @@ | ||
import _formatMuiErrorMessage from '@mui/utils/formatMuiErrorMessage'; | ||
const foo = 'foo'; | ||
const bar = 'bar'; | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' | ||
? `MUI: ${foo}, ${bar}` | ||
: _formatMuiErrorMessage(1, foo, bar), | ||
); | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' | ||
? `MUI: ${foo}` + `, ${bar}` | ||
: _formatMuiErrorMessage(1, foo, bar), | ||
); | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' | ||
? 'MUI: ' + `${foo}, ${bar}` | ||
: _formatMuiErrorMessage(1, foo, bar), | ||
); |
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
packages-internal/babel-plugin-minify-errors/__fixtures__/literal/input.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,6 @@ | ||
throw /* minify-error */ new Error( | ||
'MUI: Expected valid input target.\n' + 'Did you use `inputComponent`', | ||
); | ||
throw /* minify-error */ new Error( | ||
`MUI: Expected valid input target.\n` + `Did you use \`inputComponent\``, | ||
); |
11 changes: 11 additions & 0 deletions
11
packages-internal/babel-plugin-minify-errors/__fixtures__/literal/output.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,11 @@ | ||
import _formatMuiErrorMessage from '@mui/utils/formatMuiErrorMessage'; | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' | ||
? 'MUI: Expected valid input target.\n' + 'Did you use `inputComponent`' | ||
: _formatMuiErrorMessage(1), | ||
); | ||
throw new Error( | ||
process.env.NODE_ENV !== 'production' | ||
? `MUI: Expected valid input target.\n` + `Did you use \`inputComponent\`` | ||
: _formatMuiErrorMessage(1), | ||
); |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages-internal/babel-plugin-minify-errors/__fixtures__/no-error-code-annotation/input.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,3 @@ | ||
throw /* minify-error */ new Error( | ||
'MUI: Expected valid input target.\n' + 'Did you use inputComponent', | ||
); |
3 changes: 3 additions & 0 deletions
3
packages-internal/babel-plugin-minify-errors/__fixtures__/no-error-code-annotation/output.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,3 @@ | ||
throw /* FIXME (minify-errors-in-prod): Unminified error message in production build! */ new Error( | ||
'MUI: Expected valid input target.\n' + 'Did you use inputComponent', | ||
); |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages-internal/babel-plugin-minify-errors/__fixtures__/no-error-code-throw/input.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 @@ | ||
throw /* minify-error */ new Error('missing'); |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
packages-internal/babel-plugin-minify-errors/__fixtures__/unminifyable-annotation/input.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,4 @@ | ||
const foo = 'foo'; | ||
const bar = ['bar']; | ||
throw /* minify-error */ new Error(foo); | ||
throw /* minify-error */ new Error(...bar); |
4 changes: 4 additions & 0 deletions
4
packages-internal/babel-plugin-minify-errors/__fixtures__/unminifyable-annotation/output.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,4 @@ | ||
const foo = 'foo'; | ||
const bar = ['bar']; | ||
throw /* FIXME (minify-errors-in-prod): Unminifyable error in production! */ new Error(foo); | ||
throw /* FIXME (minify-errors-in-prod): Unminifyable error in production! */ new Error(...bar); |
1 change: 1 addition & 0 deletions
1
...ages-internal/babel-plugin-minify-errors/__fixtures__/unminifyable-throw/error-codes.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 @@ | ||
{} |
4 changes: 4 additions & 0 deletions
4
packages-internal/babel-plugin-minify-errors/__fixtures__/unminifyable-throw/input.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,4 @@ | ||
const foo = 'foo'; | ||
const bar = ['bar']; | ||
throw /* minify-error */ new Error(foo); | ||
throw /* minify-error */ new Error(...bar); |
Oops, something went wrong.