@modern-js/app-tools 2.63.2 → 2.63.3
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/compat/hooks.js +16 -1
- package/dist/cjs/compat/index.js +3 -1
- package/dist/cjs/compat/utils.js +29 -8
- package/dist/cjs/plugins/deploy/platforms/netlify.js +7 -4
- package/dist/cjs/plugins/deploy/platforms/node.js +6 -3
- package/dist/cjs/plugins/deploy/platforms/vercel.js +7 -4
- package/dist/esm/compat/hooks.js +83 -24
- package/dist/esm/compat/index.js +4 -2
- package/dist/esm/compat/utils.js +29 -8
- package/dist/esm/plugins/deploy/platforms/netlify.js +6 -3
- package/dist/esm/plugins/deploy/platforms/node.js +5 -2
- package/dist/esm/plugins/deploy/platforms/vercel.js +6 -3
- package/dist/esm-node/compat/hooks.js +16 -1
- package/dist/esm-node/compat/index.js +4 -2
- package/dist/esm-node/compat/utils.js +29 -8
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -3
- package/dist/esm-node/plugins/deploy/platforms/node.js +5 -2
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -3
- package/dist/types/compat/utils.d.ts +8 -1
- package/package.json +19 -23
- package/dist/cjs/plugins/deploy/dependencies/index.js +0 -237
- package/dist/cjs/plugins/deploy/dependencies/utils.js +0 -179
- package/dist/cjs/plugins/deploy/exports.js +0 -28
- package/dist/esm/plugins/deploy/dependencies/index.js +0 -615
- package/dist/esm/plugins/deploy/dependencies/utils.js +0 -421
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -202
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -137
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -20
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +0 -44
- package/dist/types/plugins/deploy/exports.d.ts +0 -1
@@ -2,5 +2,12 @@
|
|
2
2
|
* Maps old plugin hook function names to new plugin API names
|
3
3
|
*/
|
4
4
|
export declare function transformHookRunner(hookRunnerName: string): string;
|
5
|
-
|
5
|
+
/**
|
6
|
+
* Note:
|
7
|
+
* isMultiple Indicates whether the function parameter represents multiple values.
|
8
|
+
*/
|
9
|
+
export declare function transformHookParams(hookRunnerName: string, params: any): {
|
10
|
+
isMultiple: boolean;
|
11
|
+
params: any;
|
12
|
+
};
|
6
13
|
export declare function transformHookResult(hookRunnerName: string, result: any): any;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.63.
|
18
|
+
"version": "2.63.3",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -48,11 +48,6 @@
|
|
48
48
|
"types": "./dist/types/exports/server.d.ts",
|
49
49
|
"jsnext:source": "./src/exports/server.ts",
|
50
50
|
"default": "./dist/cjs/exports/server.js"
|
51
|
-
},
|
52
|
-
"./deploy": {
|
53
|
-
"types": "./dist/types/plugins/deploy/exports.d.ts",
|
54
|
-
"jsnext:source": "./src/plugins/deploy/exports.ts",
|
55
|
-
"default": "./dist/cjs/plugins/deploy/exports.js"
|
56
51
|
}
|
57
52
|
},
|
58
53
|
"engines": {
|
@@ -85,7 +80,7 @@
|
|
85
80
|
"@babel/parser": "^7.22.15",
|
86
81
|
"@babel/traverse": "^7.23.2",
|
87
82
|
"@babel/types": "^7.26.0",
|
88
|
-
"@rsbuild/core": "1.1.
|
83
|
+
"@rsbuild/core": "1.1.10",
|
89
84
|
"@rsbuild/plugin-node-polyfill": "1.2.0",
|
90
85
|
"@swc/helpers": "0.5.13",
|
91
86
|
"@vercel/nft": "^0.26.4",
|
@@ -95,21 +90,22 @@
|
|
95
90
|
"flatted": "^3.2.9",
|
96
91
|
"mlly": "^1.6.1",
|
97
92
|
"pkg-types": "^1.1.0",
|
93
|
+
"ndepe": "0.1.4",
|
98
94
|
"std-env": "^3.7.0",
|
99
|
-
"@modern-js/core": "2.63.
|
100
|
-
"@modern-js/
|
101
|
-
"@modern-js/
|
102
|
-
"@modern-js/plugin
|
103
|
-
"@modern-js/
|
104
|
-
"@modern-js/plugin-
|
105
|
-
"@modern-js/
|
106
|
-
"@modern-js/plugin-
|
107
|
-
"@modern-js/server
|
108
|
-
"@modern-js/server": "2.63.
|
109
|
-
"@modern-js/server-utils": "2.63.
|
110
|
-
"@modern-js/
|
111
|
-
"@modern-js/
|
112
|
-
"@modern-js/
|
95
|
+
"@modern-js/core": "2.63.3",
|
96
|
+
"@modern-js/node-bundle-require": "2.63.3",
|
97
|
+
"@modern-js/plugin-data-loader": "2.63.3",
|
98
|
+
"@modern-js/plugin": "2.63.3",
|
99
|
+
"@modern-js/plugin-i18n": "2.63.3",
|
100
|
+
"@modern-js/plugin-v2": "2.63.3",
|
101
|
+
"@modern-js/prod-server": "2.63.3",
|
102
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.63.3",
|
103
|
+
"@modern-js/server": "2.63.3",
|
104
|
+
"@modern-js/server-core": "2.63.3",
|
105
|
+
"@modern-js/server-utils": "2.63.3",
|
106
|
+
"@modern-js/uni-builder": "2.63.3",
|
107
|
+
"@modern-js/utils": "2.63.3",
|
108
|
+
"@modern-js/types": "2.63.3"
|
113
109
|
},
|
114
110
|
"devDependencies": {
|
115
111
|
"@rsbuild/plugin-webpack-swc": "1.0.9",
|
@@ -121,8 +117,8 @@
|
|
121
117
|
"tsconfig-paths": "^4.2.0",
|
122
118
|
"typescript": "^5",
|
123
119
|
"webpack": "^5.97.1",
|
124
|
-
"@scripts/
|
125
|
-
"@scripts/
|
120
|
+
"@scripts/jest-config": "2.63.3",
|
121
|
+
"@scripts/build": "2.63.3"
|
126
122
|
},
|
127
123
|
"peerDependencies": {
|
128
124
|
"ts-node": "^10.7.0",
|
@@ -1,237 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var dependencies_exports = {};
|
30
|
-
__export(dependencies_exports, {
|
31
|
-
handleDependencies: () => handleDependencies,
|
32
|
-
nodeFileTrace: () => import_nft.nodeFileTrace
|
33
|
-
});
|
34
|
-
module.exports = __toCommonJS(dependencies_exports);
|
35
|
-
var import_node_path = __toESM(require("node:path"));
|
36
|
-
var import_utils = require("@modern-js/utils");
|
37
|
-
var import_mlly = require("mlly");
|
38
|
-
var import_pkg_types = require("pkg-types");
|
39
|
-
var import_utils2 = require("./utils");
|
40
|
-
var import_nft = require("@vercel/nft");
|
41
|
-
const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions }) => {
|
42
|
-
const base = "/";
|
43
|
-
const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
|
44
|
-
const fileTrace = await traceFiles({
|
45
|
-
entryFiles: entryFiles.concat(includeEntries),
|
46
|
-
serverRootDir,
|
47
|
-
base,
|
48
|
-
traceOptions
|
49
|
-
});
|
50
|
-
const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
|
51
|
-
const dependencySearchRoot = import_node_path.default.resolve(appDir, "../../../../../../");
|
52
|
-
const tracedFiles = Object.fromEntries(await Promise.all([
|
53
|
-
...fileTrace.reasons.entries()
|
54
|
-
].map(async ([_path, reasons]) => {
|
55
|
-
if (reasons.ignored) {
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
const filePath = await (0, import_utils2.resolveTracedPath)(base, _path);
|
59
|
-
if ((0, import_utils2.isSubPath)(serverRootDir, filePath) || (0, import_utils2.isSubPath)(appDir, filePath) && !(0, import_utils2.isSubPath)(currentProjectModules, filePath)) {
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
if (!await (0, import_utils2.isFile)(filePath)) {
|
63
|
-
return;
|
64
|
-
}
|
65
|
-
let baseDir;
|
66
|
-
let pkgName;
|
67
|
-
let subpath;
|
68
|
-
let pkgPath;
|
69
|
-
if (filePath.includes("node_modules")) {
|
70
|
-
const parsed = (0, import_mlly.parseNodeModulePath)(filePath);
|
71
|
-
baseDir = parsed.dir;
|
72
|
-
pkgName = parsed.name;
|
73
|
-
subpath = parsed.subpath;
|
74
|
-
pkgPath = import_node_path.default.join(baseDir, pkgName);
|
75
|
-
} else {
|
76
|
-
const MODERN_UTILS_PATH = "packages/toolkit/utils";
|
77
|
-
const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
|
78
|
-
const match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
79
|
-
const packageJsonPath = match ? import_node_path.default.join(match[0], "package.json") : await (0, import_utils.pkgUp)({
|
80
|
-
cwd: import_node_path.default.dirname(filePath)
|
81
|
-
});
|
82
|
-
if (packageJsonPath && (0, import_utils2.isSubPath)(dependencySearchRoot, packageJsonPath)) {
|
83
|
-
const packageJson = await import_utils.fs.readJSON(packageJsonPath);
|
84
|
-
pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
|
85
|
-
subpath = import_node_path.default.relative(baseDir, filePath);
|
86
|
-
pkgName = packageJson.name;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
if (!baseDir) {
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
const parents = await Promise.all([
|
93
|
-
...reasons.parents
|
94
|
-
].map((p) => (0, import_utils2.resolveTracedPath)(base, p)));
|
95
|
-
const tracedFile = {
|
96
|
-
path: filePath,
|
97
|
-
parents,
|
98
|
-
isDirectDep: parents.some((parent) => {
|
99
|
-
return (0, import_utils2.isSubPath)(appDir, parent) && !(0, import_utils2.isSubPath)(currentProjectModules, parent);
|
100
|
-
}),
|
101
|
-
subpath,
|
102
|
-
pkgName,
|
103
|
-
pkgPath
|
104
|
-
};
|
105
|
-
return [
|
106
|
-
filePath,
|
107
|
-
tracedFile
|
108
|
-
];
|
109
|
-
})).then((r) => r.filter(Boolean)));
|
110
|
-
const tracedPackages = {};
|
111
|
-
for (const tracedFile of Object.values(tracedFiles)) {
|
112
|
-
const { pkgName } = tracedFile;
|
113
|
-
let tracedPackage = tracedPackages[pkgName];
|
114
|
-
let pkgJSON = await (0, import_pkg_types.readPackageJSON)(tracedFile.pkgPath, {
|
115
|
-
cache: true
|
116
|
-
}).catch(() => {
|
117
|
-
});
|
118
|
-
if (!pkgJSON) {
|
119
|
-
pkgJSON = {
|
120
|
-
name: pkgName,
|
121
|
-
version: "0.0.0"
|
122
|
-
};
|
123
|
-
}
|
124
|
-
if (!tracedPackage) {
|
125
|
-
tracedPackage = {
|
126
|
-
name: pkgName,
|
127
|
-
versions: {}
|
128
|
-
};
|
129
|
-
tracedPackages[pkgName] = tracedPackage;
|
130
|
-
}
|
131
|
-
let tracedPackageVersion = tracedPackage.versions[pkgJSON.version];
|
132
|
-
if (!tracedPackageVersion) {
|
133
|
-
tracedPackageVersion = {
|
134
|
-
path: tracedFile.pkgPath,
|
135
|
-
files: [],
|
136
|
-
isDirectDep: false,
|
137
|
-
pkgJSON
|
138
|
-
};
|
139
|
-
if (tracedFile.isDirectDep) {
|
140
|
-
tracedPackageVersion.isDirectDep = tracedFile.isDirectDep;
|
141
|
-
}
|
142
|
-
tracedPackage.versions[pkgJSON.version] = tracedPackageVersion;
|
143
|
-
}
|
144
|
-
tracedFile.pkgName = pkgName;
|
145
|
-
tracedFile.pkgVersion = pkgJSON.version;
|
146
|
-
const shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
|
147
|
-
if (tracedFile.path.startsWith(tracedFile.pkgPath) && // Merged package files are based on the version, not on paths, to handle some boundary cases
|
148
|
-
tracedPackageVersion.pkgJSON.version === tracedFile.pkgVersion) {
|
149
|
-
if (shouldCopyWholePackage) {
|
150
|
-
const allFiles = await (0, import_utils2.readDirRecursive)(tracedFile.pkgPath);
|
151
|
-
tracedPackageVersion.files.push(...allFiles);
|
152
|
-
} else {
|
153
|
-
tracedPackageVersion.files.push(tracedFile.path);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
}
|
157
|
-
const multiVersionPkgs = {};
|
158
|
-
const singleVersionPackages = [];
|
159
|
-
for (const tracedPackage of Object.values(tracedPackages)) {
|
160
|
-
const versions = Object.keys(tracedPackage.versions);
|
161
|
-
if (versions.length === 1) {
|
162
|
-
singleVersionPackages.push(tracedPackage.name);
|
163
|
-
continue;
|
164
|
-
}
|
165
|
-
multiVersionPkgs[tracedPackage.name] = {};
|
166
|
-
for (const version of versions) {
|
167
|
-
multiVersionPkgs[tracedPackage.name][version] = (0, import_utils2.findPackageParents)(tracedPackage, version, tracedFiles);
|
168
|
-
}
|
169
|
-
}
|
170
|
-
await Promise.all(singleVersionPackages.map((pkgName) => {
|
171
|
-
const pkg = tracedPackages[pkgName];
|
172
|
-
const version = Object.keys(pkg.versions)[0];
|
173
|
-
return (0, import_utils2.writePackage)({
|
174
|
-
pkg,
|
175
|
-
version,
|
176
|
-
projectDir: serverRootDir
|
177
|
-
});
|
178
|
-
}));
|
179
|
-
const projectPkgJson = await (0, import_pkg_types.readPackageJSON)(serverRootDir).catch(() => ({}));
|
180
|
-
for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
|
181
|
-
const versionEntires = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
|
182
|
-
var _tracedPackages_pkgName_versions_v1, _tracedPackages_pkgName_versions, _tracedPackages_pkgName, _tracedPackages_pkgName_versions_v2, _tracedPackages_pkgName_versions1, _tracedPackages_pkgName1;
|
183
|
-
const shouldHoist1 = (_tracedPackages_pkgName = tracedPackages[pkgName]) === 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;
|
184
|
-
const shouldHoist2 = (_tracedPackages_pkgName1 = tracedPackages[pkgName]) === 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;
|
185
|
-
if (shouldHoist1 && !shouldHoist2) {
|
186
|
-
return -1;
|
187
|
-
}
|
188
|
-
if (!shouldHoist1 && shouldHoist2) {
|
189
|
-
return 1;
|
190
|
-
}
|
191
|
-
if (p1.length === 0) {
|
192
|
-
return -1;
|
193
|
-
}
|
194
|
-
if (p2.length === 0) {
|
195
|
-
return 1;
|
196
|
-
}
|
197
|
-
return import_utils.semver.lt(v1, v2, {
|
198
|
-
loose: true
|
199
|
-
}) ? 1 : -1;
|
200
|
-
});
|
201
|
-
for (const [version, parentPkgs] of versionEntires) {
|
202
|
-
const pkg = tracedPackages[pkgName];
|
203
|
-
const pkgDestPath = `.modernjs/${pkgName}@${version}/node_modules/${pkgName}`;
|
204
|
-
await (0, import_utils2.writePackage)({
|
205
|
-
pkg,
|
206
|
-
version,
|
207
|
-
projectDir: serverRootDir,
|
208
|
-
_pkgPath: pkgDestPath
|
209
|
-
});
|
210
|
-
await (0, import_utils2.linkPackage)(pkgDestPath, `${pkgName}`, serverRootDir);
|
211
|
-
for (const parentPkg of parentPkgs) {
|
212
|
-
const parentPkgName = parentPkg.replace(/@[^@]+$/, "");
|
213
|
-
await (multiVersionPkgs[parentPkgName] ? (0, import_utils2.linkPackage)(pkgDestPath, `.modernjs/${parentPkg}/node_modules/${pkgName}`, serverRootDir) : (0, import_utils2.linkPackage)(pkgDestPath, `${parentPkgName}/node_modules/${pkgName}`, serverRootDir));
|
214
|
-
}
|
215
|
-
}
|
216
|
-
}
|
217
|
-
const outputPkgPath = import_node_path.default.join(serverRootDir, "package.json");
|
218
|
-
const newPkgJson = {
|
219
|
-
name: `${projectPkgJson.name || "modernjs-project"}-prod`,
|
220
|
-
version: projectPkgJson.version || "0.0.0",
|
221
|
-
private: true,
|
222
|
-
type: projectPkgJson.type || "commonjs",
|
223
|
-
dependencies: Object.fromEntries([
|
224
|
-
...Object.values(tracedPackages).map((pkg) => [
|
225
|
-
pkg.name,
|
226
|
-
Object.keys(pkg.versions)[0]
|
227
|
-
])
|
228
|
-
].sort(([a], [b]) => a.localeCompare(b)))
|
229
|
-
};
|
230
|
-
const finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
|
231
|
-
await import_utils.fs.writeJSON(outputPkgPath, finalPkgJson);
|
232
|
-
};
|
233
|
-
// Annotate the CommonJS export names for ESM import in node:
|
234
|
-
0 && (module.exports = {
|
235
|
-
handleDependencies,
|
236
|
-
nodeFileTrace
|
237
|
-
});
|
@@ -1,179 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var utils_exports = {};
|
30
|
-
__export(utils_exports, {
|
31
|
-
findEntryFiles: () => findEntryFiles,
|
32
|
-
findPackageParents: () => findPackageParents,
|
33
|
-
isFile: () => isFile,
|
34
|
-
isSubPath: () => isSubPath,
|
35
|
-
linkPackage: () => linkPackage,
|
36
|
-
readDirRecursive: () => readDirRecursive,
|
37
|
-
resolveTracedPath: () => resolveTracedPath,
|
38
|
-
traceFiles: () => traceFiles,
|
39
|
-
writePackage: () => writePackage
|
40
|
-
});
|
41
|
-
module.exports = __toCommonJS(utils_exports);
|
42
|
-
var import_node_os = __toESM(require("node:os"));
|
43
|
-
var import_path = __toESM(require("path"));
|
44
|
-
var import_utils = require("@modern-js/utils");
|
45
|
-
var import_nft = require("@vercel/nft");
|
46
|
-
var import_mlly = require("mlly");
|
47
|
-
function applyPublicCondition(pkg) {
|
48
|
-
var _pkg_publishConfig;
|
49
|
-
if (pkg === null || pkg === void 0 ? void 0 : (_pkg_publishConfig = pkg.publishConfig) === null || _pkg_publishConfig === void 0 ? void 0 : _pkg_publishConfig.exports) {
|
50
|
-
var _pkg_publishConfig1;
|
51
|
-
pkg.exports = pkg === null || pkg === void 0 ? void 0 : (_pkg_publishConfig1 = pkg.publishConfig) === null || _pkg_publishConfig1 === void 0 ? void 0 : _pkg_publishConfig1.exports;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
const writePackage = async (options) => {
|
55
|
-
const { pkg, version, projectDir, _pkgPath } = options;
|
56
|
-
const pkgPath = _pkgPath || pkg.name;
|
57
|
-
for (const src of pkg.versions[version].files) {
|
58
|
-
if (src.includes("node_modules")) {
|
59
|
-
const { subpath } = (0, import_mlly.parseNodeModulePath)(src);
|
60
|
-
const dest = import_path.default.join(projectDir, "node_modules", pkgPath, subpath);
|
61
|
-
const dirname = import_path.default.dirname(dest);
|
62
|
-
await import_utils.fs.ensureDir(dirname);
|
63
|
-
await import_utils.fs.copyFile(src, dest);
|
64
|
-
} else {
|
65
|
-
const subpath = import_path.default.relative(pkg.versions[version].path, src);
|
66
|
-
const dest = import_path.default.join(projectDir, "node_modules", pkgPath, subpath);
|
67
|
-
const dirname = import_path.default.dirname(dest);
|
68
|
-
await import_utils.fs.ensureDir(dirname);
|
69
|
-
await import_utils.fs.copyFile(src, dest);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
const { pkgJSON } = pkg.versions[version];
|
73
|
-
applyPublicCondition(pkgJSON);
|
74
|
-
const packageJsonPath = import_path.default.join(projectDir, "node_modules", pkgPath, "package.json");
|
75
|
-
await import_utils.fs.ensureDir(import_path.default.dirname(packageJsonPath));
|
76
|
-
await import_utils.fs.writeFile(packageJsonPath, JSON.stringify(pkgJSON, null, 2));
|
77
|
-
};
|
78
|
-
const isWindows = import_node_os.default.platform() === "win32";
|
79
|
-
const linkPackage = async (from, to, projectRootDir) => {
|
80
|
-
const src = import_path.default.join(projectRootDir, "node_modules", from);
|
81
|
-
const dest = import_path.default.join(projectRootDir, "node_modules", to);
|
82
|
-
const dstStat = await import_utils.fs.lstat(dest).catch(() => null);
|
83
|
-
const exists = dstStat === null || dstStat === void 0 ? void 0 : dstStat.isSymbolicLink();
|
84
|
-
if (exists) {
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
await import_utils.fs.mkdir(import_path.default.dirname(dest), {
|
88
|
-
recursive: true
|
89
|
-
});
|
90
|
-
await import_utils.fs.symlink(import_path.default.relative(import_path.default.dirname(dest), src), dest, isWindows ? "junction" : "dir").catch((error) => {
|
91
|
-
console.error("Cannot link", from, "to", to, error);
|
92
|
-
});
|
93
|
-
};
|
94
|
-
const readDirRecursive = async (dir, options = {}) => {
|
95
|
-
const { filter } = options;
|
96
|
-
const files = await import_utils.fs.readdir(dir, {
|
97
|
-
withFileTypes: true
|
98
|
-
});
|
99
|
-
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
100
|
-
const resolvedPath = import_path.default.resolve(dir, file.name);
|
101
|
-
if (file.isDirectory()) {
|
102
|
-
return readDirRecursive(resolvedPath, options);
|
103
|
-
} else {
|
104
|
-
return filter && !filter(resolvedPath) ? [] : resolvedPath;
|
105
|
-
}
|
106
|
-
}));
|
107
|
-
return filesAndDirs.flat();
|
108
|
-
};
|
109
|
-
const isFile = async (file) => {
|
110
|
-
try {
|
111
|
-
const stat = await import_utils.fs.stat(file);
|
112
|
-
return stat.isFile();
|
113
|
-
} catch (error) {
|
114
|
-
if (error.code === "ENOENT") {
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
throw error;
|
118
|
-
}
|
119
|
-
};
|
120
|
-
const findEntryFiles = async (rootDir, entryFilter) => {
|
121
|
-
const files = await readDirRecursive(rootDir, {
|
122
|
-
filter: entryFilter
|
123
|
-
});
|
124
|
-
return files.filter((file) => file.endsWith(".mjs") || file.endsWith(".cjs") || file.endsWith(".js"));
|
125
|
-
};
|
126
|
-
const findPackageParents = (pkg, version, tracedFiles) => {
|
127
|
-
const versionFiles = pkg.versions[version].files.map((path2) => tracedFiles[path2]);
|
128
|
-
const parentPkgs = [
|
129
|
-
...new Set(versionFiles.flatMap((file) => (
|
130
|
-
// Because it supports copyWholePackage configuration, not all files exist.
|
131
|
-
file === null || file === void 0 ? void 0 : file.parents.map((parentPath) => {
|
132
|
-
const parentFile = tracedFiles[parentPath];
|
133
|
-
if (!parentFile || parentFile.pkgName === pkg.name) {
|
134
|
-
return null;
|
135
|
-
}
|
136
|
-
return `${parentFile.pkgName}@${parentFile.pkgVersion}`;
|
137
|
-
}).filter(Boolean)
|
138
|
-
)))
|
139
|
-
];
|
140
|
-
return parentPkgs.filter((parentPkg) => parentPkg);
|
141
|
-
};
|
142
|
-
const traceFiles = async ({ entryFiles, serverRootDir, base = "/", traceOptions }) => {
|
143
|
-
return await (0, import_nft.nodeFileTrace)(entryFiles, {
|
144
|
-
base,
|
145
|
-
processCwd: serverRootDir,
|
146
|
-
resolve: async (id, parent, job, isCjs) => {
|
147
|
-
if (id.startsWith("@modern-js/prod-server")) {
|
148
|
-
return require.resolve(id, {
|
149
|
-
paths: [
|
150
|
-
require.resolve("@modern-js/app-tools")
|
151
|
-
]
|
152
|
-
});
|
153
|
-
} else {
|
154
|
-
return (0, import_nft.resolve)(id, parent, job, isCjs);
|
155
|
-
}
|
156
|
-
},
|
157
|
-
...traceOptions
|
158
|
-
});
|
159
|
-
};
|
160
|
-
const resolveTracedPath = async (base, p) => import_utils.fs.realpath(import_path.default.resolve(base, p));
|
161
|
-
const isSubPath = (parentPath, childPath) => {
|
162
|
-
if (!parentPath || !childPath) {
|
163
|
-
return false;
|
164
|
-
}
|
165
|
-
const relative = import_path.default.relative(parentPath, childPath);
|
166
|
-
return relative && !relative.startsWith("..");
|
167
|
-
};
|
168
|
-
// Annotate the CommonJS export names for ESM import in node:
|
169
|
-
0 && (module.exports = {
|
170
|
-
findEntryFiles,
|
171
|
-
findPackageParents,
|
172
|
-
isFile,
|
173
|
-
isSubPath,
|
174
|
-
linkPackage,
|
175
|
-
readDirRecursive,
|
176
|
-
resolveTracedPath,
|
177
|
-
traceFiles,
|
178
|
-
writePackage
|
179
|
-
});
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var exports_exports = {};
|
20
|
-
__export(exports_exports, {
|
21
|
-
handleDependencies: () => import_dependencies.handleDependencies
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(exports_exports);
|
24
|
-
var import_dependencies = require("./dependencies");
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
26
|
-
0 && (module.exports = {
|
27
|
-
handleDependencies
|
28
|
-
});
|