@modern-js/app-tools 2.57.1-beta.1 → 2.57.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.
- package/dist/cjs/plugins/deploy/dependencies/index.js +5 -8
- package/dist/cjs/plugins/deploy/dependencies/utils.js +9 -0
- package/dist/esm/plugins/deploy/dependencies/index.js +5 -7
- package/dist/esm/plugins/deploy/dependencies/utils.js +8 -0
- package/dist/esm-node/plugins/deploy/dependencies/index.js +5 -7
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +8 -0
- package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -1
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -0
- package/package.json +17 -17
@@ -28,8 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
29
|
var dependencies_exports = {};
|
30
30
|
__export(dependencies_exports, {
|
31
|
-
handleDependencies: () => handleDependencies
|
32
|
-
nodeFileTrace: () => import_nft.nodeFileTrace
|
31
|
+
handleDependencies: () => handleDependencies
|
33
32
|
});
|
34
33
|
module.exports = __toCommonJS(dependencies_exports);
|
35
34
|
var import_node_path = __toESM(require("node:path"));
|
@@ -37,7 +36,6 @@ var import_utils = require("@modern-js/utils");
|
|
37
36
|
var import_pkg_types = require("pkg-types");
|
38
37
|
var import_mlly = require("mlly");
|
39
38
|
var import_utils2 = require("./utils");
|
40
|
-
var import_nft = require("@vercel/nft");
|
41
39
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
42
40
|
const base = "/";
|
43
41
|
const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
|
@@ -51,7 +49,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
51
49
|
return;
|
52
50
|
}
|
53
51
|
const filePath = await (0, import_utils2.resolveTracedPath)(base, _path);
|
54
|
-
if (
|
52
|
+
if ((0, import_utils2.isSubPath)(serverRootDir, filePath) || (0, import_utils2.isSubPath)(appDir, filePath) && !(0, import_utils2.isSubPath)(currentProjectModules, filePath)) {
|
55
53
|
return;
|
56
54
|
}
|
57
55
|
if (!await (0, import_utils2.isFile)(filePath)) {
|
@@ -74,7 +72,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
74
72
|
const packageJsonPath = match ? import_node_path.default.join(match[0], "package.json") : await (0, import_utils.pkgUp)({
|
75
73
|
cwd: import_node_path.default.dirname(filePath)
|
76
74
|
});
|
77
|
-
if (packageJsonPath
|
75
|
+
if (packageJsonPath && (0, import_utils2.isSubPath)(dependencySearchRoot, packageJsonPath)) {
|
78
76
|
const packageJson = await import_utils.fs.readJSON(packageJsonPath);
|
79
77
|
pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
|
80
78
|
subpath = import_node_path.default.relative(baseDir, filePath);
|
@@ -91,7 +89,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
91
89
|
path: filePath,
|
92
90
|
parents,
|
93
91
|
isDirectDep: parents.some((parent) => {
|
94
|
-
return
|
92
|
+
return (0, import_utils2.isSubPath)(appDir, parent) && !(0, import_utils2.isSubPath)(currentProjectModules, parent);
|
95
93
|
}),
|
96
94
|
subpath,
|
97
95
|
pkgName,
|
@@ -226,6 +224,5 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
226
224
|
};
|
227
225
|
// Annotate the CommonJS export names for ESM import in node:
|
228
226
|
0 && (module.exports = {
|
229
|
-
handleDependencies
|
230
|
-
nodeFileTrace
|
227
|
+
handleDependencies
|
231
228
|
});
|
@@ -31,6 +31,7 @@ __export(utils_exports, {
|
|
31
31
|
findEntryFiles: () => findEntryFiles,
|
32
32
|
findPackageParents: () => findPackageParents,
|
33
33
|
isFile: () => isFile,
|
34
|
+
isSubPath: () => isSubPath,
|
34
35
|
linkPackage: () => linkPackage,
|
35
36
|
readDirRecursive: () => readDirRecursive,
|
36
37
|
resolveTracedPath: () => resolveTracedPath,
|
@@ -145,11 +146,19 @@ const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
|
|
145
146
|
});
|
146
147
|
};
|
147
148
|
const resolveTracedPath = async (base, p) => import_utils.fs.realpath(import_path.default.resolve(base, p));
|
149
|
+
const isSubPath = (parentPath, childPath) => {
|
150
|
+
if (!parentPath || !childPath) {
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
const relative = import_path.default.relative(parentPath, childPath);
|
154
|
+
return relative && !relative.startsWith("..");
|
155
|
+
};
|
148
156
|
// Annotate the CommonJS export names for ESM import in node:
|
149
157
|
0 && (module.exports = {
|
150
158
|
findEntryFiles,
|
151
159
|
findPackageParents,
|
152
160
|
isFile,
|
161
|
+
isSubPath,
|
153
162
|
linkPackage,
|
154
163
|
readDirRecursive,
|
155
164
|
resolveTracedPath,
|
@@ -7,8 +7,7 @@ import path 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 as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
|
11
|
-
import { nodeFileTrace } from "@vercel/nft";
|
10
|
+
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive, isSubPath } from "./utils";
|
12
11
|
var handleDependencies = function() {
|
13
12
|
var _ref = _async_to_generator(function(param) {
|
14
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;
|
@@ -52,7 +51,7 @@ var handleDependencies = function() {
|
|
52
51
|
];
|
53
52
|
case 1:
|
54
53
|
filePath = _state2.sent();
|
55
|
-
if (
|
54
|
+
if (isSubPath(serverRootDir, filePath) || isSubPath(appDir, filePath) && !isSubPath(currentProjectModules, filePath)) {
|
56
55
|
return [
|
57
56
|
2
|
58
57
|
];
|
@@ -107,7 +106,7 @@ var handleDependencies = function() {
|
|
107
106
|
_state2.label = 6;
|
108
107
|
case 6:
|
109
108
|
packageJsonPath = _tmp;
|
110
|
-
if (!(packageJsonPath
|
109
|
+
if (!(packageJsonPath && isSubPath(dependencySearchRoot, packageJsonPath)))
|
111
110
|
return [
|
112
111
|
3,
|
113
112
|
8
|
@@ -140,7 +139,7 @@ var handleDependencies = function() {
|
|
140
139
|
path: filePath,
|
141
140
|
parents,
|
142
141
|
isDirectDep: parents.some(function(parent) {
|
143
|
-
return
|
142
|
+
return isSubPath(appDir, parent) && !isSubPath(currentProjectModules, parent);
|
144
143
|
}),
|
145
144
|
subpath,
|
146
145
|
pkgName: pkgName2,
|
@@ -604,6 +603,5 @@ var handleDependencies = function() {
|
|
604
603
|
};
|
605
604
|
}();
|
606
605
|
export {
|
607
|
-
handleDependencies
|
608
|
-
nodeFileTrace
|
606
|
+
handleDependencies
|
609
607
|
};
|
@@ -374,10 +374,18 @@ var resolveTracedPath = function() {
|
|
374
374
|
return _ref.apply(this, arguments);
|
375
375
|
};
|
376
376
|
}();
|
377
|
+
var isSubPath = function(parentPath, childPath) {
|
378
|
+
if (!parentPath || !childPath) {
|
379
|
+
return false;
|
380
|
+
}
|
381
|
+
var relative = path.relative(parentPath, childPath);
|
382
|
+
return relative && !relative.startsWith("..");
|
383
|
+
};
|
377
384
|
export {
|
378
385
|
findEntryFiles,
|
379
386
|
findPackageParents,
|
380
387
|
isFile,
|
388
|
+
isSubPath,
|
381
389
|
linkPackage,
|
382
390
|
readDirRecursive,
|
383
391
|
resolveTracedPath,
|
@@ -2,8 +2,7 @@ import path from "node:path";
|
|
2
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
|
-
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
|
6
|
-
import { nodeFileTrace } from "@vercel/nft";
|
5
|
+
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive, isSubPath } from "./utils";
|
7
6
|
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
|
8
7
|
const base = "/";
|
9
8
|
const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
|
@@ -17,7 +16,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
17
16
|
return;
|
18
17
|
}
|
19
18
|
const filePath = await resolveTracedPath(base, _path);
|
20
|
-
if (
|
19
|
+
if (isSubPath(serverRootDir, filePath) || isSubPath(appDir, filePath) && !isSubPath(currentProjectModules, filePath)) {
|
21
20
|
return;
|
22
21
|
}
|
23
22
|
if (!await isFile(filePath)) {
|
@@ -40,7 +39,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
40
39
|
const packageJsonPath = match ? path.join(match[0], "package.json") : await pkgUp({
|
41
40
|
cwd: path.dirname(filePath)
|
42
41
|
});
|
43
|
-
if (packageJsonPath
|
42
|
+
if (packageJsonPath && isSubPath(dependencySearchRoot, packageJsonPath)) {
|
44
43
|
const packageJson = await fse.readJSON(packageJsonPath);
|
45
44
|
pkgPath = baseDir = path.dirname(packageJsonPath);
|
46
45
|
subpath = path.relative(baseDir, filePath);
|
@@ -57,7 +56,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
57
56
|
path: filePath,
|
58
57
|
parents,
|
59
58
|
isDirectDep: parents.some((parent) => {
|
60
|
-
return
|
59
|
+
return isSubPath(appDir, parent) && !isSubPath(currentProjectModules, parent);
|
61
60
|
}),
|
62
61
|
subpath,
|
63
62
|
pkgName,
|
@@ -191,6 +190,5 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
|
|
191
190
|
await fse.writeJSON(outputPkgPath, finalPkgJson);
|
192
191
|
};
|
193
192
|
export {
|
194
|
-
handleDependencies
|
195
|
-
nodeFileTrace
|
193
|
+
handleDependencies
|
196
194
|
};
|
@@ -105,10 +105,18 @@ const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
|
|
105
105
|
});
|
106
106
|
};
|
107
107
|
const resolveTracedPath = async (base, p) => fse.realpath(path.resolve(base, p));
|
108
|
+
const isSubPath = (parentPath, childPath) => {
|
109
|
+
if (!parentPath || !childPath) {
|
110
|
+
return false;
|
111
|
+
}
|
112
|
+
const relative = path.relative(parentPath, childPath);
|
113
|
+
return relative && !relative.startsWith("..");
|
114
|
+
};
|
108
115
|
export {
|
109
116
|
findEntryFiles,
|
110
117
|
findPackageParents,
|
111
118
|
isFile,
|
119
|
+
isSubPath,
|
112
120
|
linkPackage,
|
113
121
|
readDirRecursive,
|
114
122
|
resolveTracedPath,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { PackageJson } from 'pkg-types';
|
2
2
|
import { traceFiles as defaultTraceFiles } from './utils';
|
3
|
-
export { nodeFileTrace } from '@vercel/nft';
|
4
3
|
export declare const handleDependencies: ({ appDir, serverRootDir, includeEntries, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, }: {
|
5
4
|
appDir: string;
|
6
5
|
serverRootDir: string;
|
@@ -34,4 +34,5 @@ export declare const findEntryFiles: (rootDir: string, entryFilter?: ((filePath:
|
|
34
34
|
export declare const findPackageParents: (pkg: TracedPackage, version: string, tracedFiles: Record<string, TracedFile>) => string[];
|
35
35
|
export declare const traceFiles: (entryFiles: string[], serverRootDir: string, base?: string) => Promise<import("@vercel/nft").NodeFileTraceResult>;
|
36
36
|
export declare const resolveTracedPath: (base: string, p: string) => Promise<string>;
|
37
|
+
export declare const isSubPath: (parentPath: string, childPath: string) => boolean | "";
|
37
38
|
export {};
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.57.1
|
18
|
+
"version": "2.57.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/
|
91
|
-
"@modern-js/
|
92
|
-
"@modern-js/
|
93
|
-
"@modern-js/
|
94
|
-
"@modern-js/
|
95
|
-
"@modern-js/plugin-
|
96
|
-
"@modern-js/plugin-
|
97
|
-
"@modern-js/
|
98
|
-
"@modern-js/
|
99
|
-
"@modern-js/
|
100
|
-
"@modern-js/
|
101
|
-
"@modern-js/
|
102
|
-
"@modern-js/
|
103
|
-
"@modern-js/
|
90
|
+
"@modern-js/core": "2.57.1",
|
91
|
+
"@modern-js/plugin": "2.57.1",
|
92
|
+
"@modern-js/node-bundle-require": "2.57.1",
|
93
|
+
"@modern-js/plugin-data-loader": "2.57.1",
|
94
|
+
"@modern-js/plugin-i18n": "2.57.1",
|
95
|
+
"@modern-js/plugin-lint": "2.57.1",
|
96
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.57.1",
|
97
|
+
"@modern-js/server": "2.57.1",
|
98
|
+
"@modern-js/prod-server": "2.57.1",
|
99
|
+
"@modern-js/server-core": "2.57.1",
|
100
|
+
"@modern-js/types": "2.57.1",
|
101
|
+
"@modern-js/utils": "2.57.1",
|
102
|
+
"@modern-js/server-utils": "2.57.1",
|
103
|
+
"@modern-js/uni-builder": "2.57.1"
|
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.57.
|
116
|
-
"@scripts/jest-config": "2.57.
|
115
|
+
"@scripts/build": "2.57.1",
|
116
|
+
"@scripts/jest-config": "2.57.1"
|
117
117
|
},
|
118
118
|
"sideEffects": false,
|
119
119
|
"publishConfig": {
|