-
-
Notifications
You must be signed in to change notification settings - Fork 14
Description
What problem does this feature solve?
When using Rstest with Vue 2 projects, the @rsbuild/plugin-vue2 plugin fails with a RuleSetCompiler error. This happens because VueLoaderPlugin (from vue-loader v15) uses Webpack's RuleSetCompiler internally, which is incompatible with Rspack's rule format when running inside Rstest.
This affects a significant portion of the Vue ecosystem that hasn't migrated to Vue 3 yet.
Error Message
Compiling RuleSet failed: Properties with are unknown (at clonedRuleSet-30: [object Object])
at RuleSetCompiler.error (node_modules/.../webpack/lib/rules/RuleSetCompiler.js:435:10)
at VueLoaderPlugin.apply (node_modules/.../vue-loader/lib/plugin-webpack5.js:68:18)
at createCompiler (node_modules/@rsbuild/core/node_modules/@rspack/core/dist/index.js)
Root Cause
VueLoaderPluginimports Webpack'sRuleSetCompilerto clone and modify bundler rules- Rstest uses Rsbuild internally, which creates rules with Rspack-specific properties
- When
VueLoaderPlugin.apply()runs, it tries to process Rspack rules with Webpack's compiler - Webpack's
RuleSetCompilerdoesn't recognize some Rspack-specific rule properties → Error
What We Tried
| Approach | Result |
|---|---|
@rsbuild/plugin-vue2 |
❌ VueLoaderPlugin fails with RuleSetCompiler error |
Manual vue-loader config via tools.rspack |
❌ Same VueLoaderPlugin error |
@rspack/loader-vue2 (Rspack-native) |
❌ Same VueLoaderPlugin error |
| Loader without VueLoaderPlugin | ❌ Loader requires the plugin to function |
Environment
- Rstest version: 0.6.8
- @rsbuild/core: 1.6.0-beta.1
- @rsbuild/plugin-vue2: 1.0.4
- vue-loader: 15.11.1
- Vue: 2.7.14
Reproduction
- Create a Vue 2 project with
.vueSFC files - Configure Rstest with
@rsbuild/plugin-vue2 - Run
rstest - Observe
RuleSetCompilererror
When using
rspack builddirectly withvue-loader+VueLoaderPluginit works with the custom configuration without having to use the vue2 plugin.
What does the proposed API look like?
Option 1: Built-in Vue 2 Support
Rstest could provide native Vue 2 SFC handling without relying on VueLoaderPlugin:
// rstest.config.ts
import { defineConfig } from '@rstest/core'
export default defineConfig({
// Built-in Vue 2 support that doesn't require VueLoaderPlugin
framework: 'vue2',
// or
plugins: [rstestPluginVue2()]
})
Option 2: Fix VueLoaderPlugin Compatibility
Ensure that rules passed to plugins are in a format that Webpack's RuleSetCompiler can understand, or provide a compatibility layer.