[dev] Fix bazel watch command (#203750)

## Summary
After https://github.com/elastic/kibana/pull/193113 - the `yarn kbn
watch` command fails with an error, because the required variable
REACT_18 is not available.

This PR fixes that, by defining the variable for bazel.
This commit is contained in:
Alex Szabo 2024-12-11 18:00:17 +01:00 committed by GitHub
parent 791aff08e4
commit 785b333fb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -27,6 +27,7 @@ export const command = {
async run({ args, log }) {
await Bazel.watch(log, {
offline: args.getBooleanValue('offline') ?? true,
reactVersion: process.env.REACT_18 ? '18' : '17',
});
},
};

View file

@ -83,7 +83,7 @@ async function runBazel(log, inputArgs, opts = undefined) {
/**
*
* @param {import('./log.mjs').Log} log
* @param {{ offline: boolean } | undefined} opts
* @param {{ offline: boolean, reactVersion?: string } | undefined} opts
*/
export async function watch(log, opts = undefined) {
const ibazel = (await getBazelRunner()).runIBazel;
@ -97,10 +97,12 @@ export async function watch(log, opts = undefined) {
...BAZEL_TARGETS,
'--show_result=1',
...(opts?.offline ? ['--config=offline'] : []),
`--define=REACT_18=${opts?.reactVersion === '18' ? 'true' : 'false'}`,
];
log.debug(`> ibazel ${args.join(' ')}`);
await ibazel(args, {
cwd: REPO_ROOT,
env: { ...process.env, REACT_18: opts?.reactVersion === '18' ? 'true' : 'false' },
logPrefix: Color.info('[ibazel]'),
onErrorExit(code, output) {
throwBazelError(log, 'ibazel', code, output);