webpack 5.12.3 → 5.16.0
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/ChunkGraph.js +14 -4
- package/lib/Compilation.js +20 -15
- package/lib/Compiler.js +6 -3
- package/lib/ContextModule.js +2 -2
- package/lib/ContextModuleFactory.js +6 -4
- package/lib/ExportsInfo.js +0 -1
- package/lib/ExternalModuleFactoryPlugin.js +46 -3
- package/lib/FileSystemInfo.js +288 -157
- package/lib/IgnoreErrorModuleFactory.js +39 -0
- package/lib/MultiCompiler.js +2 -0
- package/lib/NormalModuleFactory.js +26 -7
- package/lib/WatchIgnorePlugin.js +6 -1
- package/lib/WebpackIsIncludedPlugin.js +85 -0
- package/lib/WebpackOptionsApply.js +2 -0
- package/lib/cache/PackFileCacheStrategy.js +5 -5
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +2 -17
- package/lib/dependencies/URLDependency.js +45 -3
- package/lib/dependencies/URLPlugin.js +33 -7
- package/lib/dependencies/WebpackIsIncludedDependency.js +80 -0
- package/lib/ids/IdHelpers.js +8 -3
- package/lib/javascript/JavascriptModulesPlugin.js +4 -3
- package/lib/library/AssignLibraryPlugin.js +13 -4
- package/lib/library/EnableLibraryPlugin.js +12 -0
- package/lib/optimize/InnerGraph.js +32 -0
- package/lib/optimize/SplitChunksPlugin.js +4 -1
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ShareRuntimeModule.js +2 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -0
- package/lib/util/fs.js +51 -11
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/processAsyncTree.js +61 -0
- package/package.json +9 -7
- package/schemas/WebpackOptions.json +62 -25
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +2 -1
- package/types.d.ts +339 -236
package/lib/FileSystemInfo.js
CHANGED
@@ -11,31 +11,27 @@ const AsyncQueue = require("./util/AsyncQueue");
|
|
11
11
|
const createHash = require("./util/createHash");
|
12
12
|
const { join, dirname, relative } = require("./util/fs");
|
13
13
|
const makeSerializable = require("./util/makeSerializable");
|
14
|
+
const processAsyncTree = require("./util/processAsyncTree");
|
14
15
|
|
15
16
|
/** @typedef {import("./WebpackError")} WebpackError */
|
16
17
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
17
18
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
18
19
|
|
19
|
-
const
|
20
|
-
resolveToContext: true,
|
21
|
-
exportsFields: []
|
22
|
-
});
|
23
|
-
const resolve = createResolver({
|
24
|
-
extensions: [".js", ".json", ".node"],
|
25
|
-
conditionNames: ["require"]
|
26
|
-
});
|
20
|
+
const supportsEsm = +process.versions.modules >= 83;
|
27
21
|
|
28
22
|
let FS_ACCURACY = 2000;
|
29
23
|
|
30
24
|
const EMPTY_SET = new Set();
|
31
25
|
|
32
|
-
const
|
33
|
-
const
|
34
|
-
const
|
35
|
-
const
|
36
|
-
const
|
37
|
-
const
|
38
|
-
const
|
26
|
+
const RBDT_RESOLVE_CJS = 0;
|
27
|
+
const RBDT_RESOLVE_ESM = 1;
|
28
|
+
const RBDT_RESOLVE_DIRECTORY = 2;
|
29
|
+
const RBDT_RESOLVE_CJS_FILE = 3;
|
30
|
+
const RBDT_RESOLVE_ESM_FILE = 4;
|
31
|
+
const RBDT_DIRECTORY = 5;
|
32
|
+
const RBDT_FILE = 6;
|
33
|
+
const RBDT_DIRECTORY_DEPENDENCIES = 7;
|
34
|
+
const RBDT_FILE_DEPENDENCIES = 8;
|
39
35
|
|
40
36
|
const INVALID = Symbol("invalid");
|
41
37
|
|
@@ -880,6 +876,8 @@ class FileSystemInfo {
|
|
880
876
|
this._cachedDeprecatedFileTimestamps = undefined;
|
881
877
|
this._cachedDeprecatedContextTimestamps = undefined;
|
882
878
|
|
879
|
+
this._warnAboutExperimentalEsmTracking = false;
|
880
|
+
|
883
881
|
this._statCreatedSnapshots = 0;
|
884
882
|
this._statTestedSnapshotsCached = 0;
|
885
883
|
this._statTestedSnapshotsNotCached = 0;
|
@@ -1052,6 +1050,26 @@ class FileSystemInfo {
|
|
1052
1050
|
this.contextHashQueue.add(path, callback);
|
1053
1051
|
}
|
1054
1052
|
|
1053
|
+
_createBuildDependenciesResolvers() {
|
1054
|
+
const resolveContext = createResolver({
|
1055
|
+
resolveToContext: true,
|
1056
|
+
exportsFields: [],
|
1057
|
+
fileSystem: this.fs
|
1058
|
+
});
|
1059
|
+
const resolveCjs = createResolver({
|
1060
|
+
extensions: [".js", ".json", ".node"],
|
1061
|
+
conditionNames: ["require", "node"],
|
1062
|
+
fileSystem: this.fs
|
1063
|
+
});
|
1064
|
+
const resolveEsm = createResolver({
|
1065
|
+
extensions: [".js", ".json", ".node"],
|
1066
|
+
fullySpecified: true,
|
1067
|
+
conditionNames: ["import", "node"],
|
1068
|
+
fileSystem: this.fs
|
1069
|
+
});
|
1070
|
+
return { resolveContext, resolveEsm, resolveCjs };
|
1071
|
+
}
|
1072
|
+
|
1055
1073
|
/**
|
1056
1074
|
* @param {string} context context directory
|
1057
1075
|
* @param {Iterable<string>} deps dependencies
|
@@ -1059,11 +1077,21 @@ class FileSystemInfo {
|
|
1059
1077
|
* @returns {void}
|
1060
1078
|
*/
|
1061
1079
|
resolveBuildDependencies(context, deps, callback) {
|
1080
|
+
const {
|
1081
|
+
resolveContext,
|
1082
|
+
resolveEsm,
|
1083
|
+
resolveCjs
|
1084
|
+
} = this._createBuildDependenciesResolvers();
|
1085
|
+
|
1062
1086
|
/** @type {Set<string>} */
|
1063
1087
|
const files = new Set();
|
1064
1088
|
/** @type {Set<string>} */
|
1089
|
+
const fileSymlinks = new Set();
|
1090
|
+
/** @type {Set<string>} */
|
1065
1091
|
const directories = new Set();
|
1066
1092
|
/** @type {Set<string>} */
|
1093
|
+
const directorySymlinks = new Set();
|
1094
|
+
/** @type {Set<string>} */
|
1067
1095
|
const missing = new Set();
|
1068
1096
|
/** @type {Set<string>} */
|
1069
1097
|
const resolveFiles = new Set();
|
@@ -1073,83 +1101,99 @@ class FileSystemInfo {
|
|
1073
1101
|
const resolveMissing = new Set();
|
1074
1102
|
/** @type {Map<string, string>} */
|
1075
1103
|
const resolveResults = new Map();
|
1076
|
-
|
1077
|
-
const
|
1078
|
-
|
1104
|
+
const invalidResolveResults = new Set();
|
1105
|
+
const resolverContext = {
|
1106
|
+
fileDependencies: resolveFiles,
|
1107
|
+
contextDependencies: resolveDirectories,
|
1108
|
+
missingDependencies: resolveMissing
|
1109
|
+
};
|
1110
|
+
processAsyncTree(
|
1111
|
+
Array.from(deps, dep => ({
|
1112
|
+
type: RBDT_RESOLVE_CJS,
|
1113
|
+
context,
|
1114
|
+
path: dep,
|
1115
|
+
expected: undefined
|
1116
|
+
})),
|
1117
|
+
20,
|
1118
|
+
({ type, context, path, expected }, push, callback) => {
|
1079
1119
|
const resolveDirectory = path => {
|
1080
1120
|
const key = `d\n${context}\n${path}`;
|
1081
1121
|
if (resolveResults.has(key)) {
|
1082
1122
|
return callback();
|
1083
1123
|
}
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1124
|
+
resolveResults.set(key, undefined);
|
1125
|
+
resolveContext(context, path, resolverContext, (err, result) => {
|
1126
|
+
if (err) {
|
1127
|
+
invalidResolveResults.add(key);
|
1128
|
+
if (
|
1129
|
+
err.code === "ENOENT" ||
|
1130
|
+
err.code === "UNDECLARED_DEPENDENCY"
|
1131
|
+
) {
|
1132
|
+
return callback();
|
1133
|
+
}
|
1134
|
+
err.message += `\nwhile resolving '${path}' in ${context} to a directory`;
|
1135
|
+
return callback(err);
|
1136
|
+
}
|
1137
|
+
resolveResults.set(key, result);
|
1138
|
+
push({
|
1139
|
+
type: RBDT_DIRECTORY,
|
1140
|
+
context: undefined,
|
1141
|
+
path: result,
|
1142
|
+
expected: undefined
|
1143
|
+
});
|
1144
|
+
callback();
|
1145
|
+
});
|
1146
|
+
};
|
1147
|
+
const resolveFile = (path, symbol, resolve) => {
|
1148
|
+
const key = `${symbol}\n${context}\n${path}`;
|
1149
|
+
if (resolveResults.has(key)) {
|
1150
|
+
return callback();
|
1151
|
+
}
|
1152
|
+
resolveResults.set(key, undefined);
|
1153
|
+
resolve(context, path, resolverContext, (err, result) => {
|
1154
|
+
if (expected) {
|
1155
|
+
if (result === expected) {
|
1156
|
+
resolveResults.set(key, result);
|
1157
|
+
} else {
|
1158
|
+
invalidResolveResults.add(key);
|
1159
|
+
this.logger.debug(
|
1160
|
+
`Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${result}' instead. Resolving dependencies are ignored for this path.`
|
1161
|
+
);
|
1162
|
+
}
|
1163
|
+
} else {
|
1093
1164
|
if (err) {
|
1165
|
+
invalidResolveResults.add(key);
|
1094
1166
|
if (
|
1095
1167
|
err.code === "ENOENT" ||
|
1096
1168
|
err.code === "UNDECLARED_DEPENDENCY"
|
1097
1169
|
) {
|
1098
1170
|
return callback();
|
1099
1171
|
}
|
1100
|
-
err.message += `\nwhile resolving '${path}' in ${context}
|
1172
|
+
err.message += `\nwhile resolving '${path}' in ${context} as file`;
|
1101
1173
|
return callback(err);
|
1102
1174
|
}
|
1103
1175
|
resolveResults.set(key, result);
|
1104
|
-
|
1105
|
-
type:
|
1106
|
-
|
1176
|
+
push({
|
1177
|
+
type: RBDT_FILE,
|
1178
|
+
context: undefined,
|
1179
|
+
path: result,
|
1180
|
+
expected: undefined
|
1107
1181
|
});
|
1108
|
-
callback();
|
1109
|
-
}
|
1110
|
-
);
|
1111
|
-
};
|
1112
|
-
const resolveFile = path => {
|
1113
|
-
const key = `f\n${context}\n${path}`;
|
1114
|
-
if (resolveResults.has(key)) {
|
1115
|
-
return callback();
|
1116
|
-
}
|
1117
|
-
resolve(
|
1118
|
-
context,
|
1119
|
-
path,
|
1120
|
-
{
|
1121
|
-
fileDependencies: resolveFiles,
|
1122
|
-
contextDependencies: resolveDirectories,
|
1123
|
-
missingDependencies: resolveMissing
|
1124
|
-
},
|
1125
|
-
(err, result) => {
|
1126
|
-
if (expected) {
|
1127
|
-
if (result === expected) {
|
1128
|
-
resolveResults.set(key, result);
|
1129
|
-
}
|
1130
|
-
} else {
|
1131
|
-
if (err) {
|
1132
|
-
if (
|
1133
|
-
err.code === "ENOENT" ||
|
1134
|
-
err.code === "UNDECLARED_DEPENDENCY"
|
1135
|
-
) {
|
1136
|
-
return callback();
|
1137
|
-
}
|
1138
|
-
err.message += `\nwhile resolving '${path}' in ${context} as file`;
|
1139
|
-
return callback(err);
|
1140
|
-
}
|
1141
|
-
resolveResults.set(key, result);
|
1142
|
-
queue.push({
|
1143
|
-
type: RBDT_FILE,
|
1144
|
-
path: result
|
1145
|
-
});
|
1146
|
-
}
|
1147
|
-
callback();
|
1148
1182
|
}
|
1149
|
-
|
1183
|
+
callback();
|
1184
|
+
});
|
1150
1185
|
};
|
1151
1186
|
switch (type) {
|
1152
|
-
case
|
1187
|
+
case RBDT_RESOLVE_CJS: {
|
1188
|
+
const isDirectory = /[\\/]$/.test(path);
|
1189
|
+
if (isDirectory) {
|
1190
|
+
resolveDirectory(path.slice(0, path.length - 1));
|
1191
|
+
} else {
|
1192
|
+
resolveFile(path, "f", resolveCjs);
|
1193
|
+
}
|
1194
|
+
break;
|
1195
|
+
}
|
1196
|
+
case RBDT_RESOLVE_ESM: {
|
1153
1197
|
const isDirectory = /[\\/]$/.test(path);
|
1154
1198
|
if (isDirectory) {
|
1155
1199
|
resolveDirectory(path.slice(0, path.length - 1));
|
@@ -1162,8 +1206,12 @@ class FileSystemInfo {
|
|
1162
1206
|
resolveDirectory(path);
|
1163
1207
|
break;
|
1164
1208
|
}
|
1165
|
-
case
|
1166
|
-
resolveFile(path);
|
1209
|
+
case RBDT_RESOLVE_CJS_FILE: {
|
1210
|
+
resolveFile(path, "f", resolveCjs);
|
1211
|
+
break;
|
1212
|
+
}
|
1213
|
+
case RBDT_RESOLVE_ESM_FILE: {
|
1214
|
+
resolveFile(path, "e", resolveEsm);
|
1167
1215
|
break;
|
1168
1216
|
}
|
1169
1217
|
case RBDT_FILE: {
|
@@ -1171,18 +1219,22 @@ class FileSystemInfo {
|
|
1171
1219
|
callback();
|
1172
1220
|
break;
|
1173
1221
|
}
|
1174
|
-
|
1222
|
+
files.add(path);
|
1223
|
+
this.fs.realpath(path, (err, _realPath) => {
|
1175
1224
|
if (err) return callback(err);
|
1225
|
+
const realPath = /** @type {string} */ (_realPath);
|
1176
1226
|
if (realPath !== path) {
|
1227
|
+
fileSymlinks.add(path);
|
1177
1228
|
resolveFiles.add(path);
|
1178
|
-
|
1179
|
-
if (!files.has(realPath)) {
|
1229
|
+
if (files.has(realPath)) return callback();
|
1180
1230
|
files.add(realPath);
|
1181
|
-
queue.push({
|
1182
|
-
type: RBDT_FILE_DEPENDENCIES,
|
1183
|
-
path: realPath
|
1184
|
-
});
|
1185
1231
|
}
|
1232
|
+
push({
|
1233
|
+
type: RBDT_FILE_DEPENDENCIES,
|
1234
|
+
context: undefined,
|
1235
|
+
path: realPath,
|
1236
|
+
expected: undefined
|
1237
|
+
});
|
1186
1238
|
callback();
|
1187
1239
|
});
|
1188
1240
|
break;
|
@@ -1192,69 +1244,140 @@ class FileSystemInfo {
|
|
1192
1244
|
callback();
|
1193
1245
|
break;
|
1194
1246
|
}
|
1195
|
-
|
1247
|
+
directories.add(path);
|
1248
|
+
this.fs.realpath(path, (err, _realPath) => {
|
1196
1249
|
if (err) return callback(err);
|
1250
|
+
const realPath = /** @type {string} */ (_realPath);
|
1197
1251
|
if (realPath !== path) {
|
1252
|
+
directorySymlinks.add(path);
|
1198
1253
|
resolveFiles.add(path);
|
1199
|
-
|
1200
|
-
if (!directories.has(realPath)) {
|
1254
|
+
if (directories.has(realPath)) return callback();
|
1201
1255
|
directories.add(realPath);
|
1202
|
-
queue.push({
|
1203
|
-
type: RBDT_DIRECTORY_DEPENDENCIES,
|
1204
|
-
path: realPath
|
1205
|
-
});
|
1206
1256
|
}
|
1257
|
+
push({
|
1258
|
+
type: RBDT_DIRECTORY_DEPENDENCIES,
|
1259
|
+
context: undefined,
|
1260
|
+
path: realPath,
|
1261
|
+
expected: undefined
|
1262
|
+
});
|
1207
1263
|
callback();
|
1208
1264
|
});
|
1209
1265
|
break;
|
1210
1266
|
}
|
1211
1267
|
case RBDT_FILE_DEPENDENCIES: {
|
1212
|
-
//
|
1268
|
+
// Check for known files without dependencies
|
1269
|
+
if (/\.json5?$|\.yarn-integrity$|yarn\.lock$|\.ya?ml/.test(path)) {
|
1270
|
+
process.nextTick(callback);
|
1271
|
+
break;
|
1272
|
+
}
|
1273
|
+
// Check commonjs cache for the module
|
1213
1274
|
/** @type {NodeModule} */
|
1214
1275
|
const module = require.cache[path];
|
1215
1276
|
if (module && Array.isArray(module.children)) {
|
1216
1277
|
children: for (const child of module.children) {
|
1217
1278
|
let childPath = child.filename;
|
1218
1279
|
if (childPath) {
|
1219
|
-
|
1280
|
+
push({
|
1220
1281
|
type: RBDT_FILE,
|
1221
|
-
|
1282
|
+
context: undefined,
|
1283
|
+
path: childPath,
|
1284
|
+
expected: undefined
|
1222
1285
|
});
|
1223
|
-
if (childPath.endsWith(".js"))
|
1224
|
-
childPath = childPath.slice(0, -3);
|
1225
1286
|
const context = dirname(this.fs, path);
|
1226
1287
|
for (const modulePath of module.paths) {
|
1227
1288
|
if (childPath.startsWith(modulePath)) {
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1289
|
+
let request = childPath.slice(modulePath.length + 1);
|
1290
|
+
if (request.endsWith(".js"))
|
1291
|
+
request = request.slice(0, -3);
|
1292
|
+
push({
|
1293
|
+
type: RBDT_RESOLVE_CJS_FILE,
|
1231
1294
|
context,
|
1232
1295
|
path: request,
|
1233
|
-
expected:
|
1296
|
+
expected: child.filename
|
1234
1297
|
});
|
1235
1298
|
continue children;
|
1236
1299
|
}
|
1237
1300
|
}
|
1238
1301
|
let request = relative(this.fs, context, childPath);
|
1302
|
+
if (request.endsWith(".js")) request = request.slice(0, -3);
|
1239
1303
|
request = request.replace(/\\/g, "/");
|
1240
1304
|
if (!request.startsWith("../")) request = `./${request}`;
|
1241
|
-
|
1242
|
-
type:
|
1305
|
+
push({
|
1306
|
+
type: RBDT_RESOLVE_CJS_FILE,
|
1243
1307
|
context,
|
1244
1308
|
path: request,
|
1245
1309
|
expected: child.filename
|
1246
1310
|
});
|
1247
1311
|
}
|
1248
1312
|
}
|
1313
|
+
} else if (supportsEsm && /\.m?js$/.test(path)) {
|
1314
|
+
if (!this._warnAboutExperimentalEsmTracking) {
|
1315
|
+
this.logger.info(
|
1316
|
+
"Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.\n" +
|
1317
|
+
"Until a full solution is available webpack uses an experimental ESM tracking based on parsing.\n" +
|
1318
|
+
"As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking."
|
1319
|
+
);
|
1320
|
+
this._warnAboutExperimentalEsmTracking = true;
|
1321
|
+
}
|
1322
|
+
const lexer = require("es-module-lexer");
|
1323
|
+
lexer.init.then(() => {
|
1324
|
+
this.fs.readFile(path, (err, content) => {
|
1325
|
+
if (err) return callback(err);
|
1326
|
+
try {
|
1327
|
+
const context = dirname(this.fs, path);
|
1328
|
+
const source = content.toString();
|
1329
|
+
const [imports] = lexer.parse(source);
|
1330
|
+
for (const imp of imports) {
|
1331
|
+
try {
|
1332
|
+
let dependency;
|
1333
|
+
if (imp.d === -1) {
|
1334
|
+
// import ... from "..."
|
1335
|
+
dependency = JSON.parse(
|
1336
|
+
source.substring(imp.s - 1, imp.e + 1)
|
1337
|
+
);
|
1338
|
+
} else if (imp.d > -1) {
|
1339
|
+
// import()
|
1340
|
+
let expr = source.substring(imp.s, imp.e).trim();
|
1341
|
+
if (expr[0] === "'")
|
1342
|
+
expr = `"${expr
|
1343
|
+
.slice(1, -1)
|
1344
|
+
.replace(/"/g, '\\"')}"`;
|
1345
|
+
dependency = JSON.parse(expr);
|
1346
|
+
} else {
|
1347
|
+
// e.g. import.meta
|
1348
|
+
continue;
|
1349
|
+
}
|
1350
|
+
push({
|
1351
|
+
type: RBDT_RESOLVE_ESM_FILE,
|
1352
|
+
context,
|
1353
|
+
path: dependency,
|
1354
|
+
expected: undefined
|
1355
|
+
});
|
1356
|
+
} catch (e) {
|
1357
|
+
this.logger.warn(
|
1358
|
+
`Parsing of ${path} for build dependencies failed at 'import(${source.substring(
|
1359
|
+
imp.s,
|
1360
|
+
imp.e
|
1361
|
+
)})'.\n` +
|
1362
|
+
"Build dependencies behind this expression are ignored and might cause incorrect cache invalidation."
|
1363
|
+
);
|
1364
|
+
this.logger.debug(e.stack);
|
1365
|
+
}
|
1366
|
+
}
|
1367
|
+
} catch (e) {
|
1368
|
+
this.logger.warn(
|
1369
|
+
`Parsing of ${path} for build dependencies failed and all dependencies of this file are ignored, which might cause incorrect cache invalidation..`
|
1370
|
+
);
|
1371
|
+
this.logger.debug(e.stack);
|
1372
|
+
}
|
1373
|
+
process.nextTick(callback);
|
1374
|
+
});
|
1375
|
+
}, callback);
|
1376
|
+
break;
|
1249
1377
|
} else {
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
const directory = dirname(this.fs, path);
|
1254
|
-
queue.push({
|
1255
|
-
type: RBDT_DIRECTORY,
|
1256
|
-
path: directory
|
1257
|
-
});
|
1378
|
+
this.logger.log(
|
1379
|
+
`Assuming ${path} has no dependencies as we were unable to assign it to any module system.`
|
1380
|
+
);
|
1258
1381
|
}
|
1259
1382
|
process.nextTick(callback);
|
1260
1383
|
break;
|
@@ -1271,9 +1394,11 @@ class FileSystemInfo {
|
|
1271
1394
|
resolveMissing.add(packageJson);
|
1272
1395
|
const parent = dirname(this.fs, packagePath);
|
1273
1396
|
if (parent !== packagePath) {
|
1274
|
-
|
1397
|
+
push({
|
1275
1398
|
type: RBDT_DIRECTORY_DEPENDENCIES,
|
1276
|
-
|
1399
|
+
context: undefined,
|
1400
|
+
path: parent,
|
1401
|
+
expected: undefined
|
1277
1402
|
});
|
1278
1403
|
}
|
1279
1404
|
callback();
|
@@ -1291,10 +1416,11 @@ class FileSystemInfo {
|
|
1291
1416
|
const depsObject = packageData.dependencies;
|
1292
1417
|
if (typeof depsObject === "object" && depsObject) {
|
1293
1418
|
for (const dep of Object.keys(depsObject)) {
|
1294
|
-
|
1419
|
+
push({
|
1295
1420
|
type: RBDT_RESOLVE_DIRECTORY,
|
1296
1421
|
context: packagePath,
|
1297
|
-
path: dep
|
1422
|
+
path: dep,
|
1423
|
+
expected: undefined
|
1298
1424
|
});
|
1299
1425
|
}
|
1300
1426
|
}
|
@@ -1304,38 +1430,24 @@ class FileSystemInfo {
|
|
1304
1430
|
}
|
1305
1431
|
}
|
1306
1432
|
},
|
1307
|
-
|
1433
|
+
err => {
|
1434
|
+
if (err) return callback(err);
|
1435
|
+
for (const l of fileSymlinks) files.delete(l);
|
1436
|
+
for (const l of directorySymlinks) directories.delete(l);
|
1437
|
+
for (const k of invalidResolveResults) resolveResults.delete(k);
|
1438
|
+
callback(null, {
|
1439
|
+
files,
|
1440
|
+
directories,
|
1441
|
+
missing,
|
1442
|
+
resolveResults,
|
1443
|
+
resolveDependencies: {
|
1444
|
+
files: resolveFiles,
|
1445
|
+
directories: resolveDirectories,
|
1446
|
+
missing: resolveMissing
|
1447
|
+
}
|
1448
|
+
});
|
1449
|
+
}
|
1308
1450
|
);
|
1309
|
-
queue.drain = () => {
|
1310
|
-
callback(null, {
|
1311
|
-
files,
|
1312
|
-
directories,
|
1313
|
-
missing,
|
1314
|
-
resolveResults,
|
1315
|
-
resolveDependencies: {
|
1316
|
-
files: resolveFiles,
|
1317
|
-
directories: resolveDirectories,
|
1318
|
-
missing: resolveMissing
|
1319
|
-
}
|
1320
|
-
});
|
1321
|
-
};
|
1322
|
-
queue.error = err => {
|
1323
|
-
callback(err);
|
1324
|
-
callback = () => {};
|
1325
|
-
};
|
1326
|
-
let jobQueued = false;
|
1327
|
-
for (const dep of deps) {
|
1328
|
-
queue.push({
|
1329
|
-
type: RBDT_RESOLVE,
|
1330
|
-
context,
|
1331
|
-
path: dep
|
1332
|
-
});
|
1333
|
-
jobQueued = true;
|
1334
|
-
}
|
1335
|
-
if (!jobQueued) {
|
1336
|
-
// queue won't call drain when no jobs are queue
|
1337
|
-
queue.drain();
|
1338
|
-
}
|
1339
1451
|
}
|
1340
1452
|
|
1341
1453
|
/**
|
@@ -1344,6 +1456,11 @@ class FileSystemInfo {
|
|
1344
1456
|
* @returns {void}
|
1345
1457
|
*/
|
1346
1458
|
checkResolveResultsValid(resolveResults, callback) {
|
1459
|
+
const {
|
1460
|
+
resolveCjs,
|
1461
|
+
resolveEsm,
|
1462
|
+
resolveContext
|
1463
|
+
} = this._createBuildDependenciesResolvers();
|
1347
1464
|
asyncLib.eachLimit(
|
1348
1465
|
resolveResults,
|
1349
1466
|
20,
|
@@ -1358,7 +1475,14 @@ class FileSystemInfo {
|
|
1358
1475
|
});
|
1359
1476
|
break;
|
1360
1477
|
case "f":
|
1361
|
-
|
1478
|
+
resolveCjs(context, path, {}, (err, result) => {
|
1479
|
+
if (err) return callback(err);
|
1480
|
+
if (result !== expectedResult) return callback(INVALID);
|
1481
|
+
callback();
|
1482
|
+
});
|
1483
|
+
break;
|
1484
|
+
case "e":
|
1485
|
+
resolveEsm(context, path, {}, (err, result) => {
|
1362
1486
|
if (err) return callback(err);
|
1363
1487
|
if (result !== expectedResult) return callback(INVALID);
|
1364
1488
|
callback();
|
@@ -1604,7 +1728,7 @@ class FileSystemInfo {
|
|
1604
1728
|
if (err) {
|
1605
1729
|
if (this.logger) {
|
1606
1730
|
this.logger.debug(
|
1607
|
-
`Error snapshotting file timestamp hash combination of ${path}: ${err}`
|
1731
|
+
`Error snapshotting file timestamp hash combination of ${path}: ${err.stack}`
|
1608
1732
|
);
|
1609
1733
|
}
|
1610
1734
|
jobError();
|
@@ -1632,7 +1756,7 @@ class FileSystemInfo {
|
|
1632
1756
|
if (err) {
|
1633
1757
|
if (this.logger) {
|
1634
1758
|
this.logger.debug(
|
1635
|
-
`Error snapshotting file hash of ${path}: ${err}`
|
1759
|
+
`Error snapshotting file hash of ${path}: ${err.stack}`
|
1636
1760
|
);
|
1637
1761
|
}
|
1638
1762
|
jobError();
|
@@ -1662,7 +1786,7 @@ class FileSystemInfo {
|
|
1662
1786
|
if (err) {
|
1663
1787
|
if (this.logger) {
|
1664
1788
|
this.logger.debug(
|
1665
|
-
`Error snapshotting file timestamp of ${path}: ${err}`
|
1789
|
+
`Error snapshotting file timestamp of ${path}: ${err.stack}`
|
1666
1790
|
);
|
1667
1791
|
}
|
1668
1792
|
jobError();
|
@@ -1698,7 +1822,7 @@ class FileSystemInfo {
|
|
1698
1822
|
if (err) {
|
1699
1823
|
if (this.logger) {
|
1700
1824
|
this.logger.debug(
|
1701
|
-
`Error snapshotting context timestamp hash combination of ${path}: ${err}`
|
1825
|
+
`Error snapshotting context timestamp hash combination of ${path}: ${err.stack}`
|
1702
1826
|
);
|
1703
1827
|
}
|
1704
1828
|
jobError();
|
@@ -1726,7 +1850,7 @@ class FileSystemInfo {
|
|
1726
1850
|
if (err) {
|
1727
1851
|
if (this.logger) {
|
1728
1852
|
this.logger.debug(
|
1729
|
-
`Error snapshotting context hash of ${path}: ${err}`
|
1853
|
+
`Error snapshotting context hash of ${path}: ${err.stack}`
|
1730
1854
|
);
|
1731
1855
|
}
|
1732
1856
|
jobError();
|
@@ -1756,7 +1880,7 @@ class FileSystemInfo {
|
|
1756
1880
|
if (err) {
|
1757
1881
|
if (this.logger) {
|
1758
1882
|
this.logger.debug(
|
1759
|
-
`Error snapshotting context timestamp of ${path}: ${err}`
|
1883
|
+
`Error snapshotting context timestamp of ${path}: ${err.stack}`
|
1760
1884
|
);
|
1761
1885
|
}
|
1762
1886
|
jobError();
|
@@ -1789,7 +1913,7 @@ class FileSystemInfo {
|
|
1789
1913
|
if (err) {
|
1790
1914
|
if (this.logger) {
|
1791
1915
|
this.logger.debug(
|
1792
|
-
`Error snapshotting missing timestamp of ${path}: ${err}`
|
1916
|
+
`Error snapshotting missing timestamp of ${path}: ${err.stack}`
|
1793
1917
|
);
|
1794
1918
|
}
|
1795
1919
|
jobError();
|
@@ -1816,7 +1940,7 @@ class FileSystemInfo {
|
|
1816
1940
|
if (err) {
|
1817
1941
|
if (this.logger) {
|
1818
1942
|
this.logger.debug(
|
1819
|
-
`Error snapshotting managed item ${path}: ${err}`
|
1943
|
+
`Error snapshotting managed item ${path}: ${err.stack}`
|
1820
1944
|
);
|
1821
1945
|
}
|
1822
1946
|
jobError();
|
@@ -2346,6 +2470,11 @@ class FileSystemInfo {
|
|
2346
2470
|
this._fileHashes.set(path, null);
|
2347
2471
|
return callback(null, null);
|
2348
2472
|
}
|
2473
|
+
if (err.code === "ERR_FS_FILE_TOO_LARGE") {
|
2474
|
+
this.logger.warn(`Ignoring ${path} for hashing as it's very large`);
|
2475
|
+
this._fileHashes.set(path, "too large");
|
2476
|
+
return callback(null, "too large");
|
2477
|
+
}
|
2349
2478
|
return callback(err);
|
2350
2479
|
}
|
2351
2480
|
|
@@ -2405,7 +2534,7 @@ class FileSystemInfo {
|
|
2405
2534
|
}
|
2406
2535
|
|
2407
2536
|
_readContextTimestamp(path, callback) {
|
2408
|
-
this.fs.readdir(path, (err,
|
2537
|
+
this.fs.readdir(path, (err, _files) => {
|
2409
2538
|
if (err) {
|
2410
2539
|
if (err.code === "ENOENT") {
|
2411
2540
|
this._contextTimestamps.set(path, null);
|
@@ -2414,7 +2543,7 @@ class FileSystemInfo {
|
|
2414
2543
|
}
|
2415
2544
|
return callback(err);
|
2416
2545
|
}
|
2417
|
-
files =
|
2546
|
+
const files = /** @type {string[]} */ (_files)
|
2418
2547
|
.map(file => file.normalize("NFC"))
|
2419
2548
|
.filter(file => !/^\./.test(file))
|
2420
2549
|
.sort();
|
@@ -2501,7 +2630,7 @@ class FileSystemInfo {
|
|
2501
2630
|
}
|
2502
2631
|
|
2503
2632
|
_readContextHash(path, callback) {
|
2504
|
-
this.fs.readdir(path, (err,
|
2633
|
+
this.fs.readdir(path, (err, _files) => {
|
2505
2634
|
if (err) {
|
2506
2635
|
if (err.code === "ENOENT") {
|
2507
2636
|
this._contextHashes.set(path, null);
|
@@ -2509,7 +2638,7 @@ class FileSystemInfo {
|
|
2509
2638
|
}
|
2510
2639
|
return callback(err);
|
2511
2640
|
}
|
2512
|
-
files =
|
2641
|
+
const files = /** @type {string[]} */ (_files)
|
2513
2642
|
.map(file => file.normalize("NFC"))
|
2514
2643
|
.filter(file => !/^\./.test(file))
|
2515
2644
|
.sort();
|
@@ -2624,7 +2753,9 @@ class FileSystemInfo {
|
|
2624
2753
|
return callback(err);
|
2625
2754
|
}
|
2626
2755
|
const set = new Set(
|
2627
|
-
elements.map(element =>
|
2756
|
+
/** @type {string[]} */ (elements).map(element =>
|
2757
|
+
join(this.fs, path, element)
|
2758
|
+
)
|
2628
2759
|
);
|
2629
2760
|
callback(null, set);
|
2630
2761
|
});
|