WebPack - Dependency

About

Javascript Package - Dependency in WebPack

Management

Exclude

To exclude a package with webpack, you have to:

In development mode, it allows to avoid bundling all dependencies, which allows browsers to cache those libraries between builds.

Example with JQuery that is available on the global variable 'jQuery'. The below configuration tells WebPack to map the import (for instance for a commonjs module - require(“jquery”)) to the global variable jQuery

externals: {
        // JQuery is a peer dependency (external) and available globally with the jQuery variable
        jquery: "jQuery"
}

Other examples:

externals: [
  "react": "React",
  "react-dom": "ReactDOM"
  'library/one',
  'library/two',
  // Everything that starts with "library/"
  /^library\/.+$/
]

See https://webpack.js.org/configuration/externals/





Discover More
Welcome From Browser
How to develop, publish and use a javascript library ?

A step by step tutorial on how to create and publish a javascript library
Card Puncher Data Processing
What are Peer Dependencies?

Peer Dependencies is a dependency relationship indicating that the dependencies should be provided by parent in the dependency tree. They are provided by the parent. ie a framework (Jquery, ...) ...



Share this page:
Follow us:
Task Runner