Skip to content

Commit e9b87d3

Browse files
committed
up
1 parent 158acce commit e9b87d3

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

examples/react-component-umd/rslib.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export default defineConfig({
1313
},
1414
distPath: {
1515
root: './dist/umd',
16-
css: '.',
17-
cssAsync: '.',
1816
},
1917
},
2018
},

packages/core/src/config.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
BannerAndFooter,
3434
Format,
3535
LibConfig,
36+
LibOnlyConfig,
3637
PkgJson,
3738
Redirect,
3839
RsbuildConfigOutputTarget,
@@ -1112,19 +1113,20 @@ export async function composeCreateRsbuildConfig(
11121113
config: mergeRsbuildConfig(
11131114
constantRsbuildConfig,
11141115
libRsbuildConfig,
1115-
omit(userConfig, [
1116-
'bundle',
1117-
'format',
1118-
'autoExtension',
1119-
'autoExternal',
1120-
'redirect',
1121-
'syntax',
1122-
'externalHelpers',
1123-
'banner',
1124-
'footer',
1125-
'dts',
1126-
'shims',
1127-
]),
1116+
omit<LibConfig, keyof LibOnlyConfig>(userConfig, {
1117+
bundle: true,
1118+
format: true,
1119+
autoExtension: true,
1120+
autoExternal: true,
1121+
redirect: true,
1122+
syntax: true,
1123+
externalHelpers: true,
1124+
banner: true,
1125+
footer: true,
1126+
dts: true,
1127+
shims: true,
1128+
umdName: true,
1129+
}),
11281130
),
11291131
};
11301132
});

packages/core/src/types/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export interface LibConfig extends RsbuildConfig {
8383
umdName?: string;
8484
}
8585

86+
export type LibOnlyConfig = Omit<LibConfig, keyof RsbuildConfig>;
87+
8688
export interface RslibConfig extends RsbuildConfig {
8789
lib: LibConfig[];
8890
}

packages/core/src/utils/helper.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,17 @@ export function pick<T, U extends keyof T>(
147147

148148
export function omit<T extends object, U extends keyof T>(
149149
obj: T,
150-
keys: ReadonlyArray<U>,
151-
): Omit<T, U> {
150+
keysObj: Record<U, boolean>,
151+
): Omit<T, keyof U> {
152+
type K = keyof U;
152153
return Object.keys(obj).reduce(
153154
(ret, key) => {
154-
if (!keys.includes(key as U)) {
155-
ret[key as keyof Omit<T, U>] = obj[key as keyof Omit<T, U>];
155+
if (keysObj[key as U] !== true) {
156+
ret[key as keyof Omit<T, K>] = obj[key as keyof Omit<T, K>];
156157
}
157158
return ret;
158159
},
159-
{} as Omit<T, U>,
160+
{} as Omit<T, K>,
160161
);
161162
}
162163

tests/integration/umd/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ test('throw error when using UMD with `bundle: false`', async () => {
1919
});
2020

2121
expect(build).rejects.toThrowErrorMatchingInlineSnapshot(
22-
`[Error: When "format" is set to "umd", "bundle" must not be set to "false", consider setting "bundle" to "true" or remove the field, it's default value is "true".]`,
22+
`[Error: When using "umd" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.]`,
2323
);
2424
});

0 commit comments

Comments
 (0)