141 lines
7.7 KiB
Markdown
141 lines
7.7 KiB
Markdown
# Technical
|
|
|
|
## A Vite config cannot import a workspace package's TypeScript source
|
|
|
|
**What happened.** `apps/rosea/vite.config.ts` imported the name constants from
|
|
`@rosea/schema`, whose `main` is `src/index.ts`. `vite build` failed with
|
|
`ERR_UNKNOWN_FILE_EXTENSION ".ts"`. `--configLoader runner` fixed the build. But
|
|
`svelte-check` loads the same config on its own, still failed, and printed
|
|
*failed to load config* while reporting 0 errors.
|
|
|
|
**Why it bit.** Vite bundles a config's relative imports but externalises anything
|
|
resolved through `node_modules`. Workspace packages are symlinks there, so Node
|
|
loads them natively, and Node 22.11 does not strip types. A tool that reads the config
|
|
for you has its own loader.
|
|
|
|
**How to apply it.** In a Vite config, import workspace code by **relative path**
|
|
to a dependency-free module. Treat a failure message inside a green run as a
|
|
failure: find which tool printed it.
|
|
|
|
## Vite escapes the quotes in an injected `<meta>` CSP
|
|
|
|
**What happened.** The built `index.html` carries `content="default-src 'self'…"`.
|
|
A regex over the raw HTML looking for `'self'` would never match it.
|
|
|
|
**Why it bit.** The HTML is valid and the browser decodes the entities. Only a test
|
|
that reads the bytes sees the difference.
|
|
|
|
**How to apply it.** Read attributes from the DOM:
|
|
`page.locator('meta[http-equiv=…]').getAttribute('content')`. Keep raw-HTML checks for
|
|
byte-level questions, such as whether there is an inline `<script>` or where `<meta charset>` sits.
|
|
|
|
## Svelte 5 needs no preprocessor for `lang="ts"`
|
|
|
|
**What happened.** With `vitePreprocess()` in `svelte.config.js`, `svelte-check` tried
|
|
to load `vite.config.ts` to preprocess styles, and hit the error above. Removing the
|
|
preprocessor removed the problem, and every component still typechecks.
|
|
|
|
**Why it bit.** Svelte 5 strips type annotations natively. A preprocessor is only
|
|
needed for non-CSS style languages or TS features that emit code (enums, decorators).
|
|
|
|
**How to apply it.** Leave `svelte.config.js` as `export default {}` until a component
|
|
needs SCSS or emitted TS. Add the preprocessor in the same commit as that need.
|
|
|
|
## Turbo's cache does not see a file the app imports from outside its package
|
|
|
|
**What happened.** The app imports `docs/LETTER.md?raw`. With a sample letter written
|
|
into the file, `pnpm test:e2e` printed `@rosea/app:build: cache hit` and tested the
|
|
*old* bundle, so the link to the letter was missing. Turbo hashes a package's own
|
|
files, and `docs/` belongs to no package. Adding `docs/LETTER.md` to
|
|
`globalDependencies` in `turbo.json` turned it into a `cache miss`, and the test passed.
|
|
|
|
**Why it bit.** A build cache keyed on the wrong inputs gives a stale bundle that looks
|
|
fresh. This is CLAUDE.md §5.4 again, caused by the build tool and not the service worker.
|
|
|
|
**How to apply it.** Any file the app bundles from outside its package goes into
|
|
`globalDependencies` or the task's `inputs`, in the same commit as the import. To
|
|
check, change the file, run the build, and look for `cache miss`.
|
|
|
|
## A preview on a busy port shows someone else's app
|
|
|
|
**What happened.** The art board's local preview was given port 5180. Ludus's dev
|
|
server already listened on `localhost:5180`, so the preview pane opened **Ludus**,
|
|
whose page text appeared under the board's tab. Port 5191 was busy too. The board
|
|
rendered only on 5237, after `netstat` confirmed the port was free.
|
|
|
|
**Why it bit.** A server that fails to bind, or binds 127.0.0.1 while another app holds
|
|
`localhost`, does not always stop loudly, and the browser simply shows whatever is
|
|
listening. This machine runs many projects.
|
|
|
|
**How to apply it.** Before starting a preview, check that the port is free
|
|
(`netstat -ano | grep :<port>`). After it starts, check the page title before you trust
|
|
anything the page says.
|
|
|
|
## A predicted trap can name the right place and the wrong harm
|
|
|
|
**What happened.** CLAUDE.md §8 predicted that two tabs would make stored derived state drift and
|
|
prescribed a lock. On 2026-11-07 two e2e tests, written before any fix, showed the real harm was
|
|
elsewhere: there was no derived store and the append-only log could not conflict, but each tab's
|
|
view went stale, so a player could water the rose twice. A lock would have fixed nothing.
|
|
|
|
**Why it bit.** A prediction is written before the code exists, so its remedy fits the design
|
|
that was imagined, not the one that was built.
|
|
|
|
**How to apply it.** Before acting on a predicted trap, write the test that would show it, run it
|
|
against the built app, and fix what fails. Then rewrite the trap's row with what was measured.
|
|
|
|
## Data built against a runtime's time zones goes stale when the runtime changes
|
|
|
|
**What happened.** On 2026-11-17 Node went from 22.11 to 22.23.4 and a test found a time zone
|
|
(America/Coyhaique) with no town guess. Rebuilding the town list then showed far worse: Santiago had
|
|
sat on a southern zone's clock since the first build, because Natural Earth files it under
|
|
America/Sao_Paulo and the build trusted any zone whose clock matched one of the country's own.
|
|
|
|
**Why it bit.** A build step that consults `Intl` bakes the runtime's time zone data into a file. An
|
|
upgrade changes the answers silently; only a test that asks *every* zone notices, and then the whole
|
|
derivation deserves a second look, not just the one zone.
|
|
|
|
**How to apply it.** After a Node upgrade, run the content tests first. When generated data changes,
|
|
diff it item by item (here: every town whose zone moved) and explain each change in the review.
|
|
|
|
## A generated project is newer than anything you made before it
|
|
|
|
**What happened.** The first Android APK (2026-11-17) carried Tauri's logo. `scripts/icons.ts` copied
|
|
Rosea's icons only when the target was older than `icon.svg`, but `tauri android init` had just
|
|
written its own icon into `gen/android`, newer than both.
|
|
|
|
**Why it bit.** A date check answers "has the source changed since?", not "is this file mine?". A
|
|
generator that runs later wins every date comparison.
|
|
|
|
**How to apply it.** Copy what must survive a generator unconditionally, and check it by content
|
|
(`android.ts check` compares the icon's bytes). Then look at the artefact: the APK's own icon was
|
|
hashed against ours.
|
|
|
|
## The proof of an app's permissions is the built package
|
|
|
|
**What happened.** Following Amicitia (its lessons/technical.md), `pnpm tauri:android` ends by reading
|
|
the APK with `aapt2 dump permissions` and `dump xmltree`, and the device check reads
|
|
`dumpsys package` on the tablet. The source manifest was right; the APK also held a
|
|
`DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION` that the source never mentions (androidx merges it).
|
|
|
|
**Why it bit.** The manifest merge adds what libraries declare. A check on the source would never see
|
|
a permission a library adds.
|
|
|
|
**How to apply it.** Check permissions, backup flags and WebView switches on the APK and on the
|
|
installed package, and name each allowed exception precisely (this package's own receiver guard,
|
|
not any app's).
|
|
|
|
## Tauri's Android activity draws under the system bars
|
|
|
|
**What happened.** The first screenshot of the Android app on the tablet (2026-11-17) showed the clock
|
|
over the title and the navigation bar over *Bring her back from a file*. Tauri's generated
|
|
`MainActivity` calls `enableEdgeToEdge()`, and Android WebView does not reliably report the bars to
|
|
the page as `env(safe-area-inset-*)` (Culina found the same on an emulator).
|
|
|
|
**Why it bit.** Every test before it read the page, not the screen: the button was there, enabled and
|
|
clickable by script, and hidden from a finger.
|
|
|
|
**How to apply it.** Look at a screenshot of every new platform before calling it done. Keep the page
|
|
between the bars in the activity (padding from `WindowInsetsCompat`), paint the bars with the page's
|
|
own background, and carry the activity in `apps/rosea-tauri/android/java/` because `gen/` is regenerated.
|