Wallaby Vue Compiler
raw JSON → 1.0.6 verified Fri May 01 auth: no javascript
Wallaby.js compiler for Vue single-file components enabling code coverage display. v1.0.6 stable, low update frequency. Requires vue-template-compiler as peer dep and accepts a separate compiler (e.g., Babel) for script section compilation. Different from other Vue compilers by integrating directly with Wallaby's coverage instrumentation pipeline.
Common errors
error Error: Cannot find module 'vue-template-compiler' ↓
cause Missing peer dependency vue-template-compiler.
fix
Run npm install vue-template-compiler@^2.6.10 --save-dev
error TypeError: wallabyVueCompiler is not a function ↓
cause Importing the module but forgetting to call it as a function with a compiler argument.
fix
Use require('wallaby-vue-compiler')(wallaby.compilers.babel({})) instead of just require('wallaby-vue-compiler')
error Error: Compiler is not set or is not a valid Wallaby compiler ↓
cause The argument passed to the factory is not a valid Wallaby compiler object.
fix
Pass wallaby.compilers.something({}) as the first argument.
Warnings
deprecated Package relies on vue-template-compiler which is deprecated since Vue 2.7. ↓
fix Consider using @vue/compiler-sfc for Vue 3 or Vue 2.7+ projects.
gotcha The compiler must be invoked immediately with a script compiler argument; forgetting this will cause a runtime error. ↓
fix Always call require('wallaby-vue-compiler')(scriptCompiler) in the compilers config.
gotcha The module exports a function, not a class or object; using it as a normal compiler will fail. ↓
fix Invoke the default export as a factory: const vueCompiler = require('wallaby-vue-compiler')(wallaby.compilers.babel({}));
gotcha Only works with Vue 2 due to vue-template-compiler peer dependency. ↓
fix For Vue 3 projects, use a different coverage tool or Wallaby's native Vue 3 support.
Install
npm install wallaby-vue-compiler yarn add wallaby-vue-compiler pnpm add wallaby-vue-compiler Imports
- default wrong
import compiler from 'wallaby-vue-compiler';correctconst compiler = require('wallaby-vue-compiler')(wallaby.compilers.babel({})); - default (module.exports) wrong
const { wallabyVueCompiler } = require('wallaby-vue-compiler');correctconst wallabyVueCompiler = require('wallaby-vue-compiler'); - default (ESM attempt)
import wallabyVueCompiler from 'wallaby-vue-compiler';
Quickstart
// wallaby.js
module.exports = function (wallaby) {
return {
files: ['src/**/*.vue', 'src/**/*.js'],
tests: ['test/**/*.spec.js'],
compilers: {
'**/*.js': wallaby.compilers.babel({}),
'**/*.vue': require('wallaby-vue-compiler')(wallaby.compilers.babel({}))
},
env: {
type: 'node'
}
};
};