@ainc/fs 0.1.22 → 0.1.23
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/dist/cache.d.ts +16 -0
- package/dist/cache.js +24 -0
- package/dist/dict.d.ts +21 -0
- package/dist/dict.js +66 -0
- package/dist/downloadFile.js +19 -13
- package/dist/index.d.ts +37 -1
- package/dist/index.exports.json +34 -0
- package/dist/index.js +59 -3
- package/dist/isEsmModule.d.ts +18 -0
- package/dist/isEsmModule.js +63 -0
- package/dist/loadPackageDescription.d.ts +61 -0
- package/dist/loadPackageDescription.js +71 -0
- package/dist/loadTsConfig.d.ts +87 -0
- package/dist/loadTsConfig.js +219 -0
- package/dist/match.d.ts +30 -0
- package/dist/match.js +59 -0
- package/dist/resolveAlias.d.ts +25 -0
- package/dist/resolveAlias.js +82 -0
- package/dist/resolveDirect.d.ts +15 -0
- package/dist/resolveDirect.js +144 -0
- package/dist/resolveExports.d.ts +19 -0
- package/dist/resolveExports.js +54 -0
- package/dist/resolveImports.d.ts +21 -0
- package/dist/resolveImports.js +114 -0
- package/dist/resolveModuleDir.d.ts +12 -0
- package/dist/resolveModuleDir.js +67 -0
- package/dist/resolveModuleId.d.ts +6 -0
- package/dist/resolveModuleId.js +32 -0
- package/dist/resolvePath.d.ts +23 -0
- package/dist/resolvePath.js +86 -0
- package/dist/resolvePaths.d.ts +13 -0
- package/dist/resolvePaths.js +42 -0
- package/dist/split.d.ts +6 -0
- package/dist/split.js +24 -0
- package/dist/sys.d.ts +60 -0
- package/dist/sys.js +260 -0
- package/esm/cache.mjs +22 -0
- package/esm/dict.mjs +63 -0
- package/esm/downloadFile.mjs +19 -13
- package/esm/index.exports.json +34 -0
- package/esm/index.mjs +29 -1
- package/esm/isEsmModule.mjs +59 -0
- package/esm/loadPackageDescription.mjs +67 -0
- package/esm/loadTsConfig.mjs +215 -0
- package/esm/match.mjs +53 -0
- package/esm/resolveAlias.mjs +79 -0
- package/esm/resolveDirect.mjs +142 -0
- package/esm/resolveExports.mjs +51 -0
- package/esm/resolveImports.mjs +112 -0
- package/esm/resolveModuleDir.mjs +64 -0
- package/esm/resolveModuleId.mjs +30 -0
- package/esm/resolvePath.mjs +84 -0
- package/esm/resolvePaths.mjs +40 -0
- package/esm/split.mjs +22 -0
- package/esm/sys.mjs +258 -0
- package/package.json +3 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2025-06-22 11:21:37
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.resolveImports = resolveImports;
|
|
10
|
+
const match_1 = require("./match");
|
|
11
|
+
const cache_1 = require("./cache");
|
|
12
|
+
const resolveAlias_1 = require("./resolveAlias");
|
|
13
|
+
const resolveDirect_1 = require("./resolveDirect");
|
|
14
|
+
/**
|
|
15
|
+
*****************************************
|
|
16
|
+
* 缓存
|
|
17
|
+
*****************************************
|
|
18
|
+
*/
|
|
19
|
+
const cached = (0, cache_1.cache)(new WeakMap());
|
|
20
|
+
/**
|
|
21
|
+
*****************************************
|
|
22
|
+
* 解析目标
|
|
23
|
+
*****************************************
|
|
24
|
+
*/
|
|
25
|
+
function resolveImports(id, conditions, target, handler) {
|
|
26
|
+
const rules = cached.get(target, () => (0, resolveAlias_1.resolveDict)(target, resolveTargetDescription));
|
|
27
|
+
const resolve = handler || match_1.unary;
|
|
28
|
+
// 返回匹配函数
|
|
29
|
+
return rules.match(rule => {
|
|
30
|
+
if (rule.test(id)) {
|
|
31
|
+
return resolvePath(id, conditions, rule.direct, resolve);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*****************************************
|
|
37
|
+
* 解析规则
|
|
38
|
+
*****************************************
|
|
39
|
+
*/
|
|
40
|
+
function resolveTargetDescription(key, value) {
|
|
41
|
+
const { test, resolve } = (0, resolveDirect_1.resolveDirect)(key);
|
|
42
|
+
// 返回配置规则
|
|
43
|
+
return {
|
|
44
|
+
test,
|
|
45
|
+
direct: walk(value, resolve),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
*****************************************
|
|
50
|
+
* 解析重定向
|
|
51
|
+
*****************************************
|
|
52
|
+
*/
|
|
53
|
+
function walk(value, handler) {
|
|
54
|
+
switch (typeof value) {
|
|
55
|
+
case 'string':
|
|
56
|
+
return handler(value);
|
|
57
|
+
case 'object':
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
return match_1.nil;
|
|
61
|
+
}
|
|
62
|
+
// 处理空目标
|
|
63
|
+
if (!value) {
|
|
64
|
+
return match_1.nil;
|
|
65
|
+
}
|
|
66
|
+
// 处理数组目标
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
return value.map(id => walk(id, handler));
|
|
69
|
+
}
|
|
70
|
+
// 定义结果
|
|
71
|
+
const direct = {};
|
|
72
|
+
// 遍历目标描述
|
|
73
|
+
Object.keys(value)
|
|
74
|
+
.forEach(key => {
|
|
75
|
+
direct[key] = walk(value[key], handler);
|
|
76
|
+
});
|
|
77
|
+
// 返回结果
|
|
78
|
+
return direct;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
*****************************************
|
|
82
|
+
* 解析规则
|
|
83
|
+
*****************************************
|
|
84
|
+
*/
|
|
85
|
+
function resolvePath(id, conditions, rule, handler) {
|
|
86
|
+
switch (typeof rule) {
|
|
87
|
+
case 'function':
|
|
88
|
+
return resolvePath(id, conditions, rule(id), handler);
|
|
89
|
+
case 'string':
|
|
90
|
+
return handler(rule);
|
|
91
|
+
case 'object':
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// 处理空规则
|
|
97
|
+
if (!rule) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
// 处理数组
|
|
101
|
+
if (Array.isArray(rule)) {
|
|
102
|
+
return (0, match_1.match)(rule, value => resolvePath(id, conditions, value, handler));
|
|
103
|
+
}
|
|
104
|
+
// 处理条件映射
|
|
105
|
+
const condition = conditions.find(key => rule[key]);
|
|
106
|
+
const value = condition ? rule[condition] : rule.default;
|
|
107
|
+
// 存在解析时,继续解析
|
|
108
|
+
if (value) {
|
|
109
|
+
return resolvePath(id, conditions, value, handler);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* 解析模块目录
|
|
4
|
+
*****************************************
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveModuleDir(id: string, from: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
*****************************************
|
|
9
|
+
* 解析模块目录列表
|
|
10
|
+
*****************************************
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveModuleDirs(from: string | undefined): string[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2025-05-29 20:26:27
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.resolveModuleDir = resolveModuleDir;
|
|
10
|
+
exports.resolveModuleDirs = resolveModuleDirs;
|
|
11
|
+
/**
|
|
12
|
+
*****************************************
|
|
13
|
+
* 加载依赖
|
|
14
|
+
*****************************************
|
|
15
|
+
*/
|
|
16
|
+
const node_path_1 = require("node:path");
|
|
17
|
+
const dirname_1 = require("./dirname");
|
|
18
|
+
const stat_1 = require("./stat");
|
|
19
|
+
const match_1 = require("./match");
|
|
20
|
+
/**
|
|
21
|
+
*****************************************
|
|
22
|
+
* 模块路径缓存
|
|
23
|
+
*****************************************
|
|
24
|
+
*/
|
|
25
|
+
const cacheModuleDirs = new Map();
|
|
26
|
+
const cacheModuleDir = new Map();
|
|
27
|
+
/**
|
|
28
|
+
*****************************************
|
|
29
|
+
* 解析模块目录
|
|
30
|
+
*****************************************
|
|
31
|
+
*/
|
|
32
|
+
function resolveModuleDir(id, from) {
|
|
33
|
+
const cacheId = `${from}:${id}`;
|
|
34
|
+
if (cacheModuleDir.has(cacheId)) {
|
|
35
|
+
return cacheModuleDir.get(cacheId);
|
|
36
|
+
}
|
|
37
|
+
// 解析目录
|
|
38
|
+
const dirs = resolveModuleDirs(from);
|
|
39
|
+
const result = (0, match_1.match)(dirs, dir => (0, stat_1.isDir)((0, node_path_1.resolve)(dir, id)));
|
|
40
|
+
// 缓存结果
|
|
41
|
+
cacheModuleDir.set(cacheId, result);
|
|
42
|
+
// 返回结果
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
*****************************************
|
|
47
|
+
* 解析模块目录列表
|
|
48
|
+
*****************************************
|
|
49
|
+
*/
|
|
50
|
+
function resolveModuleDirs(from) {
|
|
51
|
+
if (!from) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
// 存在缓存时,直接返回
|
|
55
|
+
const cached = cacheModuleDirs.get(from);
|
|
56
|
+
if (cached) {
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
// 解析目录
|
|
60
|
+
const dirs = resolveModuleDirs((0, dirname_1.dirname)(from));
|
|
61
|
+
const dir = (0, node_path_1.join)(from, 'node_modules');
|
|
62
|
+
const result = (0, stat_1.isDir)(dir) ? [dir, ...dirs] : dirs;
|
|
63
|
+
// 缓存结果
|
|
64
|
+
cacheModuleDirs.set(from, result);
|
|
65
|
+
// 返回结果
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2025-05-29 20:26:27
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.resolveModuleId = resolveModuleId;
|
|
10
|
+
/**
|
|
11
|
+
*****************************************
|
|
12
|
+
* 解析模块路径
|
|
13
|
+
*****************************************
|
|
14
|
+
*/
|
|
15
|
+
function resolveModuleId(id) {
|
|
16
|
+
const idx1 = id.indexOf('/');
|
|
17
|
+
// 处理不带域的模块路径
|
|
18
|
+
if (idx1 === -1) {
|
|
19
|
+
return [id, '.'];
|
|
20
|
+
}
|
|
21
|
+
else if (id.charAt(0) !== '@') {
|
|
22
|
+
return [id.slice(0, idx1), '.' + id.slice(idx1)];
|
|
23
|
+
}
|
|
24
|
+
// 分割模块路径
|
|
25
|
+
const idx2 = id.indexOf('/', idx1 + 1);
|
|
26
|
+
if (idx2 === -1) {
|
|
27
|
+
return [id, '.'];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return [id.slice(0, idx2), '.' + id.slice(idx2)];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* 文件系统
|
|
4
|
+
*****************************************
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
alias?: Record<string, string>;
|
|
9
|
+
paths?: Record<string, string[]>;
|
|
10
|
+
cache?: Map<string, string | null | undefined>;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
module?: boolean;
|
|
13
|
+
moduleExports?: boolean;
|
|
14
|
+
mainFields?: string[];
|
|
15
|
+
conditions?: string[];
|
|
16
|
+
extensions?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*****************************************
|
|
20
|
+
* 解析路径
|
|
21
|
+
*****************************************
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvePath(id: string, issuer?: string, options?: Options): string | null | undefined;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2026-03-18 20:06:20
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.resolvePath = resolvePath;
|
|
10
|
+
/**
|
|
11
|
+
*****************************************
|
|
12
|
+
* 加载依赖
|
|
13
|
+
*****************************************
|
|
14
|
+
*/
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const loadTsConfig_1 = require("./loadTsConfig");
|
|
17
|
+
const sys_1 = require("./sys");
|
|
18
|
+
const isEsmModule_1 = require("./isEsmModule");
|
|
19
|
+
/**
|
|
20
|
+
*****************************************
|
|
21
|
+
* 创建文件系统
|
|
22
|
+
*****************************************
|
|
23
|
+
*/
|
|
24
|
+
function createFileSystem(options) {
|
|
25
|
+
return {
|
|
26
|
+
...sys_1.sys,
|
|
27
|
+
...options,
|
|
28
|
+
cache: options.cache || sys_1.sys.cache,
|
|
29
|
+
cwd: options.cwd || sys_1.sys.cwd,
|
|
30
|
+
mainFields: options.mainFields || sys_1.sys.mainFields,
|
|
31
|
+
conditions: options.conditions || sys_1.sys.conditions,
|
|
32
|
+
extensions: options.extensions || sys_1.sys.extensions,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*****************************************
|
|
37
|
+
* 判断是否为 ESM 模块
|
|
38
|
+
*****************************************
|
|
39
|
+
*/
|
|
40
|
+
function isEsmModule(dir, filename) {
|
|
41
|
+
if (filename) {
|
|
42
|
+
const result = (0, isEsmModule_1.isEsmFile)(filename);
|
|
43
|
+
if (result !== undefined) {
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// 判断为 ESM 模块
|
|
48
|
+
if ((0, isEsmModule_1.isEsmPackage)(dir)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
// 判断 TS 配置
|
|
52
|
+
const { module } = (0, loadTsConfig_1.loadCompilerOptions)(dir) || {};
|
|
53
|
+
if (module && module.toLowerCase().startsWith('es')) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
*****************************************
|
|
62
|
+
* 解析路径
|
|
63
|
+
*****************************************
|
|
64
|
+
*/
|
|
65
|
+
function resolvePath(id, issuer, options) {
|
|
66
|
+
const from = issuer ? (0, node_path_1.dirname)((0, node_path_1.resolve)(issuer)) : process.cwd();
|
|
67
|
+
const opts = options || {};
|
|
68
|
+
const sys = createFileSystem(opts);
|
|
69
|
+
// 设置模块路径映射
|
|
70
|
+
if (!opts.paths && !opts.baseUrl) {
|
|
71
|
+
const { baseUrl, paths } = (0, loadTsConfig_1.loadCompilerOptions)(from) || {};
|
|
72
|
+
sys.baseUrl = baseUrl;
|
|
73
|
+
sys.paths = paths;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
sys.baseUrl = opts.baseUrl && (0, node_path_1.resolve)(opts.baseUrl);
|
|
77
|
+
}
|
|
78
|
+
// 设置加载条件
|
|
79
|
+
if (!opts.conditions) {
|
|
80
|
+
sys.conditions = isEsmModule(from, issuer) ? ['import', 'node'] : ['require', 'node'];
|
|
81
|
+
}
|
|
82
|
+
// 生成缓存 ID
|
|
83
|
+
sys.cacheSalt = sys.conditions.join(',');
|
|
84
|
+
// 执行解析
|
|
85
|
+
return sys.resolve(id, from);
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* 加载依赖
|
|
4
|
+
*****************************************
|
|
5
|
+
*/
|
|
6
|
+
import { Dict } from './dict';
|
|
7
|
+
import { Match } from './resolveAlias';
|
|
8
|
+
/**
|
|
9
|
+
*****************************************
|
|
10
|
+
* 解析别名
|
|
11
|
+
*****************************************
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolvePaths(paths: Record<string, string[]>): Dict<Match>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2025-05-26 22:30:23
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.resolvePaths = resolvePaths;
|
|
10
|
+
const match_1 = require("./match");
|
|
11
|
+
const cache_1 = require("./cache");
|
|
12
|
+
const resolveAlias_1 = require("./resolveAlias");
|
|
13
|
+
const resolveDirect_1 = require("./resolveDirect");
|
|
14
|
+
/**
|
|
15
|
+
*****************************************
|
|
16
|
+
* 缓存
|
|
17
|
+
*****************************************
|
|
18
|
+
*/
|
|
19
|
+
const cached = (0, cache_1.cache)(new WeakMap());
|
|
20
|
+
/**
|
|
21
|
+
*****************************************
|
|
22
|
+
* 解析别名
|
|
23
|
+
*****************************************
|
|
24
|
+
*/
|
|
25
|
+
function resolvePaths(paths) {
|
|
26
|
+
return cached.get(paths, () => (0, resolveAlias_1.resolveDict)(paths, resolvePath));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*****************************************
|
|
30
|
+
* 解析匹配规则
|
|
31
|
+
*****************************************
|
|
32
|
+
*/
|
|
33
|
+
function resolvePath(key, paths) {
|
|
34
|
+
const { test, resolve } = (0, resolveDirect_1.resolveDirect)(key);
|
|
35
|
+
const rules = paths.map(resolve);
|
|
36
|
+
// 返回解析函数
|
|
37
|
+
return function resolve(id, handler) {
|
|
38
|
+
if (test(id)) {
|
|
39
|
+
return (0, match_1.match)(rules, direct => handler(direct(id)));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
package/dist/split.d.ts
ADDED
package/dist/split.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2025-05-24 23:56:16
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.split = split;
|
|
10
|
+
/**
|
|
11
|
+
*****************************************
|
|
12
|
+
* 分割字符串
|
|
13
|
+
*****************************************
|
|
14
|
+
*/
|
|
15
|
+
function split(str, sep) {
|
|
16
|
+
const idx = str.indexOf(sep);
|
|
17
|
+
// 执行切割
|
|
18
|
+
if (idx === -1) {
|
|
19
|
+
return [str, undefined];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return [str.slice(0, idx), str.slice(idx + sep.length)];
|
|
23
|
+
}
|
|
24
|
+
}
|
package/dist/sys.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { PackageDescription } from './loadPackageDescription';
|
|
2
|
+
/**
|
|
3
|
+
*****************************************
|
|
4
|
+
* 文件系统
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
export type FileSystem = typeof sys;
|
|
8
|
+
/**
|
|
9
|
+
*****************************************
|
|
10
|
+
* 文件系统
|
|
11
|
+
*****************************************
|
|
12
|
+
*/
|
|
13
|
+
export declare const sys: {
|
|
14
|
+
/** 解析基准路径 */
|
|
15
|
+
baseUrl: string | undefined;
|
|
16
|
+
/** 别名配置 */
|
|
17
|
+
alias: Record<string, string> | undefined;
|
|
18
|
+
/** 路径配置 */
|
|
19
|
+
paths: Record<string, string[]> | undefined;
|
|
20
|
+
/** 缓存 ID */
|
|
21
|
+
cacheSalt: string;
|
|
22
|
+
/** 缓存 */
|
|
23
|
+
cache: Map<string, string | null | undefined>;
|
|
24
|
+
/** 当前目录 */
|
|
25
|
+
cwd: string;
|
|
26
|
+
/** 是否解析模块 */
|
|
27
|
+
module: boolean;
|
|
28
|
+
/** 是否解析模块导出 */
|
|
29
|
+
moduleExports: boolean;
|
|
30
|
+
/** 解析 main 字段 */
|
|
31
|
+
mainFields: string[];
|
|
32
|
+
/** 解析条件 */
|
|
33
|
+
conditions: string[];
|
|
34
|
+
/** 解析扩展名 */
|
|
35
|
+
extensions: string[];
|
|
36
|
+
/** 解析路径 */
|
|
37
|
+
resolve(id: string, from: string): string | null | undefined;
|
|
38
|
+
/** 解析内部模块 */
|
|
39
|
+
resolveBuiltin(id: string): string | undefined;
|
|
40
|
+
/** 解析文件 */
|
|
41
|
+
resolveFile(id: string, from: string): string | null | undefined;
|
|
42
|
+
/** 解析文件目标 */
|
|
43
|
+
resolveTarget(path: string): string | undefined;
|
|
44
|
+
/** 解析目录 */
|
|
45
|
+
resolveDir(path: string): string | undefined;
|
|
46
|
+
/** 解析 main 文件 */
|
|
47
|
+
resolveMainFile(path: string, pkg: PackageDescription): string | undefined;
|
|
48
|
+
/** 解析 index 文件 */
|
|
49
|
+
resolveIndex(path: string): string | undefined;
|
|
50
|
+
/** 解析扩展名 */
|
|
51
|
+
resolveExtensions(path: string): string | undefined;
|
|
52
|
+
/** 解析包自身 */
|
|
53
|
+
resolveSelf(name: string, path: string, from: string): string | null | undefined;
|
|
54
|
+
/** 解析模块 */
|
|
55
|
+
resolveModule(id: string, from: string): string | null | undefined;
|
|
56
|
+
/** 解析模块导入 */
|
|
57
|
+
resolveModuleImports(id: string, from: string): string | null | undefined;
|
|
58
|
+
/** 解析模块导出 */
|
|
59
|
+
resolveModuleExports(id: string, from: string, pkg: PackageDescription): string | null | undefined;
|
|
60
|
+
};
|