Build Requirements
Before building, you need:- Python 3.10+ with pip
- One of the following JavaScript runtimes:
- Deno 2.0.0+
- Bun 1.0.31+
- Node.js 20.0+ with npm
- pnpm 10+
The build system automatically detects and uses any available JavaScript runtime. You only need one runtime installed.
Quick Build with hatch_build.py
The simplest way to build is using thehatch_build.py script, which automatically selects an available runtime:
- Detect available JavaScript runtimes (pnpm, Deno, Bun, or npm/Node)
- Install dependencies
- Run the bundle script
- Generate JavaScript files in the
dist/directory
Building with Specific Runtimes
Building with Deno
Building with Bun
Building with Node.js
Building with pnpm
Building the Python Package
To build the complete Python package with bundled JavaScript:- Source distribution (
tar.gz) indist/ - Wheel (
.whl) indist/
deno, bun, or node as required to bundle the JavaScript before packaging.
The Python package uses a PEP 518-compatible build system with hatchling. The build hook in
hatch_build.py automatically bundles JavaScript during the build process.Using Rollup Directly
You can also invoke Rollup directly if you have dependencies installed:rollup.config.js to generate all build outputs.
Build Outputs
The build process generates multiple JavaScript files in thedist/ directory:
Core Solver Files
yt.solver.core.js- Unminified IIFE bundle for debuggingyt.solver.core.min.js- Minified IIFE bundle for production
Library Files
yt.solver.lib.js- Unminified library buildyt.solver.lib.min.js- Minified library build
Runtime-Specific Libraries
yt.solver.deno.lib.js- Deno-specific build with npm: importsyt.solver.bun.lib.js- Bun-specific build
Build Output Details
Build Output Details
Each output file:
- Uses Sucrase to transpile TypeScript
- Includes license headers with bundled dependency information
- Is processed with Terser (minified versions remove comments and optimize)
- Is formatted with Prettier (non-minified versions)
- Has its SHA3-512 hash printed during build
rollup.config.js defines separate outputs for different target formats (IIFE and ES modules).Build Artifacts in Python Package
When building the Python package, only the minified files are included:yt_dlp_ejs/yt/solver/core.min.jsyt_dlp_ejs/yt/solver/lib.min.js
Verifying Build Consistency
All supported runtimes should produce identical output. The CI system verifies this by:- Building with Deno as the control
- Generating SHA-256 hashes of all outputs
- Building with pnpm, Bun, and Node
- Comparing hashes to ensure consistency
Troubleshooting
”No suitable JavaScript runtime found”
This error occurs whenhatch_build.py cannot find any supported runtime. Install one of:
- Deno (
deno --version) - Bun (
bun --version) - Node.js (
node --version) - pnpm (
pnpm --version)
Lockfile Errors
Always use the frozen lockfile flags:- Deno:
--frozen - Bun:
--frozen-lockfile - pnpm:
--frozen-lockfile - npm: use
npm ciinstead ofnpm install
