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.
npm install webpack-build-linked-packagesVerified import paths — ran on the pinned version, not inferred.
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.
Ensure all linked packages have the specified `scriptName` (defaulting to 'build') defined in their `scripts` section of `package.json`. If a package doesn't need a build script, you might need to conditionally apply the plugin or ensure a no-op script exists.
Optimize the build scripts within your linked packages for speed. Consider caching strategies or only running essential steps. If performance becomes a critical issue, manually triggering builds for linked packages might be necessary instead of relying on this plugin for every change.
Verify that your local package dependencies are indeed symlinked in `node_modules`. Use `ls -l node_modules/your-linked-package` to check for symbolic links. If you are using other local dependency management strategies, this plugin may not be suitable.
Add a 'build' script to the `scripts` section of `your-linked-package/package.json`, or configure the `webpack-build-linked-packages` plugin with a different `scriptName` that *does* exist in all relevant linked packages (e.g., `new WebpackBuildLinkedPackages({ scriptName: 'prepare' })`).1. Double-check that `new WebpackBuildLinkedPackages()` is included in your `plugins` array in `webpack.config.js`. 2. Verify `npm link` or `yarn link` created actual symlinks in `node_modules`. 3. Manually run `npm run <scriptName>` (e.g., `npm run build`) in your linked package's directory to ensure its build script works standalone.