Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add =<val> to --help flags that accept values #17237

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

How are you supposed to know which CLI flags accept a value and which do not when we don't say in the CLI flag itself?

Before:

Usage:
  Transpile and bundle one or more files.
  bun build [flags] <entrypoint>

Flags:
      --compile                       Generate a standalone Bun executable containing your bundled code
      --bytecode                      Use a bytecode cache
      --watch                         Automatically restart the process on file change
      --no-clear-screen               Disable clearing the terminal screen on reload when --watch is enabled
      --target                        The intended execution environment for the bundle. "browser", "bun" or "node"
      --outdir                        Default to "dist" if multiple files
      --outfile                       Write to a file
      --sourcemap                     Build with sourcemaps - 'linked', 'inline', 'external', or 'none'
      --banner                        Add a banner to the bundled output such as "use client"; for a bundle being used with RSCs
      --footer                        Add a footer to the bundled output such as // built with bun!
      --format                        Specifies the module format to build to. Only "esm" is supported.
      --root                          Root directory used for multiple entry points
      --splitting                     Enable code splitting
      --public-path                   A prefix to be appended to any import paths in bundled code
  -e, --external                      Exclude module from transpilation (can use * wildcards). ex: -e react
      --packages                      Add dependencies to bundle or keep them external. "external", "bundle" is supported. Defaults to "bundle".
      --entry-naming                  Customize entry point filenames. Defaults to "[dir]/[name].[ext]"
      --chunk-naming                  Customize chunk filenames. Defaults to "[name]-[hash].[ext]"
      --asset-naming                  Customize asset filenames. Defaults to "[name]-[hash].[ext]"
      --react-fast-refresh            Enable React Fast Refresh transform (does not emit hot-module code, use this for testing)
      --no-bundle                     Transpile file only, do not bundle
      --emit-dce-annotations          Re-emit DCE annotations in bundles. Enabled by default unless --minify-whitespace is passed.
      --minify                        Enable all minification flags
      --minify-syntax                 Minify syntax and inline data
      --minify-whitespace             Minify whitespace
      --minify-identifiers            Minify identifiers
      --css-chunking                  Chunk CSS files together to reduce duplicated CSS loaded in a browser. Only has an effect when multiple entrypoints import CSS
      --conditions                    Pass custom conditions to resolve
      --app                           (EXPERIMENTAL) Build a web app for production using Bun Bake.
      --server-components             (EXPERIMENTAL) Enable server components
      --env                           Inline environment variables into the bundle as process.env.${name}. Defaults to 'disable'. To inline environment variables matching a prefix, use my prefix like 'FOO_PUBLIC_*'.
      --windows-hide-console          When using --compile targeting Windows, prevent a Command prompt from opening alongside the executable
      --windows-icon                  When using --compile targeting Windows, assign an executable icon
      --debug-dump-server-files       When --app is set, dump all server files to disk even when building statically
      --debug-no-minify               When --app is set, do not minify anything

Examples:
  Frontend web apps:
  bun build --outfile=bundle.js ./src/index.ts
  bun build --minify --splitting --outdir=out ./index.jsx ./lib/worker.ts

  Bundle code to be run in Bun (reduces server startup time)
  bun build --target=bun --outfile=server.js ./server.ts

  Creating a standalone executable (see https://bun.sh/docs/bundler/executables)
  bun build --compile --outfile=my-app ./cli.ts

A full list of flags is available at https://bun.sh/docs/bundler

After:

Usage:
  Transpile and bundle one or more files.
  bun build [flags] <entrypoint>

Flags:
      --compile                       Generate a standalone Bun executable containing your bundled code
      --bytecode                      Use a bytecode cache
      --watch                         Automatically restart the process on file change
      --no-clear-screen               Disable clearing the terminal screen on reload when --watch is enabled
      --target=<val>                  The intended execution environment for the bundle. "browser", "bun" or "node"
      --outdir=<val>                  Default to "dist" if multiple files
      --outfile=<val>                 Write to a file
      --sourcemap=<val>               Build with sourcemaps - 'linked', 'inline', 'external', or 'none'
      --banner=<val>                  Add a banner to the bundled output such as "use client"; for a bundle being used with RSCs
      --footer=<val>                  Add a footer to the bundled output such as // built with bun!
      --format=<val>                  Specifies the module format to build to. Only "esm" is supported.
      --root=<val>                    Root directory used for multiple entry points
      --splitting                     Enable code splitting
      --public-path=<val>             A prefix to be appended to any import paths in bundled code
  -e, --external=<val>                Exclude module from transpilation (can use * wildcards). ex: -e react
      --packages=<val>                Add dependencies to bundle or keep them external. "external", "bundle" is supported. Defaults to "bundle".
      --entry-naming=<val>            Customize entry point filenames. Defaults to "[dir]/[name].[ext]"
      --chunk-naming=<val>            Customize chunk filenames. Defaults to "[name]-[hash].[ext]"
      --asset-naming=<val>            Customize asset filenames. Defaults to "[name]-[hash].[ext]"
      --react-fast-refresh            Enable React Fast Refresh transform (does not emit hot-module code, use this for testing)
      --no-bundle                     Transpile file only, do not bundle
      --emit-dce-annotations          Re-emit DCE annotations in bundles. Enabled by default unless --minify-whitespace is passed.
      --minify                        Enable all minification flags
      --minify-syntax                 Minify syntax and inline data
      --minify-whitespace             Minify whitespace
      --minify-identifiers            Minify identifiers
      --css-chunking                  Chunk CSS files together to reduce duplicated CSS loaded in a browser. Only has an effect when multiple entrypoints import CSS
      --conditions=<val>              Pass custom conditions to resolve
      --app                           (EXPERIMENTAL) Build a web app for production using Bun Bake.
      --server-components             (EXPERIMENTAL) Enable server components
      --env=<val>                     Inline environment variables into the bundle as process.env.${name}. Defaults to 'disable'. To inline environment variables matching a prefix, use my prefix like 'FOO_PUBLIC_*'.
      --windows-hide-console          When using --compile targeting Windows, prevent a Command prompt from opening alongside the executable
      --windows-icon=<val>            When using --compile targeting Windows, assign an executable icon
      --debug-dump-server-files       When --app is set, dump all server files to disk even when building statically
      --debug-no-minify               When --app is set, do not minify anything

Examples:
  Frontend web apps:
  bun build --outfile=bundle.js ./src/index.ts
  bun build --minify --splitting --outdir=out ./index.jsx ./lib/worker.ts

  Bundle code to be run in Bun (reduces server startup time)
  bun build --target=bun --outfile=server.js ./server.ts

  Creating a standalone executable (see https://bun.sh/docs/bundler/executables)
  bun build --compile --outfile=my-app ./cli.ts

A full list of flags is available at https://bun.sh/docs/bundler

How did you verify your code works?

@robobun
Copy link

robobun commented Feb 10, 2025

Updated 7:52 AM PT - Feb 10th, 2025

@Jarred-Sumner, your commit eafeb5d has 6 failures in Build #11384:


🧪   try this PR locally:

bunx bun-pr 17237

@RiskyMH
Copy link
Member

RiskyMH commented Feb 10, 2025

would be nice to somehow also show which commands are "optional" and require= separator

@Jarred-Sumner
Copy link
Collaborator Author

would be nice to somehow also show which commands are "optional" and require= separator

yeah, but this is better than status quo

@Jarred-Sumner Jarred-Sumner merged commit 02d4534 into main Feb 11, 2025
52 of 69 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/usage branch February 11, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants