## Problem
Switching a local checkout from `STUDIO_FRAMEWORK=next` to `tanstack`
leaves `apps/studio/.next` behind, including a full `node_modules` copy
under `.next/standalone`. Vite's dev server watches all of it, logging
hundreds of `page reload .next/server/pages/...` lines and wasting file
handles.
## Change
Add `**/.next/**` to `server.watch.ignored` in
`apps/studio/vite.config.ts`. Vite's default ignores (`.git`,
`node_modules`) still apply.
## Verification
With a stale `.next` present, ran `STUDIO_FRAMEWORK=tanstack pnpm run
dev`, touched `.next/server/pages/account/me.html`: no reload logged
(previously ~220 `.next` reloads on startup).
Proposed mitigation, the obvious tradeoff is that clearing the cache
will make compilation slower on subsequent dev server starts, but more
consistent.
Various people have been observing `next-server` use up to ~34 GB
memory. I've observed 12.59 GB memory, with ~1.5k `postcss` processes:
```
ps aux | grep postcss | grep -v grep | wc -l
1526
```
Going down to 3 `postcss` process and 4.71 GB memory after clearing
cache:
```
ps aux | grep postcss | grep -v grep | wc -l
3
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Chores**
* Development infrastructure: adds an automated pre-development step
that clears the local dev cache before starting the development server
by introducing a new lifecycle hook and supporting cleanup script;
purely maintenance-oriented with no user-facing changes or functional
impact.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
#44798 removed these entries. An explicit `pnpm add turbo
--workspace-root` re-added these entries. Otherwise, for a clean build,
I'm seeing this:
```
Turborepo did not find the correct binary for your platform.
We will attempt to install it now.
Installation has failed.
***
Turborepo failed to start.
Turborepo detected that you are running:
darwin arm64
***
We were not able to find the binary at:
@turbo/darwin-arm64/bin/turbo
or: turbo-darwin-arm64/bin/turbo
```
* fix: enable `useDefineForClassFields` in Studio `tsconfig.json`
Per https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties. Needed to switch to SWC.
* fix: remove Studio `.babelrc` to enable SWC
This was tried previously and reverted. I believe that it should work now with `useDefineForClassField` enabled in the previous commit, support for which was added to Next.js in https://github.com/vercel/next.js/pull/36335.
* fix: set Studio `onDemandEntries` options `maxInactiveAge` to 1 day, `pagesBufferLength` to 100
This will keep up to 100 built pages in memory for 1 day, speeding up development. You'd expect that this speed up would come at the cost of memory usage, but in my unscientific testing involving clicking around every page I could get to, with SWC compilation, memory usage maxed out at ~3.3 GB with these options enabled, and no compilation was needed for any revisited pages, whereas without these options, memory usage maxed out at ~4 GB(?!), and revisited pages were compiled once they were out of the buffer. Perhaps the recompilation actually worsens memory usage.
* fix prettier
---------
Co-authored-by: Alaister Young <a@alaisteryoung.com>
It's possible to set up most Node.js version managers to automatically switch versions based on `.nvmrc` when changing directory. There's `.node-version` too but `.nvmrc` seems to be supported by every Node.js version manager that supports `.node-version`, and NVM too.
It's possible to set up most Node.js version managers to automatically switch versions based on `.nvmrc` when changing directory. There's `.node-version` too but `.nvmrc` seems to be supported by every Node.js version manager that supports `.node-version`, and NVM too.