@umijs/babel-preset-umi 4.6.1 → 4.6.2
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 +31 -18
- 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 exports = (opts == null ? void 0 : opts.exports) || [];
|
|
43
43
|
expressions.forEach((exp) => {
|
|
44
44
|
if (!(t.isExportNamedDeclaration(exp) || t.isExportDefaultDeclaration(exp)))
|
|
45
45
|
return;
|
|
@@ -48,36 +48,46 @@ var stripExports_default = () => {
|
|
|
48
48
|
handleExportsDefault(exp);
|
|
49
49
|
});
|
|
50
50
|
function handleExportsIndividual(path2) {
|
|
51
|
-
if (!path2.node)
|
|
52
|
-
|
|
53
|
-
if (!
|
|
51
|
+
if (!path2.node)
|
|
52
|
+
return;
|
|
53
|
+
if (!t.isExportNamedDeclaration(path2))
|
|
54
|
+
return;
|
|
55
|
+
if (!path2.get("declaration").node)
|
|
56
|
+
return;
|
|
54
57
|
const declaration = path2.get("declaration");
|
|
55
58
|
if (t.isVariableDeclaration(declaration)) {
|
|
56
59
|
const variables = declaration.get("declarations");
|
|
57
60
|
variables.forEach((variable) => {
|
|
58
|
-
|
|
61
|
+
exports.includes(variable.get("id.name").node) && variable.remove();
|
|
59
62
|
});
|
|
60
63
|
} else {
|
|
61
|
-
|
|
64
|
+
exports.includes(declaration.get("id.name").node) && declaration.remove();
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
function handleExportsList(path2) {
|
|
65
|
-
if (!path2.node)
|
|
66
|
-
|
|
68
|
+
if (!path2.node)
|
|
69
|
+
return;
|
|
70
|
+
if (!t.isExportNamedDeclaration(path2))
|
|
71
|
+
return;
|
|
67
72
|
const specifiers = path2.get("specifiers");
|
|
68
|
-
if (!specifiers || specifiers.length === 0)
|
|
73
|
+
if (!specifiers || specifiers.length === 0)
|
|
74
|
+
return;
|
|
69
75
|
specifiers.forEach((specifier) => {
|
|
70
|
-
if (
|
|
76
|
+
if (exports.includes(specifier.get("exported.name").node))
|
|
71
77
|
specifier.remove();
|
|
72
78
|
});
|
|
73
|
-
if (path2.get("specifiers").length === 0)
|
|
79
|
+
if (path2.get("specifiers").length === 0)
|
|
80
|
+
path2.remove();
|
|
74
81
|
}
|
|
75
82
|
function handleExportsDefault(path2) {
|
|
76
|
-
if (!path2.node)
|
|
77
|
-
|
|
83
|
+
if (!path2.node)
|
|
84
|
+
return;
|
|
85
|
+
if (!t.isExportDefaultDeclaration(path2))
|
|
86
|
+
return;
|
|
78
87
|
const declaration = path2.get("declaration");
|
|
79
|
-
if (!declaration.node)
|
|
80
|
-
|
|
88
|
+
if (!declaration.node)
|
|
89
|
+
return;
|
|
90
|
+
if (exports.includes(declaration.get("name").node))
|
|
81
91
|
declaration.remove();
|
|
82
92
|
}
|
|
83
93
|
},
|
|
@@ -85,13 +95,16 @@ var stripExports_default = () => {
|
|
|
85
95
|
path.scope.crawl();
|
|
86
96
|
const expressions = path.get("body");
|
|
87
97
|
expressions.forEach((exp) => {
|
|
88
|
-
if (!t.isImportDeclaration(exp))
|
|
98
|
+
if (!t.isImportDeclaration(exp))
|
|
99
|
+
return;
|
|
89
100
|
const specifiers = exp.get("specifiers");
|
|
90
101
|
specifiers.forEach((s) => {
|
|
91
102
|
const name = s.get("local.name").node;
|
|
92
|
-
if (!s.scope.getBinding(name).referenced)
|
|
103
|
+
if (!s.scope.getBinding(name).referenced)
|
|
104
|
+
s.remove();
|
|
93
105
|
});
|
|
94
|
-
if (exp.get("specifiers").length === 0)
|
|
106
|
+
if (exp.get("specifiers").length === 0)
|
|
107
|
+
exp.remove();
|
|
95
108
|
});
|
|
96
109
|
}
|
|
97
110
|
}
|
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.2",
|
|
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/
|
|
22
|
-
"@umijs/utils": "4.6.
|
|
21
|
+
"@umijs/utils": "4.6.2",
|
|
22
|
+
"@umijs/bundler-utils": "4.6.2"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|