@jsenv/node-esm-resolution 1.2.0 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/node-esm-resolution",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,5 +23,13 @@
23
23
  "/src/",
24
24
  "/main.js"
25
25
  ],
26
- "sideEffects": false
26
+ "sideEffects": false,
27
+ "dependencies": {
28
+ "@jsenv/filesystem": "4.15.2"
29
+ },
30
+ "devDependencies": {
31
+ "@jsenv/snapshot": "../snapshot",
32
+ "@jsenv/assert": "../assert",
33
+ "@jsenv/node-esm-resolution": "./"
34
+ }
27
35
  }
@@ -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
- if (key === "default" || conditions.includes(key)) {
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,