Skip to content

Commit

Permalink
[dev] Fix bazel watch command (#203750)
Browse files Browse the repository at this point in the history
## Summary
After #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.

(cherry picked from commit 785b333)
  • Loading branch information
delanni committed Dec 11, 2024
1 parent 0cf7aa3 commit 70f7a0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions kbn_pm/src/commands/watch_command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
},
};
4 changes: 3 additions & 1 deletion kbn_pm/src/lib/bazel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 70f7a0a

Please sign in to comment.