@lynx-js/react-alias-rsbuild-plugin 0.10.3 → 0.10.4
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export interface Options {
|
|
|
8
8
|
rootPath?: string | undefined;
|
|
9
9
|
}
|
|
10
10
|
export declare function pluginReactAlias(options: Options): RsbuildPlugin;
|
|
11
|
-
export declare function createLazyResolver(
|
|
11
|
+
export declare function createLazyResolver(directory: string, conditionNames: string[]): (request: string) => Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -84,14 +84,25 @@ function pluginReactAlias(options) {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function createLazyResolver(
|
|
87
|
+
function createLazyResolver(directory, conditionNames) {
|
|
88
88
|
let lazyExports;
|
|
89
89
|
let resolverLazy;
|
|
90
90
|
return async (request)=>{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
if (!lazyExports) lazyExports = {};
|
|
92
|
+
if (void 0 === lazyExports[request]) {
|
|
93
|
+
if (!resolverLazy) {
|
|
94
|
+
const { ResolverFactory } = await import("unrs-resolver");
|
|
95
|
+
const resolver = new ResolverFactory({
|
|
96
|
+
conditionNames
|
|
97
|
+
});
|
|
98
|
+
resolverLazy = (dir, req)=>resolver.sync(dir, req);
|
|
99
|
+
}
|
|
100
|
+
const resolveResult = resolverLazy(directory, request);
|
|
101
|
+
if (resolveResult.error) throw new Error(resolveResult.error);
|
|
102
|
+
if (!resolveResult.path) throw new Error(`Failed to resolve ${request}`);
|
|
103
|
+
lazyExports[request] = resolveResult.path;
|
|
104
|
+
}
|
|
105
|
+
return lazyExports[request];
|
|
95
106
|
};
|
|
96
107
|
}
|
|
97
108
|
export { createLazyResolver, pluginReactAlias };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-alias-rsbuild-plugin",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "A rsbuild plugin for making alias in ReactLynx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rsbuild",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"
|
|
35
|
+
"unrs-resolver": "^1.7.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@microsoft/api-extractor": "7.52.8",
|
|
39
39
|
"@rsbuild/core": "1.3.21",
|
|
40
|
-
"@lynx-js/react": "0.
|
|
41
|
-
"@lynx-js/react-webpack-plugin": "0.6.
|
|
40
|
+
"@lynx-js/react": "0.110.0",
|
|
41
|
+
"@lynx-js/react-webpack-plugin": "0.6.16",
|
|
42
42
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|