@startracex/node-resolve 0.0.0 → 0.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.
- package/module-resolver.d.ts +1 -1
- package/module-resolver.d.ts.map +1 -1
- package/module-resolver.js +5 -8
- package/module-resolver.ts +8 -18
- package/package.json +4 -4
- package/specifier.d.ts.map +1 -1
- package/specifier.js +0 -1
- package/specifier.ts +0 -1
- package/subpath-resolver.d.ts.map +1 -1
- package/subpath-resolver.ts +1 -4
package/module-resolver.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class ModuleResolver extends SubpathResolver {
|
|
|
5
5
|
modulesDirectoryName: string;
|
|
6
6
|
manifestFileName: string;
|
|
7
7
|
mainFields: string[];
|
|
8
|
-
isCoreModule: (
|
|
8
|
+
isCoreModule: (name: string) => boolean;
|
|
9
9
|
path: {
|
|
10
10
|
dirname: (path: string) => string;
|
|
11
11
|
join: (...paths: string[]) => string;
|
package/module-resolver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["module-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAkB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,cAAe,SAAQ,eAAe;IACjD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["module-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAkB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,cAA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AAE,MAAM,GAAG,MAAM,GAAG,SAAS;IA0CzE,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/E,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIzD,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG;QAC5B,MAAM,IAAI,OAAO,CAAC;QAClB,WAAW,IAAI,OAAO,CAAC;KACxB,GAAG,IAAI;CAOT"}
|
package/module-resolver.js
CHANGED
|
@@ -9,7 +9,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
9
9
|
path;
|
|
10
10
|
fs;
|
|
11
11
|
index;
|
|
12
|
-
constructor({ extensions, isCoreModule
|
|
12
|
+
constructor({ extensions, isCoreModule, modulesDirectoryName = "node_modules", manifestFileName = "package.json", mainFields = ["main"], index = "index", path, fs, ...args } = {}) {
|
|
13
13
|
super(args);
|
|
14
14
|
this.extensions = extensions;
|
|
15
15
|
this.isCoreModule = isCoreModule;
|
|
@@ -36,9 +36,6 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
36
36
|
return paths;
|
|
37
37
|
}
|
|
38
38
|
resolve(path, base) {
|
|
39
|
-
if (this.isCoreModule?.(path)) {
|
|
40
|
-
return path;
|
|
41
|
-
}
|
|
42
39
|
if (path.startsWith("#")) {
|
|
43
40
|
const paths = this.resolveImports(path);
|
|
44
41
|
if (paths) {
|
|
@@ -53,6 +50,9 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
53
50
|
}
|
|
54
51
|
const spec = parseSpecifier(path);
|
|
55
52
|
if (spec?.name) {
|
|
53
|
+
if (this.isCoreModule?.(spec.name)) {
|
|
54
|
+
return path;
|
|
55
|
+
}
|
|
56
56
|
return this.resolveModuleSpecifier(spec, base);
|
|
57
57
|
}
|
|
58
58
|
return this.resolveFileOrDir(this.path.join(base, path));
|
|
@@ -70,10 +70,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
resolveFile(filePath) {
|
|
73
|
-
const candidates = [
|
|
74
|
-
filePath,
|
|
75
|
-
...(this.extensions || []).map((ext) => filePath + ext),
|
|
76
|
-
];
|
|
73
|
+
const candidates = [filePath, ...(this.extensions || []).map((ext) => filePath + ext)];
|
|
77
74
|
for (const file of candidates) {
|
|
78
75
|
const stat = this.stat(file);
|
|
79
76
|
if (!stat || stat.isDirectory()) {
|
package/module-resolver.ts
CHANGED
|
@@ -6,7 +6,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
6
6
|
modulesDirectoryName: string;
|
|
7
7
|
manifestFileName: string;
|
|
8
8
|
mainFields: string[];
|
|
9
|
-
isCoreModule: (
|
|
9
|
+
isCoreModule: (name: string) => boolean;
|
|
10
10
|
path: {
|
|
11
11
|
dirname: (path: string) => string;
|
|
12
12
|
join: (...paths: string[]) => string;
|
|
@@ -22,7 +22,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
22
22
|
|
|
23
23
|
constructor({
|
|
24
24
|
extensions,
|
|
25
|
-
isCoreModule
|
|
25
|
+
isCoreModule,
|
|
26
26
|
modulesDirectoryName = "node_modules",
|
|
27
27
|
manifestFileName = "package.json",
|
|
28
28
|
mainFields = ["main"],
|
|
@@ -62,10 +62,6 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
resolve(path: string, base: string): string | undefined {
|
|
65
|
-
if (this.isCoreModule?.(path)) {
|
|
66
|
-
return path;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
65
|
if (path.startsWith("#")) {
|
|
70
66
|
const paths = this.resolveImports(path);
|
|
71
67
|
if (paths) {
|
|
@@ -82,16 +78,16 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
82
78
|
const spec = parseSpecifier(path);
|
|
83
79
|
|
|
84
80
|
if (spec?.name) {
|
|
81
|
+
if (this.isCoreModule?.(spec.name)) {
|
|
82
|
+
return path;
|
|
83
|
+
}
|
|
85
84
|
return this.resolveModuleSpecifier(spec, base);
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
return this.resolveFileOrDir(this.path.join(base, path));
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
resolveModuleSpecifier(
|
|
92
|
-
{ name, path }: Specifier,
|
|
93
|
-
base?: string,
|
|
94
|
-
): string | undefined {
|
|
90
|
+
resolveModuleSpecifier({ name, path }: Specifier, base?: string): string | undefined {
|
|
95
91
|
const dirs = this.modulesPaths(base, name);
|
|
96
92
|
for (const dir of dirs) {
|
|
97
93
|
const stat = this.stat(dir);
|
|
@@ -105,10 +101,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
protected resolveFile(filePath: string): string | undefined {
|
|
108
|
-
const candidates = [
|
|
109
|
-
filePath,
|
|
110
|
-
...(this.extensions || []).map((ext) => filePath + ext),
|
|
111
|
-
];
|
|
104
|
+
const candidates = [filePath, ...(this.extensions || []).map((ext) => filePath + ext)];
|
|
112
105
|
for (const file of candidates) {
|
|
113
106
|
const stat = this.stat(file);
|
|
114
107
|
if (!stat || stat.isDirectory()) {
|
|
@@ -162,10 +155,7 @@ export class ModuleResolver extends SubpathResolver {
|
|
|
162
155
|
return this.resolveFileOrDir(subPath);
|
|
163
156
|
}
|
|
164
157
|
|
|
165
|
-
protected resolveFileOrDir(
|
|
166
|
-
subPath: string,
|
|
167
|
-
entry?: string,
|
|
168
|
-
): string | undefined {
|
|
158
|
+
protected resolveFileOrDir(subPath: string, entry?: string): string | undefined {
|
|
169
159
|
return this.resolveFile(subPath) || this.resolveDir(subPath, entry);
|
|
170
160
|
}
|
|
171
161
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startracex/node-resolve",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Node resolve algorithm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"check": "dprint check"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@startracex/dev-config": "^0.
|
|
15
|
-
"dprint": "^0.50.
|
|
14
|
+
"@startracex/dev-config": "^0.3.0",
|
|
15
|
+
"dprint": "^0.50.1",
|
|
16
16
|
"typescript": "^5.8.3"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"*.{js,ts}+(|.map)"
|
|
32
32
|
],
|
|
33
|
-
"packageManager": "pnpm@10.
|
|
33
|
+
"packageManager": "pnpm@10.12.4"
|
|
34
34
|
}
|
package/specifier.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifier.d.ts","sourceRoot":"","sources":["specifier.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"specifier.d.ts","sourceRoot":"","sources":["specifier.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,SAAS,GAAG,IAuB1D,CAAC"}
|
package/specifier.js
CHANGED
package/specifier.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subpath-resolver.d.ts","sourceRoot":"","sources":["subpath-resolver.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"subpath-resolver.d.ts","sourceRoot":"","sources":["subpath-resolver.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC;AAsE1D,eAAO,MAAM,cAAc,GACzB,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,YAAY,MAAM,EAAE,EACpB,OAAO,MAAM,KACZ,MAAM,EAAE,GAAG,IA6Bb,CAAC;AAcF,qBAAa,eAAe;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAEnB,EACV,OAAO,EACP,OAAO,EACP,UAAwB,GACzB,EAAE;QACD,OAAO,CAAC,EAAE,KAAK,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB;IAMD,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;CAM/C"}
|
package/subpath-resolver.ts
CHANGED
|
@@ -48,10 +48,7 @@ const findWildcardMatch = (
|
|
|
48
48
|
return bestMatch ? { key: bestMatch.key, replacement } : null;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const resolveMappingValue = (
|
|
52
|
-
value: Value | undefined,
|
|
53
|
-
conditions: string[],
|
|
54
|
-
): string[] | null => {
|
|
51
|
+
const resolveMappingValue = (value: Value | undefined, conditions: string[]): string[] | null => {
|
|
55
52
|
if (!value) return null;
|
|
56
53
|
|
|
57
54
|
if (typeof value === "string") {
|