BROWSERIFY(1)

πŸ’– BROWSERIFY πŸ’–

okay bestie, welcome to the browserify manual β€” section 1 of the manual, the "user commands" shelf, and honestly it's giving main character energy. this whole page is about browserify, the tool that browserifies your Node.js sources. let's get into it, no cap. ✨


πŸŽ€ NAME πŸŽ€

browserify β€” browserify Node.js sources πŸ¦‹

πŸ’… SYNOPSIS πŸ’…

browserify [entry files] {OPTIONS}

🌸 DESCRIPTION 🌸

okay so here's the literal tea, and it's kind of iconic: browsers do not have the require method defined. like, it's just not a thing over there. but Node.js does have it. πŸ™ˆ

and with Browserify you can write code that uses require in the exact same way that you would use it in Node. that's the whole vibe. that's the whole point. periodt. πŸ’–


✨ OPTIONS ✨

⭐ Standard Options ⭐

  • --outfile, -o β€” write the browserify bundle to this file. if you don't specify one, browserify just prints to stdout. lowkey iconic default behavior πŸ’«
  • --require, -r β€” a module name or file to bundle.require(). optionally use a colon separator to set the target. 🫢
  • --entry, -e β€” an entry point of your app. your lil doorway, your main character moment πŸšͺ✨
  • --ignore, -i β€” replace a file with an empty stub. files can be globs. bye bestie, you're an empty stub now πŸ’€
  • --exclude, -u β€” omit a file from the output bundle. files can be globs. not invited to the party πŸ™…
  • --external, -x β€” reference a file from another bundle. files can be globs. it lives somewhere else, we're just saying hi πŸ‘‹
  • --transform, -t β€” use a transform module on top-level files.
  • --command, -c β€” use a transform command on top-level files.
  • --standalone, -s β€” generate a UMD bundle for the supplied export name. this bundle works with other module systems, and it sets the name you gave as a window global if no module system is found. versatile queen πŸ‘‘
  • --debug, -d β€” enable source maps that let you debug your files separately. literally a lifesaver when everything is on fire 😭
  • --help, -h β€” show this message.

for advanced options, type browserify --help advanced.

specify a parameter.

πŸ”₯ Advanced Options πŸ”₯

  • --insert-globals, --ig, --fast β€” [default: false] skip detection and always insert definitions for process, global, __filename, and __dirname.

benefit: faster builds. cost: extra bytes. speed demon behavior but she's thicc πŸ’…

  • --insert-global-vars, --igv β€” comma-separated list of global variables to detect and define.

default: __filename,__dirname,process,Buffer,global

  • --detect-globals, --dg β€” [default: true] detect the presence of process, global, __filename, and __dirname and define these values when present.

benefit: npm modules more likely to work. cost: slower builds. slow and steady, but she WORKS 🐒✨

  • --ignore-missing, --im β€” [default: false] ignore require() statements that don't resolve to anything. let it go, let it gooo 🧊
  • --noparse=FILE β€” don't parse FILE at all. this will make bundling much, much faster for giant libs like jquery or threejs. the way that skipping the parse makes the build zoom?? obsessed πŸš€
  • --no-builtins β€” turn off builtins. this is handy when you want to run a bundle in node, which provides the core builtins. πŸ“
  • --no-commondir β€” turn off setting a commondir. this is useful if you want to preserve the original paths that a bundle was generated with.
  • --no-bundle-external β€” turn off bundling of all external modules. this is useful if you only want to bundle your local files. homegirl only, no strangers 🌈
  • --bare β€” alias for both --no-builtins, --no-commondir, and sets --insert-global-vars to just "__filename,__dirname". this is handy if you want to run bundles in node. the minimalist icon πŸŽ€
  • --no-browser-field, --no-bf β€” turn off package.json browser field resolution. this is also handy if you need to run a bundle in node.
  • --transform-key β€” instead of the default package.json#browserify#transform field to list all transforms to apply when running browserify, a custom field, like, e.g. package.json#browserify#production or package.json#browserify#staging can be used, by for example running:
    • browserify index.js --transform-key=production > bundle.js
    • browserify index.js --transform-key=staging > bundle.js

pick your era, pick your field πŸ’œ

  • --node β€” alias for --bare and --no-browser-field.
  • --full-paths β€” turn off converting module ids into numerical indexes. this is useful for preserving the original paths that a bundle was generated with.
  • --deps β€” instead of standard bundle output, print the dependency array generated by module-deps. it's giving receipts 🧾
  • --no-dedupe β€” turn off deduping. no more copy-paste merging, everyone stands on their own πŸ’ͺ
  • --list β€” print each file in the dependency graph. useful for makefiles. a lil roster of everyone invited πŸ“‹
  • --extension=EXTENSION β€” consider files with the specified EXTENSION as modules. this option can be used multiple times. stack 'em, queen πŸ₯ž
  • --global-transform=MODULE, -g MODULE β€” use a transform module on all files after any ordinary transforms have run. everybody gets a glow-up ✨
  • --plugin=MODULE, -p MODULE β€” register MODULE as a plugin. πŸ¦‹
  • --preserve-symlinks β€” preserves symlinks when resolving modules. πŸŽ€

🌟 Passing arguments to transforms and plugins 🌟

for -t, -g, and -p, you may use subarg syntax to pass options to the transforms or plugin function as the second parameter. for example:

-t [ foo -x 3 --beep ]

will call the foo transform for each applicable file by calling:

foo(file, { x: 3, beep: true })

so cute, so powerful, iykyk πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

browser-pack(1)


and that's the whole page bestie!! 🫢 this was browserify version 17.0.0, dated September 2021, and the manual page itself is the BROWSERIFY(1) page β€” go forth and bundle, you absolute legend πŸ’–βœ¨πŸŒΈ