Skip to content

Commit f68236e

Browse files
authored
chore: throw error when using bundleless mode with mf format (#983)
1 parent aa6a4d9 commit f68236e

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

packages/core/src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ const composeFormatConfig = ({
680680
return config;
681681
}
682682
case 'mf':
683+
if (bundle === false) {
684+
throw new Error(
685+
'When using "mf" 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.',
686+
);
687+
}
688+
683689
return {
684690
dev: {
685691
writeToDisk: true,

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/format/index.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,14 @@ test('CJS exports should be statically analyzable (cjs-module-lexer for Node.js)
100100
}
101101
`);
102102
});
103+
104+
test('throw error when using mf with `bundle: false`', async () => {
105+
const fixturePath = path.resolve(__dirname, 'mf-bundle-false');
106+
const build = buildAndGetResults({
107+
fixturePath,
108+
});
109+
110+
await expect(build).rejects.toThrowErrorMatchingInlineSnapshot(
111+
`[Error: When using "mf" 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.]`,
112+
);
113+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "format-mf-bundle-false-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { generateBundleMFConfig } from 'test-helper';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleMFConfig(
7+
{
8+
name: 'test',
9+
},
10+
{
11+
bundle: false,
12+
},
13+
),
14+
],
15+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'foo';

0 commit comments

Comments
 (0)