Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

safe-umd-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-umd-webpack-plugin

Webpack plugin to handle optional dependency safely when using libraryTarget: umd

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
698
decreased by-6.81%
Maintainers
1
Weekly downloads
 
Created
Source

safe-umd-webpack-plugin

Webpack plugin to handle optional dependencies safely when using libraryTarget: umd.

When to use

When using umd as a libraryTarget with config like :

module.exports = {
  entry: './src/index.js',
  output: {
    library: ['my', 'module'],
    libraryTarget: 'umd',
    filename: 'bundle.js'
  },
  externals: {
    'my-ext-module': {
      commonjs: 'my-ext-module',
      commonjs2: 'my-ext-module',
      amd: 'my-ext-module',
      root: ['my', 'ext', 'module']
    }
  }
}; 

You can't use optional dependencies for a root (namespace) because of the generated code like :

root["my"] = root["my"] || {}, root["my"]["module"] = factory(root["my"]["ext"]["module"]);

This plugin replace code above to safely access the namespace with code like :

root["my"] = root["my"] || {}, root["my"]["module"] = factory(root["my"] && root["my"]["ext"] && root["my"]["ext"]["module"]);

How to use

Install

npm install safe-umd-webpack-plugin --save-dev

Config

// webpack.config.js

var SafeUmdPlugin = require('safe-umd-webpack-plugin');

// ...
module.exports = {
  // ...
  plugins: [
    //...
    new SafeUmdPlugin()
  ]
}

FAQs

Package last updated on 27 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc