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
6 changes: 6 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,12 @@ const composeFormatConfig = ({
return config;
}
case 'mf':
if (bundle === false) {
throw new 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.',
);
}

return {
dev: {
writeToDisk: true,
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/integration/format/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ test('CJS exports should be statically analyzable (cjs-module-lexer for Node.js)
}
`);
});

test('throw error when using mf with `bundle: false`', async () => {
const fixturePath = path.resolve(__dirname, 'mf-bundle-false');
const build = buildAndGetResults({
fixturePath,
});

await expect(build).rejects.toThrowErrorMatchingInlineSnapshot(
`[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.]`,
);
});
6 changes: 6 additions & 0 deletions tests/integration/format/mf-bundle-false/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "format-mf-bundle-false-test",
"version": "1.0.0",
"private": true,
"type": "module"
}
15 changes: 15 additions & 0 deletions tests/integration/format/mf-bundle-false/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from '@rslib/core';
import { generateBundleMFConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleMFConfig(
{
name: 'test',
},
{
bundle: false,
},
),
],
});
1 change: 1 addition & 0 deletions tests/integration/format/mf-bundle-false/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = 'foo';
Loading