Skip to content

Commit 7ccee19

Browse files
authored
fix(web): support isServer flag in babel (#5158)
1 parent 5bfb5a4 commit 7ccee19

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/web/babel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = function (api: any, options: NxReactBabelPresetOptions = {}) {
1616
api.assertVersion(7);
1717

1818
const isModern = api.caller((caller) => caller?.isModern);
19+
// `isServer` is passed from `next-babel-loader`, when it compiles for the server
20+
const isServer = api.caller((caller) => caller?.isServer);
1921
const emitDecoratorMetadata = api.caller(
2022
(caller) => caller?.emitDecoratorMetadata ?? true
2123
);
@@ -28,7 +30,7 @@ module.exports = function (api: any, options: NxReactBabelPresetOptions = {}) {
2830
// For Jest tests, NODE_ENV is set as 'test' and we only want to set target as Node.
2931
// All other options will fail in Jest since Node does not support some ES features
3032
// such as import syntax.
31-
process.env.NODE_ENV === 'test'
33+
isServer || process.env.NODE_ENV === 'test'
3234
? { targets: { node: 'current' } }
3335
: {
3436
// Allow importing core-js in entrypoint and use browserlist to select polyfills.

0 commit comments

Comments
 (0)