@modern-js/app-tools 2.56.2-alpha.1 → 2.56.2
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/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +1 -1
- package/dist/cjs/commands/dev.js +9 -6
- package/dist/cjs/plugins/deploy/dependencies/index.js +2 -15
- package/dist/esm/builder/generator/getBuilderEnvironments.js +2 -0
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +1 -1
- package/dist/esm/commands/dev.js +11 -10
- package/dist/esm/plugins/deploy/dependencies/index.js +5 -18
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +1 -1
- package/dist/esm-node/commands/dev.js +9 -6
- package/dist/esm-node/plugins/deploy/dependencies/index.js +3 -16
- package/dist/types/exports/server.d.ts +1 -0
- package/package.json +17 -17
|
@@ -42,7 +42,7 @@ function getBuilderEnvironments(normalizedConfig, appContext) {
|
|
|
42
42
|
const serverEntries = {};
|
|
43
43
|
for (const entry in entries) {
|
|
44
44
|
const v = entries[entry];
|
|
45
|
-
serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx"));
|
|
45
|
+
serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx")).map((entry2) => entry2.replace("bootstrap.jsx", "bootstrap.server.jsx"));
|
|
46
46
|
}
|
|
47
47
|
const environments = {
|
|
48
48
|
web: {
|
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -95,19 +95,22 @@ const dev = async (api, options, devServerOptions = {}) => {
|
|
|
95
95
|
};
|
|
96
96
|
if (apiOnly) {
|
|
97
97
|
var _normalizedConfig_dev;
|
|
98
|
-
const
|
|
98
|
+
const server = await (0, import_server.createDevServer)({
|
|
99
|
+
...serverOptions,
|
|
100
|
+
runCompile: false
|
|
101
|
+
}, import_prod_server.applyPlugins);
|
|
99
102
|
const host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || import_utils.DEFAULT_DEV_HOST;
|
|
100
|
-
|
|
103
|
+
server.listen({
|
|
101
104
|
port,
|
|
102
105
|
host
|
|
103
106
|
}, () => {
|
|
104
107
|
(0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
105
108
|
});
|
|
106
109
|
} else {
|
|
107
|
-
const
|
|
108
|
-
serverOptions,
|
|
109
|
-
|
|
110
|
-
});
|
|
110
|
+
const server = await (0, import_server.createDevServer)({
|
|
111
|
+
...serverOptions,
|
|
112
|
+
builder: appContext.builder
|
|
113
|
+
}, import_prod_server.applyPlugins);
|
|
111
114
|
(0, import_createServer.setServer)(server);
|
|
112
115
|
}
|
|
113
116
|
};
|
|
@@ -36,21 +36,12 @@ var import_utils = require("@modern-js/utils");
|
|
|
36
36
|
var import_pkg_types = require("pkg-types");
|
|
37
37
|
var import_mlly = require("mlly");
|
|
38
38
|
var import_utils2 = require("./utils");
|
|
39
|
-
const createGetMonoRoot = (appDir) => {
|
|
40
|
-
let monorepoRoot;
|
|
41
|
-
return () => {
|
|
42
|
-
if (!monorepoRoot) {
|
|
43
|
-
monorepoRoot = (0, import_utils.findMonorepoRoot)(appDir, 8);
|
|
44
|
-
}
|
|
45
|
-
return monorepoRoot;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
39
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
|
49
40
|
const base = "/";
|
|
50
41
|
const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
|
|
51
42
|
const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
|
|
52
43
|
const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
|
|
53
|
-
const
|
|
44
|
+
const dependencySearchRoot = import_node_path.default.resolve(appDir, "../../../../../../");
|
|
54
45
|
const tracedFiles = Object.fromEntries(await Promise.all([
|
|
55
46
|
...fileTrace.reasons.entries()
|
|
56
47
|
].map(async ([_path, reasons]) => {
|
|
@@ -78,14 +69,10 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
|
78
69
|
const MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
79
70
|
const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
|
|
80
71
|
const match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
81
|
-
const monorepoRoot = getMonorepoRoot();
|
|
82
72
|
const packageJsonPath = match ? import_node_path.default.join(match[0], "package.json") : await (0, import_utils.pkgUp)({
|
|
83
73
|
cwd: import_node_path.default.dirname(filePath)
|
|
84
74
|
});
|
|
85
|
-
if (packageJsonPath
|
|
86
|
-
if (!match) {
|
|
87
|
-
console.log("filePath", filePath, packageJsonPath);
|
|
88
|
-
}
|
|
75
|
+
if (packageJsonPath === null || packageJsonPath === void 0 ? void 0 : packageJsonPath.startsWith(dependencySearchRoot)) {
|
|
89
76
|
const packageJson = await import_utils.fs.readJSON(packageJsonPath);
|
|
90
77
|
pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
|
|
91
78
|
subpath = import_node_path.default.relative(baseDir, filePath);
|
|
@@ -38,6 +38,8 @@ function getBuilderEnvironments(normalizedConfig, appContext) {
|
|
|
38
38
|
var v = entries[entry1];
|
|
39
39
|
serverEntries[entry1] = v.map(function(entry2) {
|
|
40
40
|
return entry2.replace("index.jsx", "index.server.jsx");
|
|
41
|
+
}).map(function(entry2) {
|
|
42
|
+
return entry2.replace("bootstrap.jsx", "bootstrap.server.jsx");
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
var environments = {
|
package/dist/esm/commands/dev.js
CHANGED
|
@@ -15,7 +15,7 @@ import { generateRoutes } from "../utils/routes";
|
|
|
15
15
|
import { buildServerConfig } from "../utils/config";
|
|
16
16
|
var dev = function() {
|
|
17
17
|
var _ref = _async_to_generator(function(api, options) {
|
|
18
|
-
var devServerOptions, _normalizedConfig_source, _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, meta, serverConfigPath, pluginInstances, serverOptions, _normalizedConfig_dev,
|
|
18
|
+
var devServerOptions, _normalizedConfig_source, _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, meta, serverConfigPath, pluginInstances, serverOptions, _normalizedConfig_dev, server, host, server1;
|
|
19
19
|
var _arguments = arguments;
|
|
20
20
|
return _ts_generator(this, function(_state) {
|
|
21
21
|
switch (_state.label) {
|
|
@@ -99,12 +99,14 @@ var dev = function() {
|
|
|
99
99
|
];
|
|
100
100
|
return [
|
|
101
101
|
4,
|
|
102
|
-
createDevServer(serverOptions,
|
|
102
|
+
createDevServer(_object_spread_props(_object_spread({}, serverOptions), {
|
|
103
|
+
runCompile: false
|
|
104
|
+
}), applyPlugins)
|
|
103
105
|
];
|
|
104
106
|
case 6:
|
|
105
|
-
|
|
107
|
+
server = _state.sent();
|
|
106
108
|
host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
|
|
107
|
-
|
|
109
|
+
server.listen({
|
|
108
110
|
port,
|
|
109
111
|
host
|
|
110
112
|
}, function() {
|
|
@@ -117,14 +119,13 @@ var dev = function() {
|
|
|
117
119
|
case 7:
|
|
118
120
|
return [
|
|
119
121
|
4,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
})
|
|
122
|
+
createDevServer(_object_spread_props(_object_spread({}, serverOptions), {
|
|
123
|
+
builder: appContext.builder
|
|
124
|
+
}), applyPlugins)
|
|
124
125
|
];
|
|
125
126
|
case 8:
|
|
126
|
-
|
|
127
|
-
setServer(
|
|
127
|
+
server1 = _state.sent();
|
|
128
|
+
setServer(server1);
|
|
128
129
|
_state.label = 9;
|
|
129
130
|
case 9:
|
|
130
131
|
return [
|
|
@@ -4,22 +4,13 @@ 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
6
|
import path from "node:path";
|
|
7
|
-
import {
|
|
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
10
|
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
|
|
11
|
-
var createGetMonoRoot = function(appDir) {
|
|
12
|
-
var monorepoRoot;
|
|
13
|
-
return function() {
|
|
14
|
-
if (!monorepoRoot) {
|
|
15
|
-
monorepoRoot = findMonorepoRoot(appDir, 8);
|
|
16
|
-
}
|
|
17
|
-
return monorepoRoot;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
11
|
var handleDependencies = function() {
|
|
21
12
|
var _ref = _async_to_generator(function(param) {
|
|
22
|
-
var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, base, entryFiles, fileTrace, currentProjectModules,
|
|
13
|
+
var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, base, entryFiles, fileTrace, currentProjectModules, dependencySearchRoot, tracedFiles, _, tracedPackages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, tracedFile, pkgName, tracedPackage, pkgJSON, tracedPackageVersion, shouldCopyWholePackage, _tracedPackageVersion_files, allFiles, 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, newPkgJson, finalPkgJson;
|
|
23
14
|
return _ts_generator(this, function(_state) {
|
|
24
15
|
switch (_state.label) {
|
|
25
16
|
case 0:
|
|
@@ -38,13 +29,13 @@ var handleDependencies = function() {
|
|
|
38
29
|
case 2:
|
|
39
30
|
fileTrace = _state.sent();
|
|
40
31
|
currentProjectModules = path.join(appDir, "node_modules");
|
|
41
|
-
|
|
32
|
+
dependencySearchRoot = path.resolve(appDir, "../../../../../../");
|
|
42
33
|
_ = Object.fromEntries;
|
|
43
34
|
return [
|
|
44
35
|
4,
|
|
45
36
|
Promise.all(_to_consumable_array(fileTrace.reasons.entries()).map(function() {
|
|
46
37
|
var _ref2 = _async_to_generator(function(param2) {
|
|
47
|
-
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match,
|
|
38
|
+
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match, packageJsonPath, _tmp, packageJson, parents, tracedFile2;
|
|
48
39
|
return _ts_generator(this, function(_state2) {
|
|
49
40
|
switch (_state2.label) {
|
|
50
41
|
case 0:
|
|
@@ -93,7 +84,6 @@ var handleDependencies = function() {
|
|
|
93
84
|
MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
94
85
|
MODERN_UTILS_PATH_REGEX = new RegExp("(.*".concat(MODERN_UTILS_PATH, ")"));
|
|
95
86
|
match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
96
|
-
monorepoRoot = getMonorepoRoot();
|
|
97
87
|
if (!match)
|
|
98
88
|
return [
|
|
99
89
|
3,
|
|
@@ -116,14 +106,11 @@ var handleDependencies = function() {
|
|
|
116
106
|
_state2.label = 6;
|
|
117
107
|
case 6:
|
|
118
108
|
packageJsonPath = _tmp;
|
|
119
|
-
if (!(packageJsonPath
|
|
109
|
+
if (!(packageJsonPath === null || packageJsonPath === void 0 ? void 0 : packageJsonPath.startsWith(dependencySearchRoot)))
|
|
120
110
|
return [
|
|
121
111
|
3,
|
|
122
112
|
8
|
|
123
113
|
];
|
|
124
|
-
if (!match) {
|
|
125
|
-
console.log("filePath", filePath, packageJsonPath);
|
|
126
|
-
}
|
|
127
114
|
return [
|
|
128
115
|
4,
|
|
129
116
|
fse.readJSON(packageJsonPath)
|
|
@@ -19,7 +19,7 @@ function getBuilderEnvironments(normalizedConfig, appContext) {
|
|
|
19
19
|
const serverEntries = {};
|
|
20
20
|
for (const entry in entries) {
|
|
21
21
|
const v = entries[entry];
|
|
22
|
-
serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx"));
|
|
22
|
+
serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx")).map((entry2) => entry2.replace("bootstrap.jsx", "bootstrap.server.jsx"));
|
|
23
23
|
}
|
|
24
24
|
const environments = {
|
|
25
25
|
web: {
|
|
@@ -62,19 +62,22 @@ const dev = async (api, options, devServerOptions = {}) => {
|
|
|
62
62
|
};
|
|
63
63
|
if (apiOnly) {
|
|
64
64
|
var _normalizedConfig_dev;
|
|
65
|
-
const
|
|
65
|
+
const server = await createDevServer({
|
|
66
|
+
...serverOptions,
|
|
67
|
+
runCompile: false
|
|
68
|
+
}, applyPlugins);
|
|
66
69
|
const host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
|
|
67
|
-
|
|
70
|
+
server.listen({
|
|
68
71
|
port,
|
|
69
72
|
host
|
|
70
73
|
}, () => {
|
|
71
74
|
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
72
75
|
});
|
|
73
76
|
} else {
|
|
74
|
-
const
|
|
75
|
-
serverOptions,
|
|
76
|
-
|
|
77
|
-
});
|
|
77
|
+
const server = await createDevServer({
|
|
78
|
+
...serverOptions,
|
|
79
|
+
builder: appContext.builder
|
|
80
|
+
}, applyPlugins);
|
|
78
81
|
setServer(server);
|
|
79
82
|
}
|
|
80
83
|
};
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
3
3
|
import { readPackageJSON } from "pkg-types";
|
|
4
4
|
import { parseNodeModulePath } from "mlly";
|
|
5
5
|
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
|
|
6
|
-
const createGetMonoRoot = (appDir) => {
|
|
7
|
-
let monorepoRoot;
|
|
8
|
-
return () => {
|
|
9
|
-
if (!monorepoRoot) {
|
|
10
|
-
monorepoRoot = findMonorepoRoot(appDir, 8);
|
|
11
|
-
}
|
|
12
|
-
return monorepoRoot;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
6
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
|
16
7
|
const base = "/";
|
|
17
8
|
const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
|
|
18
9
|
const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
|
|
19
10
|
const currentProjectModules = path.join(appDir, "node_modules");
|
|
20
|
-
const
|
|
11
|
+
const dependencySearchRoot = path.resolve(appDir, "../../../../../../");
|
|
21
12
|
const tracedFiles = Object.fromEntries(await Promise.all([
|
|
22
13
|
...fileTrace.reasons.entries()
|
|
23
14
|
].map(async ([_path, reasons]) => {
|
|
@@ -45,14 +36,10 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
|
45
36
|
const MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
46
37
|
const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
|
|
47
38
|
const match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
48
|
-
const monorepoRoot = getMonorepoRoot();
|
|
49
39
|
const packageJsonPath = match ? path.join(match[0], "package.json") : await pkgUp({
|
|
50
40
|
cwd: path.dirname(filePath)
|
|
51
41
|
});
|
|
52
|
-
if (packageJsonPath
|
|
53
|
-
if (!match) {
|
|
54
|
-
console.log("filePath", filePath, packageJsonPath);
|
|
55
|
-
}
|
|
42
|
+
if (packageJsonPath === null || packageJsonPath === void 0 ? void 0 : packageJsonPath.startsWith(dependencySearchRoot)) {
|
|
56
43
|
const packageJson = await fse.readJSON(packageJsonPath);
|
|
57
44
|
pkgPath = baseDir = path.dirname(packageJsonPath);
|
|
58
45
|
subpath = path.relative(baseDir, filePath);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UnstableMiddleware, UnstableMiddlewareContext, UnstableNext } from '@modern-js/types';
|
|
2
|
+
export type { ServerPlugin } from '@modern-js/server-core';
|
|
2
3
|
export type RenderMiddleware = UnstableMiddleware;
|
|
3
4
|
export type RenderMiddlewareContext = UnstableMiddlewareContext;
|
|
4
5
|
export type RenderNext = UnstableNext;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.56.2
|
|
18
|
+
"version": "2.56.2",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -87,20 +87,20 @@
|
|
|
87
87
|
"mlly": "^1.6.1",
|
|
88
88
|
"pkg-types": "^1.1.0",
|
|
89
89
|
"std-env": "^3.7.0",
|
|
90
|
-
"@modern-js/
|
|
91
|
-
"@modern-js/
|
|
92
|
-
"@modern-js/plugin": "2.56.
|
|
93
|
-
"@modern-js/plugin-
|
|
94
|
-
"@modern-js/plugin-
|
|
95
|
-
"@modern-js/
|
|
96
|
-
"@modern-js/prod-server": "2.56.
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/server-
|
|
100
|
-
"@modern-js/
|
|
101
|
-
"@modern-js/
|
|
102
|
-
"@modern-js/
|
|
103
|
-
"@modern-js/
|
|
90
|
+
"@modern-js/core": "2.56.2",
|
|
91
|
+
"@modern-js/node-bundle-require": "2.56.2",
|
|
92
|
+
"@modern-js/plugin": "2.56.2",
|
|
93
|
+
"@modern-js/plugin-data-loader": "2.56.2",
|
|
94
|
+
"@modern-js/plugin-i18n": "2.56.2",
|
|
95
|
+
"@modern-js/plugin-lint": "2.56.2",
|
|
96
|
+
"@modern-js/prod-server": "2.56.2",
|
|
97
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.56.2",
|
|
98
|
+
"@modern-js/server": "2.56.2",
|
|
99
|
+
"@modern-js/server-core": "2.56.2",
|
|
100
|
+
"@modern-js/server-utils": "2.56.2",
|
|
101
|
+
"@modern-js/types": "2.56.2",
|
|
102
|
+
"@modern-js/utils": "2.56.2",
|
|
103
|
+
"@modern-js/uni-builder": "2.56.2"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@rsbuild/plugin-swc": "1.0.1-beta.3",
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"tsconfig-paths": "^4.2.0",
|
|
113
113
|
"typescript": "^5",
|
|
114
114
|
"webpack": "^5.93.0",
|
|
115
|
-
"@scripts/build": "2.56.
|
|
116
|
-
"@scripts/jest-config": "2.56.
|
|
115
|
+
"@scripts/build": "2.56.2",
|
|
116
|
+
"@scripts/jest-config": "2.56.2"
|
|
117
117
|
},
|
|
118
118
|
"sideEffects": false,
|
|
119
119
|
"publishConfig": {
|