@bloqr/compiler-core
The open-source, dependency-free TypeScript filter compilation engine that every compiler in this repository dogfoods, published to JSR at v1.0.0.
Overview
@bloqr/compiler-core is this repository's own package — its canonical source lives at src/adblock-compiler-core/ and it's published to JSR. It replaced the AdGuard-maintained @adguard/hostlist-compiler npm package that the .NET, Python, and Rust compilers in this repo used to shell out to — they now shell out to @bloqr/compiler-core instead, and the TypeScript compiler is the package, compiling in-process.
It's a minimal, dependency-free compilation engine: no @adguard/agtree or other third-party AdGuard library, no Cloudflare-specific code, no commercial features. It's deliberately kept separate from Bloqr's commercial @bloqr/compiler product, which layers AST tooling, linting, plugins, and Cloudflare Workers deployment on top of AdGuard libraries.
Key Features
Multi-Source Compilation
Combine filter lists from URLs and local files with automatic format detection and validation.
Dependency-Free Core
No @adguard/agtree or other third-party AdGuard library — rule classification is string/regex-based.
Chunked Parallel Compilation
For large rule lists (10M+ entries), with SHA-384 hash consistency preserved across chunks.
Dependency Injection
Inject a custom logger and compilation event hooks into FilterCompiler for testability and custom logging/monitoring.
Thoroughly Tested
1008 passing tests, clean type-check, lint, and format checks on every change.
Interactive Console
Menu-driven interactive mode alongside full CLI support — no separate web UI needed.
JSR Distribution
Installable with deno add jsr:@bloqr/compiler-core, or run directly with deno run — no npm required.
11 Transformations
Deduplicate, compress, validate, remove comments, and more—all applied in a fixed, documented order.
Quick Start
Installation
# Install from JSR
deno add jsr:@bloqr/compiler-core
# Or run directly without installation
deno run jsr:@bloqr/compiler-core/cli
Basic Usage
import { compile } from '@bloqr/compiler-core';
// Compile from configuration
const rules = await compile({
name: "My Filter List",
sources: [
{
source: "https://example.com/filters.txt"
}
],
transformations: ["Deduplicate", "RemoveEmptyLines"]
});
console.log(`Compiled ${rules.length} rules`);CLI Usage
# Compile from config file
deno run --allow-read --allow-write --allow-env --allow-net --allow-run jsr:@bloqr/compiler-core/cli -c config.json
# Show version
deno run jsr:@bloqr/compiler-core/cli --version
How the Other Compilers Use It
The TypeScript compiler (src/adblock-compiler-core/) compiles in-process — it is this package. The .NET, Python, and Rust compilers shell out to it via Deno instead of maintaining their own copy of the engine:
deno run --allow-read --allow-write --allow-env --allow-net --allow-run \ jsr:@bloqr/compiler-core/cli \ --config config.json --output data/output/filters.txt
Each compiler keeps its own public API and field names unchanged across this migration — only what populates them changed. See the full guide for CI/CD integration examples (GitHub Actions, GitLab CI, Jenkins, Docker).
Configuration
@bloqr/compiler-core supports the same configuration schema as AdGuard's hostlist-compiler, so existing configurations carry over without changes.
Configuration Example (JSON)
{
"name": "My Filter List",
"description": "Custom ad-blocking filter",
"version": "1.0.0",
"sources": [
{
"name": "Local Rules",
"source": "data/local.txt",
"type": "adblock"
},
{
"name": "EasyList",
"source": "https://easylist.to/easylist/easylist.txt",
"transformations": ["RemoveModifiers", "Validate"]
}
],
"transformations": ["Deduplicate", "RemoveEmptyLines", "InsertFinalNewLine"],
"exclusions": ["*.google.com", "/analytics/"]
}Available Transformations
- ConvertToAscii - Convert internationalized domains
- TrimLines - Remove whitespace
- RemoveComments - Strip comments
- Compress - Convert hosts to adblock syntax
- RemoveModifiers - Remove unsupported modifiers
- InvertAllow - Convert to allowlist
- Validate - Remove invalid rules
- ValidateAllowIp - Validate but keep IPs
- Deduplicate - Remove duplicates
- RemoveEmptyLines - Clean empty lines
- InsertFinalNewLine - Add final newline
Documentation & Resources
Source Code
src/adblock-compiler-core/ in the main repository.
JSR Package
Install, browse the API reference, and see release history.
Complete Guide
Architecture, CI/CD integration examples, migration steps, and full API reference.
Comparison with AdGuard's hostlist-compiler
@bloqr/compiler-core superseded @adguard/hostlist-compiler across every compiler in this repository — not as an npm-compatible fork with a fallback path, but as a full replacement.
| Feature | @adguard/hostlist-compiler | @bloqr/compiler-core |
|---|---|---|
| Maintained by | AdGuard | This repo |
| Distribution | npm | JSR |
| 11 Transformations | ✓ | ✓ |
| Chunked parallel compilation | ✕ | ✓ |
| Dependency injection | ✕ | ✓ |
| Interactive console mode | ✕ | ✓ |
| We can fix/extend it ourselves | ✕ | ✓ |
Next Steps
Getting Started
Learn how to compile your first filter list with any of the four compilers.
Compare Compilers
See how the TypeScript, .NET, Python, and Rust compilers stack up.
View on GitHub
Explore the source code and contribute to development.