@modern-js/app-tools 2.53.1-alpha.3 → 2.54.0
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +0 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/cjs/commands/build.js +2 -0
- package/dist/cjs/commands/deploy.js +2 -2
- package/dist/cjs/commands/dev.js +19 -5
- package/dist/cjs/commands/index.js +113 -7
- package/dist/cjs/commands/serve.js +19 -5
- package/dist/cjs/hooks.js +5 -0
- package/dist/cjs/index.js +14 -83
- package/dist/cjs/plugins/analyze/constants.js +56 -0
- package/dist/cjs/{analyze → plugins/analyze}/generateCode.js +11 -84
- package/dist/cjs/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/cjs/{analyze → plugins/analyze}/getFileSystemEntry.js +33 -47
- package/dist/cjs/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/cjs/{analyze → plugins/analyze}/index.js +9 -24
- package/dist/cjs/plugins/analyze/templates.js +101 -0
- package/dist/cjs/{analyze → plugins/analyze}/utils.js +12 -55
- package/dist/cjs/plugins/deploy/dependencies/index.js +16 -25
- package/dist/cjs/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/cjs/plugins/deploy/platforms/netlify.js +5 -9
- package/dist/cjs/plugins/deploy/platforms/node.js +5 -13
- package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -9
- package/dist/cjs/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +10 -4
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/{getServerInternalPlugins.js → loadPlugins.js} +18 -11
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm/commands/build.js +16 -9
- package/dist/esm/commands/deploy.js +2 -2
- package/dist/esm/commands/dev.js +13 -9
- package/dist/esm/commands/index.js +411 -3
- package/dist/esm/commands/serve.js +12 -8
- package/dist/esm/hooks.js +5 -0
- package/dist/esm/index.js +12 -394
- package/dist/esm/plugins/analyze/constants.js +24 -0
- package/dist/esm/{analyze → plugins/analyze}/generateCode.js +27 -169
- package/dist/esm/plugins/analyze/getBundleEntry.js +101 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +195 -0
- package/dist/esm/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm/{analyze → plugins/analyze}/index.js +42 -70
- package/dist/esm/plugins/analyze/templates.js +22 -0
- package/dist/esm/{analyze → plugins/analyze}/utils.js +13 -135
- package/dist/esm/plugins/deploy/dependencies/index.js +69 -94
- package/dist/esm/plugins/deploy/dependencies/utils.js +3 -4
- package/dist/esm/plugins/deploy/platforms/netlify.js +8 -10
- package/dist/esm/plugins/deploy/platforms/node.js +8 -14
- package/dist/esm/plugins/deploy/platforms/vercel.js +8 -10
- package/dist/esm/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm/plugins/serverBuild.js +13 -6
- package/dist/esm/utils/createServer.js +2 -2
- package/dist/esm/utils/loadPlugins.js +64 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm-node/commands/build.js +2 -0
- package/dist/esm-node/commands/deploy.js +2 -2
- package/dist/esm-node/commands/dev.js +11 -7
- package/dist/esm-node/commands/index.js +92 -3
- package/dist/esm-node/commands/serve.js +10 -6
- package/dist/esm-node/hooks.js +5 -0
- package/dist/esm-node/index.js +12 -79
- package/dist/esm-node/plugins/analyze/constants.js +24 -0
- package/dist/esm-node/{analyze → plugins/analyze}/generateCode.js +14 -87
- package/dist/esm-node/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm-node/{analyze → plugins/analyze}/index.js +10 -25
- package/dist/esm-node/plugins/analyze/templates.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/utils.js +13 -52
- package/dist/esm-node/plugins/deploy/dependencies/index.js +18 -27
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -10
- package/dist/esm-node/plugins/deploy/platforms/node.js +6 -14
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -10
- package/dist/esm-node/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm-node/plugins/serverBuild.js +11 -5
- package/dist/esm-node/utils/createServer.js +2 -2
- package/dist/esm-node/utils/loadPlugins.js +21 -0
- package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
- package/dist/types/commands/index.d.ts +10 -3
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/exports/server.d.ts +4 -0
- package/dist/types/index.d.ts +2 -5
- package/dist/types/plugins/analyze/constants.d.ts +9 -0
- package/dist/types/{analyze → plugins/analyze}/generateCode.d.ts +1 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -0
- package/dist/types/{analyze → plugins/analyze}/getHtmlTemplate.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/getServerRoutes.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/index.d.ts +1 -1
- package/dist/types/plugins/analyze/templates.d.ts +19 -0
- package/dist/types/{analyze → plugins/analyze}/utils.d.ts +4 -6
- package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -9
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -7
- package/dist/types/{initialize → plugins/initialize}/index.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +11 -1
- package/dist/types/utils/loadPlugins.d.ts +5 -0
- package/package.json +22 -30
- package/dist/cjs/analyze/constants.js +0 -122
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +0 -197
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +0 -195
- package/dist/cjs/analyze/getClientRoutes/index.js +0 -31
- package/dist/cjs/analyze/getClientRoutes/utils.js +0 -59
- package/dist/cjs/analyze/makeLegalIdentifier.js +0 -37
- package/dist/cjs/analyze/nestedRoutes.js +0 -295
- package/dist/cjs/analyze/templates.js +0 -444
- package/dist/cjs/plugins/deploy/exports.js +0 -28
- package/dist/esm/analyze/constants.js +0 -76
- package/dist/esm/analyze/getBundleEntry.js +0 -75
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +0 -185
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +0 -183
- package/dist/esm/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm/analyze/getClientRoutes/utils.js +0 -28
- package/dist/esm/analyze/getFileSystemEntry.js +0 -113
- package/dist/esm/analyze/makeLegalIdentifier.js +0 -15
- package/dist/esm/analyze/nestedRoutes.js +0 -398
- package/dist/esm/analyze/templates.js +0 -435
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/utils/getServerInternalPlugins.js +0 -40
- package/dist/esm-node/analyze/constants.js +0 -76
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +0 -163
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +0 -161
- package/dist/esm-node/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +0 -22
- package/dist/esm-node/analyze/getFileSystemEntry.js +0 -89
- package/dist/esm-node/analyze/makeLegalIdentifier.js +0 -13
- package/dist/esm-node/analyze/nestedRoutes.js +0 -259
- package/dist/esm-node/analyze/templates.js +0 -405
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
- package/dist/js/modern/analyze/constants.js +0 -15
- package/dist/js/modern/analyze/generateCode.js +0 -179
- package/dist/js/modern/analyze/getBundleEntry.js +0 -75
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -74
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -82
- package/dist/js/modern/analyze/getServerRoutes.js +0 -192
- package/dist/js/modern/analyze/index.js +0 -148
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -32
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -16
- package/dist/js/modern/analyze/templates.js +0 -88
- package/dist/js/modern/analyze/utils.js +0 -92
- package/dist/js/modern/commands/build.js +0 -154
- package/dist/js/modern/commands/deploy.js +0 -5
- package/dist/js/modern/commands/dev.js +0 -95
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -69
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/exports/server.js +0 -1
- package/dist/js/modern/hooks.js +0 -21
- package/dist/js/modern/index.js +0 -109
- package/dist/js/modern/locale/en.js +0 -35
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -35
- package/dist/js/modern/utils/config.js +0 -78
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/modern/utils/createServer.js +0 -18
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -36
- package/dist/js/modern/utils/language.js +0 -5
- package/dist/js/modern/utils/printInstructions.js +0 -11
- package/dist/js/modern/utils/routes.js +0 -15
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -36
- package/dist/js/node/analyze/generateCode.js +0 -208
- package/dist/js/node/analyze/getBundleEntry.js +0 -89
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -90
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -106
- package/dist/js/node/analyze/getServerRoutes.js +0 -208
- package/dist/js/node/analyze/index.js +0 -178
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -50
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -24
- package/dist/js/node/analyze/templates.js +0 -106
- package/dist/js/node/analyze/utils.js +0 -113
- package/dist/js/node/commands/build.js +0 -174
- package/dist/js/node/commands/deploy.js +0 -14
- package/dist/js/node/commands/dev.js +0 -120
- package/dist/js/node/commands/index.js +0 -44
- package/dist/js/node/commands/inspect.js +0 -98
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/exports/server.js +0 -13
- package/dist/js/node/hooks.js +0 -39
- package/dist/js/node/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -42
- package/dist/js/node/locale/index.js +0 -20
- package/dist/js/node/locale/zh.js +0 -42
- package/dist/js/node/utils/config.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/js/node/utils/createServer.js +0 -35
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -46
- package/dist/js/node/utils/language.js +0 -13
- package/dist/js/node/utils/printInstructions.js +0 -22
- package/dist/js/node/utils/routes.js +0 -25
- package/dist/js/node/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +0 -42
- package/dist/types/analyze/getBundleEntry.d.ts +0 -3
- package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +0 -8
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +0 -9
- package/dist/types/analyze/getClientRoutes/index.d.ts +0 -2
- package/dist/types/analyze/getClientRoutes/utils.d.ts +0 -5
- package/dist/types/analyze/getFileSystemEntry.d.ts +0 -4
- package/dist/types/analyze/makeLegalIdentifier.d.ts +0 -1
- package/dist/types/analyze/nestedRoutes.d.ts +0 -7
- package/dist/types/analyze/templates.d.ts +0 -30
- package/dist/types/plugins/deploy/exports.d.ts +0 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +0 -2
- /package/dist/cjs/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/cjs/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/types/{analyze → plugins/analyze}/isDefaultExportFunction.d.ts +0 -0
@@ -1,3 +1,411 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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";
|
5
|
+
import { newAction, upgradeAction } from "@modern-js/utils";
|
6
|
+
import { castArray } from "@rsbuild/shared";
|
7
|
+
import { i18n, localeKeys } from "../locale";
|
8
|
+
var devCommand = function() {
|
9
|
+
var _ref = _async_to_generator(function(program, api) {
|
10
|
+
var runner, devToolMetas, devProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, meta, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, subCmd;
|
11
|
+
return _ts_generator(this, function(_state) {
|
12
|
+
switch (_state.label) {
|
13
|
+
case 0:
|
14
|
+
runner = api.useHookRunners();
|
15
|
+
return [
|
16
|
+
4,
|
17
|
+
runner.registerDev()
|
18
|
+
];
|
19
|
+
case 1:
|
20
|
+
devToolMetas = _state.sent();
|
21
|
+
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() {
|
22
|
+
var _ref2 = _async_to_generator(function(options) {
|
23
|
+
var dev;
|
24
|
+
return _ts_generator(this, function(_state2) {
|
25
|
+
switch (_state2.label) {
|
26
|
+
case 0:
|
27
|
+
return [
|
28
|
+
4,
|
29
|
+
import("./dev")
|
30
|
+
];
|
31
|
+
case 1:
|
32
|
+
dev = _state2.sent().dev;
|
33
|
+
return [
|
34
|
+
4,
|
35
|
+
dev(api, options)
|
36
|
+
];
|
37
|
+
case 2:
|
38
|
+
_state2.sent();
|
39
|
+
return [
|
40
|
+
2
|
41
|
+
];
|
42
|
+
}
|
43
|
+
});
|
44
|
+
});
|
45
|
+
return function(options) {
|
46
|
+
return _ref2.apply(this, arguments);
|
47
|
+
};
|
48
|
+
}());
|
49
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
50
|
+
try {
|
51
|
+
for (_iterator = devToolMetas[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
52
|
+
meta = _step.value;
|
53
|
+
if (!meta.subCommands) {
|
54
|
+
continue;
|
55
|
+
}
|
56
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
57
|
+
try {
|
58
|
+
for (_iterator1 = meta.subCommands[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
59
|
+
subCmd = _step1.value;
|
60
|
+
devProgram.command(subCmd).action(/* @__PURE__ */ _async_to_generator(function() {
|
61
|
+
var options, appDirectory, isTypescript;
|
62
|
+
var _arguments = arguments;
|
63
|
+
return _ts_generator(this, function(_state2) {
|
64
|
+
switch (_state2.label) {
|
65
|
+
case 0:
|
66
|
+
options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
|
67
|
+
appDirectory = api.useAppContext().appDirectory;
|
68
|
+
return [
|
69
|
+
4,
|
70
|
+
import("@modern-js/utils")
|
71
|
+
];
|
72
|
+
case 1:
|
73
|
+
isTypescript = _state2.sent().isTypescript;
|
74
|
+
return [
|
75
|
+
4,
|
76
|
+
runner.beforeDevTask(meta)
|
77
|
+
];
|
78
|
+
case 2:
|
79
|
+
_state2.sent();
|
80
|
+
return [
|
81
|
+
4,
|
82
|
+
meta.action(options, {
|
83
|
+
isTsProject: isTypescript(appDirectory)
|
84
|
+
})
|
85
|
+
];
|
86
|
+
case 3:
|
87
|
+
_state2.sent();
|
88
|
+
return [
|
89
|
+
2
|
90
|
+
];
|
91
|
+
}
|
92
|
+
});
|
93
|
+
}));
|
94
|
+
}
|
95
|
+
} catch (err) {
|
96
|
+
_didIteratorError1 = true;
|
97
|
+
_iteratorError1 = err;
|
98
|
+
} finally {
|
99
|
+
try {
|
100
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
101
|
+
_iterator1.return();
|
102
|
+
}
|
103
|
+
} finally {
|
104
|
+
if (_didIteratorError1) {
|
105
|
+
throw _iteratorError1;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
} catch (err) {
|
111
|
+
_didIteratorError = true;
|
112
|
+
_iteratorError = err;
|
113
|
+
} finally {
|
114
|
+
try {
|
115
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
116
|
+
_iterator.return();
|
117
|
+
}
|
118
|
+
} finally {
|
119
|
+
if (_didIteratorError) {
|
120
|
+
throw _iteratorError;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
return [
|
125
|
+
2
|
126
|
+
];
|
127
|
+
}
|
128
|
+
});
|
129
|
+
});
|
130
|
+
return function devCommand2(program, api) {
|
131
|
+
return _ref.apply(this, arguments);
|
132
|
+
};
|
133
|
+
}();
|
134
|
+
var buildCommand = function() {
|
135
|
+
var _ref = _async_to_generator(function(program, api) {
|
136
|
+
var runner, platformBuilders, buildProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
|
137
|
+
return _ts_generator(this, function(_state) {
|
138
|
+
switch (_state.label) {
|
139
|
+
case 0:
|
140
|
+
runner = api.useHookRunners();
|
141
|
+
return [
|
142
|
+
4,
|
143
|
+
runner.registerBuildPlatform()
|
144
|
+
];
|
145
|
+
case 1:
|
146
|
+
platformBuilders = _state.sent();
|
147
|
+
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() {
|
148
|
+
var _ref2 = _async_to_generator(function(options) {
|
149
|
+
var build;
|
150
|
+
return _ts_generator(this, function(_state2) {
|
151
|
+
switch (_state2.label) {
|
152
|
+
case 0:
|
153
|
+
return [
|
154
|
+
4,
|
155
|
+
import("./build")
|
156
|
+
];
|
157
|
+
case 1:
|
158
|
+
build = _state2.sent().build;
|
159
|
+
return [
|
160
|
+
4,
|
161
|
+
build(api, options)
|
162
|
+
];
|
163
|
+
case 2:
|
164
|
+
_state2.sent();
|
165
|
+
return [
|
166
|
+
2
|
167
|
+
];
|
168
|
+
}
|
169
|
+
});
|
170
|
+
});
|
171
|
+
return function(options) {
|
172
|
+
return _ref2.apply(this, arguments);
|
173
|
+
};
|
174
|
+
}());
|
175
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
176
|
+
try {
|
177
|
+
_loop = function() {
|
178
|
+
var platformBuilder = _step.value;
|
179
|
+
var platforms = castArray(platformBuilder.platform);
|
180
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
181
|
+
try {
|
182
|
+
var _loop2 = function() {
|
183
|
+
var platform = _step1.value;
|
184
|
+
buildProgram.command(platform).action(/* @__PURE__ */ _async_to_generator(function() {
|
185
|
+
var appDirectory, isTypescript;
|
186
|
+
return _ts_generator(this, function(_state2) {
|
187
|
+
switch (_state2.label) {
|
188
|
+
case 0:
|
189
|
+
appDirectory = api.useAppContext().appDirectory;
|
190
|
+
return [
|
191
|
+
4,
|
192
|
+
import("@modern-js/utils")
|
193
|
+
];
|
194
|
+
case 1:
|
195
|
+
isTypescript = _state2.sent().isTypescript;
|
196
|
+
return [
|
197
|
+
4,
|
198
|
+
runner.beforeBuildPlatform(platformBuilders)
|
199
|
+
];
|
200
|
+
case 2:
|
201
|
+
_state2.sent();
|
202
|
+
return [
|
203
|
+
4,
|
204
|
+
platformBuilder.build(platform, {
|
205
|
+
isTsProject: isTypescript(appDirectory)
|
206
|
+
})
|
207
|
+
];
|
208
|
+
case 3:
|
209
|
+
_state2.sent();
|
210
|
+
return [
|
211
|
+
2
|
212
|
+
];
|
213
|
+
}
|
214
|
+
});
|
215
|
+
}));
|
216
|
+
};
|
217
|
+
for (var _iterator2 = platforms[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true)
|
218
|
+
_loop2();
|
219
|
+
} catch (err) {
|
220
|
+
_didIteratorError2 = true;
|
221
|
+
_iteratorError2 = err;
|
222
|
+
} finally {
|
223
|
+
try {
|
224
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
225
|
+
_iterator2.return();
|
226
|
+
}
|
227
|
+
} finally {
|
228
|
+
if (_didIteratorError2) {
|
229
|
+
throw _iteratorError2;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
};
|
234
|
+
for (_iterator = platformBuilders[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)
|
235
|
+
_loop();
|
236
|
+
} catch (err) {
|
237
|
+
_didIteratorError = true;
|
238
|
+
_iteratorError = err;
|
239
|
+
} finally {
|
240
|
+
try {
|
241
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
242
|
+
_iterator.return();
|
243
|
+
}
|
244
|
+
} finally {
|
245
|
+
if (_didIteratorError) {
|
246
|
+
throw _iteratorError;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
return [
|
251
|
+
2
|
252
|
+
];
|
253
|
+
}
|
254
|
+
});
|
255
|
+
});
|
256
|
+
return function buildCommand2(program, api) {
|
257
|
+
return _ref.apply(this, arguments);
|
258
|
+
};
|
259
|
+
}();
|
260
|
+
var serverCommand = function(program, api) {
|
261
|
+
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() {
|
262
|
+
var start;
|
263
|
+
return _ts_generator(this, function(_state) {
|
264
|
+
switch (_state.label) {
|
265
|
+
case 0:
|
266
|
+
return [
|
267
|
+
4,
|
268
|
+
import("./serve")
|
269
|
+
];
|
270
|
+
case 1:
|
271
|
+
start = _state.sent().start;
|
272
|
+
return [
|
273
|
+
4,
|
274
|
+
start(api)
|
275
|
+
];
|
276
|
+
case 2:
|
277
|
+
_state.sent();
|
278
|
+
return [
|
279
|
+
2
|
280
|
+
];
|
281
|
+
}
|
282
|
+
});
|
283
|
+
}));
|
284
|
+
};
|
285
|
+
var deployCommand = function(program, api) {
|
286
|
+
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
|
287
|
+
var _ref = _async_to_generator(function(options) {
|
288
|
+
var build, deploy;
|
289
|
+
return _ts_generator(this, function(_state) {
|
290
|
+
switch (_state.label) {
|
291
|
+
case 0:
|
292
|
+
if (!!options.skipBuild)
|
293
|
+
return [
|
294
|
+
3,
|
295
|
+
3
|
296
|
+
];
|
297
|
+
return [
|
298
|
+
4,
|
299
|
+
import("./build")
|
300
|
+
];
|
301
|
+
case 1:
|
302
|
+
build = _state.sent().build;
|
303
|
+
return [
|
304
|
+
4,
|
305
|
+
build(api)
|
306
|
+
];
|
307
|
+
case 2:
|
308
|
+
_state.sent();
|
309
|
+
_state.label = 3;
|
310
|
+
case 3:
|
311
|
+
return [
|
312
|
+
4,
|
313
|
+
import("./deploy")
|
314
|
+
];
|
315
|
+
case 4:
|
316
|
+
deploy = _state.sent().deploy;
|
317
|
+
return [
|
318
|
+
4,
|
319
|
+
deploy(api, options)
|
320
|
+
];
|
321
|
+
case 5:
|
322
|
+
_state.sent();
|
323
|
+
process.exit(0);
|
324
|
+
return [
|
325
|
+
2
|
326
|
+
];
|
327
|
+
}
|
328
|
+
});
|
329
|
+
});
|
330
|
+
return function(options) {
|
331
|
+
return _ref.apply(this, arguments);
|
332
|
+
};
|
333
|
+
}());
|
334
|
+
};
|
335
|
+
var newCommand = function(program, locale) {
|
336
|
+
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--config-file <configFile>", i18n.t(localeKeys.command.shared.config)).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)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)).action(function() {
|
337
|
+
var _ref = _async_to_generator(function(options) {
|
338
|
+
return _ts_generator(this, function(_state) {
|
339
|
+
switch (_state.label) {
|
340
|
+
case 0:
|
341
|
+
return [
|
342
|
+
4,
|
343
|
+
newAction(_object_spread_props(_object_spread({}, options), {
|
344
|
+
locale: options.lang || locale
|
345
|
+
}), "mwa")
|
346
|
+
];
|
347
|
+
case 1:
|
348
|
+
_state.sent();
|
349
|
+
return [
|
350
|
+
2
|
351
|
+
];
|
352
|
+
}
|
353
|
+
});
|
354
|
+
});
|
355
|
+
return function(options) {
|
356
|
+
return _ref.apply(this, arguments);
|
357
|
+
};
|
358
|
+
}());
|
359
|
+
};
|
360
|
+
var inspectCommand = function(program, api) {
|
361
|
+
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() {
|
362
|
+
var _ref = _async_to_generator(function(options) {
|
363
|
+
var inspect;
|
364
|
+
return _ts_generator(this, function(_state) {
|
365
|
+
switch (_state.label) {
|
366
|
+
case 0:
|
367
|
+
return [
|
368
|
+
4,
|
369
|
+
import("./inspect")
|
370
|
+
];
|
371
|
+
case 1:
|
372
|
+
inspect = _state.sent().inspect;
|
373
|
+
inspect(api, options);
|
374
|
+
return [
|
375
|
+
2
|
376
|
+
];
|
377
|
+
}
|
378
|
+
});
|
379
|
+
});
|
380
|
+
return function(options) {
|
381
|
+
return _ref.apply(this, arguments);
|
382
|
+
};
|
383
|
+
}());
|
384
|
+
};
|
385
|
+
var upgradeCommand = function(program) {
|
386
|
+
program.command("upgrade").allowUnknownOption().option("-h --help", "Show help").action(/* @__PURE__ */ _async_to_generator(function() {
|
387
|
+
return _ts_generator(this, function(_state) {
|
388
|
+
switch (_state.label) {
|
389
|
+
case 0:
|
390
|
+
return [
|
391
|
+
4,
|
392
|
+
upgradeAction()
|
393
|
+
];
|
394
|
+
case 1:
|
395
|
+
_state.sent();
|
396
|
+
return [
|
397
|
+
2
|
398
|
+
];
|
399
|
+
}
|
400
|
+
});
|
401
|
+
}));
|
402
|
+
};
|
403
|
+
export {
|
404
|
+
buildCommand,
|
405
|
+
deployCommand,
|
406
|
+
devCommand,
|
407
|
+
inspectCommand,
|
408
|
+
newCommand,
|
409
|
+
serverCommand,
|
410
|
+
upgradeCommand
|
411
|
+
};
|
@@ -2,20 +2,21 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
|
-
import
|
5
|
+
import path from "path";
|
6
|
+
import { logger, isApiOnly, getTargetDir, getMeta, SERVER_DIR } from "@modern-js/utils";
|
6
7
|
import { createProdServer } from "@modern-js/prod-server";
|
7
8
|
import { printInstructions } from "../utils/printInstructions";
|
8
|
-
import {
|
9
|
+
import { loadServerPlugins } from "../utils/loadPlugins";
|
9
10
|
var start = function() {
|
10
11
|
var _ref = _async_to_generator(function(api) {
|
11
|
-
var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, distDirectory, appDirectory, port,
|
12
|
+
var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, distDirectory, appDirectory, port, metaName, serverRoutes, serverConfigFile, apiOnly, runMode, meta, serverConfigPath, pluginInstances, app;
|
12
13
|
return _ts_generator(this, function(_state) {
|
13
14
|
switch (_state.label) {
|
14
15
|
case 0:
|
15
16
|
appContext = api.useAppContext();
|
16
17
|
userConfig = api.useResolvedConfigContext();
|
17
18
|
hookRunners = api.useHookRunners();
|
18
|
-
distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, port = appContext.port,
|
19
|
+
distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, port = appContext.port, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes, serverConfigFile = appContext.serverConfigFile;
|
19
20
|
logger.info("Starting production server...");
|
20
21
|
return [
|
21
22
|
4,
|
@@ -26,12 +27,14 @@ var start = function() {
|
|
26
27
|
if (apiOnly) {
|
27
28
|
runMode = "apiOnly";
|
28
29
|
}
|
30
|
+
meta = getMeta(metaName);
|
31
|
+
serverConfigPath = path.resolve(distDirectory, SERVER_DIR, "".concat(meta, ".server"));
|
29
32
|
return [
|
30
33
|
4,
|
31
|
-
|
34
|
+
loadServerPlugins(api, appDirectory)
|
32
35
|
];
|
33
36
|
case 2:
|
34
|
-
|
37
|
+
pluginInstances = _state.sent();
|
35
38
|
return [
|
36
39
|
4,
|
37
40
|
createProdServer({
|
@@ -44,14 +47,15 @@ var start = function() {
|
|
44
47
|
}, userConfig.output || {})
|
45
48
|
}),
|
46
49
|
routes: serverRoutes,
|
50
|
+
plugins: pluginInstances,
|
51
|
+
serverConfigFile,
|
52
|
+
serverConfigPath,
|
47
53
|
appContext: {
|
48
54
|
appDirectory,
|
49
55
|
sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
|
50
56
|
apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
|
51
57
|
lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
|
52
58
|
},
|
53
|
-
serverConfigFile,
|
54
|
-
internalPlugins: serverInternalPlugins,
|
55
59
|
runMode
|
56
60
|
})
|
57
61
|
];
|
package/dist/esm/hooks.js
CHANGED
@@ -7,10 +7,15 @@ var hooks = {
|
|
7
7
|
modifyAsyncEntry: createAsyncWaterfall(),
|
8
8
|
modifyFileSystemRoutes: createAsyncWaterfall(),
|
9
9
|
modifyServerRoutes: createAsyncWaterfall(),
|
10
|
+
/** add entry point info to entrypoints array */
|
11
|
+
modifyEntrypoints: createAsyncWaterfall(),
|
12
|
+
/** add entry type */
|
13
|
+
checkEntryPoint: createAsyncWaterfall(),
|
10
14
|
htmlPartials: createAsyncWaterfall(),
|
11
15
|
beforeGenerateRoutes: createAsyncWaterfall(),
|
12
16
|
addDefineTypes: createAsyncWaterfall(),
|
13
17
|
collectServerPlugins: createAsyncWaterfall(),
|
18
|
+
_internalServerPlugins: createAsyncWaterfall(),
|
14
19
|
beforeDev: createAsyncWorkflow(),
|
15
20
|
afterDev: createAsyncWorkflow(),
|
16
21
|
beforeCreateCompiler: createAsyncWorkflow(),
|