rushstack/webpack/webpack-workspace-resolve-p...
Rushbot 7f1ca5f5e9 Bump versions [skip ci] 2024-10-24 00:15:51 +00:00
..
config [workspace-resolve-plugin] Create plugin for more efficient resolution when repo structure is known (#4880) 2024-08-15 09:36:18 -07:00
src Bump webpack 5 (#4951) 2024-10-01 17:51:17 -04:00
.eslintrc.js [workspace-resolve-plugin] Create plugin for more efficient resolution when repo structure is known (#4880) 2024-08-15 09:36:18 -07:00
.npmignore [workspace-resolve-plugin] Create plugin for more efficient resolution when repo structure is known (#4880) 2024-08-15 09:36:18 -07:00
CHANGELOG.json Update changelogs [skip ci] 2024-10-24 00:15:48 +00:00
CHANGELOG.md Update changelogs [skip ci] 2024-10-24 00:15:48 +00:00
LICENSE [workspace-resolve-plugin] Create plugin for more efficient resolution when repo structure is known (#4880) 2024-08-15 09:36:18 -07:00
README.md Include `basePath` in resolver cache file, instead of being external (#4906) 2024-08-27 16:53:34 -07:00
package.json Bump versions [skip ci] 2024-10-24 00:15:51 +00:00
tsconfig.json [workspace-resolve-plugin] Create plugin for more efficient resolution when repo structure is known (#4880) 2024-08-15 09:36:18 -07:00

README.md

@rushstack/webpack-workspace-resolve-plugin

This package contains a plugin for webpack 5 that leverages a cache file generated from package manager metadata to greatly accelerate module resolution. Local benchmarks have shown a savings of around 10% of build time for some fairly large closed source projects.

Installation

npm install @rushstack/webpack-workspace-resolve-plugin --save-dev

Overview

This plugin is intended primarily for use in pnpm monorepos, but any tool that produces a strict package layout can be made compatible by generating the necessary cache file.

The cache file contains information about the locations of every package.json file known to the package manager (including those in subdirectories of packages), as well as the list of declared dependencies of each and where they can be found.

When using this plugin, the following options should be configured for your resolver:

  • symlinks: false - Since the cache knows the symlinks for package dependencies, you can avoid the cost of testing for other symlinks unless you are using additional symlinks.
  • modules: [] - The cache should contain all information necessary to locate available dependencies for any arbitrary folder. If you need to allow resolution in other roots, you can add those, but omit 'node_modules'.

Impact

This plugin should eliminate file system calls associated with the following operations of NodeJS module resolution in webpack:

  • Find the nearest package.json to the calling module
  • Locate a named package from a calling module
  • Identify a package.json in a resolved directory
  • Find the nearest package.json to a resolved file path

Limitations

This plugin depends on the presence of a cache file in the workspace to function. Data in this cache file is assumed not to change while the webpack process is running.

Note: Generating the cache file is not in the scope of this plugin.

This plugin does not currently support having subdirectory package.json files within workspace projects (e.g. for declaring { "type": "module" } in mixed CommonJS/ESM packages). This plugin does not work (well) with a hoisted node_modules installation layout.

@rushstack/webpack5-workspace-resolve-plugin is part of the Rush Stack family of projects.