Webpack Plugin for Linked Package Builds

0.4.0 · active · verified Tue Apr 21

This webpack plugin automates the build process for symlinked packages within `node_modules`, typically created using `npm link` or `yarn link`. Designed to streamline local development workflows, it ensures that any changes made to a linked package with a build step (e.g., TypeScript compilation, Babel transpilation) are automatically reflected in the consuming project's webpack compilation without manual intervention. The current stable version is `0.4.0`. Its primary differentiator is solving the common problem of forgetting to rebuild local packages during active development, providing a hands-off solution by integrating directly into the webpack build cycle. This package targets a specific niche within front-end and full-stack development that heavily relies on local package linking for monorepos or component library development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate the plugin into a basic webpack configuration, ensuring that `npm link`-ed packages have their `prepare` script executed during the webpack build process.

const WebpackBuildLinkedPackages = require('webpack-build-linked-packages');
const path = require('path');

module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  plugins: [
    new WebpackBuildLinkedPackages({
      // Optionally specify a different script name than 'build'
      scriptName: 'prepare' // Example: run 'npm run prepare' in linked packages
    })
  ],
  // Typical webpack config setup
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  }
};

view raw JSON →