@modern-js/app-tools 2.48.6 → 2.49.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/builder/builder-webpack/index.js +1 -1
- package/dist/cjs/commands/build.js +3 -0
- package/dist/cjs/commands/dev.js +16 -16
- package/dist/cjs/commands/serve.js +14 -22
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/plugins/deploy/dependencies.js +257 -0
- package/dist/cjs/plugins/deploy/entrys/netlify.js +95 -0
- package/dist/cjs/plugins/deploy/entrys/node.js +88 -0
- package/dist/cjs/plugins/deploy/entrys/vercel.js +95 -0
- package/dist/cjs/plugins/deploy/index.js +140 -0
- package/dist/cjs/plugins/deploy/utils.js +150 -0
- package/dist/cjs/utils/createServer.js +5 -27
- package/dist/cjs/utils/env.js +2 -2
- package/dist/cjs/utils/register.js +103 -0
- package/dist/esm/builder/builder-webpack/index.js +1 -1
- package/dist/esm/commands/build.js +16 -9
- package/dist/esm/commands/dev.js +34 -38
- package/dist/esm/commands/serve.js +28 -32
- package/dist/esm/index.js +3 -1
- package/dist/esm/plugins/deploy/dependencies.js +726 -0
- package/dist/esm/plugins/deploy/entrys/netlify.js +41 -0
- package/dist/esm/plugins/deploy/entrys/node.js +39 -0
- package/dist/esm/plugins/deploy/entrys/vercel.js +41 -0
- package/dist/esm/plugins/deploy/index.js +219 -0
- package/dist/esm/plugins/deploy/utils.js +244 -0
- package/dist/esm/utils/createServer.js +14 -50
- package/dist/esm/utils/env.js +1 -1
- package/dist/esm/utils/register.js +129 -0
- package/dist/esm-node/builder/builder-webpack/index.js +1 -1
- package/dist/esm-node/commands/build.js +3 -0
- package/dist/esm-node/commands/dev.js +17 -17
- package/dist/esm-node/commands/serve.js +14 -12
- package/dist/esm-node/index.js +3 -1
- package/dist/esm-node/plugins/deploy/dependencies.js +223 -0
- package/dist/esm-node/plugins/deploy/entrys/netlify.js +71 -0
- package/dist/esm-node/plugins/deploy/entrys/node.js +64 -0
- package/dist/esm-node/plugins/deploy/entrys/vercel.js +71 -0
- package/dist/esm-node/plugins/deploy/index.js +110 -0
- package/dist/esm-node/plugins/deploy/utils.js +109 -0
- package/dist/esm-node/utils/createServer.js +6 -17
- package/dist/esm-node/utils/env.js +1 -1
- package/dist/esm-node/utils/register.js +69 -0
- package/dist/types/plugins/deploy/dependencies.d.ts +1 -0
- package/dist/types/plugins/deploy/entrys/netlify.d.ts +5 -0
- package/dist/types/plugins/deploy/entrys/node.d.ts +5 -0
- package/dist/types/plugins/deploy/entrys/vercel.d.ts +5 -0
- package/dist/types/plugins/deploy/index.d.ts +4 -0
- package/dist/types/plugins/deploy/utils.d.ts +27 -0
- package/dist/types/types/config/tools.d.ts +1 -1
- package/dist/types/utils/createServer.d.ts +4 -9
- package/dist/types/utils/register.d.ts +3 -0
- package/package.json +28 -22
package/dist/esm/commands/dev.js
CHANGED
@@ -4,14 +4,17 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
5
|
import { ResolvedConfigContext } from "@modern-js/core";
|
6
6
|
import { DEFAULT_DEV_HOST } from "@modern-js/utils";
|
7
|
+
import { createDevServer } from "@modern-js/server";
|
8
|
+
import { initProdMiddlewares } from "@modern-js/prod-server";
|
9
|
+
import { registerCompiler } from "../utils/register";
|
7
10
|
import { printInstructions } from "../utils/printInstructions";
|
8
|
-
import { setServer
|
11
|
+
import { setServer } from "../utils/createServer";
|
9
12
|
import { generateRoutes } from "../utils/routes";
|
10
13
|
import { buildServerConfig } from "../utils/config";
|
11
14
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
12
15
|
var dev = function() {
|
13
16
|
var _ref = _async_to_generator(function(api, options) {
|
14
|
-
var devServerOptions, _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
|
17
|
+
var devServerOptions, _normalizedConfig_source, _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
|
15
18
|
var _arguments = arguments;
|
16
19
|
return _ts_generator(this, function(_state) {
|
17
20
|
switch (_state.label) {
|
@@ -23,11 +26,17 @@ var dev = function() {
|
|
23
26
|
normalizedConfig = api.useResolvedConfigContext();
|
24
27
|
appContext = api.useAppContext();
|
25
28
|
hookRunners = api.useHookRunners();
|
29
|
+
return [
|
30
|
+
4,
|
31
|
+
registerCompiler(appContext.appDirectory, appContext.distDirectory, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias)
|
32
|
+
];
|
33
|
+
case 1:
|
34
|
+
_state.sent();
|
26
35
|
normalizedConfig = _object_spread_props(_object_spread({}, normalizedConfig), {
|
27
36
|
cliOptions: options
|
28
37
|
});
|
29
38
|
ResolvedConfigContext.set(normalizedConfig);
|
30
|
-
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName;
|
39
|
+
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes;
|
31
40
|
return [
|
32
41
|
4,
|
33
42
|
buildServerConfig({
|
@@ -37,13 +46,13 @@ var dev = function() {
|
|
37
46
|
watch: true
|
38
47
|
})
|
39
48
|
];
|
40
|
-
case
|
49
|
+
case 2:
|
41
50
|
_state.sent();
|
42
51
|
return [
|
43
52
|
4,
|
44
53
|
hookRunners.beforeDev()
|
45
54
|
];
|
46
|
-
case
|
55
|
+
case 3:
|
47
56
|
_state.sent();
|
48
57
|
if (!appContext.builder && !apiOnly) {
|
49
58
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
@@ -52,81 +61,68 @@ var dev = function() {
|
|
52
61
|
4,
|
53
62
|
generateRoutes(appContext)
|
54
63
|
];
|
55
|
-
case
|
64
|
+
case 4:
|
56
65
|
_state.sent();
|
57
66
|
return [
|
58
67
|
4,
|
59
68
|
getServerInternalPlugins(api)
|
60
69
|
];
|
61
|
-
case
|
70
|
+
case 5:
|
62
71
|
serverInternalPlugins = _state.sent();
|
63
72
|
serverOptions = _object_spread({
|
73
|
+
metaName,
|
64
74
|
dev: _object_spread({
|
65
75
|
port,
|
66
76
|
https: normalizedConfig.dev.https,
|
67
77
|
host: normalizedConfig.dev.host
|
68
78
|
}, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
|
69
79
|
appContext: {
|
70
|
-
|
71
|
-
appDirectory: appContext.appDirectory,
|
72
|
-
sharedDirectory: appContext.sharedDirectory,
|
80
|
+
appDirectory,
|
73
81
|
apiDirectory: appContext.apiDirectory,
|
74
|
-
lambdaDirectory: appContext.lambdaDirectory
|
82
|
+
lambdaDirectory: appContext.lambdaDirectory,
|
83
|
+
sharedDirectory: appContext.sharedDirectory
|
75
84
|
},
|
85
|
+
routes: serverRoutes,
|
76
86
|
pwd: appDirectory,
|
77
87
|
config: normalizedConfig,
|
78
88
|
serverConfigFile,
|
79
|
-
internalPlugins:
|
89
|
+
internalPlugins: serverInternalPlugins
|
80
90
|
}, devServerOptions);
|
81
91
|
if (!apiOnly)
|
82
92
|
return [
|
83
93
|
3,
|
84
|
-
|
94
|
+
7
|
85
95
|
];
|
86
96
|
return [
|
87
97
|
4,
|
88
|
-
|
89
|
-
compiler: null
|
90
|
-
}))
|
98
|
+
createDevServer(serverOptions, initProdMiddlewares)
|
91
99
|
];
|
92
|
-
case
|
100
|
+
case 6:
|
93
101
|
app = _state.sent();
|
94
102
|
host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
|
95
103
|
app.listen({
|
96
104
|
port,
|
97
105
|
host
|
98
106
|
}, function() {
|
99
|
-
|
100
|
-
|
101
|
-
if (err) {
|
102
|
-
throw err;
|
103
|
-
}
|
104
|
-
printInstructions(hookRunners, appContext, normalizedConfig);
|
105
|
-
return [
|
106
|
-
2
|
107
|
-
];
|
108
|
-
});
|
109
|
-
});
|
110
|
-
return function(err) {
|
111
|
-
return _ref2.apply(this, arguments);
|
112
|
-
};
|
113
|
-
}());
|
107
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
108
|
+
});
|
114
109
|
return [
|
115
110
|
3,
|
116
|
-
|
111
|
+
9
|
117
112
|
];
|
118
|
-
case
|
113
|
+
case 7:
|
119
114
|
return [
|
120
115
|
4,
|
121
116
|
appContext.builder.startDevServer({
|
122
|
-
serverOptions
|
117
|
+
serverOptions,
|
118
|
+
initProdMiddlewares
|
123
119
|
})
|
124
120
|
];
|
125
|
-
case
|
121
|
+
case 8:
|
126
122
|
server = _state.sent().server;
|
127
123
|
setServer(server);
|
128
|
-
_state.label =
|
129
|
-
case
|
124
|
+
_state.label = 9;
|
125
|
+
case 9:
|
130
126
|
return [
|
131
127
|
2
|
132
128
|
];
|
@@ -3,20 +3,19 @@ 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
5
|
import { logger, isApiOnly, getTargetDir } from "@modern-js/utils";
|
6
|
-
import
|
6
|
+
import { createProdServer } from "@modern-js/prod-server";
|
7
7
|
import { printInstructions } from "../utils/printInstructions";
|
8
|
-
import { injectDataLoaderPlugin } from "../utils/createServer";
|
9
8
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
10
9
|
var start = function() {
|
11
10
|
var _ref = _async_to_generator(function(api) {
|
12
|
-
var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, appDirectory, port, serverConfigFile, metaName, apiOnly, serverInternalPlugins, app;
|
11
|
+
var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, distDirectory, appDirectory, port, serverConfigFile, metaName, serverRoutes, apiOnly, runMode, serverInternalPlugins, app;
|
13
12
|
return _ts_generator(this, function(_state) {
|
14
13
|
switch (_state.label) {
|
15
14
|
case 0:
|
16
15
|
appContext = api.useAppContext();
|
17
16
|
userConfig = api.useResolvedConfigContext();
|
18
17
|
hookRunners = api.useHookRunners();
|
19
|
-
appDirectory = appContext.appDirectory, port = appContext.port, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName;
|
18
|
+
distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, port = appContext.port, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes;
|
20
19
|
logger.info("Starting production server...");
|
21
20
|
return [
|
22
21
|
4,
|
@@ -24,6 +23,9 @@ var start = function() {
|
|
24
23
|
];
|
25
24
|
case 1:
|
26
25
|
apiOnly = _state.sent();
|
26
|
+
if (apiOnly) {
|
27
|
+
runMode = "apiOnly";
|
28
|
+
}
|
27
29
|
return [
|
28
30
|
4,
|
29
31
|
getServerInternalPlugins(api)
|
@@ -32,51 +34,45 @@ var start = function() {
|
|
32
34
|
serverInternalPlugins = _state.sent();
|
33
35
|
return [
|
34
36
|
4,
|
35
|
-
|
36
|
-
|
37
|
+
createProdServer({
|
38
|
+
metaName,
|
39
|
+
pwd: distDirectory,
|
37
40
|
config: _object_spread_props(_object_spread({}, userConfig), {
|
38
41
|
dev: userConfig.dev,
|
39
42
|
output: _object_spread({
|
40
43
|
path: (_userConfig_output_distPath = userConfig.output.distPath) === null || _userConfig_output_distPath === void 0 ? void 0 : _userConfig_output_distPath.root
|
41
44
|
}, userConfig.output || {})
|
42
45
|
}),
|
46
|
+
routes: serverRoutes,
|
43
47
|
appContext: {
|
44
|
-
|
48
|
+
appDirectory,
|
45
49
|
sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
|
46
50
|
apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
|
47
51
|
lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
|
48
52
|
},
|
49
53
|
serverConfigFile,
|
50
|
-
internalPlugins:
|
51
|
-
|
54
|
+
internalPlugins: serverInternalPlugins,
|
55
|
+
runMode
|
52
56
|
})
|
53
57
|
];
|
54
58
|
case 3:
|
55
59
|
app = _state.sent();
|
56
|
-
app.listen(port, function() {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
return [
|
71
|
-
2
|
72
|
-
];
|
73
|
-
}
|
74
|
-
});
|
60
|
+
app.listen(port, /* @__PURE__ */ _async_to_generator(function() {
|
61
|
+
return _ts_generator(this, function(_state2) {
|
62
|
+
switch (_state2.label) {
|
63
|
+
case 0:
|
64
|
+
return [
|
65
|
+
4,
|
66
|
+
printInstructions(hookRunners, appContext, userConfig)
|
67
|
+
];
|
68
|
+
case 1:
|
69
|
+
_state2.sent();
|
70
|
+
return [
|
71
|
+
2
|
72
|
+
];
|
73
|
+
}
|
75
74
|
});
|
76
|
-
|
77
|
-
return _ref2.apply(this, arguments);
|
78
|
-
};
|
79
|
-
}());
|
75
|
+
}));
|
80
76
|
return [
|
81
77
|
2
|
82
78
|
];
|
package/dist/esm/index.js
CHANGED
@@ -12,6 +12,7 @@ import initializePlugin from "./initialize";
|
|
12
12
|
import { hooks } from "./hooks";
|
13
13
|
import { i18n, localeKeys } from "./locale";
|
14
14
|
import serverBuildPlugin from "./plugins/serverBuild";
|
15
|
+
import deployPlugin from "./plugins/deploy";
|
15
16
|
import { restart } from "./utils/restart";
|
16
17
|
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
17
18
|
import { mergeConfig } from "@modern-js/core";
|
@@ -295,7 +296,8 @@ var appTools = function() {
|
|
295
296
|
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
296
297
|
}),
|
297
298
|
serverBuildPlugin(),
|
298
|
-
lintPlugin()
|
299
|
+
lintPlugin(),
|
300
|
+
deployPlugin()
|
299
301
|
],
|
300
302
|
setup: function(api) {
|
301
303
|
var appContext = api.useAppContext();
|