For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/build/index.md.

@blotch/angular-lynx-build

The Angular CLI builders behind ng build, ng serve, ng test and ng extract-i18n on Lynx. It's the only build dependency your app needs, as @angular/build is for a web app. RSpeedy (the Lynx build tool), the AngularLynx plugin and the native app builder come with it.

Usage

ng add @blotch/angular-lynx installs it and points your angular.json targets at it:

angular.json
"architect": {
  "build": {
    "builder": "@blotch/angular-lynx-build:application",
    "options": {
      "browser": "src/main.ts",
      "tsConfig": "tsconfig.app.json"
    }
  },
  "serve": {
    "builder": "@blotch/angular-lynx-build:dev-server"
  },
  "test": {
    "builder": "@blotch/angular-lynx-build:unit-test"
  },
  "extract-i18n": {
    "builder": "@blotch/angular-lynx-build:extract-i18n"
  }
}
BuilderCommandWhat it does
applicationng buildBuilds the bundles into dist/, and with --platform, the iOS and Android apps
dev-serverng serveServes the app to Lynx Explorer, the web preview and, with --platform, a development build of your app
unit-testng testRuns your unit tests with Angular's own unit-test builder, set up for Lynx
extract-i18nng extract-i18nExtracts the messages to translate with Angular's own extractor, set up for Lynx

They work like Angular's builders:

  • Configurations and flags override options, so -c development and --source-map work.
  • optimization picks the build. A build that optimizes scripts is a production build. Any other build is a development build, with dev mode on. There's no mode option.
  • ng build's bundles load their images from where they're deployed, in a development build too: from inside the app, or from your server with RSpeedy's output.assetPrefix. Only ng serve loads them from its dev server.

application

ng build compiles your app into bundles, the files the Lynx engine runs. For a walkthrough, see Build your app.

Build options

OptionTypeDefaultDescription
platform"ios" | "android" | "all"—Also build the native apps into dist/<platform>/. Builds only the lynx environment
runbooleanfalseWith platform, install the app on a simulator, emulator or phone and open it. See Run the app
devicestring—With run, where: a simulator's or a paired iPhone's name or UDID, or a virtual device's name or adb serial. An iPhone needs ios.teamId: see Run on a real iPhone
watchbooleanfalseRebuild the bundles when a file changes. Can't be combined with platform
configstringlynx.config.ts, if anyThe RSpeedy config file, relative to the project root. .js, .mts and .mjs are found too. See lynx.config.ts
environmentstring[]AllOnly build these RSpeedy environments, e.g. ["lynx"]. RSpeedy builds lynx for iOS and Android, and web for the web preview
intlstring[]—The Intl APIs to add to the iOS and Android bundles, which Lynx lacks, with data for your locales: any of Collator, DateTimeFormat, DisplayNames, ListFormat, NumberFormat, PluralRules and RelativeTimeFormat. See Use Intl
intlChecks"warning" | "error" | "off""warning"How the build reports code that needs an Intl API intl doesn't list. "warning" prints it and passes, "error" fails the build, "off" prints nothing. A build with Rsbuild's persistent cache (performance.buildCache) isn't checked. See Use Intl
multiTouchbooleanfalseTouch events carry every finger on the screen, as a browser's do (Lynx's enableMultiTouch page config), for a pinch of your own: Lynx recognizes none. Taps don't fire while two fingers are down. The web preview carries every finger either way. See Gestures
backgroundTreeShaking"safe" | "aggressive""safe""aggressive" drops your module-level values that nothing on the background thread reads from its script, which makes it smaller, but a top-level declaration whose value it doesn't read no longer runs there, even when it does something on purpose. See Shrink the background thread's script
eagerImportsbooleanfalseCompile your import()s on the main thread, such as a lazy route's loadComponent, as static imports. The main thread's script is smaller, but each module they load then runs when the app starts. @defer blocks stay lazy. See Make the script smaller with eagerImports
elementChecks"warning" | "error" | "off""warning"How Angular's unknown-element and unknown-property errors (NG8001, NG8002) are reported. "warning" prints them and the build passes, "error" fails the build, as ng test does, and "off" leaves them out. See What the build checks

Angular options

These are Angular's own application builder options, and they work as they do in a web app:

browser, tsConfig, polyfills, styles, inlineStyleLanguage, fileReplacements, aot (default true), sourceMap, outputHashing, i18nMissingTranslation

A few work differently on Lynx:

OptionOn Lynx
browserThe entry point, and RSpeedy's source.entry unless lynx.config.ts sets one
optimizationAlso picks a production build (scripts optimized, the default) or a development build
budgetsChecked against each entry's bundle (each is its own initial budget) and each component stylesheet. The web preview isn't checked
outputPathDefaults to dist/
baseHrefThe web bundle asks for its images under this path (RSpeedy's output.assetPrefix for web), since Lynx for Web resolves them against the page. A bundle served under /shop/ needs --base-href=/shop/. The Lynx bundle ignores it
assets, scriptsOnly ng test uses them. Bundles load assets through imports
index, extractLicensesAccepted so ng new's config stays valid. They do nothing

Native app options

ng build --platform reads these. Set the app identity, Turn on device features, Permissions and Publish to the app stores explain how to set them.

OptionTypeDefaultDescription
appNamestringThe project nameThe name under the app icon
appIdstring—The app ID for both stores, e.g. com.example.myapp
versionstringpackage.json's versionThe version users see, e.g. 1.2.0
buildNumberinteger (1 or more)—The store build number. It must increase with every upload
orientation"portrait" | "landscape" | "all""portrait"The screen orientations the app supports
edgeToEdgebooleantrueDraw the page under the status bar and the home indicator, with CSS env(safe-area-inset-*) giving the insets. false keeps it inside the safe area, with env() at 0
textScalingboolean | { "max": number }trueWhether the app's text follows the phone's text size (Dynamic Type): sizes in rem grow, px doesn't. false keeps the default size; { "max": 1.6 } caps it at 1.6 times. See Follow the phone's text size
iconstring—A 1024×1024 PNG without transparency, relative to the project root. Android gets it at each density, round and as an adaptive icon
splashobject—The splash screen: image (a PNG with transparency, drawn centered), imageWidth (its width in points and dp, needed with image), backgroundColor (#RRGGBB or #RGB, also behind the app) and dark (an image and a backgroundColor for dark mode)
permissionsobject—The reason shown for each permission the app uses: camera, microphone, location, locationAlways, photos, savePhotos, contacts, notifications, localNetwork, biometrics, bluetooth, tracking, nfc. Most also turn on a feature: see Permissions
filePickerbooleanfalseLet the person pick documents and save files with LynxFilePicker. false leaves its native code out of both apps
fileSharingbooleanfalseList the app's Documents folder in the iOS Files app, under On My iPhone (UIFileSharingEnabled), where LynxFilePicker can save a file and pick it again. iOS only
storeReviewbooleanfalseAsk for an App Store or Google Play rating in the app with LynxStoreReview. false leaves its native code out of both apps
calendarbooleanfalseAdd events to the person's calendar with LynxCalendar, through the system's event editor, without a calendar permission. false leaves its native code out of both apps
motionbooleanfalseRead the motion sensors and compass, and hear a shake, with LynxMotion. Needs no permission. false leaves its native code out of both apps
backgroundAudiobooleanfalseLet LynxAudioPlayer play on in the background and with the phone locked: iOS's audio background mode, and an Android media playback service with its notification. false still plays while the app is on the screen. App Review rejects the mode in an app that plays nothing in the background
backgroundLocationbooleanfalseLet LynxGeolocation's watchPosition({ background: true }) go on in the background and with the phone locked: iOS's location background mode, and an Android location service with its notification. Needs permissions.location, and only its "while using the app" permission
signInWithApplebooleanfalseOffer Sign in with Apple's native sheet on iOS with LynxAppleSignIn. Adds the com.apple.developer.applesignin entitlement, which needs a paid team. false leaves it and the native code out of the app
wifiobject—Read the phone's Wi-Fi network and join others with LynxWifi: { "join": true, "readCurrentNetwork": true }. Each part adds an iOS capability (a paid team) and Android permissions, and readCurrentNetwork needs permissions.location. Without it, no Wi-Fi code ships
shareTarget{ "mimeTypes": string[] } | false—Put the app in other apps' share sheets for these MIME types (text/plain, text/uri-list, image/*…), for LynxShareTarget. Android gets intent filters; iOS a Share Extension and an App Group, which needs a paid team. Left out, none of it ships
deepLinkSchemesstring[]—URL schemes that open the app, e.g. ["myapp"]. myapp://orders/42 opens it on the /orders/42 route. See Open the app from a link
appLinkDomainsstring[]—Your websites whose https:// links open the app (Universal Links, App Links), e.g. ["example.com", "*.example.com"]. The build writes the file each site serves. See Open the app from your website's links
canOpenURLSchemesstring[]—Other apps' URL schemes LynxLinking.canOpenURL() asks about, e.g. ["whatsapp"]. http, https, mailto, tel and sms are always there
nativePluginsobject[]—The app's native plugins: each a path to its folder, with ios and android objects: sourceDir, modules, elements, and on Android packageName, resDir, dependencies and repositories. See The keys
shortcutsobject[]—Things the app does that Siri, Spotlight and the Shortcuts app offer on iOS, and the app icon's menu on Android: each has an id and a title, and may have phrases, a route and a symbol. See LynxShortcuts
iosobject—teamId: your Apple Developer team ID, which alone signs the builds --run --device installs on an iPhone. export: how the .ipa is signed, "app-store-connect" (the default once signing is set) or "release-testing" (ad hoc). signing: see below
androidobject—signing: see below. adaptiveIcon: the adaptive icon's foreground (a 1024×1024 PNG) and background (a color or a PNG)

The signing fields name environment variables, so no secret goes in angular.json. See signing.

FieldHolds
ios.signing.keyIdEnvThe App Store Connect API key's ID
ios.signing.issuerIdEnvThe API key's issuer ID
ios.signing.keyPathEnvThe path to the API key file
android.signing.storeFileEnvThe path to the upload keystore
android.signing.storePasswordEnvThe keystore's password
android.signing.keyAliasThe key's alias (the value itself, not a variable name)
android.signing.keyPasswordEnvThe key's password

dev-server

ng serve runs RSpeedy's dev server. Lynx Explorer and the web preview load your app from it. With --platform, so does a development build of your app, which it opens on a simulator, emulator or phone (see Develop in the real app).

OptionTypeDefaultDescription
buildTargetstringThe project's build:developmentThe build target to serve, as project:target[:configuration]. Its options configure the build
portnumberRSpeedy's (3000)The port to serve on. Overrides server.port in lynx.config.ts. The PORT environment variable, when it's a number, overrides it, as in Angular's dev server
hoststringRSpeedy'sThe host to listen on. Overrides server.host in lynx.config.ts
environmentstring[]The build target's, or allOnly build these RSpeedy environments
platform"ios" | "android"—Also build the app's development build from the build target's native options and open it where ng build --run would. It loads from the dev server and updates on every save. Its native build is cached
devicestringA running one, else a new oneWith platform, where to open the app: a simulator's, paired iPhone's or virtual device's name, a UDID or an adb serial

When the port is taken, ng serve does what Angular's dev server does. That holds wherever the port came from: PORT, --port, lynx.config.ts or the default.

  • In a terminal, it asks whether to use a different port.

  • Anywhere else (CI, a script), it fails:

    Port 3000 is already in use. Use '--port' to specify a different port.
  • PORT=0, or --port 0 when PORT isn't set, lets the system pick a port.

  • It never moves to the next free port, as rspeedy dev does. A proxy, a script or adb reverse set up for the port would miss a server that moved, without a word.

  • server.strictPort in lynx.config.ts doesn't change this. Rsbuild, which RSpeedy runs on, fills in its default strictPort: false before ng serve sees the config, so the two can't be told apart. Choose another port with --port.

unit-test

ng test runs Angular's @angular/build:unit-test builder with Vitest. It takes the same options (include, watch, coverage, setupFiles, providersFile, ...). include defaults to both **/*.spec.ts and **/*.test.ts.

For Lynx, it also:

  • defines the compile-time flags the AngularLynx runtime reads;
  • loads the setup of @blotch/angular-lynx-testing-library when your project has it, so render() works without a setup file;
  • loads both after your polyfills. Those are the build target's polyfills, unless the test target has its own polyfills (Angular 22.3 added the option). The tests then load that list in place of the app's, and "polyfills": [] loads none of them;
  • loads imported images, fonts and media as file URLs, as RSpeedy does in the app.

It runs your project's own @angular/build, which must match your Angular version. See Testing for writing tests.

extract-i18n

ng extract-i18n runs Angular's @angular/build:extract-i18n builder. It takes the same options (format, outputPath, outFile, ...). Angular CLI picks an extractor by itself only for Angular's own build builders, so an AngularLynx app needs this target in angular.json. ng add writes it, and add-i18n sets it to write JSON to src/locale.

For Lynx, it also loads imported images, fonts and media as file URLs, as in ng test. Angular's extractor stops at the first imported image otherwise.

It needs @angular/localize, which add-i18n installs. See Internationalization.

lynx.config.ts

Your app doesn't need one. Without it, the builders configure RSpeedy from angular.json:

RSpeedy settingComes from
source.entryThe build target's browser option
environmentslynx (iOS and Android) and web (the web preview)
modeThe build target's optimization
pluginspluginAngularLynx(), plus the Lynx Explorer QR code plugin for ng serve

Add a lynx.config.ts to the project root to change anything else RSpeedy supports, or to pass the AngularLynx plugin options. Your settings replace the defaults above, except mode, which always follows optimization.

lynx.config.ts
import { defineConfig, pluginAngularLynx } from '@blotch/angular-lynx-build';

export default defineConfig({
  plugins: [pluginAngularLynx({ enableCSSInheritance: true })],
});

The builders use the plugin you list instead of adding their own. Import from @blotch/angular-lynx-build, not @lynx-js/rspeedy or @blotch/rsbuild-plugin-angular-lynx. Those are its dependencies, not your app's, so strict package managers (pnpm, Yarn PnP) can't resolve them.

Plugin options

pluginAngularLynx() compiles Angular for Lynx. All of its options are optional.

Build

OptionTypeDefaultDescription
pagesstring[] | 'all'—Build these angular.json projects as separate pages, each with its own bundle. 'all' builds every application project. See Multi-page apps
intlstring[]—The same as the intl build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set
intlChecks'warning' | 'error' | 'off'—The same as the intlChecks build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set
enableSSRbooleanfalseSupport Lynx's snapshot SSR, which renders the first screen ahead of time. See the SSR example
targetSdkVersionstring'3.2'The oldest Lynx engine version the bundle runs on
experimental_isLazyBundlebooleanfalseExperimental. Emit each lazy route and @defer block as its own lazy bundle, downloaded the first time it's needed. Needs Lynx 3.9 or later. By default, they're built into the main bundle
debugInfoOutsidebooleantrueWrite debug info to a separate file instead of into the bundle, which keeps the bundle smaller
preferredFps'high' | 'auto' | 'low''high'The frame rate Lynx asks for while it animates. 'high' lets a ProMotion iPhone animate at 120 fps. 'auto', Lynx's own default, leaves an iPhone at 60 fps, and 'low' animates at 30 at most. Android draws at the screen's rate either way
multiTouchboolean—The same as the multiTouch build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set
backgroundTreeShaking'safe' | 'aggressive'—The same as the backgroundTreeShaking build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set
eagerImportsboolean—The same as the eagerImports build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set. Has no effect with experimental_isLazyBundle
elementChecks'warning' | 'error' | 'off'—The same as the elementChecks build option, for an app whose angular.json build target isn't AngularLynx's. Replaces it when set

CSS

OptionTypeDefaultDescription
enableCSSSelectorbooleantrueMatch CSS selectors in the Lynx engine. Component styles need it
enableCSSInheritancebooleantrueText properties inherit from parents, as on the web. By default only font-size does (see customCSSInheritanceList), so a <text> without a size takes its parent's. true without a list inherits color, line-height and the rest. false inherits nothing: that <text> takes the page's size
customCSSInheritanceListstring[]['font-size']Inherit only these properties. The default list applies unless you pass enableCSSInheritance: true without a list, which inherits Lynx's whole list
enableCSSInvalidationbooleantrueRestyle what combinator selectors such as .dark .title match when a class changes, as on the web. With false, they only match when an element's classes are set, which saves some work, and dark: classes don't follow an appearance change
defaultDisplayLinearbooleantrueGive elements Lynx's display: linear unless they set display. With false, flex is the default
defaultOverflowVisiblebooleantrueLet elements draw outside their bounds unless they set overflow, as on the web. With false, elements clip their children by default, Lynx's older behavior
enableRemoveCSSScopebooleanfalseStop scoping CSS to the components that import it, so every rule applies app-wide
removeDescendantSelectorScopebooleanfalseLet descendant selectors match across CSS scopes

Gestures and accessibility

OptionTypeDefaultDescription
enableNewGesturebooleantrueTurn on Lynx's gesture system. Gestures silently don't fire without it
enableA11ybooleantrueUse Android's own accessibility views while a screen reader is on. Set it to false so UI test tools such as Maestro and Appium always see the elements
enableAccessibilityElementbooleanfalseMake every element an accessibility element by default, as if it set accessibility-element

Deprecated

enableICU, enableParallelElement and pipelineSchedulerConfig have no effect, and never did: the plugin never passed them to Lynx, and Lynx's own build plugin no longer takes them. The build warns when your config sets one. Remove them; a future release drops them.

Without the Angular CLI

To run RSpeedy yourself, install @blotch/rsbuild-plugin-angular-lynx and import the plugin from there. Nothing adds it for you, so list it in lynx.config.ts and set source.entry.

Exports

ExportKindDescription
pluginAngularLynxFunctionCreates the AngularLynx plugin. Takes the plugin options
PluginAngularLynxOptionsTypeThe plugin options
PreferredFpsTypeThe values of the preferredFps option
defineConfigFunctionRSpeedy's config helper, for lynx.config.ts
ConfigTypeRSpeedy's config type
pluginAngularCliContext, AngularCliContextFunction, typeHow the builders pass angular.json's options to the plugin. Apps don't need them
/clientTypesTypes for asset and CSS module imports and import.meta.env. ng add references them in src/rspeedy-env.d.ts