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.
@@ -9,29 +9,22 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
10
  import { assert, compose, isPromiseLike } from "./utils";
11
11
  export var ApplyPluginsType;
12
-
13
12
  (function (ApplyPluginsType) {
14
13
  ApplyPluginsType["compose"] = "compose";
15
14
  ApplyPluginsType["modify"] = "modify";
16
15
  ApplyPluginsType["event"] = "event";
17
16
  })(ApplyPluginsType || (ApplyPluginsType = {}));
18
-
19
17
  export var PluginManager = /*#__PURE__*/function () {
20
18
  function PluginManager(opts) {
21
19
  _classCallCheck(this, PluginManager);
22
-
23
20
  _defineProperty(this, "opts", void 0);
24
-
25
21
  _defineProperty(this, "hooks", {});
26
-
27
22
  this.opts = opts;
28
23
  }
29
-
30
24
  _createClass(PluginManager, [{
31
25
  key: "register",
32
26
  value: function register(plugin) {
33
27
  var _this = this;
34
-
35
28
  assert(plugin.apply, "plugin register failed, apply must supplied");
36
29
  Object.keys(plugin.apply).forEach(function (key) {
37
30
  assert(_this.opts.validKeys.indexOf(key) > -1, "register failed, invalid key ".concat(key, " ").concat(plugin.path ? "from plugin ".concat(plugin.path) : '', "."));
@@ -42,20 +35,16 @@ export var PluginManager = /*#__PURE__*/function () {
42
35
  key: "getHooks",
43
36
  value: function getHooks(keyWithDot) {
44
37
  var _keyWithDot$split = keyWithDot.split('.'),
45
- _keyWithDot$split2 = _toArray(_keyWithDot$split),
46
- key = _keyWithDot$split2[0],
47
- memberKeys = _keyWithDot$split2.slice(1);
48
-
38
+ _keyWithDot$split2 = _toArray(_keyWithDot$split),
39
+ key = _keyWithDot$split2[0],
40
+ memberKeys = _keyWithDot$split2.slice(1);
49
41
  var hooks = this.hooks[key] || [];
50
-
51
42
  if (memberKeys.length) {
52
43
  hooks = hooks.map(function (hook) {
53
44
  try {
54
45
  var ret = hook;
55
-
56
46
  var _iterator = _createForOfIteratorHelper(memberKeys),
57
- _step;
58
-
47
+ _step;
59
48
  try {
60
49
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
61
50
  var memberKey = _step.value;
@@ -66,34 +55,29 @@ export var PluginManager = /*#__PURE__*/function () {
66
55
  } finally {
67
56
  _iterator.f();
68
57
  }
69
-
70
58
  return ret;
71
59
  } catch (e) {
72
60
  return null;
73
61
  }
74
62
  }).filter(Boolean);
75
63
  }
76
-
77
64
  return hooks;
78
65
  }
79
66
  }, {
80
67
  key: "applyPlugins",
81
68
  value: function applyPlugins(_ref) {
82
69
  var key = _ref.key,
83
- type = _ref.type,
84
- initialValue = _ref.initialValue,
85
- args = _ref.args,
86
- async = _ref.async;
70
+ type = _ref.type,
71
+ initialValue = _ref.initialValue,
72
+ args = _ref.args,
73
+ async = _ref.async;
87
74
  var hooks = this.getHooks(key) || [];
88
-
89
75
  if (args) {
90
76
  assert(_typeof(args) === 'object', "applyPlugins failed, args must be plain object.");
91
77
  }
92
-
93
78
  if (async) {
94
79
  assert(type === ApplyPluginsType.modify || type === ApplyPluginsType.event, "async only works with modify and event type.");
95
80
  }
96
-
97
81
  switch (type) {
98
82
  case ApplyPluginsType.modify:
99
83
  if (async) {
@@ -105,59 +89,44 @@ export var PluginManager = /*#__PURE__*/function () {
105
89
  switch (_context.prev = _context.next) {
106
90
  case 0:
107
91
  assert(typeof hook === 'function' || _typeof(hook) === 'object' || isPromiseLike(hook), "applyPlugins failed, all hooks for key ".concat(key, " must be function, plain object or Promise."));
108
-
109
92
  if (!isPromiseLike(memo)) {
110
93
  _context.next = 5;
111
94
  break;
112
95
  }
113
-
114
96
  _context.next = 4;
115
97
  return memo;
116
-
117
98
  case 4:
118
99
  memo = _context.sent;
119
-
120
100
  case 5:
121
101
  if (!(typeof hook === 'function')) {
122
102
  _context.next = 16;
123
103
  break;
124
104
  }
125
-
126
105
  ret = hook(memo, args);
127
-
128
106
  if (!isPromiseLike(ret)) {
129
107
  _context.next = 13;
130
108
  break;
131
109
  }
132
-
133
110
  _context.next = 10;
134
111
  return ret;
135
-
136
112
  case 10:
137
113
  return _context.abrupt("return", _context.sent);
138
-
139
114
  case 13:
140
115
  return _context.abrupt("return", ret);
141
-
142
116
  case 14:
143
117
  _context.next = 21;
144
118
  break;
145
-
146
119
  case 16:
147
120
  if (!isPromiseLike(hook)) {
148
121
  _context.next = 20;
149
122
  break;
150
123
  }
151
-
152
124
  _context.next = 19;
153
125
  return hook;
154
-
155
126
  case 19:
156
127
  hook = _context.sent;
157
-
158
128
  case 20:
159
129
  return _context.abrupt("return", _objectSpread(_objectSpread({}, memo), hook));
160
-
161
130
  case 21:
162
131
  case "end":
163
132
  return _context.stop();
@@ -165,7 +134,6 @@ export var PluginManager = /*#__PURE__*/function () {
165
134
  }
166
135
  }, _callee);
167
136
  }));
168
-
169
137
  return function (_x, _x2) {
170
138
  return _ref2.apply(this, arguments);
171
139
  };
@@ -173,7 +141,6 @@ export var PluginManager = /*#__PURE__*/function () {
173
141
  } else {
174
142
  return hooks.reduce(function (memo, hook) {
175
143
  assert(typeof hook === 'function' || _typeof(hook) === 'object', "applyPlugins failed, all hooks for key ".concat(key, " must be function or plain object."));
176
-
177
144
  if (typeof hook === 'function') {
178
145
  return hook(memo, args);
179
146
  } else {
@@ -182,59 +149,44 @@ export var PluginManager = /*#__PURE__*/function () {
182
149
  }
183
150
  }, initialValue);
184
151
  }
185
-
186
152
  case ApplyPluginsType.event:
187
153
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
188
154
  var _iterator2, _step2, hook, ret;
189
-
190
155
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
191
156
  while (1) {
192
157
  switch (_context2.prev = _context2.next) {
193
158
  case 0:
194
159
  _iterator2 = _createForOfIteratorHelper(hooks);
195
160
  _context2.prev = 1;
196
-
197
161
  _iterator2.s();
198
-
199
162
  case 3:
200
163
  if ((_step2 = _iterator2.n()).done) {
201
164
  _context2.next = 12;
202
165
  break;
203
166
  }
204
-
205
167
  hook = _step2.value;
206
168
  assert(typeof hook === 'function', "applyPlugins failed, all hooks for key ".concat(key, " must be function."));
207
169
  ret = hook(args);
208
-
209
170
  if (!(async && isPromiseLike(ret))) {
210
171
  _context2.next = 10;
211
172
  break;
212
173
  }
213
-
214
174
  _context2.next = 10;
215
175
  return ret;
216
-
217
176
  case 10:
218
177
  _context2.next = 3;
219
178
  break;
220
-
221
179
  case 12:
222
180
  _context2.next = 17;
223
181
  break;
224
-
225
182
  case 14:
226
183
  _context2.prev = 14;
227
184
  _context2.t0 = _context2["catch"](1);
228
-
229
185
  _iterator2.e(_context2.t0);
230
-
231
186
  case 17:
232
187
  _context2.prev = 17;
233
-
234
188
  _iterator2.f();
235
-
236
189
  return _context2.finish(17);
237
-
238
190
  case 20:
239
191
  case "end":
240
192
  return _context2.stop();
@@ -242,7 +194,6 @@ export var PluginManager = /*#__PURE__*/function () {
242
194
  }
243
195
  }, _callee2, null, [[1, 14, 17, 20]]);
244
196
  }))();
245
-
246
197
  case ApplyPluginsType.compose:
247
198
  return function () {
248
199
  return compose({
@@ -264,7 +215,8 @@ export var PluginManager = /*#__PURE__*/function () {
264
215
  return pluginManager;
265
216
  }
266
217
  }]);
267
-
268
218
  return PluginManager;
269
- }(); // plugins meta info (in tmp file)
219
+ }();
220
+
221
+ // plugins meta info (in tmp file)
270
222
  // hooks api: usePlugin
@@ -4,12 +4,10 @@ export function assert(value, message) {
4
4
  }
5
5
  export function compose(_ref) {
6
6
  var fns = _ref.fns,
7
- args = _ref.args;
8
-
7
+ args = _ref.args;
9
8
  if (fns.length === 1) {
10
9
  return fns[0];
11
10
  }
12
-
13
11
  var last = fns.pop();
14
12
  return fns.reduce(function (a, b) {
15
13
  return function () {
package/dist/cli/cli.js CHANGED
@@ -40,7 +40,7 @@ async function run(opts) {
40
40
  boolean: ["version"]
41
41
  });
42
42
  const command = args._[0];
43
- if ([import_constants.DEV_COMMAND, "setup"].includes(command)) {
43
+ if ([import_constants.DEV_COMMAND, "mfsu", "setup"].includes(command)) {
44
44
  process.env.NODE_ENV = "development";
45
45
  } else if (command === "build") {
46
46
  process.env.NODE_ENV = "production";
package/dist/cli/dev.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
  ));
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  };
19
19
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -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/dist/test.js CHANGED
@@ -25,6 +25,7 @@ __export(test_exports, {
25
25
  getUmiAlias: () => getUmiAlias
26
26
  });
27
27
  module.exports = __toCommonJS(test_exports);
28
+ var import_utils = require("@umijs/utils");
28
29
  var import_fs = require("fs");
29
30
  var import_service = require("./service/service");
30
31
  __reExport(test_exports, require("@umijs/test"), module.exports);
@@ -56,6 +57,7 @@ async function getUmiAlias() {
56
57
  return service.config.alias;
57
58
  }
58
59
  async function configUmiAlias(config) {
60
+ (0, import_utils.setNoDeprecation)();
59
61
  config.moduleNameMapper || (config.moduleNameMapper = {});
60
62
  const alias = await getUmiAlias();
61
63
  for (const key of Object.keys(alias)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umi",
3
- "version": "4.0.50",
3
+ "version": "4.0.52",
4
4
  "description": "umi",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -38,15 +38,15 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "7.20.7",
41
- "@umijs/bundler-utils": "4.0.50",
42
- "@umijs/bundler-webpack": "4.0.50",
43
- "@umijs/core": "4.0.50",
44
- "@umijs/lint": "4.0.50",
45
- "@umijs/preset-umi": "4.0.50",
46
- "@umijs/renderer-react": "4.0.50",
47
- "@umijs/server": "4.0.50",
48
- "@umijs/test": "4.0.50",
49
- "@umijs/utils": "4.0.50",
41
+ "@umijs/bundler-utils": "4.0.52",
42
+ "@umijs/bundler-webpack": "4.0.52",
43
+ "@umijs/core": "4.0.52",
44
+ "@umijs/lint": "4.0.52",
45
+ "@umijs/preset-umi": "4.0.52",
46
+ "@umijs/renderer-react": "4.0.52",
47
+ "@umijs/server": "4.0.52",
48
+ "@umijs/test": "4.0.52",
49
+ "@umijs/utils": "4.0.52",
50
50
  "prettier-plugin-organize-imports": "^3.2.1",
51
51
  "prettier-plugin-packagejson": "2.3.0"
52
52
  },
package/plugin-utils.d.ts CHANGED
@@ -1 +1 @@
1
- export type * from './dist/pluginUtils';
1
+ export * from './dist/pluginUtils';