Skip to content

alt:V esbuild plugin to simplify development and production

Notifications You must be signed in to change notification settings

leonardssh/altv-esbuild

 
 

Repository files navigation

altv-esbuild

A plugin that greatly simplifies server/client JS and TS development (as well as production) on the alt:V platform.

(extended and improved version of the previous esbuild dev plugin)

Features

  • Write your scripts in JS/TS with enabled 5-million-polygon cars and mlo without client crashes
  • Hot reload without server restart or client reconnect (using alt:V resource restart)
  • Full client and server support
  • Restart console command for client and server ("res" by default)
  • Improved top-level exception output during development
  • Direct support for alt:V enums, even in JS code (documentation)
  • Enhanced alt.log value formatting (documentation)

Docs

Docs web page: https://xxshady.github.io/altv-esbuild

How to use?

Example resource can be found here

Install from npm

npm i altv-esbuild

Add to your build code of the server and client

Example of the build server code:

import esbuild from "esbuild"
import { altvEsbuild } from "altv-esbuild"

esbuild.build({
  entryPoints: ["src/main.js"],
  outfile: "dist/bundle.js",
  bundle: true,
  watch: dev,
  plugins: [
    altvEsbuild({
      mode: "server", // use "server" for server code, and "client" for client code

      dev: true, // see docs for more info
    }),
  ],
  
  external: [
    // none of the following is required, the plugin handles all alt:V modules automatically
    // "alt-server",
    // "alt-client",
    // "alt-shared",
    // "natives"
  ]
})

How to find exact source location of any exception?

You can use esbuild source-maps like this: sourcemap: "inline"

serverside

Enable source-maps in server.cfg and here you go.

clientside

Here its a bit complicated. If you use vscode Source maps navigator extension can help you jump to your source code.

Contributions

All contributions are greatly appreciated. If there are any questions or you would like to discuss a feature, you can always open issue.

About

alt:V esbuild plugin to simplify development and production

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.6%
  • JavaScript 3.4%