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

babel-plugin-remove-webpack

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-remove-webpack

Removes webpack-specific functions from JavaScript code.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-46.81%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-remove-webpack

Dependency Status devDependency Status Build Status Npm Version License Badges

Removes webpack-specific functions from JavaScript code.

require.ensure

require.ensure is replaced with self-executing anonymous functions.

// Before
require.ensure(['a', 'b', 'c'], function (require) {
  const a = require('a');
  const b = require('b');
  const c = require('c');
});

// After
(function () {
  const a = require('a');
  const b = require('b');
  const c = require('c');
})();

require.include

require.include is removed entirely.

// Before
require.include('a');

// After

Motivation

require.ensure and require.include are great for code splitting; however, they can cause issues when writing universal JavaScript. The typical solution is to use synchronous shims. In order for webpack code splitting to work properly these shims have to be defined in each file where they are used.

This plugin makes it possible to universally run code which uses webpack-specific functions without having to manually polyfill those functions.

Usage Notes

This plugin should not be used as a part of a build with webpack, otherwise code splitting will stop working. The intended usage is with the babel-register package or some other build with babel that specifically targets node. Usage as such will remove require.ensure and require.include calls as shown above so you can run your client code on the server without shims.

License

MIT

Keywords

FAQs

Package last updated on 08 Jan 2016

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