compiler/packages/react-forgive/scripts/build.mjs 59 lines View on github.com → Search inside
1#!/usr/bin/env node23/**4 * Copyright (c) Meta Platforms, Inc. and affiliates.5 *6 * This source code is licensed under the MIT license found in the7 * LICENSE file in the root directory of this source tree.8 */910import * as esbuild from 'esbuild';11import yargs from 'yargs';12import * as Server from './server.mjs';13import * as Client from './client.mjs';14import path from 'path';15import {fileURLToPath} from 'url';1617const IS_DEV = process.env.NODE_ENV === 'development';18const __filename = fileURLToPath(import.meta.url);19const __dirname = path.dirname(__filename);2021const argv = yargs(process.argv.slice(2))22  .choices('t', ['client', 'server'])23  .options('w', {24    alias: 'watch',25    default: false,26    type: 'boolean',27  })28  .parse();2930async function main() {31  if (argv.w) {32    const serverCtx = await esbuild.context(Server.config);33    const clientCtx = await esbuild.context(Client.config);34    await Promise.all([serverCtx.watch(), clientCtx.watch()]);35    console.log('watching for changes...');36  } else {37    switch (argv.t) {38      case 'server': {39        await esbuild.build({40          sourcemap: IS_DEV,41          minify: IS_DEV === false,42          ...Server.config,43        });44        break;45      }46      case 'client': {47        await esbuild.build({48          sourcemap: IS_DEV,49          minify: IS_DEV === false,50          ...Client.config,51        });52        break;53      }54    }55  }56}5758main();

Code quality findings 6

Use strict equality (===) to prevent type coercion bugs
info correctness loose-equality
const IS_DEV = process.env.NODE_ENV === 'development';
Ensure all async functions handle errors properly
info correctness async-without-catch
async function main() {
Remove debugging statements or use a logging library
info correctness console-log
console.log('watching for changes...');
Ensure all cases are handled or a default case is present
info correctness switch-without-default
switch (argv.t) {
Use strict equality (===) to prevent type coercion bugs
info correctness loose-equality
minify: IS_DEV === false,
Use strict equality (===) to prevent type coercion bugs
info correctness loose-equality
minify: IS_DEV === false,

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.