npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fivem-bundler

v1.1.2

Published

Build-time compiler for FiveM Lua resources with ox_lib require semantics

Readme

fivem-bundler

A build-time compiler for FiveM Lua resources. Scans client/ and server/ directories, resolves require() and lib.require() calls via AST analysis, and outputs single-file bundles that inject all modules into package.preload.

Install

npm i -g fivem-bundler
# or without installing
npx fivem-bundler <resource-root> [output-dir]

Usage

fivem-bundler <resource-root> [output-dir]

output-dir defaults to <resource-root>/dist.

Examples:

# Bundle resource in current directory, output to ./dist
fivem-bundler .

# Bundle with explicit output path
fivem-bundler ./my-resource ./my-resource/dist

# Use npx without installing
npx fivem-bundler ./my-resource

# Mark framework adapters as lazy (bundled but not auto-executed)
fivem-bundler ./my-resource --lazy "server/frameworks/**"
fivem-bundler ./my-resource --lazy "client/legacy.lua"

Options

| Flag | Description | |------|-------------| | --lazy <pattern> | Mark matching files as lazy. Can be used multiple times. | | --debug | Enable debug output (stack traces on error) | | --version, -v | Show version number | | --help, -h | Show help message |

Resource Structure

The bundler supports two discovery modes, chosen automatically:

Directory mode (client/ and server/ folders exist)

my-resource/
├─ client/
│  ├─ main.lua
│  └─ modules/
│     └─ targeting.lua
├─ server/
│  ├─ main.lua
│  └─ modules/
│     └─ database.lua
└─ shared/             # optional, bundled into both client and server
   └─ config.lua

All .lua files under client/, server/, and shared/ are discovered recursively. No fixed layout within those directories is required.

Manifest mode (no client/ or server/ folders)

When client/ and server/ directories don't exist, the bundler reads fxmanifest.lua to determine which files belong to which runtime:

my-resource/
├─ fxmanifest.lua
├─ main_client.lua
├─ main_server.lua
├─ config.lua
└─ modules/
   └─ utils.lua
-- fxmanifest.lua
client_scripts { 'main_client.lua', 'modules/*.lua' }
server_scripts { 'main_server.lua', 'modules/*.lua' }
shared_script 'config.lua'

External resource scripts (prefixed with @) are automatically skipped.

Output:

dist/
├─ client.lua
└─ server.lua

Point your fxmanifest.lua at these files:

client_script 'dist/client.lua'
server_script 'dist/server.lua'

Module IDs

Module IDs are derived from file paths relative to the side root:

| File | Module ID | |------|-----------| | client/main.lua | "main" | | client/modules/targeting.lua | "modules.targeting" | | server/modules/database.lua | "modules.database" |

Require by module ID — both forms are supported:

local targeting = require("modules.targeting")
local targeting = lib.require("modules.targeting")

Arguments must be static string literals. Dynamic requires (require(someVar)) are a hard error.

How Bundling Works

Each bundle file contains:

  1. package.preload assignments — every module is wrapped in a function and registered:
    package.preload["modules.targeting"] = function()
      -- original module source
    end
  2. Entry file execution — files not required by any other module are executed directly at the bottom, in deterministic order.

Lua's built-in require() checks package.preload automatically, so no custom loader is needed. If ox_lib is loaded, lib.require() also resolves from package.preload. Circular dependencies are supported — Lua (and ox_lib) handle them at runtime.

Lazy Configuration

Some files should be bundled (available via require()) but not auto-executed as entry points. These are called lazy modules — they only run when another module explicitly requires them. This is useful for framework adapters, optional features, or conditional code paths.

Config file

Place a bundler.config.json in your resource root:

{
  "outputDir": "dist",
  "lazy": {
    "folders": ["**/frameworks/**"],
    "files": ["client/legacy.lua"]
  }
}

CLI flags

fivem-bundler ./my-resource --lazy "server/frameworks/**"
fivem-bundler ./my-resource --lazy "client/optional.lua" --lazy "server/adapters/**"

Patterns without a file extension are treated as folder patterns. CLI flags merge with config file values — they don't replace them.

What "lazy" means

| Behavior | Normal files | Lazy files | |----------|-------------|------------| | Bundled into package.preload | Yes | Yes | | Auto-executed as entry point | Yes (if not required by others) | No | | Available via require() | Yes | Yes |

Requirements

  • Node.js >= 18 (or Bun)

ox_lib (optional)

ox_lib is not required — bundles use package.preload, which works with Lua's built-in require(). If your resource uses ox_lib, load it as usual:

shared_script '@ox_lib/init.lua'

Both require() and lib.require() resolve from package.preload automatically.

Development

bun install
bun run build        # Compile TypeScript
bun test             # Run all tests (64 tests)
bun run typecheck    # Type-check without emit

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run bun test — all tests must pass
  5. Run bun run build — must compile cleanly
  6. Open a pull request

License

MIT