cli: disable JSX transform for backend bundling

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-11-28 13:04:22 +01:00
parent 99aa3857fb
commit 8fffe42708
2 changed files with 27 additions and 16 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
JSX and React Fast Refresh transforms are no longer enabled when bundling backend code.
+22 -16
View File
@@ -62,14 +62,16 @@ export const transforms = (options: TransformOptions): Transforms => {
externalHelpers: !isBackend,
parser: {
syntax: 'typescript',
tsx: true,
tsx: !isBackend,
dynamicImport: true,
},
transform: {
react: {
runtime: 'automatic',
refresh: isDev,
},
react: isBackend
? undefined
: {
runtime: 'automatic',
refresh: isDev,
},
},
},
},
@@ -88,14 +90,16 @@ export const transforms = (options: TransformOptions): Transforms => {
externalHelpers: !isBackend,
parser: {
syntax: 'ecmascript',
jsx: true,
jsx: !isBackend,
dynamicImport: true,
},
transform: {
react: {
runtime: 'automatic',
refresh: isDev,
},
react: isBackend
? undefined
: {
runtime: 'automatic',
refresh: isDev,
},
},
},
},
@@ -119,7 +123,7 @@ export const transforms = (options: TransformOptions): Transforms => {
externalHelpers: !isBackend,
parser: {
syntax: 'ecmascript',
jsx: true,
jsx: !isBackend,
dynamicImport: true,
},
},
@@ -188,11 +192,13 @@ export const transforms = (options: TransformOptions): Transforms => {
const plugins = new Array<WebpackPluginInstance>();
if (isDev) {
plugins.push(
new ReactRefreshPlugin({
overlay: { sockProtocol: 'ws' },
}),
);
if (!isBackend) {
plugins.push(
new ReactRefreshPlugin({
overlay: { sockProtocol: 'ws' },
}),
);
}
} else {
plugins.push(
new MiniCssExtractPlugin({