Skip to content

Commit c1afd84

Browse files
committed
cr1
1 parent 1ebdcbb commit c1afd84

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
@@ -39,7 +39,6 @@ import type {
3939
DeepRequired,
4040
ExcludesFalse,
4141
Format,
42-
GetAsyncFunctionFromUnion,
4342
JsRedirect,
4443
LibConfig,
4544
LibOnlyConfig,
@@ -53,6 +52,7 @@ import type {
5352
RslibConfigAsyncFn,
5453
RslibConfigExport,
5554
RslibConfigSyncFn,
55+
RspackResolver,
5656
Shims,
5757
Syntax,
5858
} from './types';
@@ -971,14 +971,11 @@ const composeBundlelessExternalConfig = (
971971
} => {
972972
if (bundle) return { config: {} };
973973

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

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

983980
return {
984981
resolvedJsRedirect: {
@@ -995,7 +992,7 @@ const composeBundlelessExternalConfig = (
995992
}
996993

997994
if (!resolver) {
998-
resolver = (await getResolve()) as Resolver;
995+
resolver = (await getResolve()) as RspackResolver;
999996
}
1000997

1001998
// Issuer is not empty string when the module is imported by another module.
@@ -1008,7 +1005,7 @@ const composeBundlelessExternalConfig = (
10081005
callback,
10091006
jsExtension,
10101007
cssModulesAuto,
1011-
doesRedirectStyle,
1008+
isStyleRedirected,
10121009
);
10131010

10141011
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)