@umijs/babel-preset-umi 4.0.50 → 4.0.52
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
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -41,12 +45,16 @@ var src_default = (_context, opts) => {
|
|
|
41
45
|
require.resolve("@umijs/bundler-utils/compiled/babel/preset-env"),
|
|
42
46
|
{
|
|
43
47
|
bugfixes: true,
|
|
48
|
+
// 更兼容 spec,但会变慢,所以不开
|
|
44
49
|
spec: false,
|
|
50
|
+
// 推荐用 top level 的 assumptions 配置
|
|
45
51
|
loose: false,
|
|
52
|
+
// 保留 es modules 语法,交给 webpack 处理
|
|
46
53
|
modules: false,
|
|
47
54
|
debug: false,
|
|
48
55
|
useBuiltIns: "entry",
|
|
49
56
|
corejs: (0, import_utils.getCorejsVersion)((0, import_path.join)(__dirname, "../package.json")),
|
|
57
|
+
// 没必要,遇到了应该改 targets 配置
|
|
50
58
|
forceAllTransforms: false,
|
|
51
59
|
ignoreBrowserslistConfig: true,
|
|
52
60
|
...opts.presetEnv
|
|
@@ -65,6 +73,9 @@ var src_default = (_context, opts) => {
|
|
|
65
73
|
{
|
|
66
74
|
allowNamespaces: true,
|
|
67
75
|
allowDeclareFields: true,
|
|
76
|
+
// Why false?
|
|
77
|
+
// 如果为 true,babel 只删除 import type 语句,会保留其他通过 import 引入的 type
|
|
78
|
+
// 这些 type 引用走到 webpack 之后,就会报错
|
|
68
79
|
onlyRemoveTypeImports: false,
|
|
69
80
|
optimizeConstEnums: true,
|
|
70
81
|
...opts.presetTypeScript
|
|
@@ -78,10 +89,24 @@ var src_default = (_context, opts) => {
|
|
|
78
89
|
...opts.pluginStyledComponents
|
|
79
90
|
}
|
|
80
91
|
],
|
|
92
|
+
// TC39 Proposals
|
|
93
|
+
// class-static-block
|
|
94
|
+
// decorators
|
|
81
95
|
[
|
|
82
96
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-decorators"),
|
|
83
97
|
{ legacy: true }
|
|
84
98
|
],
|
|
99
|
+
// Enable loose mode to use assignment instead of defineProperty
|
|
100
|
+
// Note:
|
|
101
|
+
// 'loose' mode configuration must be the same for
|
|
102
|
+
// * @babel/plugin-proposal-class-properties
|
|
103
|
+
// * @babel/plugin-proposal-private-methods
|
|
104
|
+
// * @babel/plugin-proposal-private-property-in-object
|
|
105
|
+
// (when they are enabled)
|
|
106
|
+
// ref: https://github.com/facebook/create-react-app/issues/4263
|
|
107
|
+
// ref: https://github.com/mobxjs/mobx/issues/1471
|
|
108
|
+
// ref: https://github.com/umijs/umi/issues/9396
|
|
109
|
+
// 不移动到 feature 里的原因是因为 decorators 有顺序要求
|
|
85
110
|
opts.classPropertiesLoose && [
|
|
86
111
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-class-properties"),
|
|
87
112
|
{ loose: true }
|
|
@@ -98,25 +123,34 @@ var src_default = (_context, opts) => {
|
|
|
98
123
|
loose: true
|
|
99
124
|
}
|
|
100
125
|
],
|
|
126
|
+
// do-expressions
|
|
101
127
|
[
|
|
102
128
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-do-expressions")
|
|
103
129
|
],
|
|
130
|
+
// export-default-from
|
|
104
131
|
[
|
|
105
132
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-export-default-from")
|
|
106
133
|
],
|
|
134
|
+
// export-namespace-from
|
|
107
135
|
[
|
|
108
136
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-export-namespace-from")
|
|
109
137
|
],
|
|
138
|
+
// function-bind
|
|
110
139
|
[
|
|
111
140
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-function-bind")
|
|
112
141
|
],
|
|
142
|
+
// function-sent
|
|
143
|
+
// partial-application
|
|
113
144
|
[
|
|
114
145
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-partial-application")
|
|
115
146
|
],
|
|
147
|
+
// pipeline-operator
|
|
116
148
|
[
|
|
117
149
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-pipeline-operator"),
|
|
118
150
|
{ proposal: "minimal" }
|
|
119
151
|
],
|
|
152
|
+
// throw-expressions
|
|
153
|
+
// record-and-tuple
|
|
120
154
|
[
|
|
121
155
|
require.resolve("@umijs/bundler-utils/compiled/babel/plugin-proposal-record-and-tuple"),
|
|
122
156
|
{
|
|
@@ -132,12 +166,18 @@ var src_default = (_context, opts) => {
|
|
|
132
166
|
{
|
|
133
167
|
helpers: true,
|
|
134
168
|
regenerator: true,
|
|
169
|
+
// 7.13 之后根据 exports 自动选择 esm 和 cjs,无需此配置
|
|
135
170
|
useESModules: false,
|
|
171
|
+
// lock the version of @babel/runtime
|
|
172
|
+
// make sure we are using the correct version
|
|
173
|
+
// ref: https://github.com/babel/babel/blob/v7.16.12/packages/babel-plugin-transform-runtime/src/get-runtime-path/index.ts#L19
|
|
174
|
+
// ref: https://github.com/umijs/umi/pull/7816
|
|
136
175
|
absoluteRuntime: (0, import_path.dirname)(require.resolve("../package.json")),
|
|
137
176
|
version: `^${require("@babel/runtime/package.json").version}`,
|
|
138
177
|
...opts.pluginTransformRuntime
|
|
139
178
|
}
|
|
140
179
|
],
|
|
180
|
+
// none official plugins
|
|
141
181
|
opts.pluginLockCoreJS && [import_lockCoreJS.default],
|
|
142
182
|
opts.pluginDynamicImportNode && [import_dynamicImportNode.default],
|
|
143
183
|
opts.pluginAutoCSSModules && [import_autoCSSModules.default],
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -44,6 +48,8 @@ function autoCSSModules_default() {
|
|
|
44
48
|
source.value = `${value}?modules`;
|
|
45
49
|
}
|
|
46
50
|
},
|
|
51
|
+
// e.g.
|
|
52
|
+
// const styles = await import('./index.less');
|
|
47
53
|
VariableDeclarator(path) {
|
|
48
54
|
const { node } = path;
|
|
49
55
|
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))) {
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
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.52",
|
|
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",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/runtime": "7.20.7",
|
|
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.52",
|
|
27
|
+
"@umijs/utils": "4.0.52",
|
|
28
28
|
"babel-plugin-styled-components": "2.0.7",
|
|
29
29
|
"core-js": "3.27.1"
|
|
30
30
|
},
|