Socket
Socket
Sign inDemoInstall

esbuild-wasm

Package Overview
Dependencies
0
Maintainers
1
Versions
459
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esbuild-wasm

The cross-platform WebAssembly binary for esbuild, a JavaScript bundler.


Version published
Weekly downloads
2.9M
decreased by-1.21%
Maintainers
1
Install size
4.57 MB
Created
Weekly downloads
 

Package description

What is esbuild-wasm?

The esbuild-wasm package is a WebAssembly-based version of the esbuild bundler and minifier. It provides extremely fast build times and is designed to be used in environments where native binaries cannot be executed, such as in browsers or some serverless platforms. It supports transforming, bundling, and minifying JavaScript and TypeScript files.

What are esbuild-wasm's main functionalities?

Bundling JavaScript

This code initializes esbuild-wasm and bundles a JavaScript file, outputting a single bundled file. It demonstrates how to set up and execute a basic bundling process.

const esbuild = require('esbuild-wasm');
esbuild.initialize({ worker: true, wasmURL: '/path/to/esbuild.wasm' }).then(() => {
  esbuild.build({
    entryPoints: ['input.js'],
    bundle: true,
    outfile: 'output.js'
  }).catch(() => process.exit(1));
});

Minifying CSS

This example shows how to use esbuild-wasm to minify a CSS file. It sets up the esbuild environment and performs minification, outputting the minified CSS.

const esbuild = require('esbuild-wasm');
esbuild.initialize({ worker: true, wasmURL: '/path/to/esbuild.wasm' }).then(() => {
  esbuild.build({
    entryPoints: ['input.css'],
    minify: true,
    outfile: 'output.css'
  }).catch(() => process.exit(1));
});

Transpiling TypeScript

This code snippet demonstrates how to transpile TypeScript into JavaScript using esbuild-wasm. It includes setting up the environment, specifying the loader for TypeScript files, and bundling the output.

const esbuild = require('esbuild-wasm');
esbuild.initialize({ worker: true, wasmURL: '/path/to/esbuild.wasm' }).then(() => {
  esbuild.build({
    entryPoints: ['input.ts'],
    loader: { '.ts': 'ts' },
    outfile: 'output.js',
    bundle: true
  }).catch(() => process.exit(1));
});

Other packages similar to esbuild-wasm

FAQs

Last updated on 26 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc