Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
pull_request:
push:
branches: [dev]

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
id: node
with:
node-version-file: .node-version
- name: Use the declared npm version
run: npm install --global npm@11.16.0
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ runner.arch }}-node-${{ steps.node.outputs.node-version }}-npm-11.16.0-${{ hashFiles('package-lock.json') }}
- name: Install locked dependencies
run: npm ci
- name: Format, lint and types
run: npm run check
- name: Unit and route tests
run: npm test
- name: Bootstrap temporary-copy tests
run: python3 -m unittest discover -s scripts -p 'test_*.py' -v
- name: Production build
run: npm run build
- name: Verify lazy chunks and report initial JS
run: node scripts/bundle-size.mjs dist --assert-lazy
- name: Audit all dependencies
run: npm run audit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
.worktrees/
__pycache__/
dist
dist-ssr
coverage
Expand Down
67 changes: 62 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,50 @@ A modular, REST-first React starter powered by [Vite+](https://viteplus.dev/).

[![React](https://img.shields.io/badge/React_19-151923?style=for-the-badge&logo=react&logoColor=61DAFB)](https://react.dev/)
[![TypeScript](https://img.shields.io/badge/TypeScript_6-151923?style=for-the-badge&logo=typescript&logoColor=3178C6)](https://www.typescriptlang.org/)
[![Vite+](https://img.shields.io/badge/Vite%2B_1.1-151923?style=for-the-badge&logo=vite&logoColor=BD34FE)](https://viteplus.dev/)
[![Vite+](https://img.shields.io/badge/Vite%2B_1.5-151923?style=for-the-badge&logo=vite&logoColor=BD34FE)](https://viteplus.dev/)
[![Tailwind CSS](https://img.shields.io/badge/Tailwind_4-151923?style=for-the-badge&logo=tailwindcss&logoColor=06B6D4)](https://tailwindcss.com/)

**Typed APIs · Secure auth patterns · EN / UZ / RU · No GitHub CI/CD**
**Typed APIs · Secure auth patterns · EN / UZ / RU · GitHub Actions CI**

</div>

---

## 🚀 Quick start

**Node 24 LTS + npm 11** recommended. See [.node-version](.node-version) and [engine ranges](package.json).
**Node 22.18+ + npm 11.16.0** (CI uses Node 22). See [.node-version](.node-version) and [engine ranges](package.json).

```sh
python3 scripts/bootstrap.py --name my-app --dry-run
python3 scripts/bootstrap.py --name my-app
npm ci
cp .env.example .env
npm run dev
```

Open **http://127.0.0.1:3000**. No global `vp` required. This is a **frontend starter**: live auth/Todo data needs your own backend.

## Bootstrap a new project

Python 3.9+ is required only for bootstrap/testing; the CLI has no dependencies.
Run `python3 scripts/bootstrap.py --name my-app [--dry-run]` from any directory.
The name is a 1–64 character lowercase slug starting with a letter; digits and
single internal hyphens are allowed. Paths, shell syntax, whitespace and reserved
device names are rejected before writes.

Bootstrap updates `package.json`, both root names in `package-lock.json`,
`index.html`'s title and `app.name` in EN/UZ/RU. React has no native application
ID. Demo copy is otherwise unchanged. It creates `.env` from `.env.example`
with owner-only permissions **only when absent**, including preserving existing
or dangling symlinks. It never reads existing environment files, installs
dependencies, generates credentials, renames directories, changes Git remotes or
touches other credentials. `VITE_*` values are public, not secrets.

Dry-run lists changed filenames, never values; repeating the same name is a no-op.
Malformed or linked config files are rejected during preflight. Run on a trusted,
idle checkout: replacement is atomic per file, not a multi-file transaction; do
not run concurrent bootstrap/edit processes. On interruption, rerun the same name.
Review the diff and run `npm run verify` after configuration.

## ✨ Built for real projects

| Layer | Tools |
Expand All @@ -50,6 +73,40 @@ npm run build # Production output → dist/
npm run preview # Local preview → :4173, not a production server
```

## Continuous integration

[GitHub Actions](.github/workflows/ci.yml) runs on pull requests and pushes to
`dev`. It uses `.node-version`, npm 11.16.0 from `packageManager`, `npm ci`
and an npm download cache keyed by OS/architecture, resolved Node/npm versions
and the lockfile. It does not cache `node_modules`. Actions are commit-pinned,
permissions are read-only, checkout credentials are not retained and no production
secrets are required. There are no ignored failures or audit threshold exemptions.

Run the same gates locally:

```sh
npm ci
npm run check
npm test
python3 -m unittest discover -s scripts -p 'test_*.py' -v
npm run build
node scripts/bundle-size.mjs dist --assert-lazy
npm run audit
```

## Route chunks

Home and the layout remain eager. `/todos` and `/animation` use React Router
lazy imports with shared localized loading/recovery states. During navigation the
current page and navbar stay visible. A failed chunk offers a full reload (useful
after deployment) or home navigation, without showing internal exception details.
Direct entry still requires your static host's SPA fallback.

See [the reproducible production bundle comparison](docs/bundle-size.md).
`npm run build` emits a manifest; `scripts/bundle-size.mjs` sums only the
entry's transitive **static** JS imports, excluding lazy chunks, CSS and assets.
The optional `--assert-lazy` fails if either route is eager or shares one chunk.

## 🔌 Connect your API

Defaults in [.env.example](.env.example):
Expand Down Expand Up @@ -92,4 +149,4 @@ Paths stay under the configured API base; out-of-scope URLs and redirects are bl

## 📦 Deploy anywhere

Run `npm ci && npm run verify`, then upload **`dist/`** to your static host over HTTPS. Route `/api/*` to your backend **before** the SPA fallback; other frontend routes should serve `index.html`. Configure CORS/cookies and CSP/HSTS/frame restrictions on your servers. Production source maps are disabled; dev/preview are not production servers. No cloud provider or GitHub workflow required.
Run `npm ci && npm run verify`, then upload **`dist/`** to your static host over HTTPS. Route `/api/*` to your backend **before** the SPA fallback; other frontend routes should serve `index.html`. Configure CORS/cookies and CSP/HSTS/frame restrictions on your servers. Production source maps are disabled; dev/preview are not production servers. No cloud provider is required; the CI workflow verifies changes but does not deploy them.
68 changes: 68 additions & 0 deletions docs/bundle-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Production route-splitting comparison

Task: `boilerplates#839`. Measurements use Node 22.23.4, npm 11.16.0,
macOS arm64, production mode, target ES2022, no custom VITE environment, the
same final lockfile and Vite+ 1.5.0. Bytes are decimal bytes, not rounded kB.
Gzip uses Node's `gzipSync` with level 9, separately per JavaScript file.

The initial checkout (`9ea3fb5`) with Vite+ 1.1.0 emitted **561,691 initial JS
bytes**. Its dependency audit reported five moderate advisories. Vite+, its Vite
core alias and override were upgraded together to 1.5.0; the regenerated lockfile
passes the full audit. To avoid attributing toolchain changes to lazy loading,
the controlled comparison below uses the **same upgraded toolchain/lockfile on
both sides**. Baseline source is `9ea3fb5`; only package.json/package-lock.json
are replaced by the delivered versions before that baseline build.

| Metric | Static-route baseline | Lazy routes | Reduction |
| ------------------------ | --------------------: | ----------: | -----------------: |
| Initial JavaScript | 560,007 B | 438,305 B | 121,702 B (21.73%) |
| Initial JavaScript, gzip | 180,407 B | 141,235 B | 39,172 B (21.71%) |
| Initial JavaScript files | 6 | 5 | 1 |

“Initial” is the recursive static `imports` closure of `index.html` in Vite's
manifest, excluding dynamic imports, CSS and assets. It is not just the small
entry file and not the sum of all emitted chunks. This measures transferred-code
size, not browser timings, memory, HTTP compression settings or user latency.

## Emitted route chunks

- Todos: separate dynamic entry, **2,117 B** raw (903 B gzip in the measured build).
- Animation: separate dynamic entry, **30,329 B** raw (10,440 B gzip).
- Motion vendor chunk: **92,887 B** raw; outside the initial static import closure,
loaded with Animation instead. Shared React/Query/i18n dependencies stay eager.

Hashes and compressed sizes can change with source/formatting or Node's zlib
version. The repeatable initial closure and disjoint route entries, rather than
specific hashed filenames, are the CI assertions.

## Reproduce

In the delivered checkout, with the documented Node/npm versions:

```sh
npm ci
npm run build
node scripts/bundle-size.mjs dist --assert-lazy
```

For the controlled baseline, make a disposable copy (never overwrite live source):

```sh
baseline=$(mktemp -d)
git archive 9ea3fb5 | tar -x -C "$baseline"
cp package.json package-lock.json "$baseline/"
mkdir -p "$baseline/scripts"
cp scripts/bundle-size.mjs "$baseline/scripts/"
(cd "$baseline" && npm ci && npm run build -- --manifest && node scripts/bundle-size.mjs)
# Remove only this disposable directory when finished.
rm -rf "$baseline"
```

Use the same environment for both builds, without a local `.env` override. The
route tests cover real Todo/Animation module imports, direct entry, home → todos
→ animation → back → home navigation, pending chunks and rejected imports. Both
lazy children have a hydration fallback so rejected lazy imports retain their
own recovery boundary. Recovery copy is translated in EN/UZ/RU and never exposes
internal error details. Tests use the real memory router and server rendering;
visual/browser timing validation is not claimed. Static hosts must serve the
SPA entry for frontend deep links as documented in the README.
Loading
Loading