@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.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.
- package/CHANGELOG.md +181 -0
- package/dist/js/modern/analyze/generateCode.js +29 -37
- package/dist/js/modern/analyze/getBundleEntry.js +4 -12
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/modern/analyze/getFileSystemEntry.js +4 -17
- package/dist/js/modern/analyze/getHtmlTemplate.js +2 -9
- package/dist/js/modern/analyze/getServerRoutes.js +15 -32
- package/dist/js/modern/analyze/index.js +79 -22
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/modern/analyze/nestedRoutes.js +8 -33
- package/dist/js/modern/analyze/templates.js +22 -37
- package/dist/js/modern/analyze/utils.js +0 -7
- package/dist/js/modern/builder/builderPlugins/compatModern.js +30 -48
- package/dist/js/modern/builder/createHtmlConfig.js +2 -2
- package/dist/js/modern/builder/createOutputConfig.js +7 -4
- package/dist/js/modern/builder/createSourceConfig.js +0 -11
- package/dist/js/modern/builder/createToolsConfig.js +3 -10
- package/dist/js/modern/builder/index.js +24 -22
- package/dist/js/modern/builder/share.js +0 -4
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +6 -46
- package/dist/js/modern/commands/dev.js +4 -16
- package/dist/js/modern/commands/inspect.js +3 -20
- package/dist/js/modern/commands/start.js +0 -2
- package/dist/js/modern/index.js +6 -15
- package/dist/js/modern/utils/config.js +1 -12
- package/dist/js/modern/utils/createServer.js +0 -5
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +2 -1
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/generateCode.js +29 -60
- package/dist/js/node/analyze/getBundleEntry.js +4 -18
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
- package/dist/js/node/analyze/getFileSystemEntry.js +4 -25
- package/dist/js/node/analyze/getHtmlTemplate.js +2 -23
- package/dist/js/node/analyze/getServerRoutes.js +14 -40
- package/dist/js/node/analyze/index.js +79 -32
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
- package/dist/js/node/analyze/nestedRoutes.js +8 -41
- package/dist/js/node/analyze/templates.js +22 -47
- package/dist/js/node/analyze/utils.js +0 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +30 -59
- package/dist/js/node/builder/createHtmlConfig.js +2 -10
- package/dist/js/node/builder/createOutputConfig.js +7 -6
- package/dist/js/node/builder/createSourceConfig.js +0 -17
- package/dist/js/node/builder/createToolsConfig.js +3 -12
- package/dist/js/node/builder/index.js +24 -36
- package/dist/js/node/builder/share.js +0 -12
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +4 -57
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +3 -27
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +3 -27
- package/dist/js/node/commands/start.js +0 -11
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +7 -34
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/utils/commands.js +0 -2
- package/dist/js/node/utils/config.js +1 -25
- package/dist/js/node/utils/createServer.js +0 -15
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
- package/dist/js/node/utils/language.js +0 -2
- package/dist/js/node/utils/printInstructions.js +2 -5
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/generateCode.js +57 -100
- package/dist/js/treeshaking/analyze/getBundleEntry.js +11 -19
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +4 -17
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +2 -26
- package/dist/js/treeshaking/analyze/getServerRoutes.js +24 -37
- package/dist/js/treeshaking/analyze/index.js +185 -65
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
- package/dist/js/treeshaking/analyze/templates.js +31 -50
- package/dist/js/treeshaking/analyze/utils.js +7 -14
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +40 -59
- package/dist/js/treeshaking/builder/createHtmlConfig.js +15 -15
- package/dist/js/treeshaking/builder/createOutputConfig.js +26 -23
- package/dist/js/treeshaking/builder/createSourceConfig.js +7 -19
- package/dist/js/treeshaking/builder/createToolsConfig.js +16 -21
- package/dist/js/treeshaking/builder/index.js +38 -49
- package/dist/js/treeshaking/builder/share.js +0 -4
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +26 -111
- package/dist/js/treeshaking/commands/deploy.js +0 -3
- package/dist/js/treeshaking/commands/dev.js +13 -35
- package/dist/js/treeshaking/commands/inspect.js +5 -28
- package/dist/js/treeshaking/commands/start.js +0 -9
- package/dist/js/treeshaking/index.js +2 -39
- package/dist/js/treeshaking/utils/config.js +1 -17
- package/dist/js/treeshaking/utils/createServer.js +0 -10
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
- package/dist/js/treeshaking/utils/printInstructions.js +0 -5
- package/dist/js/treeshaking/utils/routes.js +0 -4
- package/dist/types/analyze/index.d.ts +2 -3
- package/dist/types/analyze/nestedRoutes.d.ts +1 -1
- package/dist/types/analyze/templates.d.ts +3 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +0 -1
- package/dist/types/builder/index.d.ts +2 -6
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/inspect.d.ts +1 -4
- package/dist/types/index.d.ts +0 -2
- package/dist/types/utils/config.d.ts +0 -1
- package/package.json +23 -22
- package/dist/js/modern/utils/createCompiler.js +0 -58
- package/dist/js/node/utils/createCompiler.js +0 -75
- package/dist/js/treeshaking/utils/createCompiler.js +0 -117
- package/dist/types/utils/createCompiler.d.ts +0 -12
|
@@ -2,166 +2,81 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
5
|
-
import { logger,
|
|
5
|
+
import { logger, printBuildError } from '@modern-js/utils';
|
|
6
6
|
import { generateRoutes } from "../utils/routes";
|
|
7
|
-
import { buildServerConfig
|
|
8
|
-
import createBuilder from "../builder";
|
|
7
|
+
import { buildServerConfig } from "../utils/config";
|
|
9
8
|
export var build = /*#__PURE__*/function () {
|
|
10
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
11
|
-
var resolvedConfig, appContext, hookRunners, apiOnly, _appDirectory, _distDirectory, _serverConfigFile, distDirectory, appDirectory, serverConfigFile,
|
|
12
|
-
|
|
13
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
9
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, options) {
|
|
10
|
+
var resolvedConfig, appContext, hookRunners, apiOnly, _appDirectory, _distDirectory, _serverConfigFile, distDirectory, appDirectory, serverConfigFile, _appContext$builder;
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14
12
|
while (1) {
|
|
15
|
-
switch (
|
|
13
|
+
switch (_context.prev = _context.next) {
|
|
16
14
|
case 0:
|
|
17
15
|
resolvedConfig = api.useResolvedConfigContext();
|
|
18
16
|
appContext = api.useAppContext();
|
|
19
17
|
hookRunners = api.useHookRunners();
|
|
20
18
|
apiOnly = appContext.apiOnly;
|
|
21
|
-
|
|
22
19
|
if (!apiOnly) {
|
|
23
|
-
|
|
20
|
+
_context.next = 15;
|
|
24
21
|
break;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
_appDirectory = appContext.appDirectory, _distDirectory = appContext.distDirectory, _serverConfigFile = appContext.serverConfigFile;
|
|
28
|
-
|
|
24
|
+
_context.next = 8;
|
|
29
25
|
return hookRunners.beforeBuild({
|
|
30
26
|
// "null" bundlerConfigs
|
|
31
27
|
bundlerConfigs: undefined
|
|
32
28
|
});
|
|
33
|
-
|
|
34
29
|
case 8:
|
|
35
|
-
|
|
30
|
+
_context.next = 10;
|
|
36
31
|
return buildServerConfig({
|
|
37
32
|
appDirectory: _appDirectory,
|
|
38
33
|
distDirectory: _distDirectory,
|
|
39
34
|
configFile: _serverConfigFile
|
|
40
35
|
});
|
|
41
|
-
|
|
42
36
|
case 10:
|
|
43
|
-
|
|
37
|
+
_context.next = 12;
|
|
44
38
|
return generateRoutes(appContext);
|
|
45
|
-
|
|
46
39
|
case 12:
|
|
47
|
-
|
|
40
|
+
_context.next = 14;
|
|
48
41
|
return hookRunners.afterBuild({
|
|
49
42
|
// "null" stats
|
|
50
43
|
stats: undefined
|
|
51
44
|
});
|
|
52
|
-
|
|
53
45
|
case 14:
|
|
54
|
-
return
|
|
55
|
-
|
|
46
|
+
return _context.abrupt("return");
|
|
56
47
|
case 15:
|
|
57
48
|
resolvedConfig = _objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
58
49
|
cliOptions: options
|
|
59
50
|
});
|
|
60
51
|
ResolvedConfigContext.set(resolvedConfig);
|
|
61
52
|
distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, serverConfigFile = appContext.serverConfigFile;
|
|
62
|
-
|
|
53
|
+
_context.next = 20;
|
|
63
54
|
return buildServerConfig({
|
|
64
55
|
appDirectory: appDirectory,
|
|
65
56
|
distDirectory: distDirectory,
|
|
66
57
|
configFile: serverConfigFile
|
|
67
58
|
});
|
|
68
|
-
|
|
69
59
|
case 20:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (resolvedConfig.output.enableModernMode) {
|
|
73
|
-
targets.push('modern-web');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (isUseSSRBundle(resolvedConfig)) {
|
|
77
|
-
targets.push('node');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
_context3.prev = 23;
|
|
81
|
-
_context3.next = 26;
|
|
82
|
-
return createBuilder({
|
|
83
|
-
target: targets,
|
|
84
|
-
appContext: appContext,
|
|
85
|
-
normalizedConfig: resolvedConfig,
|
|
86
|
-
compatPluginConfig: {
|
|
87
|
-
onBeforeBuild: function onBeforeBuild(_ref2) {
|
|
88
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
89
|
-
var bundlerConfigs;
|
|
90
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
91
|
-
while (1) {
|
|
92
|
-
switch (_context.prev = _context.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
bundlerConfigs = _ref2.bundlerConfigs;
|
|
95
|
-
_context.next = 3;
|
|
96
|
-
return generateRoutes(appContext);
|
|
97
|
-
|
|
98
|
-
case 3:
|
|
99
|
-
_context.next = 5;
|
|
100
|
-
return hookRunners.beforeBuild({
|
|
101
|
-
bundlerConfigs: bundlerConfigs
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
case 5:
|
|
105
|
-
case "end":
|
|
106
|
-
return _context.stop();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, _callee);
|
|
110
|
-
}))();
|
|
111
|
-
},
|
|
112
|
-
onAfterBuild: function onAfterBuild(_ref3) {
|
|
113
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
114
|
-
var stats;
|
|
115
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
116
|
-
while (1) {
|
|
117
|
-
switch (_context2.prev = _context2.next) {
|
|
118
|
-
case 0:
|
|
119
|
-
stats = _ref3.stats;
|
|
120
|
-
_context2.next = 3;
|
|
121
|
-
return hookRunners.afterBuild({
|
|
122
|
-
stats: stats
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
case 3:
|
|
126
|
-
_context2.next = 5;
|
|
127
|
-
return emitResolvedConfig(appDirectory, resolvedConfig);
|
|
128
|
-
|
|
129
|
-
case 5:
|
|
130
|
-
case "end":
|
|
131
|
-
return _context2.stop();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}, _callee2);
|
|
135
|
-
}))();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
case 26:
|
|
141
|
-
builder = _context3.sent;
|
|
60
|
+
_context.prev = 20;
|
|
142
61
|
logger.info('Create a production build...\n');
|
|
143
|
-
|
|
144
|
-
return builder.build();
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_context3.next = 36;
|
|
62
|
+
_context.next = 24;
|
|
63
|
+
return (_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.build();
|
|
64
|
+
case 24:
|
|
65
|
+
_context.next = 30;
|
|
148
66
|
break;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
67
|
+
case 26:
|
|
68
|
+
_context.prev = 26;
|
|
69
|
+
_context.t0 = _context["catch"](20);
|
|
70
|
+
printBuildError(_context.t0);
|
|
71
|
+
// eslint-disable-next-line no-process-exit
|
|
155
72
|
process.exit(1);
|
|
156
|
-
|
|
157
|
-
case 36:
|
|
73
|
+
case 30:
|
|
158
74
|
case "end":
|
|
159
|
-
return
|
|
75
|
+
return _context.stop();
|
|
160
76
|
}
|
|
161
77
|
}
|
|
162
|
-
},
|
|
78
|
+
}, _callee, null, [[20, 26]]);
|
|
163
79
|
}));
|
|
164
|
-
|
|
165
80
|
return function build(_x, _x2) {
|
|
166
81
|
return _ref.apply(this, arguments);
|
|
167
82
|
};
|
|
@@ -10,11 +10,9 @@ export var deploy = /*#__PURE__*/function () {
|
|
|
10
10
|
hookRunners = api.useHookRunners();
|
|
11
11
|
_context.next = 3;
|
|
12
12
|
return hookRunners.beforeDeploy(options);
|
|
13
|
-
|
|
14
13
|
case 3:
|
|
15
14
|
_context.next = 5;
|
|
16
15
|
return hookRunners.afterDeploy(options);
|
|
17
|
-
|
|
18
16
|
case 5:
|
|
19
17
|
case "end":
|
|
20
18
|
return _context.stop();
|
|
@@ -22,7 +20,6 @@ export var deploy = /*#__PURE__*/function () {
|
|
|
22
20
|
}
|
|
23
21
|
}, _callee);
|
|
24
22
|
}));
|
|
25
|
-
|
|
26
23
|
return function deploy(_x, _x2) {
|
|
27
24
|
return _ref.apply(this, arguments);
|
|
28
25
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
import { logger
|
|
4
|
+
import { logger } from '@modern-js/utils';
|
|
5
5
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
6
6
|
import { printInstructions } from "../utils/printInstructions";
|
|
7
|
-
import { createDevCompiler } from "../utils/createCompiler";
|
|
8
7
|
import { createServer, injectDataLoaderPlugin } from "../utils/createServer";
|
|
9
8
|
import { generateRoutes } from "../utils/routes";
|
|
10
9
|
import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
|
|
11
10
|
import { buildServerConfig } from "../utils/config";
|
|
12
11
|
export var dev = /*#__PURE__*/function () {
|
|
13
12
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api, options) {
|
|
14
|
-
var userConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, entrypoints, serverConfigFile, serverInternalPlugins, checkedEntries, compiler,
|
|
13
|
+
var userConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, entrypoints, serverConfigFile, serverInternalPlugins, checkedEntries, compiler, _appContext$builder, app;
|
|
15
14
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
16
15
|
while (1) {
|
|
17
16
|
switch (_context2.prev = _context2.next) {
|
|
@@ -26,7 +25,6 @@ export var dev = /*#__PURE__*/function () {
|
|
|
26
25
|
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, entrypoints = appContext.entrypoints, serverConfigFile = appContext.serverConfigFile, serverInternalPlugins = appContext.serverInternalPlugins;
|
|
27
26
|
_context2.next = 8;
|
|
28
27
|
return getSpecifiedEntries(options.entry || false, entrypoints);
|
|
29
|
-
|
|
30
28
|
case 8:
|
|
31
29
|
checkedEntries = _context2.sent;
|
|
32
30
|
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
@@ -44,37 +42,24 @@ export var dev = /*#__PURE__*/function () {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
});
|
|
47
|
-
|
|
48
45
|
case 13:
|
|
49
46
|
_context2.next = 15;
|
|
50
47
|
return hookRunners.beforeDev();
|
|
51
|
-
|
|
52
48
|
case 15:
|
|
53
49
|
compiler = null;
|
|
54
|
-
|
|
55
50
|
if (apiOnly) {
|
|
56
|
-
_context2.next =
|
|
51
|
+
_context2.next = 20;
|
|
57
52
|
break;
|
|
58
53
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return createDevCompiler({
|
|
63
|
-
target: target,
|
|
64
|
-
api: api,
|
|
65
|
-
normalizedConfig: userConfig,
|
|
66
|
-
appContext: appContext
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
case 20:
|
|
54
|
+
_context2.next = 19;
|
|
55
|
+
return (_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.createCompiler();
|
|
56
|
+
case 19:
|
|
70
57
|
compiler = _context2.sent;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
_context2.next = 23;
|
|
58
|
+
case 20:
|
|
59
|
+
_context2.next = 22;
|
|
74
60
|
return generateRoutes(appContext);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_context2.next = 25;
|
|
61
|
+
case 22:
|
|
62
|
+
_context2.next = 24;
|
|
78
63
|
return createServer({
|
|
79
64
|
dev: _objectSpread(_objectSpread({}, {
|
|
80
65
|
client: {
|
|
@@ -96,8 +81,7 @@ export var dev = /*#__PURE__*/function () {
|
|
|
96
81
|
serverConfigFile: serverConfigFile,
|
|
97
82
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
98
83
|
});
|
|
99
|
-
|
|
100
|
-
case 25:
|
|
84
|
+
case 24:
|
|
101
85
|
app = _context2.sent;
|
|
102
86
|
app.listen(port, /*#__PURE__*/function () {
|
|
103
87
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(err) {
|
|
@@ -109,16 +93,13 @@ export var dev = /*#__PURE__*/function () {
|
|
|
109
93
|
_context.next = 2;
|
|
110
94
|
break;
|
|
111
95
|
}
|
|
112
|
-
|
|
113
96
|
throw err;
|
|
114
|
-
|
|
115
97
|
case 2:
|
|
116
98
|
if (!apiOnly) {
|
|
117
|
-
logger.info("Starting dev server
|
|
99
|
+
logger.info("Starting dev server...\n");
|
|
118
100
|
} else {
|
|
119
101
|
printInstructions(hookRunners, appContext, userConfig);
|
|
120
102
|
}
|
|
121
|
-
|
|
122
103
|
case 3:
|
|
123
104
|
case "end":
|
|
124
105
|
return _context.stop();
|
|
@@ -126,20 +107,17 @@ export var dev = /*#__PURE__*/function () {
|
|
|
126
107
|
}
|
|
127
108
|
}, _callee);
|
|
128
109
|
}));
|
|
129
|
-
|
|
130
110
|
return function (_x3) {
|
|
131
111
|
return _ref2.apply(this, arguments);
|
|
132
112
|
};
|
|
133
113
|
}());
|
|
134
|
-
|
|
135
|
-
case 27:
|
|
114
|
+
case 26:
|
|
136
115
|
case "end":
|
|
137
116
|
return _context2.stop();
|
|
138
117
|
}
|
|
139
118
|
}
|
|
140
119
|
}, _callee2);
|
|
141
120
|
}));
|
|
142
|
-
|
|
143
121
|
return function dev(_x, _x2) {
|
|
144
122
|
return _ref.apply(this, arguments);
|
|
145
123
|
};
|
|
@@ -1,51 +1,28 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import { isUseSSRBundle } from '@modern-js/utils';
|
|
5
|
-
import createBuilder from "../builder";
|
|
6
4
|
export var inspect = /*#__PURE__*/function () {
|
|
7
5
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, options) {
|
|
8
|
-
var
|
|
6
|
+
var _appContext$builder;
|
|
7
|
+
var appContext;
|
|
9
8
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10
9
|
while (1) {
|
|
11
10
|
switch (_context.prev = _context.next) {
|
|
12
11
|
case 0:
|
|
13
|
-
resolvedConfig = api.useResolvedConfigContext();
|
|
14
12
|
appContext = api.useAppContext();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (resolvedConfig.output.enableModernMode) {
|
|
18
|
-
targets.push('modern-web');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (isUseSSRBundle(resolvedConfig)) {
|
|
22
|
-
targets.push('node');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_context.next = 7;
|
|
26
|
-
return createBuilder({
|
|
27
|
-
target: targets,
|
|
28
|
-
appContext: appContext,
|
|
29
|
-
normalizedConfig: resolvedConfig
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
case 7:
|
|
33
|
-
builder = _context.sent;
|
|
34
|
-
return _context.abrupt("return", builder.inspectConfig({
|
|
13
|
+
return _context.abrupt("return", (_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.inspectConfig({
|
|
35
14
|
env: options.env,
|
|
36
15
|
verbose: options.verbose,
|
|
37
|
-
outputPath: join(builder.context.distPath, options.output),
|
|
16
|
+
outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
38
17
|
writeToDisk: true
|
|
39
18
|
}));
|
|
40
|
-
|
|
41
|
-
case 9:
|
|
19
|
+
case 2:
|
|
42
20
|
case "end":
|
|
43
21
|
return _context.stop();
|
|
44
22
|
}
|
|
45
23
|
}
|
|
46
24
|
}, _callee);
|
|
47
25
|
}));
|
|
48
|
-
|
|
49
26
|
return function inspect(_x, _x2) {
|
|
50
27
|
return _ref.apply(this, arguments);
|
|
51
28
|
};
|
|
@@ -7,7 +7,6 @@ import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
|
7
7
|
export var start = /*#__PURE__*/function () {
|
|
8
8
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api) {
|
|
9
9
|
var _userConfig$source;
|
|
10
|
-
|
|
11
10
|
var appContext, userConfig, hookRunners, appDirectory, port, serverConfigFile, apiOnly, app;
|
|
12
11
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
13
12
|
while (1) {
|
|
@@ -20,7 +19,6 @@ export var start = /*#__PURE__*/function () {
|
|
|
20
19
|
logger.log(chalk.cyan("Starting the modern server..."));
|
|
21
20
|
_context2.next = 7;
|
|
22
21
|
return isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.entriesDir);
|
|
23
|
-
|
|
24
22
|
case 7:
|
|
25
23
|
apiOnly = _context2.sent;
|
|
26
24
|
_context2.next = 10;
|
|
@@ -31,7 +29,6 @@ export var start = /*#__PURE__*/function () {
|
|
|
31
29
|
internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
|
|
32
30
|
apiOnly: apiOnly
|
|
33
31
|
});
|
|
34
|
-
|
|
35
32
|
case 10:
|
|
36
33
|
app = _context2.sent;
|
|
37
34
|
app.listen(port, /*#__PURE__*/function () {
|
|
@@ -44,13 +41,10 @@ export var start = /*#__PURE__*/function () {
|
|
|
44
41
|
_context.next = 2;
|
|
45
42
|
break;
|
|
46
43
|
}
|
|
47
|
-
|
|
48
44
|
throw err;
|
|
49
|
-
|
|
50
45
|
case 2:
|
|
51
46
|
_context.next = 4;
|
|
52
47
|
return printInstructions(hookRunners, appContext, userConfig);
|
|
53
|
-
|
|
54
48
|
case 4:
|
|
55
49
|
case "end":
|
|
56
50
|
return _context.stop();
|
|
@@ -58,12 +52,10 @@ export var start = /*#__PURE__*/function () {
|
|
|
58
52
|
}
|
|
59
53
|
}, _callee);
|
|
60
54
|
}));
|
|
61
|
-
|
|
62
55
|
return function (_x2) {
|
|
63
56
|
return _ref2.apply(this, arguments);
|
|
64
57
|
};
|
|
65
58
|
}());
|
|
66
|
-
|
|
67
59
|
case 12:
|
|
68
60
|
case "end":
|
|
69
61
|
return _context2.stop();
|
|
@@ -71,7 +63,6 @@ export var start = /*#__PURE__*/function () {
|
|
|
71
63
|
}
|
|
72
64
|
}, _callee2);
|
|
73
65
|
}));
|
|
74
|
-
|
|
75
66
|
return function start(_x) {
|
|
76
67
|
return _ref.apply(this, arguments);
|
|
77
68
|
};
|