npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-external-module

v3.0.1

Published

[![Build Status](https://travis-ci.org/azcn2503/webpack-external-module.svg?branch=master)](https://travis-ci.org/azcn2503/webpack-external-module)

Downloads

16

Readme

Webpack External Module Plugin

Build Status

A handy way to create a vendor bundle for your Webpack build process.

Webpack does not know about what is "external" and what is "private", so we need to tell it.

It is easy enough using CommonsChunkPlugin to split your bundle so that everything inside node_modules becomes an external bundle (typically a vendor bundle); but sometimes you want to keep some of those modules inside your application bundle for whatever reason (you own it, for example).

How to use:

Require it in your webpack.config.js

var webpackExternalModule = require("webpack-external-module");

Then configure your commons chunk plugin like this:

Make all modules external

new webpack.optimize.CommonsChunkPlugin({
  name: "vendor",
  filename: "[name]-bundle.js",
  minChunks: function(module) {
    return webpackExternalModule.isExternal(module, {
      smartDetection: false
    });
  }
})

This will split every module inside your node_modules directory in to a vendor-bundle.js output file.

Make all modules external, except when the module path matches an expression

new webpack.optimize.CommonsChunkPlugin({
  name: "vendor",
  filename: "[name]-bundle.js",
  minChunks: function(module) {
    return webpackExternalModule.isExternal(module, {
      privatePattern: /node_modules\/(package1|package2)\//
    });
  }
})

This will split every module excluding those matching the privatePattern rule in to a bundle. This is a great way to keep your own modules in your non-vendor bundles. privatePattern is tested against the full path of the module.

Make all modules external, except when the package name or version match an expression

new webpack.optimize.CommonsChunkPlugin({
  name: "vendor",
  filename: "[name]-bundle.js",
  minChunks: function(module) {
    return webpackExternalModule.isExternal(module, {
      privatePattern: {
        name: /mycompany/,
        version: /mycompany/ // if your package version is a GitHub url, this works quite well!
      }
    });
  }
})

Use smart detection to detect external modules

new webpack.optimize.CommonsChunkPlugin({
  name: "vendor",
  filename: "[name]-bundle.js",
  minChunks: function(module) {
    return webpackExternalModule.isExternal(module, {
      smartDetection: ["author.name"]
    });
  }
})

Smart detection will load each modules package.json and compare the specified properties to see if they match the parent modules package.json file. So if you are building the application with an author name of Joe Bloggs, and a module also contains an author name of Joe Bloggs, then the module will be excluded from bundling (and therefore retained for another bundle, typically your application bundle).

Note that smartDetection defaults to ["author.name", "author.email"], and will flag a module as private if any of the conditions pass.