main = async (args, { loadModule, pid, log }) => {
  await null;
  const {
    values: {
      format: moduleFormat = 'endoZipBase64',
      condition: conditions = [],
      'no-transforms': noTransforms,
      'elide-comments': elideComments,
      'cache-json': cacheJson,
      'cache-js': cacheJs,
      // deprecated
      to: cacheJsAlias,
    },
    positionals,
  } = parseArgs({ args, options, allowPositionals: true });

  if (noTransforms && elideComments) {
    throw Error(
      `Cannot elide comments without transforms (-T,--no-transforms + -e,--elide-comments)`,
    );
  }
  if (!SUPPORTED_FORMATS.includes(moduleFormat)) {
    throw Error(`Unsupported format: ${moduleFormat}\n\n${USAGE}`);
  }
  const format = /** @type {ModuleFormat} */ (moduleFormat);

  /** @type {string} */
  let dest;
  let cacheOpts;
  // `--to` option is deprecated, but we now use it to mean `--cache-js`.
  if (cacheJs !== undefined) {
    dest = cacheJs;
    cacheOpts = jsOpts;
  } else if (cacheJsAlias !== undefined) {
    dest = cacheJsAlias;
    cacheOpts = jsOpts;
  } else if (cacheJson !== undefined) {
    dest = cacheJson;
    cacheOpts = jsonOpts;
  } else {
    if (positionals.length !== 1) {
      throw new Error(USAGE);
    }
    const [entryPath] = positionals;
    const bundle = await bundleSource(entryPath, {
      noTransforms,
      elideComments,
      format,
      conditions,
    });
    process.stdout.write(JSON.stringify(bundle));
    process.stdout.write('\n');
    return;
  }

  if (
    !(
      positionals.length > 0 &&
      positionals.length % 2 === 0 &&
      [cacheJson, cacheJs, cacheJsAlias].filter(Boolean).length === 1
    )
  ) {
    throw Error(USAGE);
  }

  const cache = await makeNodeBundleCache(
    dest,
    { cacheOpts, cacheSourceMaps: true, log },
    loadModule,
    pid,
  );

  for (let ix = 0; ix < positionals.length; ix += 2) {
    const [bundleRoot, bundleName] = positionals.slice(ix, ix + 2);

    // eslint-disable-next-line no-await-in-loop
    await cache.validateOrAdd(bundleRoot, bundleName, undefined, {
      noTransforms,
      elideComments,
      format,
      conditions,
    });
  }
}
@param {[to: string, dest: string, ...rest: string[]]} args
@param {object} powers
@param {(spec: string) => any} powers.loadModule
@param {number} powers.pid
@param {import('../cache.js').Logger} [powers.log]
@returns {Promise<void>}