@modern-js/plugin-v2 2.63.7 → 2.63.8-alpha.1

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.
Files changed (101) hide show
  1. package/dist/cjs/cli/run/create.js +25 -14
  2. package/dist/cjs/hooks.js +74 -2
  3. package/dist/cjs/index.js +8 -2
  4. package/dist/cjs/manager.js +3 -5
  5. package/dist/cjs/runtime/api.js +79 -0
  6. package/dist/cjs/runtime/context.js +51 -0
  7. package/dist/cjs/runtime/hooks.js +36 -0
  8. package/dist/cjs/runtime/index.js +39 -0
  9. package/dist/cjs/runtime/run/create.js +74 -0
  10. package/dist/cjs/runtime/run/index.js +29 -0
  11. package/dist/cjs/runtime/run/types.js +16 -0
  12. package/dist/cjs/types/runtime/api.js +16 -0
  13. package/dist/cjs/types/runtime/context.js +16 -0
  14. package/dist/cjs/types/runtime/hooks.js +16 -0
  15. package/dist/cjs/types/runtime/index.js +16 -0
  16. package/dist/cjs/types/runtime/plugin.js +16 -0
  17. package/dist/esm/cli/api.js +103 -0
  18. package/dist/esm/cli/context.js +53 -0
  19. package/dist/esm/cli/hooks.js +42 -0
  20. package/dist/esm/cli/index.js +14 -0
  21. package/dist/esm/cli/run/config/createLoadedConfig.js +190 -0
  22. package/dist/esm/cli/run/config/createResolvedConfig.js +30 -0
  23. package/dist/esm/cli/run/config/loadConfig.js +210 -0
  24. package/dist/esm/cli/run/create.js +300 -0
  25. package/dist/esm/cli/run/index.js +10 -0
  26. package/dist/esm/cli/run/run.js +60 -0
  27. package/dist/esm/cli/run/types.js +0 -0
  28. package/dist/esm/cli/run/utils/checkIsDuplicationPlugin.js +24 -0
  29. package/dist/esm/cli/run/utils/commander.js +42 -0
  30. package/dist/esm/cli/run/utils/createFileWatcher.js +110 -0
  31. package/dist/esm/cli/run/utils/debug.js +5 -0
  32. package/dist/esm/cli/run/utils/initAppDir.js +36 -0
  33. package/dist/esm/cli/run/utils/loadEnv.js +24 -0
  34. package/dist/esm/cli/run/utils/mergeConfig.js +43 -0
  35. package/dist/esm/hooks.js +378 -0
  36. package/dist/esm/index.js +6 -357
  37. package/dist/esm/manager.js +161 -0
  38. package/dist/esm/runtime/api.js +59 -0
  39. package/dist/esm/runtime/context.js +25 -0
  40. package/dist/esm/runtime/hooks.js +12 -0
  41. package/dist/esm/runtime/index.js +11 -0
  42. package/dist/esm/runtime/run/create.js +72 -0
  43. package/dist/esm/runtime/run/index.js +5 -0
  44. package/dist/esm/runtime/run/types.js +0 -0
  45. package/dist/esm/types/cli/api.js +0 -0
  46. package/dist/esm/types/cli/context.js +0 -0
  47. package/dist/esm/types/cli/hooks.js +0 -0
  48. package/dist/esm/types/cli/index.js +0 -0
  49. package/dist/esm/types/cli/plugin.js +0 -0
  50. package/dist/esm/types/hooks.js +0 -0
  51. package/dist/esm/types/index.js +0 -0
  52. package/dist/esm/types/plugin.js +0 -0
  53. package/dist/esm/types/runtime/api.js +0 -0
  54. package/dist/esm/types/runtime/context.js +0 -0
  55. package/dist/esm/types/runtime/hooks.js +0 -0
  56. package/dist/esm/types/runtime/index.js +0 -0
  57. package/dist/esm/types/runtime/plugin.js +0 -0
  58. package/dist/esm/types/utils.js +0 -0
  59. package/dist/esm-node/cli/run/create.js +26 -15
  60. package/dist/esm-node/hooks.js +70 -1
  61. package/dist/esm-node/index.js +5 -2
  62. package/dist/esm-node/manager.js +2 -4
  63. package/dist/esm-node/runtime/api.js +55 -0
  64. package/dist/esm-node/runtime/context.js +26 -0
  65. package/dist/esm-node/runtime/hooks.js +12 -0
  66. package/dist/esm-node/runtime/index.js +11 -0
  67. package/dist/esm-node/runtime/run/create.js +50 -0
  68. package/dist/esm-node/runtime/run/index.js +5 -0
  69. package/dist/esm-node/runtime/run/types.js +0 -0
  70. package/dist/esm-node/types/runtime/api.js +0 -0
  71. package/dist/esm-node/types/runtime/context.js +0 -0
  72. package/dist/esm-node/types/runtime/hooks.js +0 -0
  73. package/dist/esm-node/types/runtime/index.js +0 -0
  74. package/dist/esm-node/types/runtime/plugin.js +0 -0
  75. package/dist/types/cli/hooks.d.ts +3 -3
  76. package/dist/types/cli/run/create.d.ts +2 -1
  77. package/dist/types/cli/run/index.d.ts +4 -4
  78. package/dist/types/hooks.d.ts +4 -1
  79. package/dist/types/index.d.ts +2 -1
  80. package/dist/types/manager.d.ts +3 -0
  81. package/dist/types/runtime/api.d.ts +9 -0
  82. package/dist/types/runtime/context.d.ts +11 -0
  83. package/dist/types/runtime/hooks.d.ts +2 -0
  84. package/dist/types/runtime/index.d.ts +5 -0
  85. package/dist/types/runtime/run/create.d.ts +7 -0
  86. package/dist/types/runtime/run/index.d.ts +5 -0
  87. package/dist/types/runtime/run/types.d.ts +6 -0
  88. package/dist/types/types/cli/api.d.ts +2 -2
  89. package/dist/types/types/cli/context.d.ts +1 -1
  90. package/dist/types/types/cli/hooks.d.ts +3 -3
  91. package/dist/types/types/cli/plugin.d.ts +2 -1
  92. package/dist/types/types/hooks.d.ts +14 -2
  93. package/dist/types/types/index.d.ts +1 -0
  94. package/dist/types/types/plugin.d.ts +1 -1
  95. package/dist/types/types/runtime/api.d.ts +15 -0
  96. package/dist/types/types/runtime/context.d.ts +13 -0
  97. package/dist/types/types/runtime/hooks.d.ts +12 -0
  98. package/dist/types/types/runtime/index.d.ts +4 -0
  99. package/dist/types/types/runtime/plugin.d.ts +14 -0
  100. package/dist/types/types/utils.d.ts +1 -0
  101. package/package.json +13 -9
@@ -0,0 +1,378 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
+ function createAsyncInterruptHook() {
5
+ var callbacks = [];
6
+ var tap = function(cb) {
7
+ callbacks.push(cb);
8
+ };
9
+ var call = function() {
10
+ var _ref = _async_to_generator(function() {
11
+ var _len, params, _key, interrupted, interruptResult, interrupt, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback, result, err;
12
+ var _arguments = arguments;
13
+ return _ts_generator(this, function(_state) {
14
+ switch (_state.label) {
15
+ case 0:
16
+ for (_len = _arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
17
+ params[_key] = _arguments[_key];
18
+ }
19
+ interrupted = false;
20
+ interrupt = function(info) {
21
+ interrupted = true;
22
+ interruptResult = info;
23
+ };
24
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
25
+ _state.label = 1;
26
+ case 1:
27
+ _state.trys.push([
28
+ 1,
29
+ 6,
30
+ 7,
31
+ 8
32
+ ]);
33
+ _iterator = callbacks[Symbol.iterator]();
34
+ _state.label = 2;
35
+ case 2:
36
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
37
+ return [
38
+ 3,
39
+ 5
40
+ ];
41
+ callback = _step.value;
42
+ if (interrupted)
43
+ return [
44
+ 3,
45
+ 5
46
+ ];
47
+ return [
48
+ 4,
49
+ callback.apply(void 0, _to_consumable_array(params).concat([
50
+ interrupt
51
+ ]))
52
+ ];
53
+ case 3:
54
+ result = _state.sent();
55
+ if (result !== void 0) {
56
+ params[0] = result;
57
+ }
58
+ _state.label = 4;
59
+ case 4:
60
+ _iteratorNormalCompletion = true;
61
+ return [
62
+ 3,
63
+ 2
64
+ ];
65
+ case 5:
66
+ return [
67
+ 3,
68
+ 8
69
+ ];
70
+ case 6:
71
+ err = _state.sent();
72
+ _didIteratorError = true;
73
+ _iteratorError = err;
74
+ return [
75
+ 3,
76
+ 8
77
+ ];
78
+ case 7:
79
+ try {
80
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
81
+ _iterator.return();
82
+ }
83
+ } finally {
84
+ if (_didIteratorError) {
85
+ throw _iteratorError;
86
+ }
87
+ }
88
+ return [
89
+ 7
90
+ ];
91
+ case 8:
92
+ return [
93
+ 2,
94
+ interrupted ? interruptResult : params[0] || []
95
+ ];
96
+ }
97
+ });
98
+ });
99
+ return function call2() {
100
+ return _ref.apply(this, arguments);
101
+ };
102
+ }();
103
+ return {
104
+ tap,
105
+ call
106
+ };
107
+ }
108
+ function createSyncHook() {
109
+ var callbacks = [];
110
+ var tap = function(cb) {
111
+ callbacks.push(cb);
112
+ };
113
+ var call = function() {
114
+ for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
115
+ params[_key] = arguments[_key];
116
+ }
117
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
118
+ try {
119
+ for (var _iterator = callbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
120
+ var callback = _step.value;
121
+ var result = callback.apply(void 0, _to_consumable_array(params));
122
+ if (result !== void 0) {
123
+ params[0] = result;
124
+ }
125
+ }
126
+ } catch (err) {
127
+ _didIteratorError = true;
128
+ _iteratorError = err;
129
+ } finally {
130
+ try {
131
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
132
+ _iterator.return();
133
+ }
134
+ } finally {
135
+ if (_didIteratorError) {
136
+ throw _iteratorError;
137
+ }
138
+ }
139
+ }
140
+ return params[0];
141
+ };
142
+ return {
143
+ tap,
144
+ call
145
+ };
146
+ }
147
+ function createAsyncHook() {
148
+ var callbacks = [];
149
+ var tap = function(cb) {
150
+ callbacks.push(cb);
151
+ };
152
+ var call = function() {
153
+ var _ref = _async_to_generator(function() {
154
+ var _len, params, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback, result, err;
155
+ var _arguments = arguments;
156
+ return _ts_generator(this, function(_state) {
157
+ switch (_state.label) {
158
+ case 0:
159
+ for (_len = _arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
160
+ params[_key] = _arguments[_key];
161
+ }
162
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
163
+ _state.label = 1;
164
+ case 1:
165
+ _state.trys.push([
166
+ 1,
167
+ 6,
168
+ 7,
169
+ 8
170
+ ]);
171
+ _iterator = callbacks[Symbol.iterator]();
172
+ _state.label = 2;
173
+ case 2:
174
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
175
+ return [
176
+ 3,
177
+ 5
178
+ ];
179
+ callback = _step.value;
180
+ return [
181
+ 4,
182
+ callback.apply(void 0, _to_consumable_array(params))
183
+ ];
184
+ case 3:
185
+ result = _state.sent();
186
+ if (result !== void 0) {
187
+ params[0] = result;
188
+ }
189
+ _state.label = 4;
190
+ case 4:
191
+ _iteratorNormalCompletion = true;
192
+ return [
193
+ 3,
194
+ 2
195
+ ];
196
+ case 5:
197
+ return [
198
+ 3,
199
+ 8
200
+ ];
201
+ case 6:
202
+ err = _state.sent();
203
+ _didIteratorError = true;
204
+ _iteratorError = err;
205
+ return [
206
+ 3,
207
+ 8
208
+ ];
209
+ case 7:
210
+ try {
211
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
212
+ _iterator.return();
213
+ }
214
+ } finally {
215
+ if (_didIteratorError) {
216
+ throw _iteratorError;
217
+ }
218
+ }
219
+ return [
220
+ 7
221
+ ];
222
+ case 8:
223
+ return [
224
+ 2,
225
+ params[0] || []
226
+ ];
227
+ }
228
+ });
229
+ });
230
+ return function call2() {
231
+ return _ref.apply(this, arguments);
232
+ };
233
+ }();
234
+ return {
235
+ tap,
236
+ call
237
+ };
238
+ }
239
+ function createCollectAsyncHook() {
240
+ var callbacks = [];
241
+ var tap = function(cb) {
242
+ callbacks.push(cb);
243
+ };
244
+ var call = function() {
245
+ var _ref = _async_to_generator(function() {
246
+ var _len, params, _key, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback, result, err;
247
+ var _arguments = arguments;
248
+ return _ts_generator(this, function(_state) {
249
+ switch (_state.label) {
250
+ case 0:
251
+ for (_len = _arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
252
+ params[_key] = _arguments[_key];
253
+ }
254
+ results = [];
255
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
256
+ _state.label = 1;
257
+ case 1:
258
+ _state.trys.push([
259
+ 1,
260
+ 6,
261
+ 7,
262
+ 8
263
+ ]);
264
+ _iterator = callbacks[Symbol.iterator]();
265
+ _state.label = 2;
266
+ case 2:
267
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
268
+ return [
269
+ 3,
270
+ 5
271
+ ];
272
+ callback = _step.value;
273
+ return [
274
+ 4,
275
+ callback(params)
276
+ ];
277
+ case 3:
278
+ result = _state.sent();
279
+ if (result !== void 0) {
280
+ results.push(result);
281
+ }
282
+ _state.label = 4;
283
+ case 4:
284
+ _iteratorNormalCompletion = true;
285
+ return [
286
+ 3,
287
+ 2
288
+ ];
289
+ case 5:
290
+ return [
291
+ 3,
292
+ 8
293
+ ];
294
+ case 6:
295
+ err = _state.sent();
296
+ _didIteratorError = true;
297
+ _iteratorError = err;
298
+ return [
299
+ 3,
300
+ 8
301
+ ];
302
+ case 7:
303
+ try {
304
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
305
+ _iterator.return();
306
+ }
307
+ } finally {
308
+ if (_didIteratorError) {
309
+ throw _iteratorError;
310
+ }
311
+ }
312
+ return [
313
+ 7
314
+ ];
315
+ case 8:
316
+ return [
317
+ 2,
318
+ results
319
+ ];
320
+ }
321
+ });
322
+ });
323
+ return function call2() {
324
+ return _ref.apply(this, arguments);
325
+ };
326
+ }();
327
+ return {
328
+ tap,
329
+ call
330
+ };
331
+ }
332
+ function createCollectSyncHook() {
333
+ var callbacks = [];
334
+ var tap = function(cb) {
335
+ callbacks.push(cb);
336
+ };
337
+ var call = function() {
338
+ for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
339
+ params[_key] = arguments[_key];
340
+ }
341
+ var results = [];
342
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
343
+ try {
344
+ for (var _iterator = callbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
345
+ var callback = _step.value;
346
+ var result = callback(params);
347
+ if (result !== void 0) {
348
+ results.push(result);
349
+ }
350
+ }
351
+ } catch (err) {
352
+ _didIteratorError = true;
353
+ _iteratorError = err;
354
+ } finally {
355
+ try {
356
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
357
+ _iterator.return();
358
+ }
359
+ } finally {
360
+ if (_didIteratorError) {
361
+ throw _iteratorError;
362
+ }
363
+ }
364
+ }
365
+ return results;
366
+ };
367
+ return {
368
+ tap,
369
+ call
370
+ };
371
+ }
372
+ export {
373
+ createAsyncHook,
374
+ createAsyncInterruptHook,
375
+ createCollectAsyncHook,
376
+ createCollectSyncHook,
377
+ createSyncHook
378
+ };