NetPack.Core 0.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetPack.Core --version 0.5.1
                    
NuGet\Install-Package NetPack.Core -Version 0.5.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPack.Core" Version="0.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetPack.Core" Version="0.5.1" />
                    
Directory.Packages.props
<PackageReference Include="NetPack.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetPack.Core --version 0.5.1
                    
#r "nuget: NetPack.Core, 0.5.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetPack.Core@0.5.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetPack.Core&version=0.5.1
                    
Install as a Cake Addin
#tool nuget:?package=NetPack.Core&version=0.5.1
                    
Install as a Cake Tool

NetPack

A fast, batteries-included web bundler engine for .NET. NetPack bundles and optimizes JavaScript, TypeScript, JSX/TSX, CSS and HTML directly from managed code — with a hand-written TypeScript/JSX parser, printer, scope-aware minifier and tree-shaker. The core has no native dependencies and no external toolchain to install.

Looking for the command-line tool? Install it from npm (npm i -D netpack). This package is the embeddable library for use from .NET: ASP.NET Core build steps, MSBuild tasks, custom tooling, or tests.

Install

dotnet add package NetPack.Core

The package is NetPack.Core, but the assembly and namespace are NetPack — so you still write using NetPack;.

Bundle a project

using NetPack;

// …in memory
var result = await Bundler.BundleAsync("src/index.html", new BundleOptions
{
    Minify = true,
    Platform = Platform.Web,
    Format = ModuleFormat.Esm,
});

byte[] indexHtml = result.Outputs["index.html"];
foreach (var file in result.Files)
    Console.WriteLine($"{file.Name}  {file.Size} bytes  ({file.Modules} modules)");

// …or straight to a directory
await Bundler.WriteToDirectoryAsync("src/index.html", "dist",
    new BundleOptions { Minify = true, SourceMaps = true });

BundleOptions mirrors the CLI flags — all optional, with production-friendly defaults:

Option Purpose
Minify, SourceMaps optimize for size; emit source maps
Format Esm (default), CommonJs, Umd, SystemJs
Platform Web (default), Node, Deno
EntryNames naming template, e.g. [name]-[hash] for cache-busting
PublicPath base URL/path prepended to emitted-file references
Externals, Shared keep external / emit as shared bundles + import map
Define, Alias, Loader, Conditions compile-time constants, import rewrites, per-extension loaders, extra exports conditions
ExternalPackages keep every node_modules import external

Use the parser / printer directly

The TypeScript/JSX front-end is public, so you can parse, transform and print without bundling:

using NetPack.Syntax;
using NetPack.Syntax.Printer;

var module = Parser.ParseModule("const x: number = 1;", "in.ts");
string js = JsPrinter.Print(module);            // -> "const x = 1;"

NetPack.Syntax exposes the Tokenizer, Parser, the AST (NetPack.Syntax.Ast), JsPrinter, and the source-map builder.

Native asset processing is pluggable

The core references only AngleSharp (for HTML/CSS). Image resizing and re-encoding are opt-in: implement IAssetProcessor and register it per extension. netpack's own CLI registers a SkiaSharp-based processor exactly this way, which is what keeps the core dependency-free.

using NetPack.Assets;

AssetProcessorFactory.Register(".png", new MySkiaImageProcessor());
// unregistered types fall back to a pass-through copy

Notes

  • Dependency-free core — the only managed dependency is AngleSharp.
  • Node.js is needed only for the optional Sass/Less/PostCSS/Svelte features (which shell out to a local Node install). Plain JS/TS/JSX/CSS/HTML bundling needs nothing extra.
  • Targets .NET 8; trim/AOT-friendly.

License

MIT. Source, documentation and issues: https://github.com/FlorianRappl/netpack.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.1 60 8/12/2026
0.8.0 230 8/7/2026
0.7.0 95 8/3/2026
0.6.0 465 7/27/2026
0.5.2 58 7/24/2026
0.5.1 60 7/24/2026