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 🙏

© 2024 – Pkg Stats / Ryan Hefner

altv-esbuild

v0.9.3

Published

[![ingame demo](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExdXJxejQ5dGE5cHE1ZzA2OWxqOXRiYmVmbGk2d20xZzg2cGRnZ3gzdiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Qq64W7EXWNcppAd1fC/giphy.gif)](https://imgur.com/a/vWBZsoe) > You can click for better quality

Downloads

848

Readme

altv-esbuild

ingame demo

You can click for better quality

Special thanks ❤️ to innxz and uncle_ara for financially supporting me and this library.

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)~~ it was integrated into js module

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"

// your own variable
const DEV_MODE = true

esbuild.build({
  entryPoints: ["src/main.js"],
  outfile: "dist/bundle.js",
  bundle: true,
  watch: DEV_MODE, // this build option is outdated, see example directory in the repo
  target: "esnext",
  format: "esm",
  
  plugins: [
    altvEsbuild({
      mode: "server", // use "server" for server code, and "client" for client code

      // see docs for more info about these options:
      dev: {
        enabled: DEV_MODE,

        // if `DEV_MODE` is false it will also be automatically set to false too
        enhancedRestartCommand: true, 
      },
    }),
  ],
  
  external: [
    // none of the following is required, this plugin handles all alt:V modules automatically
    // "alt-server",
    // "alt-client",
    // "alt-shared",
    // "natives"
  ]
})

Limitations

Imports of types, interfaces

esbuild doesn't support importing types as values, you should use type-only imports import type or import { type YourType } syntax. typescript-eslint with consistent-type-imports rule helps a lot with this.

types.ts

export type SomeType = number

script.ts

import { type SomeType } from './types.ts'

alt:V

Connection queue is not supported between hot reloads (or just resource restarts). Player disconnect is also not supported between hot reloads. Only player connect is emulated for now in dev environment.

esbuild

Not supported build options

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.toml 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.

Some libraries don't work with bundling

If you see such errors it may mean this is your case:

  • Error: Dynamic require of "crypto" is not supported
  • SyntaxError: Unexpected identifier
  • ReferenceError: __dirname is not defined

Libraries that must be external: discord.js, Prisma, TypeORM

Solution: add this library to external build option of esbuild

Contributions

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