This template is intentionally not a ReactLynx app. It builds the Lynx UI with native FiberElement Element PAPI calls in src/main-thread.ts, then packages the generated main-thread asset, background asset, and CSS into dist/card.bundle.
Use this example when you need to understand the lower-level Lynx bundle assembly path:
src/main-thread.tscreates and updates the UI tree with APIs such as__CreatePage,__CreateText,__CreateRawText,__AppendElement,__SetClasses,__SetAttribute, and__FlushElementTree.src/background.tshandles application logic and event dispatch. It receives the publishedhandleClickevent and callslynx.getNativeApp().callLepusMethod('updatePage', payload)to update main-thread state.src/style.cssis built through the webpack CSS pipeline, then converted into encoded template CSS data.plugin.jsdefinespluginTemplateWebpack(), the custom Rspeedy plugin that wires webpack entries and fillsLynxTemplatePluginencode data.lynx.config.jskeeps the app-level Rspeedy configuration and composespluginTemplateWebpack()with the QR code plugin.
pluginTemplateWebpack() replaces the default Rspeedy entries with two explicit entries:
card__backgroundemits.rspeedy/card/background.js.card__main-threadimportssrc/main-thread.tsandsrc/style.css, emits.rspeedy/card/main-thread.js, and lets webpack emit the extracted CSS asset for the same chunk.
The plugin then:
- creates the template container with
LynxTemplatePlugin; - wraps only
background.jswithRuntimeWrapperWebpackPlugin; - enables final bundle encoding with
LynxEncodePlugin; - uses
LynxTemplatePlugin'sbeforeEncodehook to placebackground.jsintoencodeData.manifest,main-thread.jsintoencodeData.lepusCode, and webpack-processed CSS from thecard__main-threadchunk intoencodeData.css.
The final Lynx bundle is emitted as:
dist/card.bundle
From this directory:
pnpm build
pnpm devFrom the repository root:
pnpm --dir examples/template-webpack build
pnpm --dir examples/template-webpack dev