Repository navigation
fix(deps): complete vite 8 migration (drop stale vite ^7 override) - #6434
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideCompletes the Vite 8 migration by removing stale Vite 7/plugin overrides, regenerating the lockfile to resolve Vite 8.3.5, and adjusting React and FlexSearch integration for Vite 8's Rolldown/OXC transform behavior. Sequence diagram for Vite 8 browser search initializationsequenceDiagram
participant App as Browser search
participant FlexSearch as flexsearch
participant Client as BrowserSearchClient
App->>FlexSearch: import('flexsearch')
FlexSearch-->>App: Document constructor
App->>Client: new BrowserSearchClient(Document, config)
Client-->>App: initialized search client
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
px Advisor ReviewRisk: unknown No summary available No findings. |
The workspace declared vite ^8.3.5 but a stale overrides entry pinned vite ^7 (and @vitejs/plugin-react ^5), so the lockfile resolved vite 7.3.7 - below astro 7.3.5's own ^8.0.13 requirement. Drop the stale overrides so the declared versions resolve. Vite 8 (rolldown/oxc) needs two code adjustments: - astro.config: narrow the react() include globs to JS/TS so .module.css files no longer leak into the OXC JS pipeline. - search-browser: drop the flexsearch/dist/module/document fallback import that Vite 8 cannot analyse.
03af941 to
b88ebb5
Compare
Lighthouse CI ResultsRoutes audited: Thresholds: Performance ≥90 | Accessibility ≥90 | Best Practices ≥85 Reports
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astro.config.mjs" line_range="652-654" />
<code_context>
+ // pipeline (esbuild in Vite 7 sniffed the loader and silently
+ // ignored it). `@astrojs/react` only transforms JSX/TSX, so the
+ // narrowed set is sufficient.
+ include: [
+ '**/react/*.{js,jsx,ts,tsx}',
+ '**/components/**/*.{js,jsx,ts,tsx}',
+ ],
experimentalReactChildren: true,
</code_context>
<issue_to_address>
**Docker builds fail on component CSS**
When a Docker build selects `infra/docker/astro.config.mjs` and processes component CSS modules, the broad `include` in `infra/docker/astro.config.mjs` also matches component `.module.css` files, so Vite 8 sends the CSS through OXC's JavaScript transform and the Docker build fails.
Restrict the Docker config's `include` patterns to JavaScript and TypeScript files.
</issue_to_address>
### Comment 2
<location path="apps/web/src/lib/search-browser.ts" line_range="241-248" />
<code_context>
- throw error
- }
+ // Use dynamic import with module specifier pattern that Vite can analyze
+ const flexsearchPath = 'flexsearch'
+ const flexsearch = (await import(flexsearchPath)) as {
+ default?: { Document?: FlexSearchDocumentConstructor }
+ Document?: FlexSearchDocumentConstructor
}
+ Document = (flexsearch.default?.Document ??
+ flexsearch.Document) as FlexSearchDocumentConstructor
if (Document) {
return new BrowserSearchClient(Document, config)
</code_context>
<issue_to_address>
**Search disappears on root import failure**
When the `flexsearch` root entry fails to load while its document subpath is still available, `initBrowserSearch` now tries only the `flexsearch` entry point; when that entry cannot load but `flexsearch/dist/module/document` remains loadable, the catch returns an empty fallback client, so browser search produces no results. The error is logged, but the removed alternate import no longer recovers.
Retain a Vite-analyzable recovery path for the document subpath, or verify that all supported browser builds can load the root entry before removing the fallback.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: astro.config.mjs:654, apps/web/src/lib/search-browser.ts:248
| include: [ | ||
| '**/react/*.{js,jsx,ts,tsx}', | ||
| '**/components/**/*.{js,jsx,ts,tsx}', |
There was a problem hiding this comment.
🟡 Medium · Docker builds fail on component CSS
When a Docker build selects infra/docker/astro.config.mjs and processes component CSS modules, the broad include in infra/docker/astro.config.mjs also matches component .module.css files, so Vite 8 sends the CSS through OXC's JavaScript transform and the Docker build fails.
Restrict the Docker config's include patterns to JavaScript and TypeScript files.
Prompt for AI agents
In `astro.config.mjs` at lines 652-654:
**Docker builds fail on component CSS**
When a Docker build selects `infra/docker/astro.config.mjs` and processes component CSS modules, the broad `include` in `infra/docker/astro.config.mjs` also matches component `.module.css` files, so Vite 8 sends the CSS through OXC's JavaScript transform and the Docker build fails.
Restrict the Docker config's `include` patterns to JavaScript and TypeScript files.| const flexsearchPath = 'flexsearch' | ||
| const flexsearch = (await import(flexsearchPath)) as { | ||
| default?: { Document?: FlexSearchDocumentConstructor } | ||
| Document?: FlexSearchDocumentConstructor | ||
| } | ||
| Document = (flexsearch.default?.Document ?? | ||
| flexsearch.Document) as FlexSearchDocumentConstructor | ||
|
|
There was a problem hiding this comment.
🟡 Medium · Search disappears on root import failure
When the flexsearch root entry fails to load while its document subpath is still available, initBrowserSearch now tries only the flexsearch entry point; when that entry cannot load but flexsearch/dist/module/document remains loadable, the catch returns an empty fallback client, so browser search produces no results. The error is logged, but the removed alternate import no longer recovers.
Retain a Vite-analyzable recovery path for the document subpath, or verify that all supported browser builds can load the root entry before removing the fallback.
Prompt for AI agents
In `apps/web/src/lib/search-browser.ts` at lines 241-248:
**Search disappears on root import failure**
When the `flexsearch` root entry fails to load while its document subpath is still available, `initBrowserSearch` now tries only the `flexsearch` entry point; when that entry cannot load but `flexsearch/dist/module/document` remains loadable, the catch returns an empty fallback client, so browser search produces no results. The error is logged, but the removed alternate import no longer recovers.
Retain a Vite-analyzable recovery path for the document subpath, or verify that all supported browser builds can load the root entry before removing the fallback.
px Advisor ReviewRisk: unknown No summary available No findings. |
| // Use dynamic import with module specifier pattern that Vite can analyze | ||
| const flexsearchPath = 'flexsearch' | ||
| const flexsearch = (await import(flexsearchPath)) as { | ||
| default?: { Document?: FlexSearchDocumentConstructor } | ||
| Document?: FlexSearchDocumentConstructor | ||
| } | ||
| Document = (flexsearch.default?.Document ?? | ||
| flexsearch.Document) as FlexSearchDocumentConstructor |
There was a problem hiding this comment.
Bug: Dynamic import using a variable await import(flexsearchPath) cannot be statically analyzed by bundlers, causing module resolution failure in the browser.
Severity: HIGH
Suggested Fix
Use a static string literal in the dynamic import, such as await import('flexsearch'), allowing bundlers to detect, bundle, and resolve the module properly for the browser.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: apps/web/src/lib/search-browser.ts#L228-L235
Potential issue: Dynamic import uses a variable specifier `await import(flexsearchPath)`
instead of a string literal. Because bundlers like Vite and rolldown cannot statically
analyze dynamic imports with variable specifiers, the bare module specifier is left
untouched in the client bundle. At runtime in the browser, resolving bare specifiers
fails without an import map, rejecting the import promise and falling back to a dummy
client that always returns empty search results.
Did we get this right? 👍 / 👎 to inform future reviews.
Lighthouse CI ResultsRoutes audited: Thresholds: Performance ≥90 | Accessibility ≥90 | Best Practices ≥85 Reports
|
Summary
Completes the vite 8 migration that the manifests already declared but the lockfile never resolved.
pnpm-workspace.yamlcarried staleoverridesentries —vite: ^7and@vitejs/plugin-react: ^5.2.0— while rootpackage.jsondeclaresvite ^8.3.5and@vitejs/plugin-react ^6.1.1. The override won, so the lockfile resolved vite 7.3.7, below astro 7.3.5's own^8.0.13dependency range. Dropping the two stale overrides restores the declared resolution: vite 8.3.5.astro.config.mjs: narrow thereact()include globs to{js,jsx,ts,tsx}. The broad**/components/**/*glob also matched.module.css, which leaks scoped CSS into the OXC JS transform.apps/web/src/lib/search-browser.ts+@types/flexsearch.d.ts: drop theflexsearch/dist/module/documentfallback dynamic import, which Vite 8 cannot analyse.Why now
astro 7.4.x (dependabot #6419) imports
transformWithOxcfrom vite; vite 7 has no such export, so that PR cannot install or build until the workspace is genuinely on vite 8. This unblocks it.Verification
pnpm install --lockfile-only --frozen-lockfilepasses in-sandbox against the regenerated lockfile (102 ms, 17 importers).[email protected]and@vitejs/[email protected]; astro stays 7.3.5 with its existing patch hash.Summary by Sourcery
Complete the Vite 8 migration so the workspace resolves compatible dependencies and builds correctly with the new toolchain.
Bug Fixes:
Build: