@umijs/babel-preset-umi 4.6.2 → 4.6.4
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/dist/plugins/stripExports.js +18 -31
- package/package.json +3 -3
|
@@ -39,7 +39,7 @@ var stripExports_default = () => {
|
|
|
39
39
|
Program: {
|
|
40
40
|
enter(path, { opts }) {
|
|
41
41
|
const expressions = path.get("body");
|
|
42
|
-
const
|
|
42
|
+
const exports2 = (opts == null ? void 0 : opts.exports) || [];
|
|
43
43
|
expressions.forEach((exp) => {
|
|
44
44
|
if (!(t.isExportNamedDeclaration(exp) || t.isExportDefaultDeclaration(exp)))
|
|
45
45
|
return;
|
|
@@ -48,46 +48,36 @@ var stripExports_default = () => {
|
|
|
48
48
|
handleExportsDefault(exp);
|
|
49
49
|
});
|
|
50
50
|
function handleExportsIndividual(path2) {
|
|
51
|
-
if (!path2.node)
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
return;
|
|
55
|
-
if (!path2.get("declaration").node)
|
|
56
|
-
return;
|
|
51
|
+
if (!path2.node) return;
|
|
52
|
+
if (!t.isExportNamedDeclaration(path2)) return;
|
|
53
|
+
if (!path2.get("declaration").node) return;
|
|
57
54
|
const declaration = path2.get("declaration");
|
|
58
55
|
if (t.isVariableDeclaration(declaration)) {
|
|
59
56
|
const variables = declaration.get("declarations");
|
|
60
57
|
variables.forEach((variable) => {
|
|
61
|
-
|
|
58
|
+
exports2.includes(variable.get("id.name").node) && variable.remove();
|
|
62
59
|
});
|
|
63
60
|
} else {
|
|
64
|
-
|
|
61
|
+
exports2.includes(declaration.get("id.name").node) && declaration.remove();
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
function handleExportsList(path2) {
|
|
68
|
-
if (!path2.node)
|
|
69
|
-
|
|
70
|
-
if (!t.isExportNamedDeclaration(path2))
|
|
71
|
-
return;
|
|
65
|
+
if (!path2.node) return;
|
|
66
|
+
if (!t.isExportNamedDeclaration(path2)) return;
|
|
72
67
|
const specifiers = path2.get("specifiers");
|
|
73
|
-
if (!specifiers || specifiers.length === 0)
|
|
74
|
-
return;
|
|
68
|
+
if (!specifiers || specifiers.length === 0) return;
|
|
75
69
|
specifiers.forEach((specifier) => {
|
|
76
|
-
if (
|
|
70
|
+
if (exports2.includes(specifier.get("exported.name").node))
|
|
77
71
|
specifier.remove();
|
|
78
72
|
});
|
|
79
|
-
if (path2.get("specifiers").length === 0)
|
|
80
|
-
path2.remove();
|
|
73
|
+
if (path2.get("specifiers").length === 0) path2.remove();
|
|
81
74
|
}
|
|
82
75
|
function handleExportsDefault(path2) {
|
|
83
|
-
if (!path2.node)
|
|
84
|
-
|
|
85
|
-
if (!t.isExportDefaultDeclaration(path2))
|
|
86
|
-
return;
|
|
76
|
+
if (!path2.node) return;
|
|
77
|
+
if (!t.isExportDefaultDeclaration(path2)) return;
|
|
87
78
|
const declaration = path2.get("declaration");
|
|
88
|
-
if (!declaration.node)
|
|
89
|
-
|
|
90
|
-
if (exports.includes(declaration.get("name").node))
|
|
79
|
+
if (!declaration.node) return;
|
|
80
|
+
if (exports2.includes(declaration.get("name").node))
|
|
91
81
|
declaration.remove();
|
|
92
82
|
}
|
|
93
83
|
},
|
|
@@ -95,16 +85,13 @@ var stripExports_default = () => {
|
|
|
95
85
|
path.scope.crawl();
|
|
96
86
|
const expressions = path.get("body");
|
|
97
87
|
expressions.forEach((exp) => {
|
|
98
|
-
if (!t.isImportDeclaration(exp))
|
|
99
|
-
return;
|
|
88
|
+
if (!t.isImportDeclaration(exp)) return;
|
|
100
89
|
const specifiers = exp.get("specifiers");
|
|
101
90
|
specifiers.forEach((s) => {
|
|
102
91
|
const name = s.get("local.name").node;
|
|
103
|
-
if (!s.scope.getBinding(name).referenced)
|
|
104
|
-
s.remove();
|
|
92
|
+
if (!s.scope.getBinding(name).referenced) s.remove();
|
|
105
93
|
});
|
|
106
|
-
if (exp.get("specifiers").length === 0)
|
|
107
|
-
exp.remove();
|
|
94
|
+
if (exp.get("specifiers").length === 0) exp.remove();
|
|
108
95
|
});
|
|
109
96
|
}
|
|
110
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/babel-preset-umi",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.4",
|
|
4
4
|
"description": "Official babel preset for umi.",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/babel-preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"@babel/runtime": "7.23.6",
|
|
19
19
|
"@bloomberg/record-tuple-polyfill": "0.0.4",
|
|
20
20
|
"core-js": "3.34.0",
|
|
21
|
-
"@umijs/utils": "4.6.
|
|
22
|
-
"@umijs/
|
|
21
|
+
"@umijs/bundler-utils": "4.6.4",
|
|
22
|
+
"@umijs/utils": "4.6.4"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|