@modern-js/app-tools 2.56.1 → 2.56.2-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -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,10 +78,14 @@ 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
|
});
|
74
|
-
if (packageJsonPath) {
|
85
|
+
if (packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)) {
|
86
|
+
if (!match) {
|
87
|
+
console.log("filePath", filePath, packageJsonPath);
|
88
|
+
}
|
75
89
|
const packageJson = await import_utils.fs.readJSON(packageJsonPath);
|
76
90
|
pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
|
77
91
|
subpath = import_node_path.default.relative(baseDir, filePath);
|
@@ -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, packageJson, 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:
|
@@ -83,6 +93,7 @@ var handleDependencies = function() {
|
|
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,11 +116,14 @@ var handleDependencies = function() {
|
|
105
116
|
_state2.label = 6;
|
106
117
|
case 6:
|
107
118
|
packageJsonPath = _tmp;
|
108
|
-
if (!packageJsonPath)
|
119
|
+
if (!(packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)))
|
109
120
|
return [
|
110
121
|
3,
|
111
122
|
8
|
112
123
|
];
|
124
|
+
if (!match) {
|
125
|
+
console.log("filePath", filePath, packageJsonPath);
|
126
|
+
}
|
113
127
|
return [
|
114
128
|
4,
|
115
129
|
fse.readJSON(packageJsonPath)
|
@@ -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,10 +45,14 @@ 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
|
});
|
41
|
-
if (packageJsonPath) {
|
52
|
+
if (packageJsonPath && monorepoRoot && packageJsonPath.startsWith(monorepoRoot)) {
|
53
|
+
if (!match) {
|
54
|
+
console.log("filePath", filePath, packageJsonPath);
|
55
|
+
}
|
42
56
|
const packageJson = await fse.readJSON(packageJsonPath);
|
43
57
|
pkgPath = baseDir = path.dirname(packageJsonPath);
|
44
58
|
subpath = path.relative(baseDir, filePath);
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.56.1",
|
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",
|
91
|
+
"@modern-js/core": "2.56.1",
|
92
92
|
"@modern-js/plugin": "2.56.1",
|
93
|
-
"@modern-js/plugin-data-loader": "2.56.1",
|
94
|
-
"@modern-js/plugin-lint": "2.56.1",
|
95
|
-
"@modern-js/prod-server": "2.56.1",
|
96
|
-
"@modern-js/rsbuild-plugin-esbuild": "2.56.1",
|
97
93
|
"@modern-js/plugin-i18n": "2.56.1",
|
94
|
+
"@modern-js/plugin-lint": "2.56.1",
|
98
95
|
"@modern-js/server": "2.56.1",
|
99
|
-
"@modern-js/server
|
100
|
-
"@modern-js/types": "2.56.1",
|
96
|
+
"@modern-js/prod-server": "2.56.1",
|
101
97
|
"@modern-js/server-core": "2.56.1",
|
102
98
|
"@modern-js/utils": "2.56.1",
|
103
|
-
"@modern-js/
|
99
|
+
"@modern-js/server-utils": "2.56.1",
|
100
|
+
"@modern-js/types": "2.56.1",
|
101
|
+
"@modern-js/uni-builder": "2.56.1",
|
102
|
+
"@modern-js/rsbuild-plugin-esbuild": "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",
|