On this page

Status and limits

vite-plugin-ngp is a first version on top of a prototype compiler. This page says exactly what works and what doesn't, so you can decide whether your app can try it. Everything marked as working was checked in the repo's playground or on this site.

What works#

PieceStatus
Per-module compilationWorks, in ngp's optimize mode, from the code Vite hands over
Adding, renaming and deleting filesWorks. New files compile as they would in a fresh build. Deleting a file that's still used is an error until the file is back. Checked by an automated dev-server test
Edits in the dev serverWork. Template, stylesheet and inline style edits update in place; other edits reload the page
Production buildsWork, through the same transform, with the CLI's build optimizer. The playground's JavaScript is within 2% of ng build's for the same app, and the same size gzipped
Linking Angular librariesWorks, in dependency pre-bundling and in builds, with Angular's linker over Vite's oxc parser. In the dev server that covers server environments another plugin adds too, like @cloudflare/vite-plugin's Worker: a test checks the linker is in such an environment's optimizer, and a Cloudflare app was run by hand
Component HMRWorks for external templates, and for .ts edits that only change a component's inline template or styles. Other .ts edits reload, as under ng serve, and so does a template saved together with such a .ts edit. Changing templateUrl or styleUrl reloads too, unlike ng serve
Component stylesheetsstyleUrl files go through Vite's CSS pipeline, so SCSS, Less and PostCSS work, with Angular's view encapsulation. Edits update in place, ShadowDom components included. See Component styles
Build options from angular.jsonfileReplacements, budgets and polyfills work, zone.js apps included. Every other option maps to Vite config; Migrating from ng build lists each
Server rendering and hydrationWorks in the dev server and in builds, with the ssr option. This site is prerendered with a render function. Event replay works too: a click made before hydration was replayed on the playground, in the dev server and from the build. With render, the build's server has to pass dist/server/index.server.html for that
@angular/ssrWorks, laid out as ng new --ssr lays it out: AngularNodeAppEngine in an Express server.ts, server routes with Prerender, Server and Client render modes, status codes, redirects, and prerendering in vite build, with getPrerenderParams. A test runs each render mode in the dev server and from the built server.js; the app-ssr template uses it. One locale only, no app shell and no critical CSS inlining. See Server rendering
InternationalizationWorks: i18n attributes and $localize, extraction with ngp-extract-i18n, and one translated folder per locale from a single build, with server rendering too. The playground ships English and German. See Internationalization
Vitest with TestBedWorks three ways, with zoneless TestBed: in Node on the server platform's DOM (Domino), so a passing component also renders on the server; on jsdom; and in Chromium through Vitest's browser mode. The playground runs its specs all three ways. TestBed overrides of components that import an NgModule, and specs that skip compileComponents() for a component with @defer dependencies, need test.jitCompat, and non-standalone components scoped by TestBed.configureTestingModule({declarations}) need test.runtimeScopes. A run compiles only the specs it runs and what they import. In a workspace with many Vitest projects, test.externalLibraries keeps Vitest from transforming Angular's libraries once per project. Watch mode reruns specs after template edits too. See Testing with Vitest
Reusing output between buildsWorks. vite build and Vitest keep ngp's output, the linker's and the optimizer's under Vite's cacheDir, or in a directory cache: {dir} names, which the projects of a workspace can share for library code, and with workspaceRoot for their own compiled modules too, and reuse an entry when the module, its templates and stylesheets, the public shape of what its templates use, and the toolchain are unchanged. Checked by a test that marks a cached module and finds the mark in the next build, then edits each input in turn. The dev server doesn't use it. See Reusing output between builds
Starting a new appWorks: npm create @push-based/ngp, and the same with pnpm, Yarn, bun or vp create, writes a browser-only or a server-rendered app, with a spec, on its own or with --monorepo in apps/web next to a library in libs/ui. A test builds, prerenders and tests a server-rendered monorepo, and runs one through vp migrate. A test scaffolds both templates, builds them, runs their specs and renders a page, as a Vite project and after vp migrate, and another runs app-ssr through yarn create and builds it with Yarn 4; after each release a workflow does the same through vp create from npm, for both layouts. See Creating an app
Generating codeWorks: ngp-generate writes a component, service, directive, pipe, guard, interceptor or resolver, as ng generate names and writes them, with a Vitest spec, and a library or a second app in a monorepo from create-ngp. --route adds a lazy route to a component, and code generated in a library is exported from its index. A test generates one of each into a fresh app, builds it and runs their specs, as a Vite project and under Vite+. No NgModules, and no schematics from libraries. See Generating code
Vite+Works: vp dev, vp build, vp test, vp check, vpx ngp-extract-i18n and vpx ngp-generate on an app moved with vp migrate or made with vp create, server rendering and per-locale builds included, and vp test on jsdom and in Chromium through browser mode. Checked with Vite+ 1.6.0, and in CI on both templates. One app in a new Nx workspace runs under Vite+ too, checked once by hand. The project must declare vite, so Vite+ installs its build of Vite under that name. vp check doesn't check templates; the plugin's check in vp build does. See Using Vite+
Nx workspacesWork, for one app at a time, with its libraries compiled from source through tsconfig paths, resolved by Vite's resolve.tsconfigPaths or turned into Vite aliases. Checked on Ghostfolio, an Nx 23 workspace with two Angular libraries, with Vite's root at the workspace root and at the app's folder. See Migrating inside an Nx workspace
Type-checkingWorks, for templates and TypeScript, with TypeScript 7 in a separate process. Errors show in the dev server's terminal and overlay, and fail vite build. Planted errors land where ng build puts them. Checked on this site and the playground. At 5,000 components a planted error shows 1.36 s after the edit with tsgo and 1.02 s with tsrs (Performance). Opt-in: the same check with tsrs, Oxc's Rust port of TypeScript 7, through typeChecker: 'tsrs' (Checking with tsrs)

What doesn't work yet#

PieceStatus
Preprocessors in inline stylesMissing. Inline styles and template <style> elements are plain CSS, because ngp compiles them and has no preprocessing hook. There's no inlineStyleLanguage
HTTP status codes with renderMissing. render returns HTML only, so a not-found page answers 200 when a Node server renders it. @angular/ssr has them
@angular/ssr with i18n, the app shellNot supported. With @angular/ssr, the i18n option stops the build
The service worker, critical CSS inlining, subresource integrity, autoCspNot supported. Migrating from ng build lists what an ng build app can't bring along
Yarn's Plug'n'PlayNot supported. ngp's analyzer reads Angular's type declarations from files on disk, and Plug'n'Play keeps packages in zip files, so the first build fails with errors like 'router-outlet' is not a known element. Set nodeLinker: node-modules in .yarnrc.yml; an app from create-ngp has that file already
Library buildsNot supported. The plugin compiles apps, and writes no .d.ts files, partially compiled output or Angular Package Format bundle. A library you publish keeps ng-packagr through ng build or nx build. See Buildable and publishable libraries
Vitest beyond thoseUntried: happy-dom, browser mode on Firefox and WebKit, coverage. fakeAsync needs zone.js, which the documented setup leaves out
WindowsDoesn't work. The package has no native engine for Windows, and the wasm engine fails there. CI installs the packed plugin into both create-ngp templates on windows-latest with engine: 'wasm'. The scaffold and the install pass, then vite build stops with TsconfigNotFound before compiling anything: the wasm engine reads paths by Unix rules, where D:\app\tsconfig.json is a relative path. The specs and servers never get to run. Use WSL 2, which is Linux and gets the native engine. Issue #148 has what the engine sees, and what a native Windows engine would take

Where it's weakest#

  • ngp is a prototype, and the plugin uses it as one. ngp's API isn't public, and the plugin reaches below it in two places to skip work it doesn't need. Any Angular commit can break that, which is why the package accepts only Angular 22.3, from 22.3.0-rc.0 on, and why a patch release of 22.3 can still break it. Compatibility says which releases were run.
  • The ngp in the package is an unofficial build. @push-based/vite-plugin-ngp carries ngp built from Angular's source, not a release from the Angular team, with native engines for macOS and for glibc Linux on x64 and arm64. Other Linux, Alpine included, needs engine: 'wasm', which analyzes up to twice as slowly. Windows needs WSL 2: the wasm engine fails on Windows itself. Each plugin version carries one ngp build, so moving to another Angular minor means a new plugin release.
  • File changes are tested on one small app. Adding, renaming and deleting components and templates is covered by a test on a three-component app, not on a large one. Deleting a component that's still used gives Angular's "is not a known element" error, which names the element, not the missing file. A missing styleUrl file isn't reported at all.
  • Type-checking is whole-program. Every check runs TypeScript 7 over the whole app. That takes 100–250 ms in the dev server on the repo's playground. On a 5,000-component app, an error shows up 1.36 s after the edit, a little sooner than under ng serve. See Type-checking.
  • SSR runs two analyzers. The browser and the server each get their own ngp compiler, because only the browser's has HMR code. A dev server with SSR needs about twice the analyzer memory, and analyzes every edit twice.
  • Component stylesheets take two paths. The dev server serves them as <link>s, and builds inline them into the JavaScript, as the CLI does. Both are tested, but a bug can show in only one.
  • The build optimizer is a copy of the CLI's. When @angular/build changes its pass, the plugin keeps the old one until someone ports the change. Nothing fails when that happens; only bundle sizes would show it.
  • The ng build options copy the CLI's rules. Budgets, the zone.js check and the server's polyfills are ported by hand from @angular/build. If the CLI changes them, the plugin keeps the old ones. Inline styles are measured unminified for anyComponentStyle, so they come out larger than under ng build.
  • i18n has one app behind it. Extraction, translation and per-locale builds are checked on the playground's two locales and 34 messages. Formats other than XLIFF 1.2 were extracted, not translated from. An ICU message inside @if inside @for fails Angular's i18n hydration, which ngc's output does too.
  • A cache key with a missing input would serve a stale module. The build cache hashes the analyzer's whole result for a file, minus its run-specific ids and spans, plus the module's code, its templates and stylesheets, and the toolchain. Every input anyone has thought of is in it, and a test covers each. One nobody has thought of would come back as a wrong module with no error. cache: false is the check.
  • The linker's gain is measured on one app. Since 9 November the plugin links with Angular's linker over Vite's oxc parser instead of Babel, the design the CLI moved to (How it works). The bench figures on the Performance page predate that and were taken with the Babel linker; only the playground has been timed since.

What has been measured, and what hasn't#

The Performance page measures the plugin's dev server and builds against ng serve, Analog and @oxc-angular/vite, on generated apps of 100 to 5,000 components and the playground, on one laptop. Benchmarks on real apps measures it against the Angular CLI on Super Productivity and against Nx on Ghostfolio, for time and memory, on GitHub's Ubuntu runners and on the same laptop. Still unmeasured:

  • Large real apps. The two real apps have 252 and 157 components. An enterprise app with a thousand components and 50 libraries hasn't been tried, and the plugin's cold start grows with the number of packages the linker has to process.
  • Windows. Every number is from macOS or Ubuntu. The plugin doesn't run on Windows itself yet (above), and nobody has timed it under WSL 2.
  • How far apart one save writes its files. The plugin holds a template update until 50 ms after the template was written, in case the same save changes the component's class. That 50 ms is a guess, and it's why the fastest template edit takes about 60 ms in the plugin against about 16 ms in @oxc-angular/vite. See Performance.
  • Where the cold start's memory goes on a large real app. On the two real apps the plugin's dev server holds 0.9–1.8 GB after a restart, where the CLIs hold 3.6–3.7 GB, and on the generated 5,000-component app 1.0 GB against ng serve's 6.0 GB (Performance). Its cold start of Super Productivity peaks at 2.6 GB on a 4-core runner, against ng serve's 3.6 GB, and which of the processes that run then, Vite's pre-bundling or typia's program, holds most of it hasn't been measured.
  • Why the plugin's dev server starts Super Productivity more slowly than in October. Its restart was 45% of ng serve's time then and is 56% now, on the runners and on a laptop alike. The ngp rebuild isn't the cause; nothing else was tested (Benchmarks).