73 lines
3.7 KiB
Markdown
73 lines
3.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.
|