@jsenv/node-esm-resolution 1.2.0 → 1.2.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/package.json
CHANGED
package/src/custom_conditions.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// https://nodejs.org/api/packages.html#resolving-user-conditions
|
|
2
2
|
export const readCustomConditionsFromProcessArgs = () => {
|
|
3
|
+
if (process.env.IGNORE_PACKAGE_CONDITIONS) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
3
6
|
const packageConditions = [];
|
|
4
7
|
for (const arg of process.execArgv) {
|
|
5
8
|
if (arg.includes("-C=")) {
|
|
@@ -17,6 +17,7 @@ const NODE_BUILTIN_MODULE_SPECIFIERS = [
|
|
|
17
17
|
"constants",
|
|
18
18
|
"crypto",
|
|
19
19
|
"_debugger",
|
|
20
|
+
"diagnostics_channel",
|
|
20
21
|
"dgram",
|
|
21
22
|
"dns",
|
|
22
23
|
"domain",
|
|
@@ -50,6 +51,7 @@ const NODE_BUILTIN_MODULE_SPECIFIERS = [
|
|
|
50
51
|
"readline",
|
|
51
52
|
"repl",
|
|
52
53
|
"smalloc",
|
|
54
|
+
"sqlite",
|
|
53
55
|
"_stream_duplex",
|
|
54
56
|
"_stream_transform",
|
|
55
57
|
"_stream_wrap",
|
|
@@ -470,7 +470,27 @@ const applyPackageTargetResolution = (target, resolutionContext) => {
|
|
|
470
470
|
if (Number.isInteger(key)) {
|
|
471
471
|
throw new Error("Invalid package configuration");
|
|
472
472
|
}
|
|
473
|
-
|
|
473
|
+
let matched;
|
|
474
|
+
if (key === "default") {
|
|
475
|
+
matched = true;
|
|
476
|
+
} else {
|
|
477
|
+
for (const conditionCandidate of conditions) {
|
|
478
|
+
if (conditionCandidate === key) {
|
|
479
|
+
matched = true;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (conditionCandidate.includes("*")) {
|
|
483
|
+
const conditionCandidateRegex = new RegExp(
|
|
484
|
+
`^${conditionCandidate.replace(/\*/g, "(.*)")}$`,
|
|
485
|
+
);
|
|
486
|
+
if (conditionCandidateRegex.test(key)) {
|
|
487
|
+
matched = true;
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (matched) {
|
|
474
494
|
const targetValue = target[key];
|
|
475
495
|
const resolved = applyPackageTargetResolution(targetValue, {
|
|
476
496
|
...resolutionContext,
|