1.0.3 • Published 2 years ago

hoist-peers-webpack-resolve-plugin v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago