@modern-js/app-tools 2.63.1 → 2.63.3
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +1 -1
- package/dist/cjs/commands/build.js +19 -13
- package/dist/cjs/commands/deploy.js +5 -5
- package/dist/cjs/commands/dev.js +11 -11
- package/dist/cjs/commands/index.js +6 -6
- package/dist/cjs/commands/inspect.js +1 -1
- package/dist/cjs/commands/serve.js +4 -4
- package/dist/cjs/{new/compat → compat}/hooks.js +21 -6
- package/dist/cjs/{new/compat → compat}/index.js +7 -2
- package/dist/cjs/{new/compat → compat}/utils.js +29 -8
- package/dist/cjs/config/default.js +6 -1
- package/dist/cjs/config/legacy/index.js +0 -1
- package/dist/cjs/index.js +154 -5
- package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
- package/dist/cjs/plugins/analyze/index.js +25 -10
- package/dist/cjs/plugins/analyze/utils.js +6 -0
- 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/cjs/plugins/serverBuild.js +30 -32
- package/dist/cjs/{new/run.js → run/index.js} +6 -6
- package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
- package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
- package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/cjs/utils/loadPlugins.js +35 -4
- package/dist/cjs/utils/printInstructions.js +2 -11
- package/dist/cjs/utils/restart.js +2 -2
- package/dist/esm/commands/build.js +18 -12
- package/dist/esm/commands/deploy.js +6 -6
- package/dist/esm/commands/dev.js +11 -11
- package/dist/esm/commands/index.js +8 -8
- package/dist/esm/commands/inspect.js +1 -1
- package/dist/esm/commands/serve.js +6 -6
- package/dist/esm/{new/compat → compat}/hooks.js +98 -49
- package/dist/esm/{new/compat → compat}/index.js +8 -3
- package/dist/esm/{new/compat → compat}/utils.js +29 -8
- package/dist/esm/config/default.js +12 -1
- package/dist/esm/config/legacy/index.js +0 -1
- package/dist/esm/index.js +245 -2
- package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm/plugins/analyze/index.js +76 -34
- package/dist/esm/plugins/analyze/utils.js +5 -0
- 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/plugins/serverBuild.js +52 -56
- package/dist/esm/{new/run.js → run/index.js} +6 -6
- package/dist/esm/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/esm/utils/loadPlugins.js +95 -7
- package/dist/esm/utils/printInstructions.js +1 -28
- package/dist/esm/utils/restart.js +3 -3
- package/dist/esm-node/commands/build.js +19 -13
- package/dist/esm-node/commands/deploy.js +5 -5
- package/dist/esm-node/commands/dev.js +12 -12
- package/dist/esm-node/commands/index.js +6 -6
- package/dist/esm-node/commands/inspect.js +1 -1
- package/dist/esm-node/commands/serve.js +5 -5
- package/dist/esm-node/{new/compat → compat}/hooks.js +21 -6
- package/dist/esm-node/{new/compat → compat}/index.js +8 -3
- package/dist/esm-node/{new/compat → compat}/utils.js +29 -8
- package/dist/esm-node/config/default.js +6 -1
- package/dist/esm-node/config/legacy/index.js +0 -1
- package/dist/esm-node/index.js +140 -2
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm-node/plugins/analyze/index.js +26 -11
- package/dist/esm-node/plugins/analyze/utils.js +5 -0
- 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/esm-node/plugins/serverBuild.js +30 -32
- package/dist/esm-node/{new/run.js → run/index.js} +6 -6
- package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
- package/dist/esm-node/utils/loadPlugins.js +34 -4
- package/dist/esm-node/utils/printInstructions.js +1 -9
- package/dist/esm-node/utils/restart.js +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/index.d.ts +6 -6
- package/dist/types/commands/inspect.d.ts +2 -2
- package/dist/types/commands/serve.d.ts +2 -2
- package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/{new/compat → compat}/utils.d.ts +8 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
- package/dist/types/plugins/analyze/utils.d.ts +1 -0
- package/dist/types/plugins/serverBuild.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/new.d.ts +11 -16
- package/dist/types/utils/generateWatchFiles.d.ts +2 -2
- package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -3
- package/dist/types/utils/printInstructions.d.ts +1 -3
- package/dist/types/utils/restart.d.ts +2 -3
- package/package.json +24 -28
- package/dist/cjs/hooks.js +0 -60
- package/dist/cjs/new/index.js +0 -79
- package/dist/cjs/new/loadPlugins.js +0 -57
- package/dist/cjs/old.js +0 -179
- 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/hooks.js +0 -36
- package/dist/esm/new/index.js +0 -55
- package/dist/esm/new/loadPlugins.js +0 -94
- package/dist/esm/old.js +0 -258
- 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/hooks.js +0 -36
- package/dist/esm-node/new/index.js +0 -52
- package/dist/esm-node/new/loadPlugins.js +0 -33
- package/dist/esm-node/old.js +0 -140
- 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/hooks.d.ts +0 -2
- package/dist/types/new/compat/index.d.ts +0 -2
- package/dist/types/new/index.d.ts +0 -6
- package/dist/types/new/loadPlugins.d.ts +0 -9
- package/dist/types/new/utils/index.d.ts +0 -1
- package/dist/types/old.d.ts +0 -13
- 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
- /package/dist/cjs/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
- /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
- /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
- /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
@@ -1,615 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
3
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
4
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
|
-
import { _ as _ts_values } from "@swc/helpers/_/_ts_values";
|
6
|
-
import path from "node:path";
|
7
|
-
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
8
|
-
import { parseNodeModulePath } from "mlly";
|
9
|
-
import { readPackageJSON } from "pkg-types";
|
10
|
-
import { traceFiles as defaultTraceFiles, findEntryFiles, findPackageParents, isFile, isSubPath, linkPackage, readDirRecursive, resolveTracedPath, writePackage } from "./utils";
|
11
|
-
import { nodeFileTrace } from "@vercel/nft";
|
12
|
-
var handleDependencies = function() {
|
13
|
-
var _ref = _async_to_generator(function(param) {
|
14
|
-
var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions, 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;
|
15
|
-
return _ts_generator(this, function(_state) {
|
16
|
-
switch (_state.label) {
|
17
|
-
case 0:
|
18
|
-
appDir = param.appDir, serverRootDir = param.serverRootDir, includeEntries = param.includeEntries, _param_traceFiles = param.traceFiles, traceFiles = _param_traceFiles === void 0 ? defaultTraceFiles : _param_traceFiles, entryFilter = param.entryFilter, modifyPackageJson = param.modifyPackageJson, copyWholePackage = param.copyWholePackage, traceOptions = param.traceOptions;
|
19
|
-
base = "/";
|
20
|
-
return [
|
21
|
-
4,
|
22
|
-
findEntryFiles(serverRootDir, entryFilter)
|
23
|
-
];
|
24
|
-
case 1:
|
25
|
-
entryFiles = _state.sent();
|
26
|
-
return [
|
27
|
-
4,
|
28
|
-
traceFiles({
|
29
|
-
entryFiles: entryFiles.concat(includeEntries),
|
30
|
-
serverRootDir,
|
31
|
-
base,
|
32
|
-
traceOptions
|
33
|
-
})
|
34
|
-
];
|
35
|
-
case 2:
|
36
|
-
fileTrace = _state.sent();
|
37
|
-
currentProjectModules = path.join(appDir, "node_modules");
|
38
|
-
dependencySearchRoot = path.resolve(appDir, "../../../../../../");
|
39
|
-
_ = Object.fromEntries;
|
40
|
-
return [
|
41
|
-
4,
|
42
|
-
Promise.all(_to_consumable_array(fileTrace.reasons.entries()).map(function() {
|
43
|
-
var _ref2 = _async_to_generator(function(param2) {
|
44
|
-
var _param, _path, reasons, filePath, baseDir, pkgName2, subpath, pkgPath, parsed, MODERN_UTILS_PATH, MODERN_UTILS_PATH_REGEX, match, packageJsonPath, _tmp, packageJson, parents, tracedFile2;
|
45
|
-
return _ts_generator(this, function(_state2) {
|
46
|
-
switch (_state2.label) {
|
47
|
-
case 0:
|
48
|
-
_param = _sliced_to_array(param2, 2), _path = _param[0], reasons = _param[1];
|
49
|
-
if (reasons.ignored) {
|
50
|
-
return [
|
51
|
-
2
|
52
|
-
];
|
53
|
-
}
|
54
|
-
return [
|
55
|
-
4,
|
56
|
-
resolveTracedPath(base, _path)
|
57
|
-
];
|
58
|
-
case 1:
|
59
|
-
filePath = _state2.sent();
|
60
|
-
if (isSubPath(serverRootDir, filePath) || isSubPath(appDir, filePath) && !isSubPath(currentProjectModules, filePath)) {
|
61
|
-
return [
|
62
|
-
2
|
63
|
-
];
|
64
|
-
}
|
65
|
-
return [
|
66
|
-
4,
|
67
|
-
isFile(filePath)
|
68
|
-
];
|
69
|
-
case 2:
|
70
|
-
if (!_state2.sent()) {
|
71
|
-
return [
|
72
|
-
2
|
73
|
-
];
|
74
|
-
}
|
75
|
-
if (!filePath.includes("node_modules"))
|
76
|
-
return [
|
77
|
-
3,
|
78
|
-
3
|
79
|
-
];
|
80
|
-
parsed = parseNodeModulePath(filePath);
|
81
|
-
baseDir = parsed.dir;
|
82
|
-
pkgName2 = parsed.name;
|
83
|
-
subpath = parsed.subpath;
|
84
|
-
pkgPath = path.join(baseDir, pkgName2);
|
85
|
-
return [
|
86
|
-
3,
|
87
|
-
8
|
88
|
-
];
|
89
|
-
case 3:
|
90
|
-
MODERN_UTILS_PATH = "packages/toolkit/utils";
|
91
|
-
MODERN_UTILS_PATH_REGEX = new RegExp("(.*".concat(MODERN_UTILS_PATH, ")"));
|
92
|
-
match = filePath.match(MODERN_UTILS_PATH_REGEX);
|
93
|
-
if (!match)
|
94
|
-
return [
|
95
|
-
3,
|
96
|
-
4
|
97
|
-
];
|
98
|
-
_tmp = path.join(match[0], "package.json");
|
99
|
-
return [
|
100
|
-
3,
|
101
|
-
6
|
102
|
-
];
|
103
|
-
case 4:
|
104
|
-
return [
|
105
|
-
4,
|
106
|
-
pkgUp({
|
107
|
-
cwd: path.dirname(filePath)
|
108
|
-
})
|
109
|
-
];
|
110
|
-
case 5:
|
111
|
-
_tmp = _state2.sent();
|
112
|
-
_state2.label = 6;
|
113
|
-
case 6:
|
114
|
-
packageJsonPath = _tmp;
|
115
|
-
if (!(packageJsonPath && isSubPath(dependencySearchRoot, packageJsonPath)))
|
116
|
-
return [
|
117
|
-
3,
|
118
|
-
8
|
119
|
-
];
|
120
|
-
return [
|
121
|
-
4,
|
122
|
-
fse.readJSON(packageJsonPath)
|
123
|
-
];
|
124
|
-
case 7:
|
125
|
-
packageJson = _state2.sent();
|
126
|
-
pkgPath = baseDir = path.dirname(packageJsonPath);
|
127
|
-
subpath = path.relative(baseDir, filePath);
|
128
|
-
pkgName2 = packageJson.name;
|
129
|
-
_state2.label = 8;
|
130
|
-
case 8:
|
131
|
-
if (!baseDir) {
|
132
|
-
return [
|
133
|
-
2
|
134
|
-
];
|
135
|
-
}
|
136
|
-
return [
|
137
|
-
4,
|
138
|
-
Promise.all(_to_consumable_array(reasons.parents).map(function(p) {
|
139
|
-
return resolveTracedPath(base, p);
|
140
|
-
}))
|
141
|
-
];
|
142
|
-
case 9:
|
143
|
-
parents = _state2.sent();
|
144
|
-
tracedFile2 = {
|
145
|
-
path: filePath,
|
146
|
-
parents,
|
147
|
-
isDirectDep: parents.some(function(parent) {
|
148
|
-
return isSubPath(appDir, parent) && !isSubPath(currentProjectModules, parent);
|
149
|
-
}),
|
150
|
-
subpath,
|
151
|
-
pkgName: pkgName2,
|
152
|
-
pkgPath
|
153
|
-
};
|
154
|
-
return [
|
155
|
-
2,
|
156
|
-
[
|
157
|
-
filePath,
|
158
|
-
tracedFile2
|
159
|
-
]
|
160
|
-
];
|
161
|
-
}
|
162
|
-
});
|
163
|
-
});
|
164
|
-
return function(_2) {
|
165
|
-
return _ref2.apply(this, arguments);
|
166
|
-
};
|
167
|
-
}())).then(function(r) {
|
168
|
-
return r.filter(Boolean);
|
169
|
-
})
|
170
|
-
];
|
171
|
-
case 3:
|
172
|
-
tracedFiles = _.apply(Object, [
|
173
|
-
_state.sent()
|
174
|
-
]);
|
175
|
-
tracedPackages = {};
|
176
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
177
|
-
_state.label = 4;
|
178
|
-
case 4:
|
179
|
-
_state.trys.push([
|
180
|
-
4,
|
181
|
-
11,
|
182
|
-
12,
|
183
|
-
13
|
184
|
-
]);
|
185
|
-
_iterator = Object.values(tracedFiles)[Symbol.iterator]();
|
186
|
-
_state.label = 5;
|
187
|
-
case 5:
|
188
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
189
|
-
return [
|
190
|
-
3,
|
191
|
-
10
|
192
|
-
];
|
193
|
-
tracedFile = _step.value;
|
194
|
-
pkgName = tracedFile.pkgName;
|
195
|
-
tracedPackage = tracedPackages[pkgName];
|
196
|
-
return [
|
197
|
-
4,
|
198
|
-
readPackageJSON(tracedFile.pkgPath, {
|
199
|
-
cache: true
|
200
|
-
}).catch(function() {
|
201
|
-
})
|
202
|
-
];
|
203
|
-
case 6:
|
204
|
-
pkgJSON = _state.sent();
|
205
|
-
if (!pkgJSON) {
|
206
|
-
pkgJSON = {
|
207
|
-
name: pkgName,
|
208
|
-
version: "0.0.0"
|
209
|
-
};
|
210
|
-
}
|
211
|
-
if (!tracedPackage) {
|
212
|
-
tracedPackage = {
|
213
|
-
name: pkgName,
|
214
|
-
versions: {}
|
215
|
-
};
|
216
|
-
tracedPackages[pkgName] = tracedPackage;
|
217
|
-
}
|
218
|
-
tracedPackageVersion = tracedPackage.versions[pkgJSON.version];
|
219
|
-
if (!tracedPackageVersion) {
|
220
|
-
tracedPackageVersion = {
|
221
|
-
path: tracedFile.pkgPath,
|
222
|
-
files: [],
|
223
|
-
isDirectDep: false,
|
224
|
-
pkgJSON
|
225
|
-
};
|
226
|
-
if (tracedFile.isDirectDep) {
|
227
|
-
tracedPackageVersion.isDirectDep = tracedFile.isDirectDep;
|
228
|
-
}
|
229
|
-
tracedPackage.versions[pkgJSON.version] = tracedPackageVersion;
|
230
|
-
}
|
231
|
-
tracedFile.pkgName = pkgName;
|
232
|
-
tracedFile.pkgVersion = pkgJSON.version;
|
233
|
-
shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
|
234
|
-
if (!(tracedFile.path.startsWith(tracedFile.pkgPath) && // Merged package files are based on the version, not on paths, to handle some boundary cases
|
235
|
-
tracedPackageVersion.pkgJSON.version === tracedFile.pkgVersion))
|
236
|
-
return [
|
237
|
-
3,
|
238
|
-
9
|
239
|
-
];
|
240
|
-
if (!shouldCopyWholePackage)
|
241
|
-
return [
|
242
|
-
3,
|
243
|
-
8
|
244
|
-
];
|
245
|
-
return [
|
246
|
-
4,
|
247
|
-
readDirRecursive(tracedFile.pkgPath)
|
248
|
-
];
|
249
|
-
case 7:
|
250
|
-
allFiles = _state.sent();
|
251
|
-
(_tracedPackageVersion_files = tracedPackageVersion.files).push.apply(_tracedPackageVersion_files, _to_consumable_array(allFiles));
|
252
|
-
return [
|
253
|
-
3,
|
254
|
-
9
|
255
|
-
];
|
256
|
-
case 8:
|
257
|
-
tracedPackageVersion.files.push(tracedFile.path);
|
258
|
-
_state.label = 9;
|
259
|
-
case 9:
|
260
|
-
_iteratorNormalCompletion = true;
|
261
|
-
return [
|
262
|
-
3,
|
263
|
-
5
|
264
|
-
];
|
265
|
-
case 10:
|
266
|
-
return [
|
267
|
-
3,
|
268
|
-
13
|
269
|
-
];
|
270
|
-
case 11:
|
271
|
-
err = _state.sent();
|
272
|
-
_didIteratorError = true;
|
273
|
-
_iteratorError = err;
|
274
|
-
return [
|
275
|
-
3,
|
276
|
-
13
|
277
|
-
];
|
278
|
-
case 12:
|
279
|
-
try {
|
280
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
281
|
-
_iterator.return();
|
282
|
-
}
|
283
|
-
} finally {
|
284
|
-
if (_didIteratorError) {
|
285
|
-
throw _iteratorError;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
return [
|
289
|
-
7
|
290
|
-
];
|
291
|
-
case 13:
|
292
|
-
multiVersionPkgs = {};
|
293
|
-
singleVersionPackages = [];
|
294
|
-
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
295
|
-
try {
|
296
|
-
for (_iterator1 = Object.values(tracedPackages)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
297
|
-
tracedPackage1 = _step1.value;
|
298
|
-
versions = Object.keys(tracedPackage1.versions);
|
299
|
-
if (versions.length === 1) {
|
300
|
-
singleVersionPackages.push(tracedPackage1.name);
|
301
|
-
continue;
|
302
|
-
}
|
303
|
-
multiVersionPkgs[tracedPackage1.name] = {};
|
304
|
-
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
305
|
-
try {
|
306
|
-
for (_iterator2 = versions[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
307
|
-
version = _step2.value;
|
308
|
-
multiVersionPkgs[tracedPackage1.name][version] = findPackageParents(tracedPackage1, version, tracedFiles);
|
309
|
-
}
|
310
|
-
} catch (err2) {
|
311
|
-
_didIteratorError2 = true;
|
312
|
-
_iteratorError2 = err2;
|
313
|
-
} finally {
|
314
|
-
try {
|
315
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
316
|
-
_iterator2.return();
|
317
|
-
}
|
318
|
-
} finally {
|
319
|
-
if (_didIteratorError2) {
|
320
|
-
throw _iteratorError2;
|
321
|
-
}
|
322
|
-
}
|
323
|
-
}
|
324
|
-
}
|
325
|
-
} catch (err2) {
|
326
|
-
_didIteratorError1 = true;
|
327
|
-
_iteratorError1 = err2;
|
328
|
-
} finally {
|
329
|
-
try {
|
330
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
331
|
-
_iterator1.return();
|
332
|
-
}
|
333
|
-
} finally {
|
334
|
-
if (_didIteratorError1) {
|
335
|
-
throw _iteratorError1;
|
336
|
-
}
|
337
|
-
}
|
338
|
-
}
|
339
|
-
return [
|
340
|
-
4,
|
341
|
-
Promise.all(singleVersionPackages.map(function(pkgName2) {
|
342
|
-
var pkg = tracedPackages[pkgName2];
|
343
|
-
var version2 = Object.keys(pkg.versions)[0];
|
344
|
-
return writePackage({
|
345
|
-
pkg,
|
346
|
-
version: version2,
|
347
|
-
projectDir: serverRootDir
|
348
|
-
});
|
349
|
-
}))
|
350
|
-
];
|
351
|
-
case 14:
|
352
|
-
_state.sent();
|
353
|
-
return [
|
354
|
-
4,
|
355
|
-
readPackageJSON(serverRootDir).catch(function() {
|
356
|
-
return {};
|
357
|
-
})
|
358
|
-
];
|
359
|
-
case 15:
|
360
|
-
projectPkgJson = _state.sent();
|
361
|
-
_iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
362
|
-
_state.label = 16;
|
363
|
-
case 16:
|
364
|
-
_state.trys.push([
|
365
|
-
16,
|
366
|
-
21,
|
367
|
-
22,
|
368
|
-
23
|
369
|
-
]);
|
370
|
-
_loop = function() {
|
371
|
-
var _step_value, pkgName2, pkgVersions, versionEntires, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value1, version2, parentPkgs, pkg, pkgDestPath, _iteratorNormalCompletion12, _didIteratorError12, _iteratorError12, _iterator12, _step12, parentPkg, parentPkgName, err2, err2;
|
372
|
-
return _ts_generator(this, function(_state2) {
|
373
|
-
switch (_state2.label) {
|
374
|
-
case 0:
|
375
|
-
_step_value = _sliced_to_array(_step3.value, 2), pkgName2 = _step_value[0], pkgVersions = _step_value[1];
|
376
|
-
versionEntires = Object.entries(pkgVersions).sort(function(param2, param1) {
|
377
|
-
var _param = _sliced_to_array(param2, 2), v1 = _param[0], p1 = _param[1], _param1 = _sliced_to_array(param1, 2), v2 = _param1[0], p2 = _param1[1];
|
378
|
-
var _tracedPackages_pkgName_versions_v1, _tracedPackages_pkgName_versions, _tracedPackages_pkgName, _tracedPackages_pkgName_versions_v2, _tracedPackages_pkgName_versions1, _tracedPackages_pkgName1;
|
379
|
-
var shouldHoist1 = (_tracedPackages_pkgName = tracedPackages[pkgName2]) === 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;
|
380
|
-
var shouldHoist2 = (_tracedPackages_pkgName1 = tracedPackages[pkgName2]) === 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;
|
381
|
-
if (shouldHoist1 && !shouldHoist2) {
|
382
|
-
return -1;
|
383
|
-
}
|
384
|
-
if (!shouldHoist1 && shouldHoist2) {
|
385
|
-
return 1;
|
386
|
-
}
|
387
|
-
if (p1.length === 0) {
|
388
|
-
return -1;
|
389
|
-
}
|
390
|
-
if (p2.length === 0) {
|
391
|
-
return 1;
|
392
|
-
}
|
393
|
-
return semver.lt(v1, v2, {
|
394
|
-
loose: true
|
395
|
-
}) ? 1 : -1;
|
396
|
-
});
|
397
|
-
_iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
398
|
-
_state2.label = 1;
|
399
|
-
case 1:
|
400
|
-
_state2.trys.push([
|
401
|
-
1,
|
402
|
-
14,
|
403
|
-
15,
|
404
|
-
16
|
405
|
-
]);
|
406
|
-
_iterator4 = versionEntires[Symbol.iterator]();
|
407
|
-
_state2.label = 2;
|
408
|
-
case 2:
|
409
|
-
if (!!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done))
|
410
|
-
return [
|
411
|
-
3,
|
412
|
-
13
|
413
|
-
];
|
414
|
-
_step_value1 = _sliced_to_array(_step4.value, 2), version2 = _step_value1[0], parentPkgs = _step_value1[1];
|
415
|
-
pkg = tracedPackages[pkgName2];
|
416
|
-
pkgDestPath = ".modernjs/".concat(pkgName2, "@").concat(version2, "/node_modules/").concat(pkgName2);
|
417
|
-
return [
|
418
|
-
4,
|
419
|
-
writePackage({
|
420
|
-
pkg,
|
421
|
-
version: version2,
|
422
|
-
projectDir: serverRootDir,
|
423
|
-
_pkgPath: pkgDestPath
|
424
|
-
})
|
425
|
-
];
|
426
|
-
case 3:
|
427
|
-
_state2.sent();
|
428
|
-
return [
|
429
|
-
4,
|
430
|
-
linkPackage(pkgDestPath, "".concat(pkgName2), serverRootDir)
|
431
|
-
];
|
432
|
-
case 4:
|
433
|
-
_state2.sent();
|
434
|
-
_iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
435
|
-
_state2.label = 5;
|
436
|
-
case 5:
|
437
|
-
_state2.trys.push([
|
438
|
-
5,
|
439
|
-
10,
|
440
|
-
11,
|
441
|
-
12
|
442
|
-
]);
|
443
|
-
_iterator12 = parentPkgs[Symbol.iterator]();
|
444
|
-
_state2.label = 6;
|
445
|
-
case 6:
|
446
|
-
if (!!(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done))
|
447
|
-
return [
|
448
|
-
3,
|
449
|
-
9
|
450
|
-
];
|
451
|
-
parentPkg = _step12.value;
|
452
|
-
parentPkgName = parentPkg.replace(/@[^@]+$/, "");
|
453
|
-
return [
|
454
|
-
4,
|
455
|
-
multiVersionPkgs[parentPkgName] ? linkPackage(pkgDestPath, ".modernjs/".concat(parentPkg, "/node_modules/").concat(pkgName2), serverRootDir) : linkPackage(pkgDestPath, "".concat(parentPkgName, "/node_modules/").concat(pkgName2), serverRootDir)
|
456
|
-
];
|
457
|
-
case 7:
|
458
|
-
_state2.sent();
|
459
|
-
_state2.label = 8;
|
460
|
-
case 8:
|
461
|
-
_iteratorNormalCompletion12 = true;
|
462
|
-
return [
|
463
|
-
3,
|
464
|
-
6
|
465
|
-
];
|
466
|
-
case 9:
|
467
|
-
return [
|
468
|
-
3,
|
469
|
-
12
|
470
|
-
];
|
471
|
-
case 10:
|
472
|
-
err2 = _state2.sent();
|
473
|
-
_didIteratorError12 = true;
|
474
|
-
_iteratorError12 = err2;
|
475
|
-
return [
|
476
|
-
3,
|
477
|
-
12
|
478
|
-
];
|
479
|
-
case 11:
|
480
|
-
try {
|
481
|
-
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
482
|
-
_iterator12.return();
|
483
|
-
}
|
484
|
-
} finally {
|
485
|
-
if (_didIteratorError12) {
|
486
|
-
throw _iteratorError12;
|
487
|
-
}
|
488
|
-
}
|
489
|
-
return [
|
490
|
-
7
|
491
|
-
];
|
492
|
-
case 12:
|
493
|
-
_iteratorNormalCompletion4 = true;
|
494
|
-
return [
|
495
|
-
3,
|
496
|
-
2
|
497
|
-
];
|
498
|
-
case 13:
|
499
|
-
return [
|
500
|
-
3,
|
501
|
-
16
|
502
|
-
];
|
503
|
-
case 14:
|
504
|
-
err2 = _state2.sent();
|
505
|
-
_didIteratorError4 = true;
|
506
|
-
_iteratorError4 = err2;
|
507
|
-
return [
|
508
|
-
3,
|
509
|
-
16
|
510
|
-
];
|
511
|
-
case 15:
|
512
|
-
try {
|
513
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
514
|
-
_iterator4.return();
|
515
|
-
}
|
516
|
-
} finally {
|
517
|
-
if (_didIteratorError4) {
|
518
|
-
throw _iteratorError4;
|
519
|
-
}
|
520
|
-
}
|
521
|
-
return [
|
522
|
-
7
|
523
|
-
];
|
524
|
-
case 16:
|
525
|
-
return [
|
526
|
-
2
|
527
|
-
];
|
528
|
-
}
|
529
|
-
});
|
530
|
-
};
|
531
|
-
_iterator3 = Object.entries(multiVersionPkgs)[Symbol.iterator]();
|
532
|
-
_state.label = 17;
|
533
|
-
case 17:
|
534
|
-
if (!!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done))
|
535
|
-
return [
|
536
|
-
3,
|
537
|
-
20
|
538
|
-
];
|
539
|
-
return [
|
540
|
-
5,
|
541
|
-
_ts_values(_loop())
|
542
|
-
];
|
543
|
-
case 18:
|
544
|
-
_state.sent();
|
545
|
-
_state.label = 19;
|
546
|
-
case 19:
|
547
|
-
_iteratorNormalCompletion3 = true;
|
548
|
-
return [
|
549
|
-
3,
|
550
|
-
17
|
551
|
-
];
|
552
|
-
case 20:
|
553
|
-
return [
|
554
|
-
3,
|
555
|
-
23
|
556
|
-
];
|
557
|
-
case 21:
|
558
|
-
err = _state.sent();
|
559
|
-
_didIteratorError3 = true;
|
560
|
-
_iteratorError3 = err;
|
561
|
-
return [
|
562
|
-
3,
|
563
|
-
23
|
564
|
-
];
|
565
|
-
case 22:
|
566
|
-
try {
|
567
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
568
|
-
_iterator3.return();
|
569
|
-
}
|
570
|
-
} finally {
|
571
|
-
if (_didIteratorError3) {
|
572
|
-
throw _iteratorError3;
|
573
|
-
}
|
574
|
-
}
|
575
|
-
return [
|
576
|
-
7
|
577
|
-
];
|
578
|
-
case 23:
|
579
|
-
outputPkgPath = path.join(serverRootDir, "package.json");
|
580
|
-
newPkgJson = {
|
581
|
-
name: "".concat(projectPkgJson.name || "modernjs-project", "-prod"),
|
582
|
-
version: projectPkgJson.version || "0.0.0",
|
583
|
-
private: true,
|
584
|
-
type: projectPkgJson.type || "commonjs",
|
585
|
-
dependencies: Object.fromEntries(_to_consumable_array(Object.values(tracedPackages).map(function(pkg) {
|
586
|
-
return [
|
587
|
-
pkg.name,
|
588
|
-
Object.keys(pkg.versions)[0]
|
589
|
-
];
|
590
|
-
})).sort(function(param2, param1) {
|
591
|
-
var _param = _sliced_to_array(param2, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
|
592
|
-
return a.localeCompare(b);
|
593
|
-
}))
|
594
|
-
};
|
595
|
-
finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
|
596
|
-
return [
|
597
|
-
4,
|
598
|
-
fse.writeJSON(outputPkgPath, finalPkgJson)
|
599
|
-
];
|
600
|
-
case 24:
|
601
|
-
_state.sent();
|
602
|
-
return [
|
603
|
-
2
|
604
|
-
];
|
605
|
-
}
|
606
|
-
});
|
607
|
-
});
|
608
|
-
return function handleDependencies2(_) {
|
609
|
-
return _ref.apply(this, arguments);
|
610
|
-
};
|
611
|
-
}();
|
612
|
-
export {
|
613
|
-
handleDependencies,
|
614
|
-
nodeFileTrace
|
615
|
-
};
|