@jsenv/node-esm-resolution 1.2.6 → 1.2.8
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.
|
|
3
|
+
"version": "1.2.8",
|
|
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.
|
|
25
|
+
"@jsenv/filesystem": "4.15.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@jsenv/assert": "../assert",
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
|
|
3
3
|
export const defaultReadPackageJson = (packageUrl) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const string = String(buffer);
|
|
4
|
+
const packageJsonFileUrl = new URL("./package.json", packageUrl);
|
|
5
|
+
let packageJsonFileContentBuffer;
|
|
7
6
|
try {
|
|
8
|
-
|
|
7
|
+
packageJsonFileContentBuffer = readFileSync(packageJsonFileUrl, "utf8");
|
|
8
|
+
} catch (e) {
|
|
9
|
+
if (e.code === "ENOENT") {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
const packageJsonFileContentString = String(packageJsonFileContentBuffer);
|
|
15
|
+
try {
|
|
16
|
+
const packageJsonFileContentObject = JSON.parse(
|
|
17
|
+
packageJsonFileContentString,
|
|
18
|
+
);
|
|
19
|
+
return packageJsonFileContentObject;
|
|
9
20
|
} catch {
|
|
10
|
-
throw new Error(`Invalid package configuration`);
|
|
21
|
+
throw new Error(`Invalid package configuration at ${packageJsonFileUrl}`);
|
|
11
22
|
}
|
|
12
23
|
};
|
|
@@ -734,7 +734,7 @@ const mainLegacyResolvers = {
|
|
|
734
734
|
};
|
|
735
735
|
},
|
|
736
736
|
node: ({ packageJson, conditions }) => {
|
|
737
|
-
if (conditions.includes("import")) {
|
|
737
|
+
if (conditions.includes("import") && !conditions.includes("require")) {
|
|
738
738
|
if (typeof packageJson.module === "string") {
|
|
739
739
|
return { type: "field:module", isMain: true, path: packageJson.module };
|
|
740
740
|
}
|
|
@@ -748,6 +748,7 @@ const mainLegacyResolvers = {
|
|
|
748
748
|
return null;
|
|
749
749
|
},
|
|
750
750
|
};
|
|
751
|
+
mainLegacyResolvers.require = mainLegacyResolvers.node;
|
|
751
752
|
|
|
752
753
|
const comparePatternKeys = (keyA, keyB) => {
|
|
753
754
|
if (!keyA.endsWith("/") && !keyA.includes("*")) {
|