@modern-js/app-tools 2.63.1 → 2.63.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +1 -1
- package/dist/cjs/commands/build.js +19 -13
- package/dist/cjs/commands/deploy.js +5 -5
- package/dist/cjs/commands/dev.js +11 -11
- package/dist/cjs/commands/index.js +6 -6
- package/dist/cjs/commands/inspect.js +1 -1
- package/dist/cjs/commands/serve.js +4 -4
- package/dist/cjs/{new/compat → compat}/hooks.js +5 -5
- package/dist/cjs/{new/compat → compat}/index.js +4 -1
- package/dist/cjs/config/default.js +6 -1
- package/dist/cjs/config/legacy/index.js +0 -1
- package/dist/cjs/index.js +154 -5
- package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
- package/dist/cjs/plugins/analyze/index.js +25 -10
- package/dist/cjs/plugins/analyze/utils.js +6 -0
- package/dist/cjs/plugins/serverBuild.js +30 -32
- package/dist/cjs/{new/run.js → run/index.js} +6 -6
- package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
- package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
- package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/cjs/utils/loadPlugins.js +35 -4
- package/dist/cjs/utils/printInstructions.js +2 -11
- package/dist/cjs/utils/restart.js +2 -2
- package/dist/esm/commands/build.js +18 -12
- package/dist/esm/commands/deploy.js +6 -6
- package/dist/esm/commands/dev.js +11 -11
- package/dist/esm/commands/index.js +8 -8
- package/dist/esm/commands/inspect.js +1 -1
- package/dist/esm/commands/serve.js +6 -6
- package/dist/esm/{new/compat → compat}/hooks.js +15 -25
- package/dist/esm/{new/compat → compat}/index.js +4 -1
- package/dist/esm/config/default.js +12 -1
- package/dist/esm/config/legacy/index.js +0 -1
- package/dist/esm/index.js +245 -2
- package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm/plugins/analyze/index.js +76 -34
- package/dist/esm/plugins/analyze/utils.js +5 -0
- package/dist/esm/plugins/serverBuild.js +52 -56
- package/dist/esm/{new/run.js → run/index.js} +6 -6
- package/dist/esm/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/esm/utils/loadPlugins.js +95 -7
- package/dist/esm/utils/printInstructions.js +1 -28
- package/dist/esm/utils/restart.js +3 -3
- package/dist/esm-node/commands/build.js +19 -13
- package/dist/esm-node/commands/deploy.js +5 -5
- package/dist/esm-node/commands/dev.js +12 -12
- package/dist/esm-node/commands/index.js +6 -6
- package/dist/esm-node/commands/inspect.js +1 -1
- package/dist/esm-node/commands/serve.js +5 -5
- package/dist/esm-node/{new/compat → compat}/hooks.js +5 -5
- package/dist/esm-node/{new/compat → compat}/index.js +4 -1
- package/dist/esm-node/config/default.js +6 -1
- package/dist/esm-node/config/legacy/index.js +0 -1
- package/dist/esm-node/index.js +140 -2
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm-node/plugins/analyze/index.js +26 -11
- package/dist/esm-node/plugins/analyze/utils.js +5 -0
- package/dist/esm-node/plugins/serverBuild.js +30 -32
- package/dist/esm-node/{new/run.js → run/index.js} +6 -6
- package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
- package/dist/esm-node/utils/loadPlugins.js +34 -4
- package/dist/esm-node/utils/printInstructions.js +1 -9
- package/dist/esm-node/utils/restart.js +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/index.d.ts +6 -6
- package/dist/types/commands/inspect.d.ts +2 -2
- package/dist/types/commands/serve.d.ts +2 -2
- package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/index.d.ts +5 -3
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
- package/dist/types/plugins/analyze/utils.d.ts +1 -0
- package/dist/types/plugins/serverBuild.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/new.d.ts +11 -16
- package/dist/types/utils/generateWatchFiles.d.ts +2 -2
- package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -3
- package/dist/types/utils/printInstructions.d.ts +1 -3
- package/dist/types/utils/restart.d.ts +2 -3
- package/package.json +23 -23
- package/dist/cjs/hooks.js +0 -60
- package/dist/cjs/new/index.js +0 -79
- package/dist/cjs/new/loadPlugins.js +0 -57
- package/dist/cjs/old.js +0 -179
- package/dist/esm/hooks.js +0 -36
- package/dist/esm/new/index.js +0 -55
- package/dist/esm/new/loadPlugins.js +0 -94
- package/dist/esm/old.js +0 -258
- package/dist/esm-node/hooks.js +0 -36
- package/dist/esm-node/new/index.js +0 -52
- package/dist/esm-node/new/loadPlugins.js +0 -33
- package/dist/esm-node/old.js +0 -140
- package/dist/types/hooks.d.ts +0 -2
- package/dist/types/new/compat/index.d.ts +0 -2
- package/dist/types/new/index.d.ts +0 -6
- package/dist/types/new/loadPlugins.d.ts +0 -9
- package/dist/types/new/utils/index.d.ts +0 -1
- package/dist/types/old.d.ts +0 -13
- /package/dist/cjs/{new/compat → compat}/utils.js +0 -0
- /package/dist/cjs/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/compat → compat}/utils.js +0 -0
- /package/dist/esm/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/esm-node/{new/compat → compat}/utils.js +0 -0
- /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
- /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/types/{new/compat → compat}/utils.d.ts +0 -0
- /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
- /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
- /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
package/dist/esm/index.js
CHANGED
@@ -1,5 +1,248 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
3
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
4
|
+
import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
|
5
|
+
import { createAsyncHook, createCollectAsyncHook } from "@modern-js/plugin-v2";
|
6
|
+
import { castArray } from "@modern-js/uni-builder";
|
7
|
+
import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
|
8
|
+
import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
|
9
|
+
import { compatPlugin } from "./compat";
|
10
|
+
import { DEFAULT_RUNTIME_CONFIG_FILE, DEFAULT_SERVER_CONFIG_FILE } from "./constants";
|
11
|
+
import { i18n } from "./locale";
|
12
|
+
import analyzePlugin from "./plugins/analyze";
|
13
|
+
import deployPlugin from "./plugins/deploy";
|
14
|
+
import initializePlugin from "./plugins/initialize";
|
15
|
+
import serverBuildPlugin from "./plugins/serverBuild";
|
16
|
+
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
17
|
+
import { initAppContext } from "./utils/initAppContext";
|
18
|
+
import { restart } from "./utils/restart";
|
19
|
+
export * from "./defineConfig";
|
20
|
+
var appTools = function() {
|
21
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
22
|
+
// default webpack to be compatible with original projects
|
23
|
+
bundler: "webpack"
|
24
|
+
};
|
25
|
+
return {
|
26
|
+
name: "@modern-js/app-tools",
|
27
|
+
usePlugins: [
|
28
|
+
compatPlugin(),
|
29
|
+
initializePlugin({
|
30
|
+
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
31
|
+
"rspack",
|
32
|
+
"experimental-rspack"
|
33
|
+
].includes(options.bundler) ? "rspack" : "webpack"
|
34
|
+
}),
|
35
|
+
analyzePlugin({
|
36
|
+
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
37
|
+
"rspack",
|
38
|
+
"experimental-rspack"
|
39
|
+
].includes(options.bundler) ? "rspack" : "webpack"
|
40
|
+
}),
|
41
|
+
serverBuildPlugin(),
|
42
|
+
deployPlugin()
|
43
|
+
],
|
44
|
+
post: [
|
45
|
+
"@modern-js/plugin-initialize",
|
46
|
+
"@modern-js/plugin-analyze",
|
47
|
+
"@modern-js/plugin-ssr",
|
48
|
+
"@modern-js/plugin-document",
|
49
|
+
"@modern-js/plugin-state",
|
50
|
+
"@modern-js/plugin-router",
|
51
|
+
"@modern-js/plugin-router-v5",
|
52
|
+
"@modern-js/plugin-polyfill"
|
53
|
+
],
|
54
|
+
registryHooks: {
|
55
|
+
onBeforeConfig: createAsyncHook(),
|
56
|
+
onAfterPrepare: createAsyncHook(),
|
57
|
+
deploy: createAsyncHook(),
|
58
|
+
_internalRuntimePlugins: createAsyncHook(),
|
59
|
+
_internalServerPlugins: createAsyncHook(),
|
60
|
+
checkEntryPoint: createAsyncHook(),
|
61
|
+
modifyEntrypoints: createAsyncHook(),
|
62
|
+
modifyFileSystemRoutes: createAsyncHook(),
|
63
|
+
modifyServerRoutes: createAsyncHook(),
|
64
|
+
generateEntryCode: createAsyncHook(),
|
65
|
+
onBeforeGenerateRoutes: createAsyncHook(),
|
66
|
+
onBeforePrintInstructions: createAsyncHook(),
|
67
|
+
registerDev: createCollectAsyncHook(),
|
68
|
+
registerBuildPlatform: createCollectAsyncHook(),
|
69
|
+
addRuntimeExports: createAsyncHook()
|
70
|
+
},
|
71
|
+
setup: function(api) {
|
72
|
+
var _userConfig_output;
|
73
|
+
var context = api.getAppContext();
|
74
|
+
var userConfig = api.getConfig();
|
75
|
+
var locale = getLocaleLanguage();
|
76
|
+
i18n.changeLanguage({
|
77
|
+
locale
|
78
|
+
});
|
79
|
+
api.updateAppContext(initAppContext({
|
80
|
+
appDirectory: context.appDirectory,
|
81
|
+
options: {},
|
82
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
|
83
|
+
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE,
|
84
|
+
tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
|
85
|
+
}));
|
86
|
+
api.addCommand(function() {
|
87
|
+
var _ref = _async_to_generator(function(param) {
|
88
|
+
var program;
|
89
|
+
return _ts_generator(this, function(_state) {
|
90
|
+
switch (_state.label) {
|
91
|
+
case 0:
|
92
|
+
program = param.program;
|
93
|
+
return [
|
94
|
+
4,
|
95
|
+
devCommand(program, api)
|
96
|
+
];
|
97
|
+
case 1:
|
98
|
+
_state.sent();
|
99
|
+
return [
|
100
|
+
4,
|
101
|
+
buildCommand(program, api)
|
102
|
+
];
|
103
|
+
case 2:
|
104
|
+
_state.sent();
|
105
|
+
serverCommand(program, api);
|
106
|
+
deployCommand(program, api);
|
107
|
+
newCommand(program, locale);
|
108
|
+
inspectCommand(program, api);
|
109
|
+
upgradeCommand(program);
|
110
|
+
deprecatedCommands(program);
|
111
|
+
return [
|
112
|
+
2
|
113
|
+
];
|
114
|
+
}
|
115
|
+
});
|
116
|
+
});
|
117
|
+
return function(_) {
|
118
|
+
return _ref.apply(this, arguments);
|
119
|
+
};
|
120
|
+
}());
|
121
|
+
api.onPrepare(/* @__PURE__ */ _async_to_generator(function() {
|
122
|
+
var command, isSkipBuild, resolvedConfig, appContext;
|
123
|
+
return _ts_generator(this, function(_state) {
|
124
|
+
switch (_state.label) {
|
125
|
+
case 0:
|
126
|
+
command = getCommand();
|
127
|
+
if (command === "deploy") {
|
128
|
+
isSkipBuild = [
|
129
|
+
"-s",
|
130
|
+
"--skip-build"
|
131
|
+
].some(function(tag) {
|
132
|
+
return getArgv().includes(tag);
|
133
|
+
});
|
134
|
+
if (isSkipBuild) {
|
135
|
+
return [
|
136
|
+
2
|
137
|
+
];
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
|
141
|
+
return [
|
142
|
+
3,
|
143
|
+
2
|
144
|
+
];
|
145
|
+
resolvedConfig = api.getNormalizedConfig();
|
146
|
+
if (!resolvedConfig.output.cleanDistPath)
|
147
|
+
return [
|
148
|
+
3,
|
149
|
+
2
|
150
|
+
];
|
151
|
+
appContext = api.getAppContext();
|
152
|
+
return [
|
153
|
+
4,
|
154
|
+
emptyDir(appContext.distDirectory)
|
155
|
+
];
|
156
|
+
case 1:
|
157
|
+
_state.sent();
|
158
|
+
_state.label = 2;
|
159
|
+
case 2:
|
160
|
+
return [
|
161
|
+
2
|
162
|
+
];
|
163
|
+
}
|
164
|
+
});
|
165
|
+
}));
|
166
|
+
api.addWatchFiles(/* @__PURE__ */ _async_to_generator(function() {
|
167
|
+
var appContext, config, files, watchFiles;
|
168
|
+
return _ts_generator(this, function(_state) {
|
169
|
+
switch (_state.label) {
|
170
|
+
case 0:
|
171
|
+
appContext = api.getAppContext();
|
172
|
+
config = api.getNormalizedConfig();
|
173
|
+
return [
|
174
|
+
4,
|
175
|
+
generateWatchFiles(appContext, config.source.configDir)
|
176
|
+
];
|
177
|
+
case 1:
|
178
|
+
files = _state.sent();
|
179
|
+
watchFiles = castArray(config.dev.watchFiles);
|
180
|
+
watchFiles.forEach(function(param) {
|
181
|
+
var type = param.type, paths = param.paths;
|
182
|
+
if (type === "reload-server") {
|
183
|
+
var _files;
|
184
|
+
(_files = files).push.apply(_files, _to_consumable_array(Array.isArray(paths) ? paths : [
|
185
|
+
paths
|
186
|
+
]));
|
187
|
+
}
|
188
|
+
});
|
189
|
+
return [
|
190
|
+
2,
|
191
|
+
files
|
192
|
+
];
|
193
|
+
}
|
194
|
+
});
|
195
|
+
}));
|
196
|
+
api.onFileChanged(function() {
|
197
|
+
var _ref = _async_to_generator(function(e) {
|
198
|
+
var filename, eventType, isPrivate, closeServer;
|
199
|
+
return _ts_generator(this, function(_state) {
|
200
|
+
switch (_state.label) {
|
201
|
+
case 0:
|
202
|
+
filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
|
203
|
+
if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
|
204
|
+
return [
|
205
|
+
3,
|
206
|
+
4
|
207
|
+
];
|
208
|
+
return [
|
209
|
+
4,
|
210
|
+
import("./utils/createServer.js")
|
211
|
+
];
|
212
|
+
case 1:
|
213
|
+
closeServer = _state.sent().closeServer;
|
214
|
+
return [
|
215
|
+
4,
|
216
|
+
closeServer()
|
217
|
+
];
|
218
|
+
case 2:
|
219
|
+
_state.sent();
|
220
|
+
return [
|
221
|
+
4,
|
222
|
+
restart(api.getHooks(), filename)
|
223
|
+
];
|
224
|
+
case 3:
|
225
|
+
_state.sent();
|
226
|
+
_state.label = 4;
|
227
|
+
case 4:
|
228
|
+
return [
|
229
|
+
2
|
230
|
+
];
|
231
|
+
}
|
232
|
+
});
|
233
|
+
});
|
234
|
+
return function(e) {
|
235
|
+
return _ref.apply(this, arguments);
|
236
|
+
};
|
237
|
+
}());
|
238
|
+
api.onBeforeRestart(function() {
|
239
|
+
cleanRequireCache([
|
240
|
+
require.resolve("./plugins/analyze")
|
241
|
+
]);
|
242
|
+
});
|
243
|
+
}
|
244
|
+
};
|
245
|
+
};
|
3
246
|
import { defineConfig, defineLegacyConfig } from "./defineConfig";
|
4
247
|
import { mergeConfig } from "@modern-js/core";
|
5
248
|
import { dev } from "./commands/dev";
|
@@ -3,9 +3,8 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
4
4
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
5
5
|
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
6
|
-
import fs from "fs";
|
7
6
|
import path from "path";
|
8
|
-
import { SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
|
7
|
+
import { fs, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
|
9
8
|
import { isMainEntry } from "../../utils/routes";
|
10
9
|
import { walkDirectory } from "./utils";
|
11
10
|
var applyBaseUrl = function(baseUrl, routes) {
|
@@ -132,6 +131,16 @@ var getServerRoutes = function(entrypoints, param) {
|
|
132
131
|
var toPosix = function(pathStr) {
|
133
132
|
return pathStr.split(path.sep).join(path.posix.sep);
|
134
133
|
};
|
134
|
+
var getProdServerRoutes = function(distDirectory) {
|
135
|
+
var routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
136
|
+
try {
|
137
|
+
var routes = fs.readJSONSync(routeJSON).routes;
|
138
|
+
return routes;
|
139
|
+
} catch (e) {
|
140
|
+
throw new Error("Failed to read routes from ".concat(routeJSON, ", please check if the file exists."));
|
141
|
+
}
|
142
|
+
};
|
135
143
|
export {
|
144
|
+
getProdServerRoutes,
|
136
145
|
getServerRoutes
|
137
146
|
};
|
@@ -2,6 +2,7 @@ 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 _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
5
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
5
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
6
7
|
import * as path from "path";
|
7
8
|
import { fs, createDebugger, getArgv, isApiOnly, isDevCommand, minimist } from "@modern-js/utils";
|
@@ -11,7 +12,7 @@ import { emitResolvedConfig } from "../../utils/config";
|
|
11
12
|
import { getSelectedEntries } from "../../utils/getSelectedEntries";
|
12
13
|
import { printInstructions } from "../../utils/printInstructions";
|
13
14
|
import { generateRoutes } from "../../utils/routes";
|
14
|
-
import { checkIsBuildCommands } from "./utils";
|
15
|
+
import { checkIsBuildCommands, checkIsServeCommand } from "./utils";
|
15
16
|
var debug = createDebugger("plugin-analyze");
|
16
17
|
function analyze_default(param) {
|
17
18
|
var bundler = param.bundler;
|
@@ -24,7 +25,7 @@ function analyze_default(param) {
|
|
24
25
|
var pagesDir = [];
|
25
26
|
var nestedRouteEntries = [];
|
26
27
|
api.onPrepare(/* @__PURE__ */ _async_to_generator(function() {
|
27
|
-
var _resolvedConfig_source, appContext, resolvedConfig, hooks, apiOnly, routes,
|
28
|
+
var _resolvedConfig_source, appContext, resolvedConfig, hooks, apiOnly, _ref, getProdServerRoutes, routes, _routes, _routes1, _ref1, modifiedRoutes, _ref2, getBundleEntry, getServerRoutes, getHtmlTemplate, entrypoints, _, _1, _tmp, routes1, _routes2, _routes3, initialRoutes, _ref3, modifiedRoutes1, _ref4, partialsByEntrypoint, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
|
28
29
|
return _ts_generator(this, function(_state) {
|
29
30
|
switch (_state.label) {
|
30
31
|
case 0:
|
@@ -49,19 +50,45 @@ function analyze_default(param) {
|
|
49
50
|
];
|
50
51
|
case 2:
|
51
52
|
_state.sent();
|
53
|
+
return [
|
54
|
+
4,
|
55
|
+
Promise.all([
|
56
|
+
import("./getServerRoutes.js")
|
57
|
+
])
|
58
|
+
];
|
59
|
+
case 3:
|
60
|
+
_ref = _sliced_to_array.apply(void 0, [
|
61
|
+
_state.sent(),
|
62
|
+
1
|
63
|
+
]), getProdServerRoutes = _ref[0].getProdServerRoutes;
|
52
64
|
if (!apiOnly)
|
65
|
+
return [
|
66
|
+
3,
|
67
|
+
7
|
68
|
+
];
|
69
|
+
routes = [];
|
70
|
+
if (!checkIsServeCommand())
|
53
71
|
return [
|
54
72
|
3,
|
55
73
|
4
|
56
74
|
];
|
75
|
+
(_routes = routes).push.apply(_routes, _to_consumable_array(getProdServerRoutes(appContext.distDirectory)));
|
76
|
+
return [
|
77
|
+
3,
|
78
|
+
6
|
79
|
+
];
|
80
|
+
case 4:
|
57
81
|
return [
|
58
82
|
4,
|
59
83
|
hooks.modifyServerRoutes.call({
|
60
84
|
routes: []
|
61
85
|
})
|
62
86
|
];
|
63
|
-
case
|
64
|
-
|
87
|
+
case 5:
|
88
|
+
_ref1 = _state.sent(), modifiedRoutes = _ref1.routes;
|
89
|
+
(_routes1 = routes).push.apply(_routes1, _to_consumable_array(modifiedRoutes));
|
90
|
+
_state.label = 6;
|
91
|
+
case 6:
|
65
92
|
debug("server routes: %o", routes);
|
66
93
|
api.updateAppContext({
|
67
94
|
apiOnly,
|
@@ -70,7 +97,7 @@ function analyze_default(param) {
|
|
70
97
|
return [
|
71
98
|
2
|
72
99
|
];
|
73
|
-
case
|
100
|
+
case 7:
|
74
101
|
return [
|
75
102
|
4,
|
76
103
|
Promise.all([
|
@@ -79,27 +106,39 @@ function analyze_default(param) {
|
|
79
106
|
import("./getHtmlTemplate.js")
|
80
107
|
])
|
81
108
|
];
|
82
|
-
case
|
83
|
-
|
109
|
+
case 8:
|
110
|
+
_ref2 = _sliced_to_array.apply(void 0, [
|
84
111
|
_state.sent(),
|
85
112
|
3
|
86
|
-
]), getBundleEntry =
|
113
|
+
]), getBundleEntry = _ref2[0].getBundleEntry, getServerRoutes = _ref2[1].getServerRoutes, getHtmlTemplate = _ref2[2].getHtmlTemplate;
|
87
114
|
_1 = (_ = hooks.modifyEntrypoints).call;
|
88
115
|
_tmp = {};
|
89
116
|
return [
|
90
117
|
4,
|
91
118
|
getBundleEntry(hooks, appContext, resolvedConfig)
|
92
119
|
];
|
93
|
-
case
|
120
|
+
case 9:
|
94
121
|
return [
|
95
122
|
4,
|
96
123
|
_1.apply(_, [
|
97
124
|
(_tmp.entrypoints = _state.sent(), _tmp)
|
98
125
|
])
|
99
126
|
];
|
100
|
-
case
|
127
|
+
case 10:
|
101
128
|
entrypoints = _state.sent().entrypoints;
|
102
129
|
debug("entrypoints: %o", entrypoints);
|
130
|
+
routes1 = [];
|
131
|
+
if (!checkIsServeCommand())
|
132
|
+
return [
|
133
|
+
3,
|
134
|
+
11
|
135
|
+
];
|
136
|
+
(_routes2 = routes1).push.apply(_routes2, _to_consumable_array(getProdServerRoutes(appContext.distDirectory)));
|
137
|
+
return [
|
138
|
+
3,
|
139
|
+
13
|
140
|
+
];
|
141
|
+
case 11:
|
103
142
|
initialRoutes = getServerRoutes(entrypoints, {
|
104
143
|
appContext,
|
105
144
|
config: resolvedConfig
|
@@ -110,8 +149,11 @@ function analyze_default(param) {
|
|
110
149
|
routes: initialRoutes
|
111
150
|
})
|
112
151
|
];
|
113
|
-
case
|
114
|
-
|
152
|
+
case 12:
|
153
|
+
_ref3 = _state.sent(), modifiedRoutes1 = _ref3.routes;
|
154
|
+
(_routes3 = routes1).push.apply(_routes3, _to_consumable_array(modifiedRoutes1));
|
155
|
+
_state.label = 13;
|
156
|
+
case 13:
|
115
157
|
debug("server routes: %o", routes1);
|
116
158
|
appContext = _object_spread_props(_object_spread({}, api.getAppContext()), {
|
117
159
|
entrypoints,
|
@@ -133,8 +175,8 @@ function analyze_default(param) {
|
|
133
175
|
config: resolvedConfig
|
134
176
|
})
|
135
177
|
];
|
136
|
-
case
|
137
|
-
|
178
|
+
case 14:
|
179
|
+
_ref4 = _state.sent(), partialsByEntrypoint = _ref4.partialsByEntrypoint, htmlTemplates = _ref4.htmlTemplates;
|
138
180
|
debug("html templates: %o", htmlTemplates);
|
139
181
|
api.updateAppContext({
|
140
182
|
partialsByEntrypoint
|
@@ -145,17 +187,17 @@ function analyze_default(param) {
|
|
145
187
|
if (!isDevCommand())
|
146
188
|
return [
|
147
189
|
3,
|
148
|
-
|
190
|
+
16
|
149
191
|
];
|
150
192
|
entry = minimist(getArgv()).entry;
|
151
193
|
return [
|
152
194
|
4,
|
153
195
|
getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints)
|
154
196
|
];
|
155
|
-
case
|
197
|
+
case 15:
|
156
198
|
checkedEntries = _state.sent();
|
157
|
-
_state.label =
|
158
|
-
case
|
199
|
+
_state.label = 16;
|
200
|
+
case 16:
|
159
201
|
appContext = _object_spread_props(_object_spread({}, api.getAppContext()), {
|
160
202
|
entrypoints,
|
161
203
|
checkedEntries,
|
@@ -167,7 +209,7 @@ function analyze_default(param) {
|
|
167
209
|
if (!checkIsBuildCommands())
|
168
210
|
return [
|
169
211
|
3,
|
170
|
-
|
212
|
+
20
|
171
213
|
];
|
172
214
|
return [
|
173
215
|
4,
|
@@ -175,14 +217,14 @@ function analyze_default(param) {
|
|
175
217
|
entrypoints
|
176
218
|
})
|
177
219
|
];
|
178
|
-
case
|
220
|
+
case 17:
|
179
221
|
_state.sent();
|
180
222
|
normalizedConfig = api.getNormalizedConfig();
|
181
223
|
return [
|
182
224
|
4,
|
183
225
|
createBuilderGenerator(bundler)
|
184
226
|
];
|
185
|
-
case
|
227
|
+
case 18:
|
186
228
|
createBuilderForModern = _state.sent();
|
187
229
|
return [
|
188
230
|
4,
|
@@ -191,10 +233,10 @@ function analyze_default(param) {
|
|
191
233
|
appContext
|
192
234
|
})
|
193
235
|
];
|
194
|
-
case
|
236
|
+
case 19:
|
195
237
|
builder = _state.sent();
|
196
238
|
builder.onBeforeBuild(function() {
|
197
|
-
var
|
239
|
+
var _ref5 = _async_to_generator(function(param2) {
|
198
240
|
var bundlerConfigs, isFirstCompile, environments, isWatch;
|
199
241
|
return _ts_generator(this, function(_state2) {
|
200
242
|
switch (_state2.label) {
|
@@ -229,11 +271,11 @@ function analyze_default(param) {
|
|
229
271
|
});
|
230
272
|
});
|
231
273
|
return function(_2) {
|
232
|
-
return
|
274
|
+
return _ref5.apply(this, arguments);
|
233
275
|
};
|
234
276
|
}());
|
235
277
|
builder.onAfterBuild(function() {
|
236
|
-
var
|
278
|
+
var _ref5 = _async_to_generator(function(param2) {
|
237
279
|
var stats, environments, isFirstCompile, isWatch;
|
238
280
|
return _ts_generator(this, function(_state2) {
|
239
281
|
switch (_state2.label) {
|
@@ -263,11 +305,11 @@ function analyze_default(param) {
|
|
263
305
|
});
|
264
306
|
});
|
265
307
|
return function(_2) {
|
266
|
-
return
|
308
|
+
return _ref5.apply(this, arguments);
|
267
309
|
};
|
268
310
|
}());
|
269
311
|
builder.onDevCompileDone(function() {
|
270
|
-
var
|
312
|
+
var _ref5 = _async_to_generator(function(param2) {
|
271
313
|
var isFirstCompile;
|
272
314
|
return _ts_generator(this, function(_state2) {
|
273
315
|
isFirstCompile = param2.isFirstCompile;
|
@@ -283,11 +325,11 @@ function analyze_default(param) {
|
|
283
325
|
});
|
284
326
|
});
|
285
327
|
return function(_2) {
|
286
|
-
return
|
328
|
+
return _ref5.apply(this, arguments);
|
287
329
|
};
|
288
330
|
}());
|
289
331
|
builder.onBeforeCreateCompiler(function() {
|
290
|
-
var
|
332
|
+
var _ref5 = _async_to_generator(function(param2) {
|
291
333
|
var bundlerConfigs, environments;
|
292
334
|
return _ts_generator(this, function(_state2) {
|
293
335
|
switch (_state2.label) {
|
@@ -309,11 +351,11 @@ function analyze_default(param) {
|
|
309
351
|
});
|
310
352
|
});
|
311
353
|
return function(_2) {
|
312
|
-
return
|
354
|
+
return _ref5.apply(this, arguments);
|
313
355
|
};
|
314
356
|
}());
|
315
357
|
builder.onAfterCreateCompiler(function() {
|
316
|
-
var
|
358
|
+
var _ref5 = _async_to_generator(function(param2) {
|
317
359
|
var compiler, environments;
|
318
360
|
return _ts_generator(this, function(_state2) {
|
319
361
|
switch (_state2.label) {
|
@@ -335,15 +377,15 @@ function analyze_default(param) {
|
|
335
377
|
});
|
336
378
|
});
|
337
379
|
return function(_2) {
|
338
|
-
return
|
380
|
+
return _ref5.apply(this, arguments);
|
339
381
|
};
|
340
382
|
}());
|
341
383
|
builder.addPlugins(resolvedConfig.builderPlugins);
|
342
384
|
api.updateAppContext({
|
343
385
|
builder
|
344
386
|
});
|
345
|
-
_state.label =
|
346
|
-
case
|
387
|
+
_state.label = 20;
|
388
|
+
case 20:
|
347
389
|
return [
|
348
390
|
2
|
349
391
|
];
|
@@ -83,6 +83,10 @@ var checkIsBuildCommands = function() {
|
|
83
83
|
var command = getCommand();
|
84
84
|
return buildCommands.includes(command);
|
85
85
|
};
|
86
|
+
var checkIsServeCommand = function() {
|
87
|
+
var command = getCommand();
|
88
|
+
return command === "serve";
|
89
|
+
};
|
86
90
|
var isSubDirOrEqual = function(parent, child) {
|
87
91
|
if (parent === child) {
|
88
92
|
return true;
|
@@ -93,6 +97,7 @@ var isSubDirOrEqual = function(parent, child) {
|
|
93
97
|
};
|
94
98
|
export {
|
95
99
|
checkIsBuildCommands,
|
100
|
+
checkIsServeCommand,
|
96
101
|
getServerCombinedModueFile,
|
97
102
|
isSubDirOrEqual,
|
98
103
|
parseModule,
|