@modern-js/app-tools 2.53.1-alpha.3 → 2.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -3,18 +3,17 @@ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import { _ as _ts_values } from "@swc/helpers/_/_ts_values";
|
|
6
|
-
import path from "node:path";
|
|
6
|
+
import path, { isAbsolute } from "node:path";
|
|
7
7
|
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
8
8
|
import { readPackageJSON } from "pkg-types";
|
|
9
9
|
import { parseNodeModulePath } from "mlly";
|
|
10
|
-
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles, findPackageParents, resolveTracedPath
|
|
10
|
+
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles, findPackageParents, resolveTracedPath } from "./utils";
|
|
11
11
|
var handleDependencies = function() {
|
|
12
|
-
var _ref = _async_to_generator(function(
|
|
13
|
-
var
|
|
12
|
+
var _ref = _async_to_generator(function(appDir, serverRootDir, include, entryFilter) {
|
|
13
|
+
var base, entryFiles, includeEntries, fileTrace, currentProjectModules, tracedFiles, _, tracedPackages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, tracedFile, pkgName, tracedPackage, pkgJSON, tracedPackageVersion, err, multiVersionPkgs, singleVersionPackages, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tracedPackage1, versions, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, version, projectPkgJson, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _loop, _iterator3, _step3, err, outputPkgPath;
|
|
14
14
|
return _ts_generator(this, function(_state) {
|
|
15
15
|
switch (_state.label) {
|
|
16
16
|
case 0:
|
|
17
|
-
appDir = param.appDir, serverRootDir = param.serverRootDir, includeEntries = param.includeEntries, entryFilter = param.entryFilter, modifyPackageJson = param.modifyPackageJson, copyWholePackage = param.copyWholePackage;
|
|
18
17
|
base = "/";
|
|
19
18
|
return [
|
|
20
19
|
4,
|
|
@@ -22,6 +21,16 @@ var handleDependencies = function() {
|
|
|
22
21
|
];
|
|
23
22
|
case 1:
|
|
24
23
|
entryFiles = _state.sent();
|
|
24
|
+
includeEntries = include.map(function(item) {
|
|
25
|
+
if (isAbsolute(item)) {
|
|
26
|
+
return item;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
return require.resolve(item);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
}
|
|
32
|
+
return item;
|
|
33
|
+
});
|
|
25
34
|
return [
|
|
26
35
|
4,
|
|
27
36
|
traceFiles(entryFiles.concat(includeEntries), serverRootDir, base)
|
|
@@ -33,12 +42,12 @@ var handleDependencies = function() {
|
|
|
33
42
|
return [
|
|
34
43
|
4,
|
|
35
44
|
Promise.all(_to_consumable_array(fileTrace.reasons.entries()).map(function() {
|
|
36
|
-
var _ref2 = _async_to_generator(function(
|
|
45
|
+
var _ref2 = _async_to_generator(function(param) {
|
|
37
46
|
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match, packageJsonPath, _tmp, packageJson, parents, tracedFile2;
|
|
38
47
|
return _ts_generator(this, function(_state2) {
|
|
39
48
|
switch (_state2.label) {
|
|
40
49
|
case 0:
|
|
41
|
-
_param = _sliced_to_array(
|
|
50
|
+
_param = _sliced_to_array(param, 2), _path = _param[0], reasons = _param[1];
|
|
42
51
|
if (reasons.ignored) {
|
|
43
52
|
return [
|
|
44
53
|
2
|
|
@@ -171,9 +180,9 @@ var handleDependencies = function() {
|
|
|
171
180
|
case 4:
|
|
172
181
|
_state.trys.push([
|
|
173
182
|
4,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
183
|
+
9,
|
|
184
|
+
10,
|
|
185
|
+
11
|
|
177
186
|
]);
|
|
178
187
|
_iterator = Object.values(tracedFiles)[Symbol.iterator]();
|
|
179
188
|
_state.label = 5;
|
|
@@ -181,7 +190,7 @@ var handleDependencies = function() {
|
|
|
181
190
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
|
182
191
|
return [
|
|
183
192
|
3,
|
|
184
|
-
|
|
193
|
+
8
|
|
185
194
|
];
|
|
186
195
|
tracedFile = _step.value;
|
|
187
196
|
pkgName = tracedFile.pkgName;
|
|
@@ -221,53 +230,30 @@ var handleDependencies = function() {
|
|
|
221
230
|
}
|
|
222
231
|
tracedPackage.versions[pkgJSON.version] = tracedPackageVersion;
|
|
223
232
|
}
|
|
233
|
+
tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath && tracedPackageVersion.files.push(tracedFile.path);
|
|
224
234
|
tracedFile.pkgName = pkgName;
|
|
225
235
|
tracedFile.pkgVersion = pkgJSON.version;
|
|
226
|
-
|
|
227
|
-
if (!(tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath))
|
|
228
|
-
return [
|
|
229
|
-
3,
|
|
230
|
-
9
|
|
231
|
-
];
|
|
232
|
-
if (!shouldCopyWholePackage)
|
|
233
|
-
return [
|
|
234
|
-
3,
|
|
235
|
-
8
|
|
236
|
-
];
|
|
237
|
-
return [
|
|
238
|
-
4,
|
|
239
|
-
readDirRecursive(tracedFile.pkgPath)
|
|
240
|
-
];
|
|
236
|
+
_state.label = 7;
|
|
241
237
|
case 7:
|
|
242
|
-
allFiles = _state.sent();
|
|
243
|
-
(_tracedPackageVersion_files = tracedPackageVersion.files).push.apply(_tracedPackageVersion_files, _to_consumable_array(allFiles));
|
|
244
|
-
return [
|
|
245
|
-
3,
|
|
246
|
-
9
|
|
247
|
-
];
|
|
248
|
-
case 8:
|
|
249
|
-
tracedPackageVersion.files.push(tracedFile.path);
|
|
250
|
-
_state.label = 9;
|
|
251
|
-
case 9:
|
|
252
238
|
_iteratorNormalCompletion = true;
|
|
253
239
|
return [
|
|
254
240
|
3,
|
|
255
241
|
5
|
|
256
242
|
];
|
|
257
|
-
case
|
|
243
|
+
case 8:
|
|
258
244
|
return [
|
|
259
245
|
3,
|
|
260
|
-
|
|
246
|
+
11
|
|
261
247
|
];
|
|
262
|
-
case
|
|
248
|
+
case 9:
|
|
263
249
|
err = _state.sent();
|
|
264
250
|
_didIteratorError = true;
|
|
265
251
|
_iteratorError = err;
|
|
266
252
|
return [
|
|
267
253
|
3,
|
|
268
|
-
|
|
254
|
+
11
|
|
269
255
|
];
|
|
270
|
-
case
|
|
256
|
+
case 10:
|
|
271
257
|
try {
|
|
272
258
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
273
259
|
_iterator.return();
|
|
@@ -280,7 +266,7 @@ var handleDependencies = function() {
|
|
|
280
266
|
return [
|
|
281
267
|
7
|
|
282
268
|
];
|
|
283
|
-
case
|
|
269
|
+
case 11:
|
|
284
270
|
multiVersionPkgs = {};
|
|
285
271
|
singleVersionPackages = [];
|
|
286
272
|
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
@@ -333,14 +319,10 @@ var handleDependencies = function() {
|
|
|
333
319
|
Promise.all(singleVersionPackages.map(function(pkgName2) {
|
|
334
320
|
var pkg = tracedPackages[pkgName2];
|
|
335
321
|
var version2 = Object.keys(pkg.versions)[0];
|
|
336
|
-
return writePackage(
|
|
337
|
-
pkg,
|
|
338
|
-
version: version2,
|
|
339
|
-
projectDir: serverRootDir
|
|
340
|
-
});
|
|
322
|
+
return writePackage(pkg, version2, serverRootDir);
|
|
341
323
|
}))
|
|
342
324
|
];
|
|
343
|
-
case
|
|
325
|
+
case 12:
|
|
344
326
|
_state.sent();
|
|
345
327
|
return [
|
|
346
328
|
4,
|
|
@@ -348,16 +330,16 @@ var handleDependencies = function() {
|
|
|
348
330
|
return {};
|
|
349
331
|
})
|
|
350
332
|
];
|
|
351
|
-
case
|
|
333
|
+
case 13:
|
|
352
334
|
projectPkgJson = _state.sent();
|
|
353
335
|
_iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
354
|
-
_state.label =
|
|
355
|
-
case
|
|
336
|
+
_state.label = 14;
|
|
337
|
+
case 14:
|
|
356
338
|
_state.trys.push([
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
339
|
+
14,
|
|
340
|
+
19,
|
|
341
|
+
20,
|
|
342
|
+
21
|
|
361
343
|
]);
|
|
362
344
|
_loop = function() {
|
|
363
345
|
var _step_value, pkgName2, pkgVersions, versionEntires, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value1, version2, parentPkgs, pkg, pkgDestPath, _iteratorNormalCompletion12, _didIteratorError12, _iteratorError12, _iterator12, _step12, parentPkg, parentPkgName, err2, err2;
|
|
@@ -365,8 +347,8 @@ var handleDependencies = function() {
|
|
|
365
347
|
switch (_state2.label) {
|
|
366
348
|
case 0:
|
|
367
349
|
_step_value = _sliced_to_array(_step3.value, 2), pkgName2 = _step_value[0], pkgVersions = _step_value[1];
|
|
368
|
-
versionEntires = Object.entries(pkgVersions).sort(function(
|
|
369
|
-
var _param = _sliced_to_array(
|
|
350
|
+
versionEntires = Object.entries(pkgVersions).sort(function(param, param1) {
|
|
351
|
+
var _param = _sliced_to_array(param, 2), v1 = _param[0], p1 = _param[1], _param1 = _sliced_to_array(param1, 2), v2 = _param1[0], p2 = _param1[1];
|
|
370
352
|
var _tracedPackages_pkgName_versions_v1, _tracedPackages_pkgName_versions, _tracedPackages_pkgName, _tracedPackages_pkgName_versions_v2, _tracedPackages_pkgName_versions1, _tracedPackages_pkgName1;
|
|
371
353
|
var shouldHoist1 = (_tracedPackages_pkgName = tracedPackages[pkgName2]) === null || _tracedPackages_pkgName === void 0 ? void 0 : (_tracedPackages_pkgName_versions = _tracedPackages_pkgName.versions) === null || _tracedPackages_pkgName_versions === void 0 ? void 0 : (_tracedPackages_pkgName_versions_v1 = _tracedPackages_pkgName_versions[v1]) === null || _tracedPackages_pkgName_versions_v1 === void 0 ? void 0 : _tracedPackages_pkgName_versions_v1.isDirectDep;
|
|
372
354
|
var shouldHoist2 = (_tracedPackages_pkgName1 = tracedPackages[pkgName2]) === null || _tracedPackages_pkgName1 === void 0 ? void 0 : (_tracedPackages_pkgName_versions1 = _tracedPackages_pkgName1.versions) === null || _tracedPackages_pkgName_versions1 === void 0 ? void 0 : (_tracedPackages_pkgName_versions_v2 = _tracedPackages_pkgName_versions1[v2]) === null || _tracedPackages_pkgName_versions_v2 === void 0 ? void 0 : _tracedPackages_pkgName_versions_v2.isDirectDep;
|
|
@@ -408,12 +390,7 @@ var handleDependencies = function() {
|
|
|
408
390
|
pkgDestPath = ".modernjs/".concat(pkgName2, "@").concat(version2, "/node_modules/").concat(pkgName2);
|
|
409
391
|
return [
|
|
410
392
|
4,
|
|
411
|
-
writePackage(
|
|
412
|
-
pkg,
|
|
413
|
-
version: version2,
|
|
414
|
-
projectDir: serverRootDir,
|
|
415
|
-
_pkgPath: pkgDestPath
|
|
416
|
-
})
|
|
393
|
+
writePackage(pkg, version2, serverRootDir, pkgDestPath)
|
|
417
394
|
];
|
|
418
395
|
case 3:
|
|
419
396
|
_state2.sent();
|
|
@@ -521,40 +498,40 @@ var handleDependencies = function() {
|
|
|
521
498
|
});
|
|
522
499
|
};
|
|
523
500
|
_iterator3 = Object.entries(multiVersionPkgs)[Symbol.iterator]();
|
|
524
|
-
_state.label =
|
|
525
|
-
case
|
|
501
|
+
_state.label = 15;
|
|
502
|
+
case 15:
|
|
526
503
|
if (!!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done))
|
|
527
504
|
return [
|
|
528
505
|
3,
|
|
529
|
-
|
|
506
|
+
18
|
|
530
507
|
];
|
|
531
508
|
return [
|
|
532
509
|
5,
|
|
533
510
|
_ts_values(_loop())
|
|
534
511
|
];
|
|
535
|
-
case
|
|
512
|
+
case 16:
|
|
536
513
|
_state.sent();
|
|
537
|
-
_state.label =
|
|
538
|
-
case
|
|
514
|
+
_state.label = 17;
|
|
515
|
+
case 17:
|
|
539
516
|
_iteratorNormalCompletion3 = true;
|
|
540
517
|
return [
|
|
541
518
|
3,
|
|
542
|
-
|
|
519
|
+
15
|
|
543
520
|
];
|
|
544
|
-
case
|
|
521
|
+
case 18:
|
|
545
522
|
return [
|
|
546
523
|
3,
|
|
547
|
-
|
|
524
|
+
21
|
|
548
525
|
];
|
|
549
|
-
case
|
|
526
|
+
case 19:
|
|
550
527
|
err = _state.sent();
|
|
551
528
|
_didIteratorError3 = true;
|
|
552
529
|
_iteratorError3 = err;
|
|
553
530
|
return [
|
|
554
531
|
3,
|
|
555
|
-
|
|
532
|
+
21
|
|
556
533
|
];
|
|
557
|
-
case
|
|
534
|
+
case 20:
|
|
558
535
|
try {
|
|
559
536
|
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
560
537
|
_iterator3.return();
|
|
@@ -567,28 +544,26 @@ var handleDependencies = function() {
|
|
|
567
544
|
return [
|
|
568
545
|
7
|
|
569
546
|
];
|
|
570
|
-
case
|
|
547
|
+
case 21:
|
|
571
548
|
outputPkgPath = path.join(serverRootDir, "package.json");
|
|
572
|
-
newPkgJson = {
|
|
573
|
-
name: "".concat(projectPkgJson.name || "modernjs-project", "-prod"),
|
|
574
|
-
version: projectPkgJson.version || "0.0.0",
|
|
575
|
-
private: true,
|
|
576
|
-
dependencies: Object.fromEntries(_to_consumable_array(Object.values(tracedPackages).map(function(pkg) {
|
|
577
|
-
return [
|
|
578
|
-
pkg.name,
|
|
579
|
-
Object.keys(pkg.versions)[0]
|
|
580
|
-
];
|
|
581
|
-
})).sort(function(param2, param1) {
|
|
582
|
-
var _param = _sliced_to_array(param2, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
|
|
583
|
-
return a.localeCompare(b);
|
|
584
|
-
}))
|
|
585
|
-
};
|
|
586
|
-
finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
|
|
587
549
|
return [
|
|
588
550
|
4,
|
|
589
|
-
fse.writeJSON(outputPkgPath,
|
|
551
|
+
fse.writeJSON(outputPkgPath, {
|
|
552
|
+
name: "".concat(projectPkgJson.name || "modernjs-project", "-prod"),
|
|
553
|
+
version: projectPkgJson.version || "0.0.0",
|
|
554
|
+
private: true,
|
|
555
|
+
dependencies: Object.fromEntries(_to_consumable_array(Object.values(tracedPackages).map(function(pkg) {
|
|
556
|
+
return [
|
|
557
|
+
pkg.name,
|
|
558
|
+
Object.keys(pkg.versions)[0]
|
|
559
|
+
];
|
|
560
|
+
})).sort(function(param, param1) {
|
|
561
|
+
var _param = _sliced_to_array(param, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
|
|
562
|
+
return a.localeCompare(b);
|
|
563
|
+
}))
|
|
564
|
+
})
|
|
590
565
|
];
|
|
591
|
-
case
|
|
566
|
+
case 22:
|
|
592
567
|
_state.sent();
|
|
593
568
|
return [
|
|
594
569
|
2
|
|
@@ -596,7 +571,7 @@ var handleDependencies = function() {
|
|
|
596
571
|
}
|
|
597
572
|
});
|
|
598
573
|
});
|
|
599
|
-
return function handleDependencies2(
|
|
574
|
+
return function handleDependencies2(appDir, serverRootDir, include, entryFilter) {
|
|
600
575
|
return _ref.apply(this, arguments);
|
|
601
576
|
};
|
|
602
577
|
}();
|
|
@@ -14,12 +14,11 @@ function applyPublicCondition(pkg) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
var writePackage = function() {
|
|
17
|
-
var _ref = _async_to_generator(function(
|
|
18
|
-
var
|
|
17
|
+
var _ref = _async_to_generator(function(pkg, version, projectDir, _pkgPath) {
|
|
18
|
+
var pkgPath, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, src, subpath, dest, dirname, subpath1, dest1, dirname1, err, pkgJSON, packageJsonPath;
|
|
19
19
|
return _ts_generator(this, function(_state) {
|
|
20
20
|
switch (_state.label) {
|
|
21
21
|
case 0:
|
|
22
|
-
pkg = options.pkg, version = options.version, projectDir = options.projectDir, _pkgPath = options._pkgPath;
|
|
23
22
|
pkgPath = _pkgPath || pkg.name;
|
|
24
23
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
25
24
|
_state.label = 1;
|
|
@@ -134,7 +133,7 @@ var writePackage = function() {
|
|
|
134
133
|
}
|
|
135
134
|
});
|
|
136
135
|
});
|
|
137
|
-
return function writePackage2(
|
|
136
|
+
return function writePackage2(pkg, version, projectDir, _pkgPath) {
|
|
138
137
|
return _ref.apply(this, arguments);
|
|
139
138
|
};
|
|
140
139
|
}();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse
|
|
4
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { isMainEntry } from "../../../utils/routes";
|
|
6
6
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
7
7
|
import { handleDependencies } from "../dependencies";
|
|
@@ -111,8 +111,10 @@ function _cleanDistDirectory() {
|
|
|
111
111
|
return _cleanDistDirectory.apply(this, arguments);
|
|
112
112
|
}
|
|
113
113
|
var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
|
|
114
|
-
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory,
|
|
115
|
-
var plugins =
|
|
114
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins;
|
|
115
|
+
var plugins = serverPlugins.map(function(plugin) {
|
|
116
|
+
return plugin.name;
|
|
117
|
+
});
|
|
116
118
|
var netlifyOutput = path.join(appDirectory, ".netlify");
|
|
117
119
|
var funcsDirectory = path.join(netlifyOutput, "functions");
|
|
118
120
|
var entryFilePath = path.join(funcsDirectory, "index.js");
|
|
@@ -271,13 +273,9 @@ var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
|
|
|
271
273
|
}
|
|
272
274
|
return [
|
|
273
275
|
4,
|
|
274
|
-
handleDependencies(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
includeEntries: [
|
|
278
|
-
require.resolve("@modern-js/prod-server")
|
|
279
|
-
]
|
|
280
|
-
})
|
|
276
|
+
handleDependencies(appDirectory, funcsDirectory, [
|
|
277
|
+
"@modern-js/prod-server"
|
|
278
|
+
])
|
|
281
279
|
];
|
|
282
280
|
case 3:
|
|
283
281
|
_state.sent();
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse,
|
|
4
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, chalk } from "@modern-js/utils";
|
|
5
5
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
6
6
|
import { handleDependencies } from "../dependencies";
|
|
7
7
|
var createNodePreset = function(appContext, config) {
|
|
8
|
-
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory,
|
|
9
|
-
var plugins =
|
|
8
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverPlugins = appContext.serverPlugins;
|
|
9
|
+
var plugins = serverPlugins.map(function(plugin) {
|
|
10
|
+
return plugin.name;
|
|
11
|
+
});
|
|
10
12
|
var outputDirectory = path.join(appDirectory, ".output");
|
|
11
13
|
var staticDirectory = path.join(outputDirectory, "static");
|
|
12
14
|
var entryFilePath = path.join(outputDirectory, "index.js");
|
|
@@ -104,17 +106,9 @@ var createNodePreset = function(appContext, config) {
|
|
|
104
106
|
};
|
|
105
107
|
return [
|
|
106
108
|
4,
|
|
107
|
-
handleDependencies(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
includeEntries: [
|
|
111
|
-
require.resolve("@modern-js/prod-server")
|
|
112
|
-
],
|
|
113
|
-
entryFilter: filter,
|
|
114
|
-
copyWholePackage: function(pkgName) {
|
|
115
|
-
return pkgName === "koa";
|
|
116
|
-
}
|
|
117
|
-
})
|
|
109
|
+
handleDependencies(appDirectory, outputDirectory, [
|
|
110
|
+
"@modern-js/prod-server"
|
|
111
|
+
], filter)
|
|
118
112
|
];
|
|
119
113
|
case 1:
|
|
120
114
|
_state.sent();
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse
|
|
4
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { isMainEntry } from "../../../utils/routes";
|
|
6
6
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
7
7
|
import { handleDependencies } from "../dependencies";
|
|
8
8
|
var createVercelPreset = function(appContext, modernConfig, needModernServer) {
|
|
9
|
-
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory,
|
|
10
|
-
var plugins =
|
|
9
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins;
|
|
10
|
+
var plugins = serverPlugins.map(function(plugin) {
|
|
11
|
+
return plugin.name;
|
|
12
|
+
});
|
|
11
13
|
var vercelOutput = path.join(appDirectory, ".vercel");
|
|
12
14
|
var outputDirectory = path.join(vercelOutput, "output");
|
|
13
15
|
var funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
|
@@ -205,13 +207,9 @@ var createVercelPreset = function(appContext, modernConfig, needModernServer) {
|
|
|
205
207
|
}
|
|
206
208
|
return [
|
|
207
209
|
4,
|
|
208
|
-
handleDependencies(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
includeEntries: [
|
|
212
|
-
require.resolve("@modern-js/prod-server")
|
|
213
|
-
]
|
|
214
|
-
})
|
|
210
|
+
handleDependencies(appDirectory, funcsDirectory, [
|
|
211
|
+
"@modern-js/prod-server"
|
|
212
|
+
])
|
|
215
213
|
];
|
|
216
214
|
case 1:
|
|
217
215
|
_state.sent();
|
|
@@ -3,7 +3,7 @@ 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 { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
6
|
-
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "
|
|
6
|
+
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../../config";
|
|
7
7
|
function initialize_default(param) {
|
|
8
8
|
var bundler = param.bundler;
|
|
9
9
|
return {
|
|
@@ -2,12 +2,19 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
|
-
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
|
5
|
+
import { SERVER_DIR, SHARED_DIR, getMeta } from "@modern-js/utils";
|
|
6
6
|
import { compile } from "@modern-js/server-utils";
|
|
7
7
|
var TS_CONFIG_FILENAME = "tsconfig.json";
|
|
8
8
|
function checkHasCache(appDir) {
|
|
9
|
-
var tsFilepath = path.resolve(appDir,
|
|
10
|
-
var jsfilepath = path.resolve(appDir,
|
|
9
|
+
var tsFilepath = path.resolve(appDir, SERVER_DIR, "cache.ts");
|
|
10
|
+
var jsfilepath = path.resolve(appDir, SERVER_DIR, "cache.js");
|
|
11
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
12
|
+
}
|
|
13
|
+
function checkHasConfig(appDir) {
|
|
14
|
+
var metaName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "modern-js";
|
|
15
|
+
var meta = getMeta(metaName);
|
|
16
|
+
var tsFilepath = path.resolve(appDir, SERVER_DIR, "".concat(meta, ".server.ts"));
|
|
17
|
+
var jsfilepath = path.resolve(appDir, SERVER_DIR, "".concat(meta, ".server.js"));
|
|
11
18
|
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
12
19
|
}
|
|
13
20
|
function serverBuild_default() {
|
|
@@ -17,12 +24,12 @@ function serverBuild_default() {
|
|
|
17
24
|
return {
|
|
18
25
|
afterBuild: function afterBuild() {
|
|
19
26
|
return _async_to_generator(function() {
|
|
20
|
-
var _api_useAppContext, appDirectory, distDirectory, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
|
|
27
|
+
var _api_useAppContext, appDirectory, distDirectory, metaName, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
|
|
21
28
|
return _ts_generator(this, function(_state) {
|
|
22
29
|
switch (_state.label) {
|
|
23
30
|
case 0:
|
|
24
|
-
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory;
|
|
25
|
-
if (!checkHasCache(appDirectory)) {
|
|
31
|
+
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory, metaName = _api_useAppContext.metaName;
|
|
32
|
+
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
|
|
26
33
|
return [
|
|
27
34
|
2
|
|
28
35
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { createDevServer } from "@modern-js/server";
|
|
4
|
-
import {
|
|
4
|
+
import { applyPlugins } from "@modern-js/prod-server";
|
|
5
5
|
var server = null;
|
|
6
6
|
var getServer = function() {
|
|
7
7
|
return server;
|
|
@@ -35,7 +35,7 @@ var createServer = function() {
|
|
|
35
35
|
}
|
|
36
36
|
return [
|
|
37
37
|
4,
|
|
38
|
-
createDevServer(options,
|
|
38
|
+
createDevServer(options, applyPlugins)
|
|
39
39
|
];
|
|
40
40
|
case 1:
|
|
41
41
|
server = _state.sent();
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
|
|
6
|
+
function getServerPlugins(api) {
|
|
7
|
+
return _getServerPlugins.apply(this, arguments);
|
|
8
|
+
}
|
|
9
|
+
function _getServerPlugins() {
|
|
10
|
+
_getServerPlugins = _async_to_generator(function(api) {
|
|
11
|
+
var runner, plugins;
|
|
12
|
+
return _ts_generator(this, function(_state) {
|
|
13
|
+
switch (_state.label) {
|
|
14
|
+
case 0:
|
|
15
|
+
runner = api.useHookRunners();
|
|
16
|
+
return [
|
|
17
|
+
4,
|
|
18
|
+
runner._internalServerPlugins({
|
|
19
|
+
plugins: []
|
|
20
|
+
})
|
|
21
|
+
];
|
|
22
|
+
case 1:
|
|
23
|
+
plugins = _state.sent().plugins;
|
|
24
|
+
api.setAppContext(_object_spread_props(_object_spread({}, api.useAppContext()), {
|
|
25
|
+
serverPlugins: plugins
|
|
26
|
+
}));
|
|
27
|
+
return [
|
|
28
|
+
2,
|
|
29
|
+
plugins
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return _getServerPlugins.apply(this, arguments);
|
|
35
|
+
}
|
|
36
|
+
function loadServerPlugins(api, appDirectory) {
|
|
37
|
+
return _loadServerPlugins.apply(this, arguments);
|
|
38
|
+
}
|
|
39
|
+
function _loadServerPlugins() {
|
|
40
|
+
_loadServerPlugins = _async_to_generator(function(api, appDirectory) {
|
|
41
|
+
var plugins, instances;
|
|
42
|
+
return _ts_generator(this, function(_state) {
|
|
43
|
+
switch (_state.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
return [
|
|
46
|
+
4,
|
|
47
|
+
getServerPlugins(api)
|
|
48
|
+
];
|
|
49
|
+
case 1:
|
|
50
|
+
plugins = _state.sent();
|
|
51
|
+
instances = loadServerPluginInstances(plugins, appDirectory);
|
|
52
|
+
return [
|
|
53
|
+
2,
|
|
54
|
+
instances
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return _loadServerPlugins.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
getServerPlugins,
|
|
63
|
+
loadServerPlugins
|
|
64
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isHtmlDisabled
|
|
1
|
+
import { isHtmlDisabled } from "@rsbuild/shared";
|
|
2
2
|
import { MAIN_ENTRY_NAME, getEntryOptions, removeTailSlash } from "@modern-js/utils";
|
|
3
3
|
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
4
4
|
import { BottomTemplatePlugin } from "../bundlerPlugins";
|
|
5
|
+
const createVirtualModule = (content) => `data:text/javascript,${content}`;
|
|
5
6
|
const builderPluginAdapterHtml = (options) => ({
|
|
6
7
|
name: "builder-plugin-adapter-modern-html",
|
|
7
8
|
setup(api) {
|
|
@@ -3,7 +3,7 @@ import { isHtmlDisabled } from "@rsbuild/shared";
|
|
|
3
3
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
4
4
|
import { fs, isUseSSRBundle } from "@modern-js/utils";
|
|
5
5
|
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
|
|
6
|
-
import { getServerCombinedModueFile } from "../../../analyze/utils";
|
|
6
|
+
import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
|
|
7
7
|
const builderPluginAdapterSSR = (options) => ({
|
|
8
8
|
name: "builder-plugin-adapter-modern-ssr",
|
|
9
9
|
setup(api) {
|
|
@@ -124,7 +124,7 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|
|
|
124
124
|
}
|
|
125
125
|
const { ssr, ssrByEntries } = serverConfig || {};
|
|
126
126
|
entryNames.forEach((name) => {
|
|
127
|
-
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
|
127
|
+
if (!ssgEntries.includes(name) && !name.includes("server-loaders") && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
|
128
128
|
chain.entryPoints.delete(name);
|
|
129
129
|
}
|
|
130
130
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ResolvedConfigContext } from "@modern-js/core";
|
|
2
2
|
import { logger } from "@modern-js/utils";
|
|
3
|
+
import { loadServerPlugins } from "../utils/loadPlugins";
|
|
3
4
|
import { generateRoutes } from "../utils/routes";
|
|
4
5
|
import { buildServerConfig } from "../utils/config";
|
|
5
6
|
import { registerCompiler } from "../utils/register";
|
|
@@ -11,6 +12,7 @@ const build = async (api, options) => {
|
|
|
11
12
|
let resolvedConfig = api.useResolvedConfigContext();
|
|
12
13
|
const appContext = api.useAppContext();
|
|
13
14
|
const hookRunners = api.useHookRunners();
|
|
15
|
+
await loadServerPlugins(api, appContext.appDirectory);
|
|
14
16
|
await registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
|
|
15
17
|
const { apiOnly } = appContext;
|
|
16
18
|
if (apiOnly) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getServerPlugins } from "../utils/loadPlugins";
|
|
2
2
|
const deploy = async (api, options) => {
|
|
3
3
|
const hookRunners = api.useHookRunners();
|
|
4
|
-
await
|
|
4
|
+
await getServerPlugins(api);
|
|
5
5
|
await hookRunners.beforeDeploy(options);
|
|
6
6
|
await hookRunners.deploy(options);
|
|
7
7
|
await hookRunners.afterDeploy(options);
|