Overview

Usage docs for netpack, in addition to the feature overview in the project README.

General

  • Getting started — install, entry points, and the bundle / serve / analyze commands.
  • Configuration & presets — shareable JSONC config files, composing presets (extends-style), and option precedence.
  • Hooks — preset-registered JavaScript modules that tap the build lifecycle (post-transformation, asset rewriting, and more).
  • Programmatic use — drive the bundler from a Node.js program with the typed netpack object (and low-level run).

Frameworks

  • React & JSX — the default React.createElement factory, retargeting it project-wide or per file, and React Fast Refresh in the dev server.
  • Solid components.jsx/.tsx compiled with Solid’s babel-preset-solid transform over the Node bridge (auto-detected when solid-js is a dependency).
  • Vue single-file components — native .vue compilation: <script setup> and its macros, build-time template precompilation, scoped styles, and the runtime-compiler fallback.
  • Astro components — native .astro compilation: frontmatter execution, the JSX-parsed template, components and slots, and the current scope (no hydration, no build-time static HTML generation yet).
  • Svelte components.svelte compilation via the Svelte compiler over the Node bridge (requires svelte installed), with runtime style injection.

Use cases

  • Module Federation — exposing and consuming federated modules via a federation.json entry point.
  • Native Federation — the same federation.json with "kind": "native", emitting a plain-ESM remote whose shared deps are wired up through an import map.
  • Styling & assets — CSS, CSS Modules, and Sass/LESS/PostCSS (incl. Tailwind).
  • Images & assets — importing images and other files, the SkiaSharp-based optimization pass, on-demand resized/re-encoded image variants, content hashing, and the public/ folder.

Advanced

  • Platforms — targeting web, Node or Deno with --platform: which modules stay external as runtime built-ins and how entry points are chosen.
  • Output formats — emitting ESM (default), CommonJS, UMD or SystemJS with --format, their trade-offs, and why ESM is the best choice.
  • Import maps & externals — leaving a dependency out of the bundle with --external, or having netpack build and wire it up itself with --shared.
  • Build-time code generation.codegen files: the loader context, async support, and the current watch-mode limitations.
  • Bundle analyzer — the interactive graph explorer, the dependency vulnerability audit, and the optimization recommendations that flag where your chunks could be split more efficiently.
  • Other features — output formats, tree shaking, source maps, minification, --define/--alias/--loader, banners, licenses, and more.

.NET

  • Using netpack from .NET — overview of the two NuGet packages and when to reach for each.
  • NetPack.Core — the bundler engine as a managed library: bundle programmatically, or use the TypeScript/JSX parser/printer.
  • NetPack.Build — MSBuild integration: bundle into wwwroot on dotnet build, with cross-platform image processing.

This content is written to also serve as the source material for the project’s docs site (www/docs) — it’s kept as plain, self-contained Markdown for that reason. The site groups these same docs into the same sections in its sidebar (see www/docs/src/lib/docs.ts).