Skip to content

Commit

Permalink
feat(react): allow setting react preset to production when using cust…
Browse files Browse the repository at this point in the history
…om BABEL_ENV
  • Loading branch information
AgentEnder committed Sep 13, 2023
1 parent f639883 commit ba298c2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/react/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

interface NxReactBabelOptions {
production?: boolean;
runtime?: string;
importSource?: string;
useBuiltIns?: boolean | string;
Expand Down Expand Up @@ -51,10 +52,20 @@ module.exports = function (api: any, options: NxReactBabelOptions) {
};
};

function getReactPresetOptions({ presetOptions, env }) {
function getReactPresetOptions({
presetOptions,
env,
}: {
env: string;
presetOptions: NxReactBabelOptions;
}) {
const reactPresetOptions: Record<string, string | boolean> = {
runtime: presetOptions.runtime ?? 'automatic',
development: env !== 'production',
development:
presetOptions.production === undefined ||
presetOptions.production === null
? env !== 'production'
: !presetOptions.production,
};

// JSX spread is transformed into object spread in `@babel/plugin-transform-react-jsx`
Expand Down

0 comments on commit ba298c2

Please sign in to comment.