Skip to content

feat: publish examples to GitHub-backed StackBlitz branches - #3

Merged
NathanWalker merged 2 commits into
mainfrom
feat/github-backed-examples
Nov 12, 2026
Merged

NathanWalker merged 2 commits into
mainfrom
feat/github-backed-examples

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Problem

The Angular and Svelte battery examples linked from nativescript.org (stackblitz.com/edit/nativescript-battery-example-{angular,svelte}) open with no files. Both are saved StackBlitz projects, and their storage was moved to bolt-…-migration storage that came back empty. The title and stats survived, but the files didn't. The flavors whose storage wasn't moved still load. Saved projects also drift from this repo: the flavor branches the README described were never created, and extract-templates.yml had broken paths.

Approach

Publish every example to a branch that StackBlitz loads straight from GitHub. Those links always reflect main, and StackBlitz storage can't lose them.

https://stackblitz.com/github/NativeScript/stackblitz-examples/tree/{example}-{flavor}?file={path}

publish-examples.yml (replaces extract-templates.yml) runs a matrix over {example} × {flavor}:

  1. Extract: tools/scripts/extract-example.mjs copies apps/{example}/{flavor} into a standalone project. It brings in each libs/* the app references, rewrites ../../../ paths, and fails if any remain.
  2. Verify: tools/scripts/verify-example.sh runs npm install and bundles for iOS and Android, the same webpack build ns preview runs. It works on a copy, so node_modules never gets published.
  3. Publish (main only): pushes to {example}-{flavor} with plain git. Branch history is kept, and nothing is pushed when the output is unchanged. git-publish-subdir-action@v2.6.0 runs on the retired node16 runtime, so it isn't used.

Pull requests run steps 1 and 2 only.

Apps still import the shared lib as @stackblitz/nativescript-battery. Each webpack.config.js aliases that name to the lib's src, replacing the file: dependency. @nativescript/webpack doesn't apply tsconfig paths, and an alias resolves the same way in the monorepo and in a published branch.

Battery flavors

  • All: @nativescript/core ~8.9.0, because NativeScript Preview doesn't support v9 yet. next had been resolving to 9.1.4-next.4.
  • Vue: rewritten for NativeScript-Vue 3 (createApp, <script setup>, src/ layout to match nativescript-vue's StackBlitz template). Preview runs with HMR.
  • Angular: v20 to match https://nativescript.new/angular, with standalone components, zoneless change detection and signals. @nativescript/angular is pinned to ~20.0.0, because 20.1.x imports SplitView, which only core 9 has (same fix as fix(angular): pin @nativescript/angular to 20.0.x for core 8.9 stackblitz-templates#23).
  • React: battery state moved into useState/useEffect. It lived in plain let variables before, so the level never rendered. The obsolete @types/react@16.9.34 patch-package step is removed.
  • Svelte: @nativescript-community/svelte-native + Svelte 4. svelte-native-preprocessor is dropped: it only supports Svelte 3, and this example doesn't use property-element syntax.
  • JavaScript: now the battery example; it was still the stock tap counter.
  • Solid: new flavor, since nativescript.org links one. @nativescript-community/solid-js's webpack plugin wires up babel and JSX.
  • Styling: Tailwind with one shared app.css in every flavor. @nativescript/theme was still imported but no longer installed. Logo URLs now use Wikimedia's standard 500px thumbnails; the old sizes return 400/404.
  • Lib: globalThis.__native instead of Node's global, so it type-checks in flavors without @types/node.

Verification

Every flavor was extracted from a clean checkout, installed with npm install, and bundled for iOS and Android:

Flavor iOS Android Notes
angular ✅ ✅ Angular 20.0.7, @nativescript/angular 20.0.0
javascript ✅ ✅
react ✅ ✅
solid ✅ ✅
svelte ✅ ✅ Svelte 4.2.20
typescript ✅ ✅
vue ✅ ✅ nativescript-vue 3.1.3, Vue runtime 3.5
  • Every bundle resolves to core 8.9.9.
  • Every bundle contains the real index.ios.ts / index.android.ts battery code and not the index.ts workspace stub.
  • No extracted project has any ../../../ path left.
  • A deliberately broken import makes the build exit 1, so the gate catches it.
  • The publish step was run against a local bare repo:
    • the first run creates the branch
    • an unchanged run is a no-op
    • an update commits on top of existing history
    • deleted files are removed from the branch

The StackBlitz runtime itself (.stackblitzrc start and the Preview QR flow) can only be checked once the branches exist after merge.

After merge

  • The first main run creates the battery-* branches.
  • Smoke-test each link from the README table in StackBlitz and the Preview app.
  • Point nativescript.org at the new links in apps/nativescript.org/components/DropDown.vue and both lists in apps/nativescript.org/pages/index.vue.

Saved StackBlitz projects can lose their files (the Angular and Svelte
battery examples did after a StackBlitz storage migration), so examples now
publish to per-flavor branches that StackBlitz loads straight from GitHub:

  https://stackblitz.com/github/NativeScript/stackblitz-examples/tree/<example>-<flavor>

Pipeline (.github/workflows/publish-examples.yml, replaces extract-templates.yml):
- tools/scripts/extract-example.mjs makes apps/<example>/<flavor> standalone,
  copying in referenced libs and rewriting ../../../ paths
- tools/scripts/verify-example.sh installs and bundles it for iOS and Android
- on main, pushes the result to the <example>-<flavor> branch with plain git
  (git-publish-subdir-action v2.6.0 runs on retired node16)
- pull requests verify without publishing

Shared lib is resolved through a webpack alias instead of a file: dependency
(@nativescript/webpack does not apply tsconfig paths), so the monorepo and the
published projects resolve it the same way.

Battery flavors:
- @nativescript/core ~8.9.0 everywhere; Preview does not support v9 yet
- Vue: NativeScript-Vue 3 (createApp, <script setup>, src/ layout)
- Angular: v20, standalone components, zoneless with signals;
  @nativescript/angular ~20.0.0 since 20.1.x needs core 9 (SplitView)
- React: battery state in useState/useEffect so the UI updates; drop
  obsolete @types/react 16 patch
- Svelte: @nativescript-community/svelte-native + Svelte 4; drop
  svelte-native-preprocessor (Svelte 3 peer only)
- JavaScript: now the battery example instead of the tap counter
- Solid: new flavor, linked from nativescript.org
- Tailwind with one shared app.css; logos use Wikimedia standard 500px
  thumbnails (previous sizes now return 400/404)
- lib: globalThis instead of Node's global so it type-checks without @types/node
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fe4f1b5-f990-44c7-869f-3fac53b0f102

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@NathanWalker
NathanWalker force-pushed the feat/github-backed-examples branch from b34977d to 527a872 Compare November 12, 2026 22:21
@NathanWalker
NathanWalker merged commit f1c5bec into main Nov 12, 2026
11 checks passed
@NathanWalker
NathanWalker deleted the feat/github-backed-examples branch November 12, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant