@mui/internal-babel-plugin-minify-errors 2.0.8-canary.17 → 2.0.8-canary.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -1
- package/index.test.js +9 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function pathToNodeImportSpecifier(importPath) {
|
|
|
26
26
|
|
|
27
27
|
const COMMENT_OPT_IN_MARKER = 'minify-error';
|
|
28
28
|
const COMMENT_OPT_OUT_MARKER = 'minify-error-disabled';
|
|
29
|
+
const SUPPORTED_ERROR_CONSTRUCTORS = new Set(['Error', 'TypeError']);
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @typedef {import('@babel/core')} babel
|
|
@@ -172,7 +173,8 @@ function handleUnminifyableError(missingError, path) {
|
|
|
172
173
|
* @returns {null | { messageNode: babel.types.Expression; messagePath: babel.NodePath<babel.types.ArgumentPlaceholder | babel.types.SpreadElement | babel.types.Expression>; message: { message: string; expressions: babel.types.Expression[] } }}
|
|
173
174
|
*/
|
|
174
175
|
function findMessageNode(t, newExpressionPath, { detection, missingError }) {
|
|
175
|
-
|
|
176
|
+
const callee = newExpressionPath.get('callee');
|
|
177
|
+
if (!callee.isIdentifier() || !SUPPORTED_ERROR_CONSTRUCTORS.has(callee.node.name)) {
|
|
176
178
|
return null;
|
|
177
179
|
}
|
|
178
180
|
|
package/index.test.js
CHANGED
|
@@ -35,6 +35,15 @@ pluginTester({
|
|
|
35
35
|
fixture: path.join(fixturePath, 'literal', 'input.js'),
|
|
36
36
|
output: readOutputFixtureSync('literal', 'output.js'),
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
title: 'type-error',
|
|
40
|
+
pluginOptions: {
|
|
41
|
+
errorCodesPath: path.join(fixturePath, 'type-error', 'error-codes.json'),
|
|
42
|
+
runtimeModule: '@mui/utils/formatMuiErrorMessage',
|
|
43
|
+
},
|
|
44
|
+
fixture: path.join(fixturePath, 'type-error', 'input.js'),
|
|
45
|
+
output: readOutputFixtureSync('type-error', 'output.js'),
|
|
46
|
+
},
|
|
38
47
|
{
|
|
39
48
|
title: 'interpolation',
|
|
40
49
|
pluginOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-babel-plugin-minify-errors",
|
|
3
|
-
"version": "2.0.8-canary.
|
|
3
|
+
"version": "2.0.8-canary.18",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "This is an internal package not meant for general use.",
|
|
6
6
|
"repository": {
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitSha": "
|
|
45
|
+
"gitSha": "0f864140382ea24bbb67b29b67b28c8d38a36190",
|
|
46
46
|
"scripts": {}
|
|
47
47
|
}
|