Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Mlc ai Web llm Package Configuration

From Leeroopedia
Knowledge Sources
Domains Build_System, Package_Management
Last Updated 2026-02-14 22:30 GMT

Overview

Concrete configuration for the @mlc-ai/web-llm npm package, defining package identity, build pipeline, entry points, and dependency declarations.

Description

The root package.json defines the @mlc-ai/web-llm npm package (version 0.2.80) as an ES module. It specifies:

  • Package identity -- Scoped name @mlc-ai/web-llm, description, keywords, license (Apache-2.0), and repository URL
  • Entry points -- main: "lib/index.js" for CommonJS consumers and types: "lib/index.d.ts" for TypeScript type resolution
  • Build pipeline -- Rollup-based bundling with a post-build cleanup script
  • Code quality -- ESLint and Prettier for linting and formatting, Husky for git hooks
  • Testing -- Jest with coverage support
  • Runtime dependency -- loglevel as the sole production dependency
  • Dev dependencies -- MLC AI runtime packages (@mlc-ai/web-runtime, @mlc-ai/web-tokenizers, @mlc-ai/web-xgrammar), TypeScript, Rollup, Jest, ESLint, Prettier, and WebGPU types

The files array restricts the published package to only the lib directory.

Usage

Reference this configuration when setting up a development environment for web-llm, understanding the build process, or inspecting dependency versions. The scripts section defines the primary developer workflows.

Code Reference

Source Location

Configuration

{
  "name": "@mlc-ai/web-llm",
  "version": "0.2.80",
  "description": "Hardware accelerated language model chats on browsers",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "type": "module",
  "scripts": {
    "build": "rollup -c && ./cleanup-index-js.sh",
    "lint": "npx eslint ./src/ ./tests/ ./examples/ && npx prettier ./src/ ./tests/ ./examples/ --check",
    "test": "jest --coverage",
    "format": "prettier --write \"./src/\" \"./examples/\" \"./tests/\"",
    "prepare": "husky"
  },
  "files": ["lib"],
  "license": "Apache-2.0"
}

Import

npm install @mlc-ai/web-llm

I/O Contract

Scripts (Commands)

Script Command Description
build rollup -c && ./cleanup-index-js.sh Bundles TypeScript source with Rollup and cleans build artifacts
lint npx eslint ./src/ ./tests/ ./examples/ && npx prettier ... --check Runs ESLint and Prettier checks on source, test, and example files
test jest --coverage Runs Jest test suite with coverage reporting
format prettier --write "./src/" "./examples/" "./tests/" Auto-formats source files with Prettier
prepare husky Installs Husky git hooks on npm install

Dependencies

Name Type Description
loglevel Runtime Lightweight logging library (sole production dependency)
@mlc-ai/web-runtime Dev MLC AI WebGPU runtime for model execution
@mlc-ai/web-tokenizers Dev Tokenizer library for text processing
@mlc-ai/web-xgrammar Dev Grammar-constrained decoding support
rollup Dev JavaScript module bundler
typescript Dev TypeScript compiler
jest Dev Testing framework
eslint Dev Linting tool
prettier Dev Code formatter
husky Dev Git hooks manager
@webgpu/types Dev WebGPU TypeScript type definitions

Outputs (Published Package)

Name Type Description
lib/index.js JavaScript Bundled ES module entry point
lib/index.d.ts TypeScript Type declaration entry point

Usage Examples

Install and Build from Source

# Clone and install dependencies
git clone https://github.com/mlc-ai/web-llm.git
cd web-llm
npm install

# Build the library
npm run build

# Run tests
npm test

# Lint the codebase
npm run lint

Install as Dependency

# Install from npm
npm install @mlc-ai/web-llm
// Import in your project
import { CreateMLCEngine, prebuiltAppConfig } from "@mlc-ai/web-llm";

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment