@jsenv/node-esm-resolution 0.0.6 → 0.0.7

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": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,14 +35,14 @@ export const applyFileSystemMagicResolution = (
35
35
  magicExtensions,
36
36
  })
37
37
  return {
38
- magicDirectoryIndex: true,
39
38
  ...result,
39
+ magicDirectoryIndex: true,
40
40
  }
41
41
  }
42
42
  return {
43
- isDirectory: true,
44
43
  found: true,
45
44
  url: fileUrl,
45
+ isDirectory: true,
46
46
  }
47
47
  }
48
48
  if (magicExtensions && magicExtensions.length) {
@@ -56,9 +56,9 @@ export const applyFileSystemMagicResolution = (
56
56
  if (extensionLeadingToFile) {
57
57
  // magic extension worked
58
58
  return {
59
- magicExtension: extensionLeadingToFile,
60
59
  found: true,
61
60
  url: `${fileUrl}${extensionLeadingToFile}`,
61
+ magicExtension: extensionLeadingToFile,
62
62
  }
63
63
  }
64
64
  }
@@ -764,26 +764,36 @@ const applyLegacyMainResolution = ({ conditions, packageUrl, packageJson }) => {
764
764
  }
765
765
  }
766
766
  const mainLegacyResolvers = {
767
- import: ({ module, jsnext }) => {
768
- if (typeof module === "string") {
769
- return { type: "module", path: module }
767
+ import: (packageJson) => {
768
+ if (typeof packageJson.module === "string") {
769
+ return { type: "module", path: packageJson.module }
770
770
  }
771
- if (typeof jsnext === "string") {
772
- return { type: "jsnext", path: jsnext }
771
+ if (typeof packageJson.jsnext === "string") {
772
+ return { type: "jsnext", path: packageJson.jsnext }
773
773
  }
774
774
  return null
775
775
  },
776
- browser: ({ browser, module }, packageUrl) => {
776
+ browser: (packageJson, packageUrl) => {
777
777
  const browserMain =
778
- typeof browser === "string"
779
- ? browser
780
- : typeof browser === "object" && browser !== null
781
- ? browser["."]
778
+ typeof packageJson.browser === "string"
779
+ ? packageJson.browser
780
+ : typeof packageJson.browser === "object" &&
781
+ packageJson.browser !== null
782
+ ? packageJson.browser["."]
782
783
  : ""
783
784
  if (!browserMain) {
785
+ if (typeof packageJson.module === "string") {
786
+ return {
787
+ type: "module",
788
+ path: packageJson.module,
789
+ }
790
+ }
784
791
  return null
785
792
  }
786
- if (typeof module !== "string" || module === browserMain) {
793
+ if (
794
+ typeof packageJson.module !== "string" ||
795
+ packageJson.module === browserMain
796
+ ) {
787
797
  return {
788
798
  type: "browser",
789
799
  path: browserMain,
@@ -798,7 +808,7 @@ const mainLegacyResolvers = {
798
808
  ) {
799
809
  return {
800
810
  type: "module",
801
- path: module,
811
+ path: packageJson.module,
802
812
  }
803
813
  }
804
814
  return {
@@ -806,11 +816,11 @@ const mainLegacyResolvers = {
806
816
  path: browserMain,
807
817
  }
808
818
  },
809
- node: ({ main }) => {
810
- if (typeof main === "string") {
819
+ node: (packageJson) => {
820
+ if (typeof packageJson.main === "string") {
811
821
  return {
812
822
  type: "main",
813
- path: main,
823
+ path: packageJson.main,
814
824
  }
815
825
  }
816
826
  return null