Skip to content

Commit 234bdcd

Browse files
committed
cr
1 parent ac405e8 commit 234bdcd

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

packages/core/src/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,14 @@ const BundlePlugin = (): RsbuildPlugin => ({
849849
if (bundlerConfigs) {
850850
for (const config of bundlerConfigs) {
851851
if (config?.module?.parser?.javascript?.jsx === true) {
852-
throw new Error(
853-
'Bundle mode does not support preserving JSX syntax. Set `bundle` to `false` or change the JSX runtime to `automatic` or `classic`.',
852+
logger.error(
853+
'Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' +
854+
color.green(
855+
'https://rslib.rs/guide/solution/react#jsx-transform',
856+
) +
857+
' for more details.',
854858
);
859+
process.exit(1);
855860
}
856861
}
857862
}

tests/integration/preserve-jsx/index.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join } from 'node:path';
22
import { expect, test } from '@rstest/core';
3-
import { buildAndGetResults, queryContent } from 'test-helper';
3+
import { buildAndGetResults, proxyConsole, queryContent } from 'test-helper';
44

55
test('JSX syntax should be preserved', async () => {
66
const fixturePath = join(__dirname, 'default');
@@ -43,9 +43,17 @@ test('JSX syntax should be preserved', async () => {
4343

4444
test('throw error when preserve JSX with bundle mode', async () => {
4545
const fixturePath = join(__dirname, 'forbid-bundle');
46-
const build = buildAndGetResults({ fixturePath });
46+
const { logs, restore } = proxyConsole();
4747

48-
await expect(build).rejects.toThrowError(
49-
'Bundle mode does not support preserving JSX syntax. Set `bundle` to `false` or change the JSX runtime to `automatic` or `classic`.',
50-
);
48+
try {
49+
await buildAndGetResults({ fixturePath });
50+
} catch {
51+
expect(logs).toMatchInlineSnapshot(`
52+
[
53+
"error Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to \`automatic\` or \`classic\`. Check out https://rslib.rs/guide/solution/react#jsx-transform for more details.",
54+
]
55+
`);
56+
} finally {
57+
restore();
58+
}
5159
});

0 commit comments

Comments
 (0)