@modern-js/app-tools 2.19.1 → 2.21.0
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/CHANGELOG.md +115 -0
- package/bin/modern.js +0 -1
- package/dist/cjs/analyze/generateCode.js +22 -48
- package/dist/cjs/analyze/getBundleEntry.js +3 -7
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +2 -6
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +2 -6
- package/dist/cjs/analyze/getClientRoutes/utils.js +2 -6
- package/dist/cjs/analyze/getFileSystemEntry.js +3 -7
- package/dist/cjs/analyze/getHtmlTemplate.js +4 -47
- package/dist/cjs/analyze/getServerRoutes.js +5 -7
- package/dist/cjs/analyze/index.js +11 -48
- package/dist/cjs/analyze/isDefaultExportFunction.js +5 -48
- package/dist/cjs/analyze/nestedRoutes.js +2 -41
- package/dist/cjs/analyze/templates.js +2 -6
- package/dist/cjs/analyze/utils.js +3 -7
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +4 -21
- package/dist/cjs/builder/builder-webpack/index.js +2 -41
- package/dist/cjs/builder/generator/index.js +3 -42
- package/dist/cjs/builder/index.js +4 -43
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +6 -56
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +6 -45
- package/dist/cjs/builder/shared/builderPlugins/index.js +4 -16
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +3 -15
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +5 -17
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -6
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +4 -16
- package/dist/cjs/builder/shared/createCopyInfo.js +2 -6
- package/dist/cjs/builder/shared/index.js +4 -16
- package/dist/cjs/commands/index.js +4 -16
- package/dist/cjs/commands/serve.js +2 -6
- package/dist/cjs/config/index.js +4 -16
- package/dist/cjs/config/initialize/inits.js +2 -41
- package/dist/cjs/index.js +41 -80
- package/dist/cjs/schema/Schema.js +2 -14
- package/dist/cjs/schema/index.js +2 -6
- package/dist/cjs/types/config/index.js +2 -14
- package/dist/cjs/types/index.js +4 -16
- package/dist/cjs/utils/config.js +2 -41
- package/dist/cjs/utils/generateWatchFiles.js +2 -6
- package/dist/cjs/utils/routes.js +2 -6
- package/dist/esm/analyze/generateCode.js +13 -170
- package/dist/esm/analyze/getBundleEntry.js +1 -1
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +2 -52
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +2 -52
- package/dist/esm/analyze/getHtmlTemplate.js +6 -151
- package/dist/esm/analyze/getServerRoutes.js +6 -118
- package/dist/esm/analyze/index.js +19 -251
- package/dist/esm/analyze/nestedRoutes.js +5 -184
- package/dist/esm/analyze/templates.js +6 -242
- package/dist/esm/analyze/utils.js +6 -205
- package/dist/esm/builder/builder-rspack/adapterCopy.js +10 -235
- package/dist/esm/builder/builder-webpack/adapterModern.js +1 -34
- package/dist/esm/builder/builder-webpack/index.js +7 -219
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +2 -52
- package/dist/esm/builder/generator/index.js +4 -133
- package/dist/esm/builder/index.js +3 -132
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +9 -191
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +10 -139
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -69
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +3 -35
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +7 -226
- package/dist/esm/commands/build.js +5 -184
- package/dist/esm/commands/deploy.js +3 -132
- package/dist/esm/commands/dev.js +6 -185
- package/dist/esm/commands/inspect.js +3 -132
- package/dist/esm/commands/serve.js +6 -185
- package/dist/esm/config/default.js +3 -52
- package/dist/esm/config/initialize/inits.js +3 -86
- package/dist/esm/defineConfig.js +2 -52
- package/dist/esm/index.js +49 -207
- package/dist/esm/initialize/index.js +6 -185
- package/dist/esm/schema/Schema.js +8 -213
- package/dist/esm/schema/index.js +1 -13
- package/dist/esm/schema/legacy.js +1 -13
- package/dist/esm/utils/config.js +7 -186
- package/dist/esm/utils/createServer.js +6 -185
- package/dist/esm/utils/generateWatchFiles.js +5 -167
- package/dist/esm/utils/getSelectedEntries.js +3 -132
- package/dist/esm/utils/getServerInternalPlugins.js +5 -184
- package/dist/esm/utils/printInstructions.js +3 -132
- package/dist/esm/utils/restart.js +3 -132
- package/dist/esm/utils/routes.js +3 -132
- package/dist/esm-node/analyze/generateCode.js +19 -2
- package/dist/esm-node/analyze/getBundleEntry.js +1 -1
- package/dist/esm-node/analyze/getServerRoutes.js +2 -0
- package/dist/esm-node/analyze/index.js +4 -2
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +1 -14
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -6
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +5 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +1 -13
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +1 -13
- package/dist/esm-node/index.js +22 -6
- package/dist/esm-node/schema/Schema.js +1 -13
- package/dist/types/analyze/index.d.ts +0 -2
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +0 -1
- package/dist/types/builder/generator/index.d.ts +1 -2
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +0 -1
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +2 -3
- package/dist/types/defineConfig.d.ts +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/initialize/index.d.ts +0 -2
- package/dist/types/types/config/index.d.ts +2 -2
- package/dist/types/types/config/output.d.ts +1 -0
- package/dist/types/types/config/security.d.ts +2 -0
- package/dist/types/types/config/source.d.ts +0 -1
- package/dist/types/types/config/tools.d.ts +0 -2
- package/dist/types/types/hooks.d.ts +3 -1
- package/dist/types/types/legacyConfig/dev.d.ts +0 -1
- package/dist/types/types/legacyConfig/output.d.ts +2 -3
- package/dist/types/types/legacyConfig/source.d.ts +0 -1
- package/dist/types/types/legacyConfig/tools.d.ts +0 -1
- package/dist/types/utils/config.d.ts +0 -1
- package/dist/types/utils/getSelectedEntries.d.ts +0 -1
- package/lib/types.d.ts +8 -8
- package/package.json +29 -29
package/dist/esm/index.js
CHANGED
|
@@ -1,186 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(void 0);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
if (key in obj) {
|
|
32
|
-
Object.defineProperty(obj, key, {
|
|
33
|
-
value: value,
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
function _object_spread(target) {
|
|
44
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
-
var ownKeys2 = Object.keys(source);
|
|
47
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
-
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
ownKeys2.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
if (enumerableOnly) {
|
|
63
|
-
symbols = symbols.filter(function(sym) {
|
|
64
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
keys.push.apply(keys, symbols);
|
|
68
|
-
}
|
|
69
|
-
return keys;
|
|
70
|
-
}
|
|
71
|
-
function _object_spread_props(target, source) {
|
|
72
|
-
source = source != null ? source : {};
|
|
73
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
-
} else {
|
|
76
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return target;
|
|
81
|
-
}
|
|
82
|
-
var __generator = function(thisArg, body) {
|
|
83
|
-
var f, y, t, g, _ = {
|
|
84
|
-
label: 0,
|
|
85
|
-
sent: function() {
|
|
86
|
-
if (t[0] & 1)
|
|
87
|
-
throw t[1];
|
|
88
|
-
return t[1];
|
|
89
|
-
},
|
|
90
|
-
trys: [],
|
|
91
|
-
ops: []
|
|
92
|
-
};
|
|
93
|
-
return g = {
|
|
94
|
-
next: verb(0),
|
|
95
|
-
"throw": verb(1),
|
|
96
|
-
"return": verb(2)
|
|
97
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
98
|
-
return this;
|
|
99
|
-
}), g;
|
|
100
|
-
function verb(n) {
|
|
101
|
-
return function(v) {
|
|
102
|
-
return step([
|
|
103
|
-
n,
|
|
104
|
-
v
|
|
105
|
-
]);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function step(op) {
|
|
109
|
-
if (f)
|
|
110
|
-
throw new TypeError("Generator is already executing.");
|
|
111
|
-
while (_)
|
|
112
|
-
try {
|
|
113
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
114
|
-
return t;
|
|
115
|
-
if (y = 0, t)
|
|
116
|
-
op = [
|
|
117
|
-
op[0] & 2,
|
|
118
|
-
t.value
|
|
119
|
-
];
|
|
120
|
-
switch (op[0]) {
|
|
121
|
-
case 0:
|
|
122
|
-
case 1:
|
|
123
|
-
t = op;
|
|
124
|
-
break;
|
|
125
|
-
case 4:
|
|
126
|
-
_.label++;
|
|
127
|
-
return {
|
|
128
|
-
value: op[1],
|
|
129
|
-
done: false
|
|
130
|
-
};
|
|
131
|
-
case 5:
|
|
132
|
-
_.label++;
|
|
133
|
-
y = op[1];
|
|
134
|
-
op = [
|
|
135
|
-
0
|
|
136
|
-
];
|
|
137
|
-
continue;
|
|
138
|
-
case 7:
|
|
139
|
-
op = _.ops.pop();
|
|
140
|
-
_.trys.pop();
|
|
141
|
-
continue;
|
|
142
|
-
default:
|
|
143
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
144
|
-
_ = 0;
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
148
|
-
_.label = op[1];
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
152
|
-
_.label = t[1];
|
|
153
|
-
t = op;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
if (t && _.label < t[2]) {
|
|
157
|
-
_.label = t[2];
|
|
158
|
-
_.ops.push(op);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
if (t[2])
|
|
162
|
-
_.ops.pop();
|
|
163
|
-
_.trys.pop();
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
op = body.call(thisArg, _);
|
|
167
|
-
} catch (e) {
|
|
168
|
-
op = [
|
|
169
|
-
6,
|
|
170
|
-
e
|
|
171
|
-
];
|
|
172
|
-
y = 0;
|
|
173
|
-
} finally {
|
|
174
|
-
f = t = 0;
|
|
175
|
-
}
|
|
176
|
-
if (op[0] & 5)
|
|
177
|
-
throw op[1];
|
|
178
|
-
return {
|
|
179
|
-
value: op[0] ? op[1] : void 0,
|
|
180
|
-
done: true
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
};
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
184
5
|
import path from "path";
|
|
185
6
|
import lintPlugin from "@modern-js/plugin-lint";
|
|
186
7
|
import { cleanRequireCache, emptyDir, Import, getCommand } from "@modern-js/utils";
|
|
@@ -199,7 +20,7 @@ var upgradeModel = Import.lazy("@modern-js/upgrade", require);
|
|
|
199
20
|
export var devCommand = function() {
|
|
200
21
|
var _ref = _async_to_generator(function(program, api) {
|
|
201
22
|
var runner, devToolMetas, devProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, meta, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, subCmd;
|
|
202
|
-
return
|
|
23
|
+
return _ts_generator(this, function(_state) {
|
|
203
24
|
switch (_state.label) {
|
|
204
25
|
case 0:
|
|
205
26
|
runner = api.useHookRunners();
|
|
@@ -212,7 +33,7 @@ export var devCommand = function() {
|
|
|
212
33
|
devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("--web-only", i18n.t(localeKeys.command.dev.webOnly)).action(function() {
|
|
213
34
|
var _ref2 = _async_to_generator(function(options) {
|
|
214
35
|
var dev;
|
|
215
|
-
return
|
|
36
|
+
return _ts_generator(this, function(_state2) {
|
|
216
37
|
switch (_state2.label) {
|
|
217
38
|
case 0:
|
|
218
39
|
return [
|
|
@@ -251,7 +72,7 @@ export var devCommand = function() {
|
|
|
251
72
|
devProgram.command(subCmd).action(/* @__PURE__ */ _async_to_generator(function() {
|
|
252
73
|
var options, appDirectory, isTypescript;
|
|
253
74
|
var _arguments = arguments;
|
|
254
|
-
return
|
|
75
|
+
return _ts_generator(this, function(_state2) {
|
|
255
76
|
switch (_state2.label) {
|
|
256
77
|
case 0:
|
|
257
78
|
options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
|
|
@@ -325,7 +146,7 @@ export var devCommand = function() {
|
|
|
325
146
|
export var buildCommand = function() {
|
|
326
147
|
var _ref = _async_to_generator(function(program, api) {
|
|
327
148
|
var runner, platformBuilders, buildProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
|
|
328
|
-
return
|
|
149
|
+
return _ts_generator(this, function(_state) {
|
|
329
150
|
switch (_state.label) {
|
|
330
151
|
case 0:
|
|
331
152
|
runner = api.useHookRunners();
|
|
@@ -338,7 +159,7 @@ export var buildCommand = function() {
|
|
|
338
159
|
buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(function() {
|
|
339
160
|
var _ref2 = _async_to_generator(function(options) {
|
|
340
161
|
var build;
|
|
341
|
-
return
|
|
162
|
+
return _ts_generator(this, function(_state2) {
|
|
342
163
|
switch (_state2.label) {
|
|
343
164
|
case 0:
|
|
344
165
|
return [
|
|
@@ -374,7 +195,7 @@ export var buildCommand = function() {
|
|
|
374
195
|
var platform = _step1.value;
|
|
375
196
|
buildProgram.command(platform).action(/* @__PURE__ */ _async_to_generator(function() {
|
|
376
197
|
var appDirectory, isTypescript;
|
|
377
|
-
return
|
|
198
|
+
return _ts_generator(this, function(_state2) {
|
|
378
199
|
switch (_state2.label) {
|
|
379
200
|
case 0:
|
|
380
201
|
appDirectory = api.useAppContext().appDirectory;
|
|
@@ -475,15 +296,36 @@ export default function() {
|
|
|
475
296
|
lintPlugin()
|
|
476
297
|
],
|
|
477
298
|
setup: function(api) {
|
|
299
|
+
var appContext = api.useAppContext();
|
|
300
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
301
|
+
toolsType: "app-tools"
|
|
302
|
+
}));
|
|
478
303
|
var locale = getLocaleLanguage();
|
|
479
304
|
i18n.changeLanguage({
|
|
480
305
|
locale: locale
|
|
481
306
|
});
|
|
482
307
|
return {
|
|
308
|
+
beforeConfig: function beforeConfig() {
|
|
309
|
+
return _async_to_generator(function() {
|
|
310
|
+
var _userConfig_output, userConfig, appContext2;
|
|
311
|
+
return _ts_generator(this, function(_state) {
|
|
312
|
+
userConfig = api.useConfigContext();
|
|
313
|
+
appContext2 = api.useAppContext();
|
|
314
|
+
if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
|
|
315
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext2), {
|
|
316
|
+
internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
return [
|
|
320
|
+
2
|
|
321
|
+
];
|
|
322
|
+
});
|
|
323
|
+
})();
|
|
324
|
+
},
|
|
483
325
|
commands: function commands(param) {
|
|
484
326
|
var program = param.program;
|
|
485
327
|
return _async_to_generator(function() {
|
|
486
|
-
return
|
|
328
|
+
return _ts_generator(this, function(_state) {
|
|
487
329
|
switch (_state.label) {
|
|
488
330
|
case 0:
|
|
489
331
|
return [
|
|
@@ -500,7 +342,7 @@ export default function() {
|
|
|
500
342
|
_state.sent();
|
|
501
343
|
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(/* @__PURE__ */ _async_to_generator(function() {
|
|
502
344
|
var start;
|
|
503
|
-
return
|
|
345
|
+
return _ts_generator(this, function(_state2) {
|
|
504
346
|
switch (_state2.label) {
|
|
505
347
|
case 0:
|
|
506
348
|
return [
|
|
@@ -524,7 +366,7 @@ export default function() {
|
|
|
524
366
|
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
|
|
525
367
|
var _ref = _async_to_generator(function(options2) {
|
|
526
368
|
var build, deploy;
|
|
527
|
-
return
|
|
369
|
+
return _ts_generator(this, function(_state2) {
|
|
528
370
|
switch (_state2.label) {
|
|
529
371
|
case 0:
|
|
530
372
|
return [
|
|
@@ -565,7 +407,7 @@ export default function() {
|
|
|
565
407
|
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(function() {
|
|
566
408
|
var _ref = _async_to_generator(function(options2) {
|
|
567
409
|
var MWANewAction;
|
|
568
|
-
return
|
|
410
|
+
return _ts_generator(this, function(_state2) {
|
|
569
411
|
switch (_state2.label) {
|
|
570
412
|
case 0:
|
|
571
413
|
return [
|
|
@@ -595,7 +437,7 @@ export default function() {
|
|
|
595
437
|
program.command("inspect").description("inspect the internal configs").option("--env <env>", i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(function() {
|
|
596
438
|
var _ref = _async_to_generator(function(options2) {
|
|
597
439
|
var inspect;
|
|
598
|
-
return
|
|
440
|
+
return _ts_generator(this, function(_state2) {
|
|
599
441
|
switch (_state2.label) {
|
|
600
442
|
case 0:
|
|
601
443
|
return [
|
|
@@ -625,8 +467,8 @@ export default function() {
|
|
|
625
467
|
},
|
|
626
468
|
prepare: function prepare() {
|
|
627
469
|
return _async_to_generator(function() {
|
|
628
|
-
var command, resolvedConfig,
|
|
629
|
-
return
|
|
470
|
+
var command, resolvedConfig, appContext2;
|
|
471
|
+
return _ts_generator(this, function(_state) {
|
|
630
472
|
switch (_state.label) {
|
|
631
473
|
case 0:
|
|
632
474
|
command = getCommand();
|
|
@@ -641,10 +483,10 @@ export default function() {
|
|
|
641
483
|
3,
|
|
642
484
|
2
|
|
643
485
|
];
|
|
644
|
-
|
|
486
|
+
appContext2 = api.useAppContext();
|
|
645
487
|
return [
|
|
646
488
|
4,
|
|
647
|
-
emptyDir(
|
|
489
|
+
emptyDir(appContext2.distDirectory)
|
|
648
490
|
];
|
|
649
491
|
case 1:
|
|
650
492
|
_state.sent();
|
|
@@ -659,13 +501,13 @@ export default function() {
|
|
|
659
501
|
},
|
|
660
502
|
watchFiles: function watchFiles() {
|
|
661
503
|
return _async_to_generator(function() {
|
|
662
|
-
var
|
|
663
|
-
return
|
|
664
|
-
|
|
504
|
+
var appContext2, config;
|
|
505
|
+
return _ts_generator(this, function(_state) {
|
|
506
|
+
appContext2 = api.useAppContext();
|
|
665
507
|
config = api.useResolvedConfigContext();
|
|
666
508
|
return [
|
|
667
509
|
2,
|
|
668
|
-
generateWatchFiles(
|
|
510
|
+
generateWatchFiles(appContext2, config.source.configDir)
|
|
669
511
|
];
|
|
670
512
|
});
|
|
671
513
|
})();
|
|
@@ -674,13 +516,13 @@ export default function() {
|
|
|
674
516
|
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
|
675
517
|
function fileChange(e) {
|
|
676
518
|
return _async_to_generator(function() {
|
|
677
|
-
var filename, eventType,
|
|
678
|
-
return
|
|
519
|
+
var filename, eventType, appContext2, appDirectory, srcDirectory, absolutePath, closeServer;
|
|
520
|
+
return _ts_generator(this, function(_state) {
|
|
679
521
|
switch (_state.label) {
|
|
680
522
|
case 0:
|
|
681
523
|
filename = e.filename, eventType = e.eventType;
|
|
682
|
-
|
|
683
|
-
appDirectory =
|
|
524
|
+
appContext2 = api.useAppContext();
|
|
525
|
+
appDirectory = appContext2.appDirectory, srcDirectory = appContext2.srcDirectory;
|
|
684
526
|
absolutePath = path.resolve(appDirectory, filename);
|
|
685
527
|
if (!(!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")))
|
|
686
528
|
return [
|
|
@@ -717,7 +559,7 @@ export default function() {
|
|
|
717
559
|
),
|
|
718
560
|
beforeRestart: function beforeRestart() {
|
|
719
561
|
return _async_to_generator(function() {
|
|
720
|
-
return
|
|
562
|
+
return _ts_generator(this, function(_state) {
|
|
721
563
|
cleanRequireCache([
|
|
722
564
|
require.resolve("./analyze")
|
|
723
565
|
]);
|
|
@@ -1,186 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(void 0);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
if (key in obj) {
|
|
32
|
-
Object.defineProperty(obj, key, {
|
|
33
|
-
value: value,
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
function _object_spread(target) {
|
|
44
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
-
var ownKeys2 = Object.keys(source);
|
|
47
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
-
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
ownKeys2.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
if (enumerableOnly) {
|
|
63
|
-
symbols = symbols.filter(function(sym) {
|
|
64
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
keys.push.apply(keys, symbols);
|
|
68
|
-
}
|
|
69
|
-
return keys;
|
|
70
|
-
}
|
|
71
|
-
function _object_spread_props(target, source) {
|
|
72
|
-
source = source != null ? source : {};
|
|
73
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
-
} else {
|
|
76
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return target;
|
|
81
|
-
}
|
|
82
|
-
var __generator = function(thisArg, body) {
|
|
83
|
-
var f, y, t, g, _ = {
|
|
84
|
-
label: 0,
|
|
85
|
-
sent: function() {
|
|
86
|
-
if (t[0] & 1)
|
|
87
|
-
throw t[1];
|
|
88
|
-
return t[1];
|
|
89
|
-
},
|
|
90
|
-
trys: [],
|
|
91
|
-
ops: []
|
|
92
|
-
};
|
|
93
|
-
return g = {
|
|
94
|
-
next: verb(0),
|
|
95
|
-
"throw": verb(1),
|
|
96
|
-
"return": verb(2)
|
|
97
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
98
|
-
return this;
|
|
99
|
-
}), g;
|
|
100
|
-
function verb(n) {
|
|
101
|
-
return function(v) {
|
|
102
|
-
return step([
|
|
103
|
-
n,
|
|
104
|
-
v
|
|
105
|
-
]);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function step(op) {
|
|
109
|
-
if (f)
|
|
110
|
-
throw new TypeError("Generator is already executing.");
|
|
111
|
-
while (_)
|
|
112
|
-
try {
|
|
113
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
114
|
-
return t;
|
|
115
|
-
if (y = 0, t)
|
|
116
|
-
op = [
|
|
117
|
-
op[0] & 2,
|
|
118
|
-
t.value
|
|
119
|
-
];
|
|
120
|
-
switch (op[0]) {
|
|
121
|
-
case 0:
|
|
122
|
-
case 1:
|
|
123
|
-
t = op;
|
|
124
|
-
break;
|
|
125
|
-
case 4:
|
|
126
|
-
_.label++;
|
|
127
|
-
return {
|
|
128
|
-
value: op[1],
|
|
129
|
-
done: false
|
|
130
|
-
};
|
|
131
|
-
case 5:
|
|
132
|
-
_.label++;
|
|
133
|
-
y = op[1];
|
|
134
|
-
op = [
|
|
135
|
-
0
|
|
136
|
-
];
|
|
137
|
-
continue;
|
|
138
|
-
case 7:
|
|
139
|
-
op = _.ops.pop();
|
|
140
|
-
_.trys.pop();
|
|
141
|
-
continue;
|
|
142
|
-
default:
|
|
143
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
144
|
-
_ = 0;
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
148
|
-
_.label = op[1];
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
152
|
-
_.label = t[1];
|
|
153
|
-
t = op;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
if (t && _.label < t[2]) {
|
|
157
|
-
_.label = t[2];
|
|
158
|
-
_.ops.push(op);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
if (t[2])
|
|
162
|
-
_.ops.pop();
|
|
163
|
-
_.trys.pop();
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
op = body.call(thisArg, _);
|
|
167
|
-
} catch (e) {
|
|
168
|
-
op = [
|
|
169
|
-
6,
|
|
170
|
-
e
|
|
171
|
-
];
|
|
172
|
-
y = 0;
|
|
173
|
-
} finally {
|
|
174
|
-
f = t = 0;
|
|
175
|
-
}
|
|
176
|
-
if (op[0] & 5)
|
|
177
|
-
throw op[1];
|
|
178
|
-
return {
|
|
179
|
-
value: op[0] ? op[1] : void 0,
|
|
180
|
-
done: true
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
};
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
184
5
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
185
6
|
import { legacySchema, schema } from "../schema";
|
|
186
7
|
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
|
|
@@ -217,7 +38,7 @@ export default function(param) {
|
|
|
217
38
|
var resolved = param2.resolved;
|
|
218
39
|
return _async_to_generator(function() {
|
|
219
40
|
var _resolved_output_distPath, appContext, userConfig, port, normalizedConfig, _normalizedConfig_autoLoadPlugins;
|
|
220
|
-
return
|
|
41
|
+
return _ts_generator(this, function(_state) {
|
|
221
42
|
switch (_state.label) {
|
|
222
43
|
case 0:
|
|
223
44
|
appContext = api.useAppContext();
|
|
@@ -284,7 +105,7 @@ function getServerPort(config) {
|
|
|
284
105
|
function _getServerPort() {
|
|
285
106
|
_getServerPort = _async_to_generator(function(config) {
|
|
286
107
|
var prodPort;
|
|
287
|
-
return
|
|
108
|
+
return _ts_generator(this, function(_state) {
|
|
288
109
|
prodPort = Number(process.env.PORT) || config.server.port || 8080;
|
|
289
110
|
if (isDev() && isDevCommand()) {
|
|
290
111
|
return [
|