Skip to content

hannq/hoist-peers-webpack-resolve-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hoist-Peers-Webpack-Resolve-Plugin

use hoisting dep's peerDependencies even though already existing in dep's node_modules

English | 简体中文

  1. Install
  2. Usage
  3. Options

Install

npm i hoist-peers-webpack-resolve-plugin --save-dev

Usage

using webpack.config.js

// webpack.config.js

// ...
const { HoistPeersWebpackResolvePlugin } = require('hoist-peers-webpack-resolve-plugin');

module.exports = {
  // ...
  resolve: {
    // ...
    plugins: [
      // ...
      new HoistPeersWebpackResolvePlugin({ deps: ['your-npm-link-dep-name'] })
    ]
  },
  // ...
}

using webpack-chain

// webpack.config.js

// ...
const Config = require('webpack-chain');
const { HoistPeersWebpackResolvePlugin } = require('hoist-peers-webpack-resolve-plugin');

// ...
const config = new Config();

// ...
config.resolve
  .plugin('HoistPeersWebpackResolvePlugin')
    .use(HoistPeersWebpackResolvePlugin, [{ deps: ['@apaas/common'] }]);

// ...

module.exports = config.toConfig();

Tips: more options see webpack-chain.

Options

deps

  • type: string[]
  • required: true
  • desc: dependences's names which peers need to be force hoisted.
  • examples:
      new HoistPeersWebpackResolvePlugin({ deps: ['lodash'] });

options

  • type: object
  • required: false
  • desc: polyfills for webpack v4. (only works in webpack v4)
  • example:
      new HoistPeersWebpackResolvePlugin({
        deps: ['lodash'],
        {
          symlinks: true,
          modules: [path.join(__dirname, './node_modules')],
          roots: [path.join(__dirname)],
        }
      });

options.symlinks

options.modules

  • type: string[]
  • required: true (if in webpack v4)
  • desc: the same option of webpack config config.resolve.modules.
  • tips: must be absolute path.

options.roots

  • type: string[]
  • required: true (if in webpack v4)
  • desc: the same option of webpack config config.resolve.roots.
  • tips: must be absolute path.

About

ignore dep's peerDependencies even though already existing in dep's node_modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published