@jsenv/node-esm-resolution 1.2.14 → 1.2.16

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.14",
3
+ "version": "1.2.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/jsenv/core",
@@ -22,7 +22,7 @@
22
22
  "/main.js"
23
23
  ],
24
24
  "dependencies": {
25
- "@jsenv/filesystem": "4.15.13"
25
+ "@jsenv/filesystem": "4.15.15"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@jsenv/assert": "../assert",
@@ -55,6 +55,10 @@ export const applyNodeEsmResolution = ({
55
55
  return resolution;
56
56
  };
57
57
 
58
+ const createResolutionResult = (data) => {
59
+ return data;
60
+ };
61
+
58
62
  const applyPackageSpecifierResolution = (specifier, resolutionContext) => {
59
63
  const { parentUrl } = resolutionContext;
60
64
  // relative specifier
@@ -72,10 +76,10 @@ const applyPackageSpecifierResolution = (specifier, resolutionContext) => {
72
76
  return browserFieldResolution;
73
77
  }
74
78
  }
75
- return {
79
+ return createResolutionResult({
76
80
  type: "relative_specifier",
77
81
  url: new URL(specifier, parentUrl).href,
78
- };
82
+ });
79
83
  }
80
84
  if (specifier[0] === "#") {
81
85
  return applyPackageImportsResolution(specifier, resolutionContext);
@@ -83,15 +87,15 @@ const applyPackageSpecifierResolution = (specifier, resolutionContext) => {
83
87
  try {
84
88
  const urlObject = new URL(specifier);
85
89
  if (specifier.startsWith("node:")) {
86
- return {
90
+ return createResolutionResult({
87
91
  type: "node_builtin_specifier",
88
92
  url: specifier,
89
- };
93
+ });
90
94
  }
91
- return {
95
+ return createResolutionResult({
92
96
  type: "absolute_specifier",
93
97
  url: urlObject.href,
94
- };
98
+ });
95
99
  } catch {
96
100
  // bare specifier
97
101
  const browserFieldResolution = applyBrowserFieldResolution(
@@ -152,13 +156,13 @@ const applyBrowserFieldResolution = (specifier, resolutionContext) => {
152
156
  }
153
157
  }
154
158
  if (url) {
155
- return {
159
+ return createResolutionResult({
156
160
  type: "field:browser",
157
161
  isMain: true,
158
162
  packageDirectoryUrl,
159
163
  packageJson,
160
164
  url,
161
- };
165
+ });
162
166
  }
163
167
  return null;
164
168
  };
@@ -207,10 +211,10 @@ const applyPackageResolve = (packageSpecifier, resolutionContext) => {
207
211
  conditions.includes("node") &&
208
212
  isSpecifierForNodeBuiltin(packageSpecifier)
209
213
  ) {
210
- return {
214
+ return createResolutionResult({
211
215
  type: "node_builtin_specifier",
212
216
  url: `node:${packageSpecifier}`,
213
- };
217
+ });
214
218
  }
215
219
  let { packageName, packageSubpath } = parsePackageSpecifier(packageSpecifier);
216
220
  if (
@@ -403,7 +407,7 @@ const applyPackageTargetResolution = (target, resolutionContext) => {
403
407
  resolutionContext,
404
408
  );
405
409
  }
406
- return {
410
+ return createResolutionResult({
407
411
  type: isImport ? "field:imports" : "field:exports",
408
412
  isMain: subpath === "" || subpath === ".",
409
413
  packageDirectoryUrl,
@@ -411,7 +415,7 @@ const applyPackageTargetResolution = (target, resolutionContext) => {
411
415
  url: pattern
412
416
  ? targetUrl.replaceAll("*", subpath)
413
417
  : new URL(subpath, targetUrl).href,
414
- };
418
+ });
415
419
  }
416
420
  if (!isImport || target.startsWith("../") || isValidUrl(target)) {
417
421
  throw createInvalidPackageTargetError(
@@ -632,13 +636,13 @@ const applyLegacySubpathResolution = (packageSubpath, resolutionContext) => {
632
636
  if (browserFieldResolution) {
633
637
  return browserFieldResolution;
634
638
  }
635
- return {
639
+ return createResolutionResult({
636
640
  type: "subpath",
637
641
  isMain: packageSubpath === ".",
638
642
  packageDirectoryUrl,
639
643
  packageJson,
640
644
  url: new URL(packageSubpath, packageDirectoryUrl).href,
641
- };
645
+ });
642
646
  };
643
647
 
644
648
  const applyLegacyMainResolution = (packageSubpath, resolutionContext) => {
@@ -650,22 +654,22 @@ const applyLegacyMainResolution = (packageSubpath, resolutionContext) => {
650
654
  }
651
655
  const resolved = conditionResolver(resolutionContext);
652
656
  if (resolved) {
653
- return {
657
+ return createResolutionResult({
654
658
  type: resolved.type,
655
659
  isMain: resolved.isMain,
656
660
  packageDirectoryUrl,
657
661
  packageJson,
658
662
  url: new URL(resolved.path, packageDirectoryUrl).href,
659
- };
663
+ });
660
664
  }
661
665
  }
662
- return {
666
+ return createResolutionResult({
663
667
  type: "field:main", // the absence of "main" field
664
668
  isMain: true,
665
669
  packageDirectoryUrl,
666
670
  packageJson,
667
671
  url: new URL("index.js", packageDirectoryUrl).href,
668
- };
672
+ });
669
673
  };
670
674
  const mainLegacyResolvers = {
671
675
  import: ({ packageJson }) => {