Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions packages/core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import type {
ConfigChainWithContext,
MaybePromise,
OneOrMany,
Optional,
TwoLevelReadonly,
} from './utils';

Expand Down Expand Up @@ -535,22 +536,13 @@ export interface ServerConfig {

export type NormalizedServerConfig = {
publicDir: Required<PublicDirOptions>[];
} & Pick<ServerConfig, 'headers' | 'https' | 'historyApiFallback' | 'proxy'> &
Required<
Pick<
ServerConfig,
| 'htmlFallback'
| 'port'
| 'host'
| 'compress'
| 'strictPort'
| 'printUrls'
| 'open'
| 'base'
| 'cors'
| 'middlewareMode'
>
>;
} & Omit<
Optional<
Required<ServerConfig>,
'headers' | 'https' | 'historyApiFallback' | 'proxy'
>,
'publicDir'
>;

export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';

Expand Down Expand Up @@ -1320,8 +1312,7 @@ export interface OutputConfig {
export interface NormalizedOutputConfig extends OutputConfig {
target: RsbuildTarget;
filename: FilenameConfig;
distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'> &
Pick<DistPathConfig, 'jsAsync' | 'cssAsync' | 'js'>;
distPath: Optional<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'>;
polyfill: Polyfill;
sourceMap:
| boolean
Expand Down Expand Up @@ -1698,8 +1689,10 @@ export type ClientConfig = {
overlay?: boolean;
};

export type NormalizedClientConfig = Pick<ClientConfig, 'protocol'> &
Omit<Required<ClientConfig>, 'protocol'>;
export type NormalizedClientConfig = Optional<
Required<ClientConfig>,
'protocol'
>;

export type { ChokidarOptions };

Expand Down Expand Up @@ -2000,10 +1993,7 @@ export type MergedEnvironmentConfig = {
resolve: NormalizedResolveConfig;
source: NormalizedSourceConfig;
output: Omit<NormalizedOutputConfig, 'distPath'> & {
distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync'> & {
jsAsync?: string;
cssAsync?: string;
};
distPath: Optional<Required<DistPathConfig>, 'jsAsync' | 'cssAsync'>;
};
plugins?: RsbuildPlugins;
security: NormalizedSecurityConfig;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type OneOrMany<T> = T | T[];

export type MaybePromise<T> = T | Promise<T>;

export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

/**
* Creates a type with readonly properties at the first and second levels only.
*/
Expand Down
Loading