Powerlines: The Framework Framework
Powerlines is a 'framework framework' and build toolkit (currently at version 0.42.41) designed to simplify the use of modern development tools and improve developer experience. Developed by Storm Software, it achieves this by providing a unified abstraction layer over various build ecosystems such as Vite, Rollup, Webpack, esbuild, Nuxt, Astro, and Next.js. It supports generating virtual or actual code modules, streamlining complex build configurations. The project maintains a very active, rapid release cadence with frequent updates across its core and plugin packages, reflecting its ongoing development. Its key differentiator is its ambition to be a meta-framework, offering a consistent approach to tooling integration and module generation, contrasting with single-bundler-focused solutions. While highly functional, it is still in an initial development phase, and users should expect potential bugs and API evolution.
Common errors
-
ERR_MODULE_NOT_FOUND: Cannot find package 'powerlines'
cause The 'powerlines' package or one of its plugins is not installed.fixRun `pnpm add -D powerlines` (or `npm install -D powerlines`, `yarn add -D powerlines`) to install the core package. Also, ensure any specific `@powerlines/plugin-*` packages are installed if you are using them. -
TypeError: (0 , powerlines__WEBPACK_IMPORTED_MODULE_0__.definePowerlinesConfig) is not a function
cause Attempting to use `definePowerlinesConfig` in a CommonJS context or with incorrect module resolution in a build tool, or a version mismatch where the function signature changed.fixEnsure your configuration file (`powerlines.config.ts`) is treated as an ESM module (e.g., using `type: 'module'` in `package.json` or configuring your bundler/TypeScript compiler accordingly). Verify the `powerlines` package version is compatible with your setup. -
Error: Peer dependency "X@Y" is not installed or incompatible
cause A plugin for Powerlines requires a specific version of a build tool (e.g., `vite`, `esbuild`) that is either missing or does not meet the specified version range.fixInstall the required peer dependency with the correct version. For example, if 'vite@^4.0.0' is required, run `pnpm add -D vite@latest` (or the specific compatible version).
Warnings
- gotcha Powerlines is explicitly stated to be in its 'initial development phase' where 'bugs and issues are expected.' It is not yet considered a 'proper release,' so exercise caution in production environments.
- breaking The project uses `0.x.x` versioning, indicating that minor versions (`0.x.y` to `0.z.0`) may introduce breaking API changes without adhering to Semantic Versioning expectations for stable releases. Frequent updates mean rapid evolution.
- gotcha Powerlines has an extensive list of peer dependencies, requiring many build tools (e.g., Vite, Rollup, Webpack, esbuild, Nuxt, Astro) to be installed separately. Missing or incompatible peer dependencies can lead to runtime errors or unexpected behavior.
Install
-
npm install powerlines -
yarn add powerlines -
pnpm add powerlines
Imports
- definePowerlinesConfig
const { defineConfig } = require('powerlines')import { definePowerlinesConfig } from 'powerlines' - createPowerlines
import Powerlines from 'powerlines'
import { createPowerlines } from 'powerlines' - PowerlinesPlugin
import type { PowerlinesPlugin } from 'powerlines'
Quickstart
import { definePowerlinesConfig } from 'powerlines';
import { createVitePlugin } from '@powerlines/plugin-vite';
import { createEsbuildPlugin } from '@powerlines/plugin-esbuild';
export default definePowerlinesConfig({
/**
* Project-wide options for Powerlines.
* For example, specifying where virtual modules should be resolved from.
*/
output: {
dir: './dist',
clean: true
},
/**
* Define your Powerlines plugins here.
* These plugins can interact with various build tools.
*/
plugins: [
createVitePlugin({
// Vite specific options
optimizeDeps: {
exclude: ['my-excluded-lib']
}
}),
createEsbuildPlugin({
// esbuild specific options
target: 'es2022',
minify: process.env.NODE_ENV === 'production'
}),
{
name: 'my-custom-plugin',
setup(powerlines) {
// Example hook: Intercepting a build event
powerlines.onBuildStart(() => {
console.log('Custom plugin: Powerlines build started!');
});
// You can register virtual modules, transform code, etc.
}
}
],
/**
* Optional: Define global constants or environment variables
* that Powerlines can inject into your builds.
*/
define: {
__APP_VERSION__: JSON.stringify('1.0.0'),
__API_URL__: JSON.stringify(process.env.API_URL ?? 'http://localhost:3000')
}
});