Varie Bundler
Varie Bundler, currently at stable version 3.0.4, provides a pre-configured and extensible Webpack setup specifically tailored for Varie framework applications. It abstracts away complex Webpack configurations, offering a fluent API to define common bundling concerns such as web/service workers, proxy URLs, custom Webpack plugins, file copying, and aggressive code splitting. While its explicit release cadence is not publicly documented, the project has undergone significant updates, moving from early 0.x versions to its current 3.x iteration, indicating active development. A key differentiator is its deep integration with the Varie ecosystem, making it an opinionated but highly efficient choice for developers working within that framework, rather than a general-purpose Webpack utility for any JavaScript project.
Common errors
-
Error: Cannot find module 'vue'
cause Missing or incompatible Vue peer dependency, required by Varie Bundler.fixInstall or upgrade Vue and vue-template-compiler to compatible versions: `npm install vue@^2 vue-template-compiler@^2` or `yarn add vue@^2 vue-template-compiler@^2`. -
TypeError: Bundler is not a constructor
cause Attempting to instantiate `Bundler` incorrectly, often due to using `import` in a CommonJS context or misinterpreting the export type.fixEnsure correct import/require syntax. If in a `varie.js` configuration, use `const { Bundler } = require('varie-bundler');`. If in an ESM module, use `import { Bundler } from 'varie-bundler';`. -
Module not found: Error: Can't resolve './src/main.js' in '...' (or similar path resolution error within Webpack output)
cause The Varie Bundler's default configuration or your custom `copy`/`webWorkers` settings are pointing to incorrect or non-existent file paths.fixReview your `Bundler` instance configuration, specifically methods like `copy()` or `webWorkers()`, to ensure all specified `from` and `to` paths accurately reflect your project's file structure.
Warnings
- gotcha Varie Bundler is tightly coupled with the Varie framework. It is not designed as a standalone or general-purpose Webpack configuration tool for arbitrary JavaScript projects.
- breaking Migration between major versions (e.g., from 0.x to 1.x, or 2.x to 3.x) likely involved significant breaking changes to the configuration API and method signatures. Specific details for all major transitions are not explicitly provided in the truncated release notes.
- gotcha Peer dependencies on Vue 2.x (`vue` and `vue-template-compiler`) must be satisfied for Varie Bundler to function correctly. Installation issues or version mismatches can lead to runtime errors during compilation.
- gotcha Earlier versions (specifically 0.4.4) had known issues related to TypeScript fork instances running incorrectly. While a fix was implemented, complex TypeScript setups may still require careful review.
Install
-
npm install varie-bundler -
yarn add varie-bundler -
pnpm add varie-bundler
Imports
- Bundler
import { Bundler } from 'varie-bundler';const { Bundler } = require('varie-bundler'); - Bundler
const { Bundler } = require('varie-bundler');import { Bundler } from 'varie-bundler'; - BundlerConfigInterface
import type { BundlerConfigInterface } from 'varie-bundler';
Quickstart
const { Bundler } = require('varie-bundler');
module.exports = {
// ... potentially other Varie configuration properties
bundler: new Bundler()
.copy([
{ from: './resources/assets/images', to: './dist/images' },
{ from: './public/manifest.json', to: './dist/manifest.json' }
])
.webWorkers() // Enable web worker support
.proxy('http://localhost:8080') // Set up a proxy server
.aggressiveSplitting() // Optimize chunk splitting
.plugin('webpackbar', require('webpackbar')) // Add a custom webpack plugin
.dontClean(['.gitkeep'])
};