@rsdoctor/core 1.6.4 → 1.6.5
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.
|
@@ -45,6 +45,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
45
45
|
shouldSkipLoader: ()=>shouldSkipLoader
|
|
46
46
|
});
|
|
47
47
|
const resolver_namespaceObject = require("@rspack/resolver");
|
|
48
|
+
const external_enhanced_resolve_namespaceObject = require("enhanced-resolve");
|
|
49
|
+
var external_enhanced_resolve_default = /*#__PURE__*/ __webpack_require__.n(external_enhanced_resolve_namespaceObject);
|
|
48
50
|
const compat_namespaceObject = require("es-toolkit/compat");
|
|
49
51
|
const external_path_namespaceObject = require("path");
|
|
50
52
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
@@ -86,8 +88,17 @@ function shouldSkipLoader(loaderContext) {
|
|
|
86
88
|
}
|
|
87
89
|
return false;
|
|
88
90
|
}
|
|
91
|
+
function normalizeFallback(fallback) {
|
|
92
|
+
if (!fallback) return;
|
|
93
|
+
return Object.fromEntries(Object.entries(fallback).map(([name, value])=>[
|
|
94
|
+
name,
|
|
95
|
+
(Array.isArray(value) ? value : [
|
|
96
|
+
value
|
|
97
|
+
]).map((item)=>false === item ? null : item)
|
|
98
|
+
]));
|
|
99
|
+
}
|
|
89
100
|
function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolveLoader) {
|
|
90
|
-
const
|
|
101
|
+
const resolverOptions = {
|
|
91
102
|
conditionNames: [
|
|
92
103
|
'loader',
|
|
93
104
|
'require',
|
|
@@ -111,11 +122,22 @@ function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolv
|
|
|
111
122
|
'node_modules'
|
|
112
123
|
],
|
|
113
124
|
...resolveLoader
|
|
114
|
-
}
|
|
125
|
+
};
|
|
126
|
+
const fallback = resolveLoader?.fallback;
|
|
127
|
+
const resolveSync = Array.isArray(fallback) ? external_enhanced_resolve_default().create.sync({
|
|
128
|
+
...resolverOptions,
|
|
129
|
+
fallback
|
|
130
|
+
}) : (()=>{
|
|
131
|
+
const resolver = new resolver_namespaceObject.ResolverFactory({
|
|
132
|
+
...resolverOptions,
|
|
133
|
+
fallback: normalizeFallback(fallback)
|
|
134
|
+
});
|
|
135
|
+
return (directory, request)=>resolver.sync(directory, request).path;
|
|
136
|
+
})();
|
|
115
137
|
const resolve = (target)=>{
|
|
116
138
|
try {
|
|
117
|
-
const result =
|
|
118
|
-
if (result
|
|
139
|
+
const result = resolveSync(cwd, target);
|
|
140
|
+
if (result) return result;
|
|
119
141
|
} catch {}
|
|
120
142
|
return target;
|
|
121
143
|
};
|
|
@@ -8,6 +8,7 @@ export declare function getOriginLoaderModule(loaderContext: Plugin.LoaderContex
|
|
|
8
8
|
export declare function shouldSkipLoader(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): boolean;
|
|
9
9
|
export type CompatibleResolve = Omit<Plugin.Configuration['resolve'], 'mainFields'> & {
|
|
10
10
|
mainFields?: string[];
|
|
11
|
+
fallback?: NonNullable<Plugin.Configuration['resolve']>['fallback'];
|
|
11
12
|
};
|
|
12
13
|
export declare function interceptLoader<T extends Plugin.BuildRuleSetRule>(rules: T[], loaderPath: string, options: Omit<ProxyLoaderInternalOptions, 'loader' | 'hasOptions'>, cwd?: string, resolveLoader?: CompatibleResolve): T[];
|
|
13
14
|
export declare function reportLoader(ctx: Plugin.LoaderContext<ProxyLoaderOptions>, start: number, startHRTime: [number, number], isPitch: boolean, sync: boolean, code: string, err: Error | null | undefined, res: string | Buffer | null, sourceMap?: Plugin.SourceMapInput): Promise<SDK.LoaderData>;
|
|
@@ -8,6 +8,7 @@ export declare function getOriginLoaderModule(loaderContext: Plugin.LoaderContex
|
|
|
8
8
|
export declare function shouldSkipLoader(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): boolean;
|
|
9
9
|
export type CompatibleResolve = Omit<Plugin.Configuration['resolve'], 'mainFields'> & {
|
|
10
10
|
mainFields?: string[];
|
|
11
|
+
fallback?: NonNullable<Plugin.Configuration['resolve']>['fallback'];
|
|
11
12
|
};
|
|
12
13
|
export declare function interceptLoader<T extends Plugin.BuildRuleSetRule>(rules: T[], loaderPath: string, options: Omit<ProxyLoaderInternalOptions, 'loader' | 'hasOptions'>, cwd?: string, resolveLoader?: CompatibleResolve): T[];
|
|
13
14
|
export declare function reportLoader(ctx: Plugin.LoaderContext<ProxyLoaderOptions>, start: number, startHRTime: [number, number], isPitch: boolean, sync: boolean, code: string, err: Error | null | undefined, res: string | Buffer | null, sourceMap?: Plugin.SourceMapInput): Promise<SDK.LoaderData>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { ResolverFactory } from "@rspack/resolver";
|
|
3
|
+
import enhanced_resolve from "enhanced-resolve";
|
|
3
4
|
import { omit } from "es-toolkit/compat";
|
|
4
5
|
import path from "path";
|
|
5
6
|
import { logger } from "@rsdoctor/utils/logger";
|
|
@@ -40,8 +41,17 @@ function shouldSkipLoader(loaderContext) {
|
|
|
40
41
|
}
|
|
41
42
|
return false;
|
|
42
43
|
}
|
|
44
|
+
function normalizeFallback(fallback) {
|
|
45
|
+
if (!fallback) return;
|
|
46
|
+
return Object.fromEntries(Object.entries(fallback).map(([name, value])=>[
|
|
47
|
+
name,
|
|
48
|
+
(Array.isArray(value) ? value : [
|
|
49
|
+
value
|
|
50
|
+
]).map((item)=>false === item ? null : item)
|
|
51
|
+
]));
|
|
52
|
+
}
|
|
43
53
|
function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolveLoader) {
|
|
44
|
-
const
|
|
54
|
+
const resolverOptions = {
|
|
45
55
|
conditionNames: [
|
|
46
56
|
'loader',
|
|
47
57
|
'require',
|
|
@@ -65,11 +75,22 @@ function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolv
|
|
|
65
75
|
'node_modules'
|
|
66
76
|
],
|
|
67
77
|
...resolveLoader
|
|
68
|
-
}
|
|
78
|
+
};
|
|
79
|
+
const fallback = resolveLoader?.fallback;
|
|
80
|
+
const resolveSync = Array.isArray(fallback) ? enhanced_resolve.create.sync({
|
|
81
|
+
...resolverOptions,
|
|
82
|
+
fallback
|
|
83
|
+
}) : (()=>{
|
|
84
|
+
const resolver = new ResolverFactory({
|
|
85
|
+
...resolverOptions,
|
|
86
|
+
fallback: normalizeFallback(fallback)
|
|
87
|
+
});
|
|
88
|
+
return (directory, request)=>resolver.sync(directory, request).path;
|
|
89
|
+
})();
|
|
69
90
|
const resolve = (target)=>{
|
|
70
91
|
try {
|
|
71
|
-
const result =
|
|
72
|
-
if (result
|
|
92
|
+
const result = resolveSync(cwd, target);
|
|
93
|
+
if (result) return result;
|
|
73
94
|
} catch {}
|
|
74
95
|
return target;
|
|
75
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -86,18 +86,19 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"browserslist-load-config": "^1.0.2",
|
|
90
89
|
"@rsbuild/plugin-check-syntax": "^1.6.1",
|
|
91
90
|
"@rspack/resolver": "^0.2.8",
|
|
91
|
+
"browserslist-load-config": "^1.0.2",
|
|
92
|
+
"enhanced-resolve": "^5.20.0",
|
|
92
93
|
"es-toolkit": "^1.49.0",
|
|
93
94
|
"filesize": "^11.0.17",
|
|
94
95
|
"fs-extra": "^11.1.1",
|
|
95
96
|
"semver": "^7.8.5",
|
|
96
97
|
"source-map": "^0.7.6",
|
|
97
|
-
"@rsdoctor/graph": "1.6.
|
|
98
|
-
"@rsdoctor/sdk": "1.6.
|
|
99
|
-
"@rsdoctor/utils": "1.6.
|
|
100
|
-
"@rsdoctor/types": "1.6.
|
|
98
|
+
"@rsdoctor/graph": "1.6.5",
|
|
99
|
+
"@rsdoctor/sdk": "1.6.5",
|
|
100
|
+
"@rsdoctor/utils": "1.6.5",
|
|
101
|
+
"@rsdoctor/types": "1.6.5"
|
|
101
102
|
},
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@rspack/core": "^2.0.5",
|