Schematics
@blotch/angular-lynx ships Angular CLI schematics that set a project up for Lynx and generate Lynx components.
npm create angular-lynx runs ng add for you. Every schematic takes --project, which defaults to the project you're in.
ng-add
What it changes:
src/main.ts: replaced. It callsbootstrapApplicationfrom@blotch/angular-lynx.src/app/app.config.ts: replaced, withprovideRenderer()andprovideRouter(routes)(from@blotch/angular-lynx).src/app/app.ts: replaced with a root component whose inline template uses Lynx elements and a<router-outlet>.app.html,app.css(or.scss) andapp.spec.tsare deleted.src/rspeedy-env.d.ts: added. It types asset and CSS module imports.tsconfig.app.jsonexcludessrc/**/*.test.ts, andtsconfig.spec.jsonincludes it.angular.json:builduses@blotch/angular-lynx-build:application. It keepsng new's configurations and the options the builder accepts, and addsappNameand a placeholderappId(com.example.<name>) for the native apps.ng new'sinitialbudget (500 kB warning, 1 MB error) becomes 2 MB and 5 MB. A new app's Lynx bundle is about 720 kB.serveuses@blotch/angular-lynx-build:dev-server, keepingbuildTarget,portandhost.testuses@blotch/angular-lynx-build:unit-test, keeping the options of an@angular/build:unit-testtarget.extract-i18nuses@blotch/angular-lynx-build:extract-i18n, song extract-i18nworks. Angular CLI can't pick an extractor for the Lynx build by itself.cli.schematicCollectionslists@blotch/angular-lynxfirst, song generate componentmakes Lynx components.
package.json:startrunsng serveandbuildrunsng build. Adds@blotch/angular-lynx-buildand@lynx-js/typesas dev dependencies..gitignore: adds.dev-logs, whereng servewritesLynxLogger's output.pnpm-workspace.yaml, in a pnpm app:allowBuildsdenies the install scripts of Angular's build tools (esbuild,@parcel/watcher,lmdbandmsgpackr-extract). pnpm 11 and later failpnpm adduntil every dependency's install script is allowed or denied, and these have nothing to do: their binaries come prebuilt. Decisions already there stay. Apps on npm, Yarn or bun, or on pnpm before 10.26, get no file.- Tailwind CSS, unless
--tailwind=false: the same changes asadd-tailwind.
It doesn't write a lynx.config.ts. The builders read everything from angular.json (see @blotch/angular-lynx-build).
component
ng add puts @blotch/angular-lynx first in cli.schematicCollections, so this command runs it. Without that setting, run ng generate @blotch/angular-lynx:component <name>. Other ng generate schematics, such as service and pipe, still come from Angular.
What it changes:
- Runs Angular's component schematic with your options and
angular.json's@schematics/angular:componentdefaults, so it creates the files you know. - The template gets Lynx elements: the
<p>dashboard works!</p>placeholder becomes<view><text>dashboard works!</text></view>, in the.htmlfile or inline. - The component imports
LYNX_ELEMENTS, so its template type-checks in your editor and underng test. A component declared in an NgModule (--standalone false) is left as Angular made it. - The test: if
@blotch/angular-lynx-testing-libraryis inpackage.json,dashboard.spec.tsis replaced bydashboard.test.ts, which renders the component withrender(). Without the library, Angular's spec stays.
It takes all of Angular's component options. Defaults come from angular.json, then Angular.
add-tailwind
Use it if you skipped Tailwind during ng add. It sets up the Tailwind version the project already depends on, or Tailwind 4. See Tailwind CSS.
What it changes, for Tailwind 4 (as Angular CLI's own Tailwind schematic does):
src/styles.css: its contents are replaced with Tailwind's theme and utilities imports, without Preflight, and@blotch/angular-lynx/tailwind.css, Lynx's own utilities and variants. A project styled withstyles.scssgets asrc/tailwind.css, added to the build'sstyles, instead..postcssrc.json: created, or@tailwindcss/postcssadded to it (or topostcss.config.json).package.json: addstailwindcssand@tailwindcss/postcss(4.x) as dev dependencies, keeping the version of a project that has them.- It warns about a
tailwind.config.tsleft from Tailwind 3, which Tailwind 4 doesn't read.
What it changes, for Tailwind 3:
tailwind.config.ts: created, or replaced, with@lynx-js/tailwind-presetandcontent: ['./src/**/*.{html,ts}'].src/styles.css(orstyles.scssif it exists): its contents are replaced with@tailwind base;and@tailwind utilities;.package.json: addstailwindcss(3.x) and@lynx-js/tailwind-presetas dev dependencies.
add-testing
Adds the testing library, so tests can render components on Lynx. See Testing.
What it changes:
package.json: adds@blotch/angular-lynx-testing-libraryas a dev dependency, plusvitestandjsdomif they're missing.ng newalready adds both. Sets thetestscript tong test.angular.json: pointstestat@blotch/angular-lynx-build:unit-test, if it isn't already.ng adddoes this for new projects.
There's no Vitest config or setup file to add: ng test loads the library's setup itself. Components you generate from then on get a test that renders them on Lynx.
add-i18n
Sets up @angular/localize with the device's language. See Internationalization.
What it changes:
angular.json: adds ani18nblock withsourceLocale: 'en-US'if there's none, and adds@angular/localize/initto the build'spolyfills. Sets theextract-i18ntarget to write JSON, the formatloadTranslations()takes, tosrc/locale, unless the target already sets aformatoroutputPath. Anextract-i18ntarget of Angular's switches to@blotch/angular-lynx-build:extract-i18n.tsconfig.app.json: adds@angular/localizetocompilerOptions.types, so$localizeis typed.src/app/app.config.ts: addsprovideLocale()as the first provider, unless the file already uses it.package.json: adds@angular/localizeas a dev dependency, at the same version range as your@angular/core.
eject
Copies the native projects (the source folders of the iOS and Android apps) that ng build --platform generates into your repo. Eject only when you need a native change that the build options don't cover. See Run on iOS and Android and Eject the native projects.
What it changes:
ios/andandroid/: created in the project folder. It stops with an error if a folder already exists and isn't empty.ng build --platformthen builds those folders as they are.
It's one-way. The app options in angular.json no longer apply to an ejected project, and keeping it up to date with Lynx, Apple's and Google's tools becomes your job. It needs @blotch/angular-lynx-build installed.
ng update
Updates @blotch/angular-lynx, @blotch/angular-lynx-build, @blotch/angular-lynx-testing-library and the packages they use together, so their versions stay in step.
It also updates your app for changes that need one:
-
22.2.3:
- adds
.htmlto the Tailwindcontentglob that older versions ofng addandadd-tailwindwrote (./src/**/*.tsbecomes./src/**/*.{html,ts}), so classes in.htmltemplates get CSS - renames
accessibility-trait, which Lynx ignores, toaccessibility-traitsin your templates - adds the
extract-i18ntarget thatng addandadd-i18nnow write, song extract-i18nworks - adds
.dev-logsto your.gitignore
- adds
-
22.3.2: imports
@blotch/angular-lynx/tailwind.cssafter Tailwind 4's imports in your stylesheet, so the Lynx utilities and variants, such aslinearandui-open:, get CSS. A Tailwind 3 app is left alone: its preset has them.
