@cspell/dynamic-import 7.3.9 → 8.1.0

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.
@@ -1,3 +1,4 @@
1
+ import { statSync } from 'node:fs';
1
2
  import { resolve } from 'import-meta-resolve';
2
3
  import { sep as pathSep } from 'path';
3
4
  import { pathToFileURL } from 'url';
@@ -23,7 +24,7 @@ export async function dynamicImportFrom(moduleName, paths) {
23
24
  }
24
25
  }
25
26
  const location = importResolveModuleName(moduleName, paths);
26
- return await import(location.toString());
27
+ return await import(location.href);
27
28
  }
28
29
  /**
29
30
  * Use Import.meta.resolve logic to try and determine possible locations for a module.
@@ -41,7 +42,18 @@ export function importResolveModuleName(moduleName, paths) {
41
42
  ? new URL(parent)
42
43
  : pathToFileURL(parent + pathSep)
43
44
  : parent;
44
- return new URL(resolve(modulesNameToImport.toString(), url.toString()));
45
+ const resolvedURL = new URL(resolve(modulesNameToImport.toString(), url.toString()));
46
+ try {
47
+ const s = statSync(resolvedURL);
48
+ if (s.isFile()) {
49
+ return resolvedURL;
50
+ }
51
+ }
52
+ catch (err) {
53
+ const error = new Error(`Cannot find module ${moduleName}`);
54
+ error.code = 'ERR_MODULE_NOT_FOUND';
55
+ lastError = error;
56
+ }
45
57
  }
46
58
  catch (err) {
47
59
  // console.warn('%o', { moduleName, modulesNameToImport, paths, parentUrl: url, err, resolved, location });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "7.3.9",
6
+ "version": "8.1.0",
7
7
  "description": "Dynamic Module Loader",
8
8
  "keywords": [
9
9
  "module",
@@ -53,10 +53,10 @@
53
53
  "url": "https://github.com/streetsidesoftware/cspell/labels/cspell-pipe"
54
54
  },
55
55
  "engines": {
56
- "node": ">=16"
56
+ "node": ">=18.0"
57
57
  },
58
58
  "dependencies": {
59
- "import-meta-resolve": "^3.1.1"
59
+ "import-meta-resolve": "^4.0.0"
60
60
  },
61
- "gitHead": "77c7fb3ffd80a626ec07d704cefcaa21d62fd460"
61
+ "gitHead": "28568808deaf39b9ffa71fd0f722441ff1b8c794"
62
62
  }