@umijs/babel-preset-umi 4.0.7 → 4.0.10
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/index.js +131 -126
- package/dist/plugins/autoCSSModules.js +52 -52
- package/dist/plugins/dynamicImportNode.js +65 -67
- package/dist/plugins/lockCoreJS.js +44 -41
- package/dist/plugins/stripExports.js +105 -106
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,128 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
4
20
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const autoCSSModules_1 = __importDefault(require("./plugins/autoCSSModules"));
|
|
9
|
-
const dynamicImportNode_1 = __importDefault(require("./plugins/dynamicImportNode"));
|
|
10
|
-
const lockCoreJS_1 = __importDefault(require("./plugins/lockCoreJS"));
|
|
11
|
-
const stripExports_1 = __importDefault(require("./plugins/stripExports"));
|
|
12
|
-
exports.default = (_context, opts) => {
|
|
13
|
-
return {
|
|
14
|
-
presets: [
|
|
15
|
-
[
|
|
16
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/preset-env'),
|
|
17
|
-
{
|
|
18
|
-
bugfixes: true,
|
|
19
|
-
// 更兼容 spec,但会变慢,所以不开
|
|
20
|
-
spec: false,
|
|
21
|
-
// 推荐用 top level 的 assumptions 配置
|
|
22
|
-
loose: false,
|
|
23
|
-
// 保留 es modules 语法,交给 webpack 处理
|
|
24
|
-
modules: false,
|
|
25
|
-
debug: false,
|
|
26
|
-
useBuiltIns: 'entry',
|
|
27
|
-
corejs: (0, utils_1.getCorejsVersion)((0, path_1.join)(__dirname, '../package.json')),
|
|
28
|
-
// 没必要,遇到了应该改 targets 配置
|
|
29
|
-
forceAllTransforms: false,
|
|
30
|
-
ignoreBrowserslistConfig: true,
|
|
31
|
-
...opts.presetEnv,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/preset-react'),
|
|
36
|
-
{
|
|
37
|
-
runtime: 'automatic',
|
|
38
|
-
development: process.env.NODE_ENV === 'development',
|
|
39
|
-
importSource: 'react',
|
|
40
|
-
...opts.presetReact,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
[
|
|
44
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/preset-typescript'),
|
|
45
|
-
{
|
|
46
|
-
// 支持 vue 后缀
|
|
47
|
-
allExtensions: true,
|
|
48
|
-
// 支持 tsx
|
|
49
|
-
isTSX: true,
|
|
50
|
-
allowNamespaces: true,
|
|
51
|
-
allowDeclareFields: true,
|
|
52
|
-
// Why false?
|
|
53
|
-
// 如果为 true,babel 只删除 import type 语句,会保留其他通过 import 引入的 type
|
|
54
|
-
// 这些 type 引用走到 webpack 之后,就会报错
|
|
55
|
-
onlyRemoveTypeImports: false,
|
|
56
|
-
optimizeConstEnums: true,
|
|
57
|
-
...opts.presetTypeScript,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
],
|
|
61
|
-
plugins: [
|
|
62
|
-
// TC39 Proposals
|
|
63
|
-
// class-static-block
|
|
64
|
-
// decorators
|
|
65
|
-
[
|
|
66
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-decorators'),
|
|
67
|
-
{ legacy: true },
|
|
68
|
-
],
|
|
69
|
-
// do-expressions
|
|
70
|
-
[
|
|
71
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-do-expressions'),
|
|
72
|
-
],
|
|
73
|
-
// export-default-from
|
|
74
|
-
[
|
|
75
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-export-default-from'),
|
|
76
|
-
],
|
|
77
|
-
// export-namespace-from
|
|
78
|
-
[
|
|
79
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-export-namespace-from'),
|
|
80
|
-
],
|
|
81
|
-
// function-bind
|
|
82
|
-
[
|
|
83
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-function-bind'),
|
|
84
|
-
],
|
|
85
|
-
// function-sent
|
|
86
|
-
// partial-application
|
|
87
|
-
[
|
|
88
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-partial-application'),
|
|
89
|
-
],
|
|
90
|
-
// pipeline-operator
|
|
91
|
-
[
|
|
92
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-pipeline-operator'),
|
|
93
|
-
{ proposal: 'minimal' },
|
|
94
|
-
],
|
|
95
|
-
// throw-expressions
|
|
96
|
-
// record-and-tuple
|
|
97
|
-
[
|
|
98
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-proposal-record-and-tuple'),
|
|
99
|
-
{
|
|
100
|
-
syntaxType: 'hash',
|
|
101
|
-
importPolyfill: true,
|
|
102
|
-
polyfillModuleName: (0, path_1.dirname)(require.resolve('@bloomberg/record-tuple-polyfill/package')),
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
opts.pluginTransformRuntime && [
|
|
106
|
-
require.resolve('@umijs/bundler-utils/compiled/babel/plugin-transform-runtime'),
|
|
107
|
-
{
|
|
108
|
-
helpers: true,
|
|
109
|
-
regenerator: true,
|
|
110
|
-
// 7.13 之后根据 exports 自动选择 esm 和 cjs,无需此配置
|
|
111
|
-
useESModules: false,
|
|
112
|
-
// lock the version of @babel/runtime
|
|
113
|
-
// make sure we are using the correct version
|
|
114
|
-
// ref: https://github.com/babel/babel/blob/v7.16.12/packages/babel-plugin-transform-runtime/src/get-runtime-path/index.ts#L19
|
|
115
|
-
// ref: https://github.com/umijs/umi/pull/7816
|
|
116
|
-
absoluteRuntime: (0, path_1.dirname)(require.resolve('../package.json')),
|
|
117
|
-
version: `^${require('@babel/runtime/package.json').version}`,
|
|
118
|
-
...opts.pluginTransformRuntime,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
// none official plugins
|
|
122
|
-
opts.pluginLockCoreJS && [lockCoreJS_1.default],
|
|
123
|
-
opts.pluginDynamicImportNode && [dynamicImportNode_1.default],
|
|
124
|
-
opts.pluginAutoCSSModules && [autoCSSModules_1.default],
|
|
125
|
-
opts.stripExports && [stripExports_1.default],
|
|
126
|
-
].filter(Boolean),
|
|
127
|
-
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
128
24
|
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// src/index.ts
|
|
37
|
+
var src_exports = {};
|
|
38
|
+
__export(src_exports, {
|
|
39
|
+
default: () => src_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
var import_utils = require("@umijs/utils");
|
|
43
|
+
var import_path = require("path");
|
|
44
|
+
var import_autoCSSModules = __toESM(require("./plugins/autoCSSModules"));
|
|
45
|
+
var import_dynamicImportNode = __toESM(require("./plugins/dynamicImportNode"));
|
|
46
|
+
var import_lockCoreJS = __toESM(require("./plugins/lockCoreJS"));
|
|
47
|
+
var import_stripExports = __toESM(require("./plugins/stripExports"));
|
|
48
|
+
var src_default = (_context, opts) => {
|
|
49
|
+
return {
|
|
50
|
+
presets: [
|
|
51
|
+
[
|
|
52
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/preset-env"),
|
|
53
|
+
__spreadValues({
|
|
54
|
+
bugfixes: true,
|
|
55
|
+
spec: false,
|
|
56
|
+
loose: false,
|
|
57
|
+
modules: false,
|
|
58
|
+
debug: false,
|
|
59
|
+
useBuiltIns: "entry",
|
|
60
|
+
corejs: (0, import_utils.getCorejsVersion)((0, import_path.join)(__dirname, "../package.json")),
|
|
61
|
+
forceAllTransforms: false,
|
|
62
|
+
ignoreBrowserslistConfig: true
|
|
63
|
+
}, opts.presetEnv)
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/preset-react"),
|
|
67
|
+
__spreadValues({
|
|
68
|
+
runtime: "automatic",
|
|
69
|
+
development: process.env.NODE_ENV === "development",
|
|
70
|
+
importSource: "react"
|
|
71
|
+
}, opts.presetReact)
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/preset-typescript"),
|
|
75
|
+
__spreadValues({
|
|
76
|
+
allowNamespaces: true,
|
|
77
|
+
allowDeclareFields: true,
|
|
78
|
+
onlyRemoveTypeImports: false,
|
|
79
|
+
optimizeConstEnums: true
|
|
80
|
+
}, opts.presetTypeScript)
|
|
81
|
+
]
|
|
82
|
+
],
|
|
83
|
+
plugins: [
|
|
84
|
+
[
|
|
85
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-decorators"),
|
|
86
|
+
{ legacy: true }
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-do-expressions")
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-export-default-from")
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-export-namespace-from")
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-function-bind")
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-partial-application")
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-pipeline-operator"),
|
|
105
|
+
{ proposal: "minimal" }
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-record-and-tuple"),
|
|
109
|
+
{
|
|
110
|
+
syntaxType: "hash",
|
|
111
|
+
importPolyfill: true,
|
|
112
|
+
polyfillModuleName: (0, import_path.dirname)(require.resolve("@bloomberg/record-tuple-polyfill/package"))
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
opts.pluginTransformRuntime && [
|
|
116
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-transform-runtime"),
|
|
117
|
+
__spreadValues({
|
|
118
|
+
helpers: true,
|
|
119
|
+
regenerator: true,
|
|
120
|
+
useESModules: false,
|
|
121
|
+
absoluteRuntime: (0, import_path.dirname)(require.resolve("../package.json")),
|
|
122
|
+
version: `^${require("@babel/runtime/package.json").version}`
|
|
123
|
+
}, opts.pluginTransformRuntime)
|
|
124
|
+
],
|
|
125
|
+
opts.pluginLockCoreJS && [import_lockCoreJS.default],
|
|
126
|
+
opts.pluginDynamicImportNode && [import_dynamicImportNode.default],
|
|
127
|
+
opts.pluginAutoCSSModules && [import_autoCSSModules.default],
|
|
128
|
+
opts.stripExports && [import_stripExports.default]
|
|
129
|
+
].filter(Boolean)
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {});
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/plugins/autoCSSModules.ts
|
|
23
|
+
var autoCSSModules_exports = {};
|
|
24
|
+
__export(autoCSSModules_exports, {
|
|
25
|
+
default: () => autoCSSModules_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(autoCSSModules_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
var CSS_EXT_NAMES = [".css", ".less", ".sass", ".scss", ".stylus", ".styl"];
|
|
31
|
+
function autoCSSModules_default() {
|
|
32
|
+
return {
|
|
33
|
+
visitor: {
|
|
34
|
+
ImportDeclaration(path) {
|
|
35
|
+
const {
|
|
36
|
+
specifiers,
|
|
37
|
+
source,
|
|
38
|
+
source: { value }
|
|
39
|
+
} = path.node;
|
|
40
|
+
if (specifiers.length && CSS_EXT_NAMES.includes((0, import_path.extname)(value))) {
|
|
41
|
+
source.value = `${value}?modules`;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
VariableDeclarator(path) {
|
|
45
|
+
const { node } = path;
|
|
46
|
+
if (t.isAwaitExpression(node.init) && t.isCallExpression(node.init.argument) && t.isImport(node.init.argument.callee) && node.init.argument.arguments.length === 1 && t.isStringLiteral(node.init.argument.arguments[0]) && CSS_EXT_NAMES.includes((0, import_path.extname)(node.init.argument.arguments[0].value))) {
|
|
47
|
+
node.init.argument.arguments[0].value = `${node.init.argument.arguments[0].value}?modules`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {});
|
|
@@ -1,75 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
10
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
27
18
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/plugins/dynamicImportNode.ts
|
|
23
|
+
var dynamicImportNode_exports = {};
|
|
24
|
+
__export(dynamicImportNode_exports, {
|
|
25
|
+
default: () => dynamicImportNode_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(dynamicImportNode_exports);
|
|
28
|
+
var import_template = __toESM(require("@umijs/bundler-utils/compiled/babel/template"));
|
|
29
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
31
30
|
function getImportSource(callNode) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
], importArguments);
|
|
31
|
+
const importArguments = callNode.arguments;
|
|
32
|
+
const [importPath] = importArguments;
|
|
33
|
+
const isString2 = t.isStringLiteral(importPath) || t.isTemplateLiteral(importPath);
|
|
34
|
+
if (isString2) {
|
|
35
|
+
t.removeComments(importPath);
|
|
36
|
+
return importPath;
|
|
37
|
+
}
|
|
38
|
+
return t.templateLiteral([
|
|
39
|
+
t.templateElement({ raw: "", cooked: "" }),
|
|
40
|
+
t.templateElement({ raw: "", cooked: "" }, true)
|
|
41
|
+
], importArguments);
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
var builders = {
|
|
44
|
+
static: (0, import_template.default)("Promise.resolve().then(() => INTEROP(require(SOURCE)))"),
|
|
45
|
+
dynamic: (0, import_template.default)("Promise.resolve(SOURCE).then(s => INTEROP(require(s)))")
|
|
48
46
|
};
|
|
49
47
|
function isString(node) {
|
|
50
|
-
|
|
51
|
-
(t.isTemplateLiteral(node) && node.expressions.length === 0));
|
|
48
|
+
return t.isStringLiteral(node) || t.isTemplateLiteral(node) && node.expressions.length === 0;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
50
|
+
var dynamicImportNode_default = () => {
|
|
51
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
52
|
+
return {
|
|
53
|
+
visitor: {
|
|
54
|
+
Import(path) {
|
|
55
|
+
if (visited) {
|
|
56
|
+
if (visited.has(path)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
visited.add(path);
|
|
60
|
+
}
|
|
61
|
+
const SOURCE = getImportSource(path.parent);
|
|
62
|
+
const builder = isString(SOURCE) ? builders.static : builders.dynamic;
|
|
63
|
+
const newImport = builder({
|
|
64
|
+
SOURCE,
|
|
65
|
+
INTEROP: path.hub.addHelper("interopRequireWildcard")
|
|
66
|
+
});
|
|
67
|
+
path.parentPath.replaceWith(newImport);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
75
71
|
};
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {});
|
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/plugins/lockCoreJS.ts
|
|
23
|
+
var lockCoreJS_exports = {};
|
|
24
|
+
__export(lockCoreJS_exports, {
|
|
25
|
+
default: () => lockCoreJS_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(lockCoreJS_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
var import_utils = require("@umijs/utils");
|
|
30
|
+
var import_path = require("path");
|
|
29
31
|
function addLastSlash(path) {
|
|
30
|
-
|
|
32
|
+
return path.endsWith("/") ? path : `${path}/`;
|
|
31
33
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
function lockCoreJS_default() {
|
|
35
|
+
return {
|
|
36
|
+
post({ path }) {
|
|
37
|
+
path.node.body.forEach((node) => {
|
|
38
|
+
if (t.isImportDeclaration(node)) {
|
|
39
|
+
if (node.source.value.startsWith("core-js/")) {
|
|
40
|
+
node.source.value = node.source.value.replace(/^core-js\//, addLastSlash((0, import_utils.winPath)((0, import_path.dirname)(require.resolve("core-js/package.json")))));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {});
|
|
@@ -1,109 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const expressions = path.get('body');
|
|
93
|
-
expressions.forEach((exp) => {
|
|
94
|
-
if (!t.isImportDeclaration(exp))
|
|
95
|
-
return;
|
|
96
|
-
const specifiers = exp.get('specifiers');
|
|
97
|
-
specifiers.forEach((s) => {
|
|
98
|
-
const name = s.get('local.name').node;
|
|
99
|
-
if (!s.scope.getBinding(name).referenced)
|
|
100
|
-
s.remove();
|
|
101
|
-
});
|
|
102
|
-
if (exp.get('specifiers').length === 0)
|
|
103
|
-
exp.remove();
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
},
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/plugins/stripExports.ts
|
|
23
|
+
var stripExports_exports = {};
|
|
24
|
+
__export(stripExports_exports, {
|
|
25
|
+
default: () => stripExports_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(stripExports_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
var stripExports_default = () => {
|
|
30
|
+
return {
|
|
31
|
+
visitor: {
|
|
32
|
+
Program: {
|
|
33
|
+
enter(path, { opts }) {
|
|
34
|
+
const expressions = path.get("body");
|
|
35
|
+
const exports = (opts == null ? void 0 : opts.exports) || [];
|
|
36
|
+
expressions.forEach((exp) => {
|
|
37
|
+
if (!(t.isExportNamedDeclaration(exp) || t.isExportDefaultDeclaration(exp)))
|
|
38
|
+
return;
|
|
39
|
+
handleExportsIndividual(exp);
|
|
40
|
+
handleExportsList(exp);
|
|
41
|
+
handleExportsDefault(exp);
|
|
42
|
+
});
|
|
43
|
+
function handleExportsIndividual(path2) {
|
|
44
|
+
if (!path2.node)
|
|
45
|
+
return;
|
|
46
|
+
if (!t.isExportNamedDeclaration(path2))
|
|
47
|
+
return;
|
|
48
|
+
if (!path2.get("declaration").node)
|
|
49
|
+
return;
|
|
50
|
+
const declaration = path2.get("declaration");
|
|
51
|
+
if (t.isVariableDeclaration(declaration)) {
|
|
52
|
+
const variables = declaration.get("declarations");
|
|
53
|
+
variables.forEach((variable) => {
|
|
54
|
+
exports.includes(variable.get("id.name").node) && variable.remove();
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
exports.includes(declaration.get("id.name").node) && declaration.remove();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function handleExportsList(path2) {
|
|
61
|
+
if (!path2.node)
|
|
62
|
+
return;
|
|
63
|
+
if (!t.isExportNamedDeclaration(path2))
|
|
64
|
+
return;
|
|
65
|
+
const specifiers = path2.get("specifiers");
|
|
66
|
+
if (!specifiers || specifiers.length === 0)
|
|
67
|
+
return;
|
|
68
|
+
specifiers.forEach((specifier) => {
|
|
69
|
+
if (exports.includes(specifier.get("exported.name").node))
|
|
70
|
+
specifier.remove();
|
|
71
|
+
});
|
|
72
|
+
if (path2.get("specifiers").length === 0)
|
|
73
|
+
path2.remove();
|
|
74
|
+
}
|
|
75
|
+
function handleExportsDefault(path2) {
|
|
76
|
+
if (!path2.node)
|
|
77
|
+
return;
|
|
78
|
+
if (!t.isExportDefaultDeclaration(path2))
|
|
79
|
+
return;
|
|
80
|
+
const declaration = path2.get("declaration");
|
|
81
|
+
if (!declaration.node)
|
|
82
|
+
return;
|
|
83
|
+
if (exports.includes(declaration.get("name").node))
|
|
84
|
+
declaration.remove();
|
|
85
|
+
}
|
|
107
86
|
},
|
|
108
|
-
|
|
87
|
+
exit(path) {
|
|
88
|
+
path.scope.crawl();
|
|
89
|
+
const expressions = path.get("body");
|
|
90
|
+
expressions.forEach((exp) => {
|
|
91
|
+
if (!t.isImportDeclaration(exp))
|
|
92
|
+
return;
|
|
93
|
+
const specifiers = exp.get("specifiers");
|
|
94
|
+
specifiers.forEach((s) => {
|
|
95
|
+
const name = s.get("local.name").node;
|
|
96
|
+
if (!s.scope.getBinding(name).referenced)
|
|
97
|
+
s.remove();
|
|
98
|
+
});
|
|
99
|
+
if (exp.get("specifiers").length === 0)
|
|
100
|
+
exp.remove();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
109
106
|
};
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/babel-preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
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",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "umi-scripts father build",
|
|
19
19
|
"build:deps": "umi-scripts bundleDeps",
|
|
20
|
-
"dev": "
|
|
20
|
+
"dev": "umi-scripts father dev",
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
24
|
+
"@babel/runtime": "7.18.9",
|
|
25
25
|
"@bloomberg/record-tuple-polyfill": "0.0.4",
|
|
26
|
-
"@umijs/bundler-utils": "4.0.
|
|
27
|
-
"@umijs/utils": "4.0.
|
|
26
|
+
"@umijs/bundler-utils": "4.0.10",
|
|
27
|
+
"@umijs/utils": "4.0.10",
|
|
28
28
|
"core-js": "3.22.4"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|