@cspell/dynamic-import 8.16.1 → 8.17.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,6 +1,6 @@
|
|
|
1
1
|
import { statSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { resolve as resolvePath } from 'node:path';
|
|
3
|
+
import { toFileDirURL, toFileURL } from '@cspell/url';
|
|
4
4
|
import { resolve } from 'import-meta-resolve';
|
|
5
5
|
const isWindowsPath = /^[a-z]:\\/i;
|
|
6
6
|
/**
|
|
@@ -40,7 +40,7 @@ export function importResolveModuleName(moduleName, paths) {
|
|
|
40
40
|
const url = typeof parent === 'string'
|
|
41
41
|
? parent.startsWith('file://')
|
|
42
42
|
? new URL(parent)
|
|
43
|
-
:
|
|
43
|
+
: dirToUrl(parent)
|
|
44
44
|
: parent;
|
|
45
45
|
const resolvedURL = new URL(resolve(modulesNameToImport.toString(), url.toString()));
|
|
46
46
|
try {
|
|
@@ -63,7 +63,7 @@ export function importResolveModuleName(moduleName, paths) {
|
|
|
63
63
|
throw lastError;
|
|
64
64
|
}
|
|
65
65
|
function normalizeModuleName(moduleName) {
|
|
66
|
-
return typeof moduleName === 'string' && isWindowsPath.test(moduleName) ?
|
|
66
|
+
return typeof moduleName === 'string' && isWindowsPath.test(moduleName) ? toFileURL(moduleName) : moduleName;
|
|
67
67
|
}
|
|
68
68
|
function toError(e) {
|
|
69
69
|
if (isError(e))
|
|
@@ -73,4 +73,8 @@ function toError(e) {
|
|
|
73
73
|
function isError(e) {
|
|
74
74
|
return e instanceof Error;
|
|
75
75
|
}
|
|
76
|
+
function dirToUrl(dir) {
|
|
77
|
+
const abs = resolvePath(dir);
|
|
78
|
+
return toFileDirURL(abs);
|
|
79
|
+
}
|
|
76
80
|
//# sourceMappingURL=dynamicImport.mjs.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "8.
|
|
7
|
+
"version": "8.17.0",
|
|
8
8
|
"description": "Dynamic Module Loader",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"module",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"node": ">=18.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
+
"@cspell/url": "8.17.0",
|
|
62
63
|
"import-meta-resolve": "^4.1.0"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "cac17fe7b993db5965aa441648b1c22cb5486929"
|
|
65
66
|
}
|