Skip to content

[BUG]: 🐞 webpack-cli add wont lookup for webpack's native plugin in plugins options #906

@anikethsaha

Description

@anikethsaha

Describe the bug
When using the add command and then selecting plugins to add and giving webpack's native plugin like webpack.DefinePlugin , it will throw error with saying no plugin exists.

What is the current behavior?
webpack-cli add wont add webpack's native plugin
The error will throw

? What property do you want to add to? plugins
? What do you want to add to plugins? webpack.DefinePlugin
webpack.DefinePlugin doesn't exist on NPM or is built in webpack, please check for any misspellings.

To Reproduce

  1. npx webpack-cli add
  2. in plugins options
  3. Give any webpack's native plugin like webpack.DefinePlugin
  4. It will throw

webpack.DefinePlugin doesn't exist on NPM or is built in webpack, please check for any misspellings.

Fix
We can have a curated list of all the native plugins and then we can look up to that list and the npmExist method before adding the plugin

Expected behavior
Should add even webpack's native plugin

Please paste the results of webpack-cli info here, and mention other relevant information

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  Binaries:
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    webpack-cli: ^3.3.2 => 3.3.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions