Update dependencies and clean up project structure. Add cloud.google.com/go/compute/metadata as an indirect requirement in go.mod. Remove unused files and update package.json for Vite and React plugins. Refactor Makefile for improved build process.

This commit is contained in:
2025-11-22 06:53:24 -06:00
parent c9ade39ad9
commit 30aa969433
1295 changed files with 343445 additions and 210041 deletions

View File

@@ -21,7 +21,7 @@ export default defineConfig({
### include/exclude
Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
```js
import { defineConfig } from 'vite'
@@ -36,9 +36,11 @@ export default defineConfig({
})
```
> `node_modules` are never processed by this plugin (but esbuild will)
### jsxImportSource
Control where the JSX factory is imported from. By default, this is inferred from `jsxImportSource` from corresponding a tsconfig file for a transformed file.
Control where the JSX factory is imported from. Default to `'react'`
```js
react({ jsxImportSource: '@emotion/react' })
@@ -102,16 +104,9 @@ react({ reactRefreshHost: 'http://localhost:3000' })
Under the hood, this simply updates the React Fash Refresh runtime URL from `/@react-refresh` to `http://localhost:3000/@react-refresh` to ensure there is only one Refresh runtime across the whole application. Note that if you define `base` option in the host application, you need to include it in the option, like: `http://localhost:3000/{base}`.
## `@vitejs/plugin-react/preamble`
## Middleware mode
The package provides `@vitejs/plugin-react/preamble` to initialize HMR runtime from client entrypoint for SSR applications which don't use [`transformIndexHtml` API](https://vite.dev/guide/api-javascript.html#vitedevserver). For example:
```js
// [entry.client.js]
import '@vitejs/plugin-react/preamble'
```
Alternatively, you can manually call `transformIndexHtml` during SSR, which sets up equivalent initialization code. Here's an example for an Express server:
In [middleware mode](https://vite.dev/config/server-options.html#server-middlewaremode), you should make sure your entry `index.html` file is transformed by Vite. Here's an example for an Express server:
```js
app.get('/', async (req, res, next) => {
@@ -128,12 +123,16 @@ app.get('/', async (req, res, next) => {
})
```
Otherwise, you'll get the following error:
Otherwise, you'll probably get this error:
```
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
```
### disableOxcRecommendation
If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured).
## Consistent components exports
For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).