Skip to content

Commit 46806c8

Browse files
committed
cr1
1 parent 46b0be4 commit 46806c8

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

packages/core/src/config.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import type {
3838
DeepRequired,
3939
ExcludesFalse,
4040
Format,
41-
GetAsyncFunctionFromUnion,
4241
JsRedirect,
4342
LibConfig,
4443
LibOnlyConfig,
@@ -52,6 +51,7 @@ import type {
5251
RslibConfigAsyncFn,
5352
RslibConfigExport,
5453
RslibConfigSyncFn,
54+
RspackResolver,
5555
Shims,
5656
Syntax,
5757
} from './types';
@@ -970,14 +970,11 @@ const composeBundlelessExternalConfig = (
970970
} => {
971971
if (bundle) return { config: {} };
972972

973-
const doesRedirectStyle = redirect.style ?? true;
973+
const isStyleRedirected = redirect.style ?? true;
974974
const jsRedirectPath = redirect.js?.path ?? true;
975975
const jsRedirectExtension = redirect.js?.extension ?? true;
976976

977-
type Resolver = GetAsyncFunctionFromUnion<
978-
ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>
979-
>;
980-
let resolver: Resolver | undefined;
977+
let resolver: RspackResolver | undefined;
981978

982979
return {
983980
resolvedJsRedirect: {
@@ -994,7 +991,7 @@ const composeBundlelessExternalConfig = (
994991
}
995992

996993
if (!resolver) {
997-
resolver = (await getResolve()) as Resolver;
994+
resolver = (await getResolve()) as RspackResolver;
998995
}
999996

1000997
// Issuer is not empty string when the module is imported by another module.
@@ -1007,7 +1004,7 @@ const composeBundlelessExternalConfig = (
10071004
callback,
10081005
jsExtension,
10091006
cssModulesAuto,
1010-
doesRedirectStyle,
1007+
isStyleRedirected,
10111008
);
10121009

10131010
if (cssExternal !== false) {

packages/core/src/types/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { RsbuildConfig } from '@rsbuild/core';
1+
import type { RsbuildConfig, Rspack } from '@rsbuild/core';
22
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
3+
import type { GetAsyncFunctionFromUnion } from './utils';
34

45
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
56

@@ -28,6 +29,9 @@ export type RsbuildConfigEntry = NonNullable<
2829
NonNullable<RsbuildConfig['source']>['entry']
2930
>;
3031
export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
32+
export type RspackResolver = GetAsyncFunctionFromUnion<
33+
ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>
34+
>;
3135

3236
export type RsbuildConfigOutputTarget = NonNullable<
3337
RsbuildConfig['output']

website/docs/en/config/lib/redirect.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Configure the redirect for import paths in output files. In bundleless mode, the
3838

3939
Common scenarios that require redirect:
4040

41-
- Automatically convert `paths` in `tsconfig.json` to correct relative path
41+
- Automatically convert `compilerOptions.paths` in tsconfig.json to correct relative path
4242

4343
For example, set `compilerOptions.paths` to `{ "@/*": ["src/*"] }` in tsconfig.json, the output file will be redirected to the correct relative path:
4444

website/docs/zh/config/lib/redirect.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const defaultRedirect = {
3838

3939
常见的需要 redirect 的场景:
4040

41-
- 自动将 tsconfig.json 路径转换为正确的相对路径
41+
- 自动将 tsconfig.json `compilerOptions.paths` 转换为正确的相对路径
4242

4343
例如,在 tsconfig.json 中将 `compilerOptions.paths` 设置为 `{ "@/*": ["src/*"] }`,输出文件将被重定向到正确的相对路径:
4444

0 commit comments

Comments
 (0)