@modern-js/app-tools 2.56.2-alpha.0 → 2.56.2-alpha.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.
|
@@ -36,11 +36,21 @@ 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
|
+
};
|
|
39
48
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
|
40
49
|
const base = "/";
|
|
41
50
|
const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
|
|
42
51
|
const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
|
|
43
52
|
const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
|
|
53
|
+
const getMonorepoRoot = createGetMonoRoot(appDir);
|
|
44
54
|
const tracedFiles = Object.fromEntries(await Promise.all([
|
|
45
55
|
...fileTrace.reasons.entries()
|
|
46
56
|
].map(async ([_path, reasons]) => {
|
|
@@ -68,9 +78,19 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
|
68
78
|
const MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
69
79
|
const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
|
|
70
80
|
const match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
81
|
+
const monorepoRoot = getMonorepoRoot();
|
|
71
82
|
const packageJsonPath = match ? import_node_path.default.join(match[0], "package.json") : await (0, import_utils.pkgUp)({
|
|
72
83
|
cwd: import_node_path.default.dirname(filePath)
|
|
73
84
|
});
|
|
85
|
+
if (packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)) {
|
|
86
|
+
if (!match) {
|
|
87
|
+
console.log("filePath", filePath, packageJsonPath);
|
|
88
|
+
}
|
|
89
|
+
const packageJson = await import_utils.fs.readJSON(packageJsonPath);
|
|
90
|
+
pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
|
|
91
|
+
subpath = import_node_path.default.relative(baseDir, filePath);
|
|
92
|
+
pkgName = packageJson.name;
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
if (!baseDir) {
|
|
76
96
|
return;
|
|
@@ -4,13 +4,22 @@ 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 { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
7
|
+
import { findMonorepoRoot, 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
|
+
};
|
|
11
20
|
var handleDependencies = function() {
|
|
12
21
|
var _ref = _async_to_generator(function(param) {
|
|
13
|
-
var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, base, entryFiles, fileTrace, currentProjectModules, 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;
|
|
22
|
+
var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, base, entryFiles, fileTrace, currentProjectModules, getMonorepoRoot, 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;
|
|
14
23
|
return _ts_generator(this, function(_state) {
|
|
15
24
|
switch (_state.label) {
|
|
16
25
|
case 0:
|
|
@@ -29,12 +38,13 @@ var handleDependencies = function() {
|
|
|
29
38
|
case 2:
|
|
30
39
|
fileTrace = _state.sent();
|
|
31
40
|
currentProjectModules = path.join(appDir, "node_modules");
|
|
41
|
+
getMonorepoRoot = createGetMonoRoot(appDir);
|
|
32
42
|
_ = Object.fromEntries;
|
|
33
43
|
return [
|
|
34
44
|
4,
|
|
35
45
|
Promise.all(_to_consumable_array(fileTrace.reasons.entries()).map(function() {
|
|
36
46
|
var _ref2 = _async_to_generator(function(param2) {
|
|
37
|
-
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match, packageJsonPath, _tmp, parents, tracedFile2;
|
|
47
|
+
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match, monorepoRoot, packageJsonPath, _tmp, packageJson, parents, tracedFile2;
|
|
38
48
|
return _ts_generator(this, function(_state2) {
|
|
39
49
|
switch (_state2.label) {
|
|
40
50
|
case 0:
|
|
@@ -77,12 +87,13 @@ var handleDependencies = function() {
|
|
|
77
87
|
pkgPath = path.join(baseDir, pkgName2);
|
|
78
88
|
return [
|
|
79
89
|
3,
|
|
80
|
-
|
|
90
|
+
8
|
|
81
91
|
];
|
|
82
92
|
case 3:
|
|
83
93
|
MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
84
94
|
MODERN_UTILS_PATH_REGEX = new RegExp("(.*".concat(MODERN_UTILS_PATH, ")"));
|
|
85
95
|
match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
96
|
+
monorepoRoot = getMonorepoRoot();
|
|
86
97
|
if (!match)
|
|
87
98
|
return [
|
|
88
99
|
3,
|
|
@@ -105,8 +116,25 @@ var handleDependencies = function() {
|
|
|
105
116
|
_state2.label = 6;
|
|
106
117
|
case 6:
|
|
107
118
|
packageJsonPath = _tmp;
|
|
108
|
-
|
|
119
|
+
if (!(packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)))
|
|
120
|
+
return [
|
|
121
|
+
3,
|
|
122
|
+
8
|
|
123
|
+
];
|
|
124
|
+
if (!match) {
|
|
125
|
+
console.log("filePath", filePath, packageJsonPath);
|
|
126
|
+
}
|
|
127
|
+
return [
|
|
128
|
+
4,
|
|
129
|
+
fse.readJSON(packageJsonPath)
|
|
130
|
+
];
|
|
109
131
|
case 7:
|
|
132
|
+
packageJson = _state2.sent();
|
|
133
|
+
pkgPath = baseDir = path.dirname(packageJsonPath);
|
|
134
|
+
subpath = path.relative(baseDir, filePath);
|
|
135
|
+
pkgName2 = packageJson.name;
|
|
136
|
+
_state2.label = 8;
|
|
137
|
+
case 8:
|
|
110
138
|
if (!baseDir) {
|
|
111
139
|
return [
|
|
112
140
|
2
|
|
@@ -118,7 +146,7 @@ var handleDependencies = function() {
|
|
|
118
146
|
return resolveTracedPath(base, p);
|
|
119
147
|
}))
|
|
120
148
|
];
|
|
121
|
-
case
|
|
149
|
+
case 9:
|
|
122
150
|
parents = _state2.sent();
|
|
123
151
|
tracedFile2 = {
|
|
124
152
|
path: filePath,
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
2
|
+
import { findMonorepoRoot, 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
|
+
};
|
|
6
15
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
|
7
16
|
const base = "/";
|
|
8
17
|
const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
|
|
9
18
|
const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
|
|
10
19
|
const currentProjectModules = path.join(appDir, "node_modules");
|
|
20
|
+
const getMonorepoRoot = createGetMonoRoot(appDir);
|
|
11
21
|
const tracedFiles = Object.fromEntries(await Promise.all([
|
|
12
22
|
...fileTrace.reasons.entries()
|
|
13
23
|
].map(async ([_path, reasons]) => {
|
|
@@ -35,9 +45,19 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
|
35
45
|
const MODERN_UTILS_PATH = "packages/toolkit/utils";
|
|
36
46
|
const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
|
|
37
47
|
const match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
|
48
|
+
const monorepoRoot = getMonorepoRoot();
|
|
38
49
|
const packageJsonPath = match ? path.join(match[0], "package.json") : await pkgUp({
|
|
39
50
|
cwd: path.dirname(filePath)
|
|
40
51
|
});
|
|
52
|
+
if (packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)) {
|
|
53
|
+
if (!match) {
|
|
54
|
+
console.log("filePath", filePath, packageJsonPath);
|
|
55
|
+
}
|
|
56
|
+
const packageJson = await fse.readJSON(packageJsonPath);
|
|
57
|
+
pkgPath = baseDir = path.dirname(packageJsonPath);
|
|
58
|
+
subpath = path.relative(baseDir, filePath);
|
|
59
|
+
pkgName = packageJson.name;
|
|
60
|
+
}
|
|
41
61
|
}
|
|
42
62
|
if (!baseDir) {
|
|
43
63
|
return;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.56.2-alpha.
|
|
18
|
+
"version": "2.56.2-alpha.1",
|
|
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/core": "2.56.1",
|
|
91
90
|
"@modern-js/node-bundle-require": "2.56.1",
|
|
92
|
-
"@modern-js/
|
|
91
|
+
"@modern-js/core": "2.56.1",
|
|
93
92
|
"@modern-js/plugin": "2.56.1",
|
|
93
|
+
"@modern-js/plugin-i18n": "2.56.1",
|
|
94
94
|
"@modern-js/plugin-lint": "2.56.1",
|
|
95
|
+
"@modern-js/server": "2.56.1",
|
|
96
|
+
"@modern-js/prod-server": "2.56.1",
|
|
97
|
+
"@modern-js/server-core": "2.56.1",
|
|
98
|
+
"@modern-js/utils": "2.56.1",
|
|
95
99
|
"@modern-js/server-utils": "2.56.1",
|
|
100
|
+
"@modern-js/types": "2.56.1",
|
|
96
101
|
"@modern-js/uni-builder": "2.56.1",
|
|
97
102
|
"@modern-js/rsbuild-plugin-esbuild": "2.56.1",
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/plugin-data-loader": "2.56.1",
|
|
100
|
-
"@modern-js/utils": "2.56.1",
|
|
101
|
-
"@modern-js/server-core": "2.56.1",
|
|
102
|
-
"@modern-js/prod-server": "2.56.1",
|
|
103
|
-
"@modern-js/server": "2.56.1"
|
|
103
|
+
"@modern-js/plugin-data-loader": "2.56.1"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@rsbuild/plugin-swc": "1.0.1-beta.3",
|