BABEL.JS(1)

πŸ’– BABEL.JS πŸ’–

okay bestie, sit down, hydrate, because we're talking about babel.js β€” the compiler for writing next generation JavaScript ✨ It's a User Command, it lives in section 1 of the manual (the one for actual commands you type, iykyk), and honestly? it's giving main character energy in every JS build pipeline ever. πŸŽ€


🌸 NAME 🌸

babel.js β€” the compiler for writing next generation JavaScript πŸ¦‹

Like, you write the fancy new syntax, and babel just handles it. No cap. πŸ’…


✨ SYNOPSIS ✨

babel [options] <files ...>

that's it, that's the whole vibe. options go in, files go in, out comes ✨compiled✨ JavaScript. 🫢


πŸ‘‘ OPTIONS πŸ‘‘

okay so here's the full menu, and yes we're going through every single one because you deserve the whole tea, not a summary. πŸ’œ

  • -f, --filename [filename] β€” the filename to use when reading from stdin. this shows up in source-maps, errors, etc. so like, when your code is screaming at you, at least it knows your name πŸ₯Ί
  • --presets [list] β€” a comma-separated list of preset names. (comma-separated! don't be out here writing spaces like a menace) 🌈
  • --plugins [list] β€” a comma-separated list of plugin names. same deal, commas, bestie πŸŽ€
  • --config-file [path] β€” path to a .babelrc file to use. point it at your config and go πŸ’…
  • --env-name [name] β€” the name of the 'env' to use when loading configs and plugins. defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'. so the fallback chain is: BABEL_ENV β†’ NODE_ENV β†’ 'development'. periodt. πŸ”₯
  • --root-mode [mode] β€” the project-root resolution mode. one of 'root' (that's the default, the standard, the moment), 'upward', or 'upward-optional'. ⭐
  • --source-type [script|module] β€” yeah so that's the option, script or module, and that's literally all it says. no extra description, we move. πŸ’€
  • --no-babelrc β€” whether or not to look up .babelrc and .babelignore files. 🧚
  • --ignore [list] β€” list of glob paths to not compile. emphasis on the not, bestie, these ones get skipped πŸ™ˆ
  • --only [list] β€” list of glob paths to only compile. the exclusive list. the VIP section. πŸ‘‘
  • --no-highlight-code β€” enable or disable ANSI syntax highlighting of code frames. it's on by default, so this is how you turn the sparkle off ✨
  • --no-comments β€” write comments to generated output. it's true by default. yeah the flag is named "no-comments" and the description says "write comments" β€” I know, I know, that's literally just how it's written, I'm not touching it 😭
  • --retain-lines β€” retain line numbers. and the manpage itself says this will result in really ugly code. their words, not mine. you have been warned πŸ’€
  • --compact [true|false|auto] β€” do not include superfluous whitespace characters and line terminators. tightening it up, slimming it down πŸŽ€
  • --minified β€” save as many bytes when printing. false by default. when you want it smol. 🐜
  • --auxiliary-comment-before [string] β€” print a comment before any injected non-user code. (the code that babel added, not yours) πŸ’¬
  • --auxiliary-comment-after [string] β€” print a comment after any injected non-user code. πŸ’¬
  • -s, --source-maps [true|false|inline|both] β€” that's the option, those are the values, no further description given. four choices, pick your fighter 🌈
  • --source-map-target [string] β€” set file on the returned source map. 🎯
  • --source-file-name [string] β€” set sources[0] on the returned source map. yes, specifically index zero. 🎯
  • --source-root [filename] β€” the root from which all sources are relative. the origin point, the home base 🏠
  • --module-root [filename] β€” optional prefix for the AMD module formatter that will be prepended to the filename on module definitions. 🧩
  • -M, --module-ids β€” insert an explicit id for modules. no more guessing, the modules get names πŸ”–
  • --module-id [string] β€” specify a custom name for module ids. you pick the name, bestie πŸ’…
  • -x, --extensions [extensions] β€” list of extensions to compile when a directory has been the input. the default set is [.js,.jsx,.es6,.es,.mjs,.cjs] πŸ“
  • --keep-file-extension β€” preserve the file extensions of the input files. don't rename my babies πŸ₯Ί
  • -w, --watch β€” recompile files on changes. it's literally watching. it sees everything. πŸ‘€
  • --skip-initial-build β€” do not compile files before watching. just watch. no initial build. 🀫
  • -o, --out-file [out] β€” compile all input files into a single file. everything, together, one file 🫢
  • -d, --out-dir [out] β€” compile an input directory of modules into an output directory. folder in, folder out πŸ“‚
  • --relative β€” compile into an output directory relative to input directory or file. requires --out-dir [out] so like, don't try it without that one, it needs its partner 🫠
  • -D, --copy-files β€” when compiling a directory, copy over non-compilable files. don't leave the stragglers behind πŸŽ’
  • --include-dotfiles β€” include dotfiles when compiling and copying non-compilable files. yes, even the ones starting with a dot, they're invited too πŸŽ€
  • --no-copy-ignored β€” exclude ignored files when copying non-compilable files. if it's ignored, it stays ignored, no exceptions 🚫
  • --verbose β€” log everything. this option conflicts with --quiet ⚠️ pick a side, bestie
  • --quiet β€” don't log anything. this option conflicts with --verbose ⚠️ yeah, same conflict, other direction
  • --delete-dir-on-start β€” delete the out directory before compilation. clean slate, fresh start, no baggage 🧹
  • --out-file-extension [string] β€” use a specific extension for the output files. 🏷️
  • -V, --version β€” output the version number πŸ”’
  • -h, --help β€” display help for command. (hi, that's me, I'm the help) πŸ™‹β™€οΈ

quick reminder bestie: --verbose and --quiet literally conflict with each other, so don't pass both unless you're trying to start drama in your terminal πŸ’€

and that's the whole page, no skips, no cuts, every flag accounted for πŸ’–

this was babel.js, version 7.20.15+ds1+~cs214.2..., from February 2025, and yeah that version string is a whole mouthful but we love her anyway 🌸 thanks for reading, go compile something cute, mwah πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from