For the complete documentation index, see llms.txt. This page is also available as Markdown.

Angular

Applies to: Angular CLI applications. Angular 17 and later build with the esbuild-based application builder by default; Angular 8–16 (and projects that kept @angular-devkit/build-angular:browser) build with webpack.

Which builder do you use?

Open angular.json → projects.<app>.architect.build.builder:

builder value

Output folder to scan

Output format

--es6Modules

@angular-devkit/build-angular:application or @angular/build:application

dist/<app>/browser

ES modules (main-*.js, chunk-*.js, polyfills-*.js)

Yes

@angular-devkit/build-angular:browser-esbuild

dist/<app>

ES modules

Yes

@angular-devkit/build-angular:browser (webpack)

dist/<app>

Classic scripts (main.*.js, runtime.*.js, polyfills.*.js)

No

Step 1: Turn on source maps for the build you scan

Production builds have source maps off by default. Turn them on in the configuration you build for testing (here production):

// angular.json → projects.<app>.architect.build.configurations.production
{
  "sourceMap": {
    "scripts": true,
    "styles": false,
    "vendor": false,
    "hidden": false
  }
}
  • "sourceMap": true also works.

  • "hidden": true works too, as long as the .map files stay next to the bundles during the scan.

  • "vendor": false keeps third-party code out of the maps.

Step 2: Build, scan and instrument

Deploy the contents of sl_dist in place of the build output folder.

Step 3: Exclude what you do not maintain

Angular internals (@angular/, zone.js, rxjs, tslib) are not instrumented by default. Exclude generated bundles from the scan with a .slignore in the project root:

Without the -es5 exclusions, Angular 8–12 builds report every method twice; see Angular 8+: Duplicate Method Reporting.

Angular-specific notes

Topic
What to do

--splitPreambleIntoFile

Angular apps set <base href>, so a relative --preambleFileUrl resolves against it and works on deep routes. If the app is served under a sub-path, make sure <base href> matches it, or pass a full URL.

Lazy-loaded routes

No extra setup: every chunk of the build reports to the same build session.

Server-side rendering (Angular Universal / @angular/ssr)

Scan dist/<app>/browser with --instrumentForBrowsers and dist/<app>/server without it, each with its own --moduleName, like the Next.js setup.

Content security policy

Angular apps often ship a CSP. Allow the SeaLights or Collector host; see Configuration → Content security policy.

Angular unit tests (Karma)

Captured separately with an NYC report; see Karma Test Framework.

Check it

  • Before CI: npx slnodejs dryRun --scanDir dist/my-angular-app/browser --es6Modules --verbose --instrumentForBrowsers --tokenFile sltoken.txt (drop --es6Modules for the webpack builder). included-files.json should list main-*.js and chunk-*.js, and sl-mapping.json should resolve to src/app/....

  • After deployment: Check that it works.

Last updated

Was this helpful?