@jsenv/node-esm-resolution 1.0.5 → 1.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,11 +1,11 @@
1
1
  {
2
2
  "name": "@jsenv/node-esm-resolution",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/jsenv/core",
8
- "directory": "packages/independent/node-esm-resolution"
8
+ "directory": "packages/independent/tooling/node-esm-resolution"
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public"
@@ -22,8 +22,5 @@
22
22
  "/dist/",
23
23
  "/src/",
24
24
  "/main.js"
25
- ],
26
- "scripts": {
27
- "test": "node --conditions=development ./tests/test.mjs"
28
- }
25
+ ]
29
26
  }
@@ -1,7 +1,7 @@
1
1
  // https://nodejs.org/api/packages.html#resolving-user-conditions
2
2
  export const readCustomConditionsFromProcessArgs = () => {
3
3
  const packageConditions = [];
4
- process.execArgv.forEach((arg) => {
4
+ for (const arg of process.execArgv) {
5
5
  if (arg.includes("-C=")) {
6
6
  const packageCondition = arg.slice(0, "-C=".length);
7
7
  packageConditions.push(packageCondition);
@@ -10,6 +10,6 @@ export const readCustomConditionsFromProcessArgs = () => {
10
10
  const packageCondition = arg.slice("--conditions=".length);
11
11
  packageConditions.push(packageCondition);
12
12
  }
13
- });
13
+ }
14
14
  return packageConditions;
15
15
  };
@@ -1,5 +1,4 @@
1
1
  import { existsSync } from "node:fs";
2
-
3
2
  import { asDirectoryUrl, getParentUrl } from "./url_utils.js";
4
3
 
5
4
  export const defaultLookupPackageScope = (url) => {
@@ -6,7 +6,7 @@ export const defaultReadPackageJson = (packageUrl) => {
6
6
  const string = String(buffer);
7
7
  try {
8
8
  return JSON.parse(string);
9
- } catch (e) {
9
+ } catch {
10
10
  throw new Error(`Invalid package configuration`);
11
11
  }
12
12
  };
@@ -1,5 +1,4 @@
1
- import { statSync } from "node:fs";
2
-
1
+ import { readEntryStatSync } from "@jsenv/filesystem";
3
2
  import { urlToExtension, urlToFilename } from "./url_utils.js";
4
3
 
5
4
  export const applyFileSystemMagicResolution = (
@@ -16,7 +15,7 @@ export const applyFileSystemMagicResolution = (
16
15
 
17
16
  if (fileStat === undefined) {
18
17
  try {
19
- fileStat = statSync(new URL(fileUrl));
18
+ fileStat = readEntryStatSync(new URL(fileUrl));
20
19
  } catch (e) {
21
20
  if (e.code === "ENOENT") {
22
21
  result.lastENOENTError = e;
@@ -58,7 +57,7 @@ export const applyFileSystemMagicResolution = (
58
57
  const urlCandidate = `${parentUrl}${urlFilename}${extensionToTry}`;
59
58
  let stat;
60
59
  try {
61
- stat = statSync(new URL(urlCandidate));
60
+ stat = readEntryStatSync(new URL(urlCandidate));
62
61
  } catch (e) {
63
62
  if (e.code === "ENOENT") {
64
63
  stat = null;
@@ -11,7 +11,6 @@
11
11
  */
12
12
  import { existsSync, readFileSync, realpathSync } from "node:fs";
13
13
  import { pathToFileURL } from "node:url";
14
-
15
14
  import { readCustomConditionsFromProcessArgs } from "./custom_conditions.js";
16
15
  import { defaultLookupPackageScope } from "./default_lookup_package_scope.js";
17
16
  import { defaultReadPackageJson } from "./default_read_package_json.js";
@@ -93,7 +92,7 @@ const applyPackageSpecifierResolution = (specifier, resolutionContext) => {
93
92
  type: "absolute_specifier",
94
93
  url: urlObject.href,
95
94
  };
96
- } catch (e) {
95
+ } catch {
97
96
  // bare specifier
98
97
  const browserFieldResolution = applyBrowserFieldResolution(
99
98
  specifier,
package/src/url_utils.js CHANGED
@@ -37,7 +37,7 @@ export const isValidUrl = (url) => {
37
37
  // eslint-disable-next-line no-new
38
38
  new URL(url);
39
39
  return true;
40
- } catch (e) {
40
+ } catch {
41
41
  return false;
42
42
  }
43
43
  };