Skip to content

[Bug Report]: @vitejs/[email protected] incompatible - shouldTransformCachedModule hook not supported #2252

@zhaowenlong20000615

Description

@zhaowenlong20000615

Steps to reproduce

Farm 1.7.11 cannot use @vitejs/[email protected] (the latest version) because the Vite plugin adapter throws an error about the unsupported shouldTransformCachedModule hook.

This forces users to downgrade to @vitejs/[email protected], which works but prevents using the latest Vue plugin features and optimizations.

Environment

  • Farm version: 1.7.11
  • @farmfe/core: 1.7.11
  • @farmfe/cli: 1.0.5
  • @vitejs/plugin-vue: 6.0.1 (fails) / 5.2.4 (works)
  • Vue: 3.5.22
  • Bun: 1.3.0
  • Node.js: v20.19.1
  • OS: macOS (Darwin 24.4.0)

Reproduction Steps

  1. Create a new Farm project with Vue:
    npm create farm@latest my-vue-app
    cd my-vue-app

Install the latest @vitejs/plugin-vue:
npm install @vitejs/plugin-vue@latest
Configure farm.config.ts:
import { defineConfig } from '@farmfe/core';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
vitePlugins: [vue()]
});
Run the dev server:
npm run dev
Expected Behavior
The dev server should start successfully, just like it does with Vite.
Actual Behavior
The dev server fails to start with the following error:
[ Farm ] Error: Failed to start the server
Caused by: Error: Vite plugin vite:vue is not compatible with Farm for now. Because it uses hook "shouldTransformCachedModule" which is not supported by Farm.
at new VitePluginAdapter (file:///node_modules/@farmfe/core/dist/plugin/js/vite-plugin-adapter.js:79:23)
at processPlugin (file:///node_modules/@farmfe/core/dist/plugin/js/index.js:45:35)
at processVitePlugin (file:///node_modules/@farmfe/core/dist/plugin/js/index.js:53:9)
at handleVitePlugins (file:///node_modules/@farmfe/core/dist/plugin/js/index.js:28:9)
at async resolvePlugins (file:///node_modules/@farmfe/core/dist/config/index.js:690:30)
at async resolveConfig (file:///node_modules/@farmfe/core/dist/config/index.js:80:73)
at async start (file:///node_modules/@farmfe/core/dist/index.js:28:36)
Root Cause Analysis
@vitejs/[email protected] (released in late 2024/early 2025) introduced the shouldTransformCachedModule hook for better caching optimization. This hook is part of the Vite/Rollup plugin API but is not yet implemented in Farm's Vite plugin adapter. Reference:
Vite Plugin API: https://vite.dev/guide/api-plugin
The hook is used to determine whether a cached module should be re-transformed
Current Workaround
Downgrade to @vitejs/[email protected]:
npm install @vitejs/[email protected]
Or use Bun/Yarn resolutions to force the version across the entire dependency tree:
{
"resolutions": {
"@vitejs/plugin-vue": "5.2.4"
}
}
Note: v5.2.4 works perfectly with Vue 3.5.x, but users miss out on the latest plugin optimizations.
Impact
High: Blocks users from using the latest @vitejs/plugin-vue version
Workaround exists: Downgrading to v5.2.4 works fine
Affects: All Farm projects using Vue
Requested Feature
Please add support for the shouldTransformCachedModule hook in Farm's Vite plugin adapter, so that @vitejs/[email protected] can be used without errors.
Additional Context
Related packages that also require v6.x:
Nuxt 4.1.3 depends on @nuxt/[email protected], which requires @vitejs/plugin-vue@^6.0.1
This creates version conflicts in monorepos mixing Vue SPA and Nuxt projects
Version compatibility:
@vitejs/[email protected] is fully compatible with Vue 3.2.x - 3.5.x
v6.x mainly adds internal optimizations, with minimal API changes
The shouldTransformCachedModule hook is primarily for build performance optimization
Proposed Solution
Implement the shouldTransformCachedModule hook in Farm's Vite plugin adapter (vite-plugin-adapter.js), similar to how other Vite/Rollup hooks are handled. Alternative: If the hook is incompatible with Farm's architecture, provide clear documentation explaining:
Why it's not supported
Which Vite plugin hooks are supported
Recommended workarounds
Would you accept a PR?
If the Farm team provides guidance on the implementation approach, I'd be happy to contribute a PR to add this hook support.
Thank you for building Farm! It's an amazing tool, and resolving this would make it even better for Vue developers. 🙏

Reproduce link

No response

What is actually happening?

Farm 1.7.11 cannot use @vitejs/[email protected] (the latest version) because the Vite plugin adapter throws an error about the unsupported shouldTransformCachedModule hook.

This forces users to downgrade to @vitejs/[email protected], which works but prevents using the latest Vue plugin features and optimizations.

System Info

- **Farm version**: 1.7.11
- **@farmfe/core**: 1.7.11
- **@farmfe/cli**: 1.0.5
- **@vitejs/plugin-vue**: 6.0.1 (fails) / 5.2.4 (works)
- **Vue**: 3.5.22
- **Bun**: 1.3.0
- **Node.js**: v20.19.1
- **OS**: macOS (Darwin 24.4.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions